Skip to content

Commit d2f94dc

Browse files
andy-shevAndi Shyti
authored andcommitted
i2c: designware: Use temporary variable for struct device
Use temporary variable for struct device to make code neater. Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Reviewed-by: Andi Shyti <andi.shyti@kernel.org> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
1 parent 157a684 commit d2f94dc

2 files changed

Lines changed: 37 additions & 40 deletions

File tree

drivers/i2c/busses/i2c-designware-pcidrv.c

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -207,32 +207,30 @@ static const struct software_node dgpu_node = {
207207
static int i2c_dw_pci_probe(struct pci_dev *pdev,
208208
const struct pci_device_id *id)
209209
{
210+
struct device *device = &pdev->dev;
210211
struct dw_i2c_dev *dev;
211212
struct i2c_adapter *adap;
212213
int r;
213214
struct dw_pci_controller *controller;
214215
struct dw_scl_sda_cfg *cfg;
215216

216217
if (id->driver_data >= ARRAY_SIZE(dw_pci_controllers))
217-
return dev_err_probe(&pdev->dev, -EINVAL,
218-
"Invalid driver data %ld\n",
218+
return dev_err_probe(device, -EINVAL, "Invalid driver data %ld\n",
219219
id->driver_data);
220220

221221
controller = &dw_pci_controllers[id->driver_data];
222222

223223
r = pcim_enable_device(pdev);
224224
if (r)
225-
return dev_err_probe(&pdev->dev, r,
226-
"Failed to enable I2C PCI device\n");
225+
return dev_err_probe(device, r, "Failed to enable I2C PCI device\n");
227226

228227
pci_set_master(pdev);
229228

230229
r = pcim_iomap_regions(pdev, 1 << 0, pci_name(pdev));
231230
if (r)
232-
return dev_err_probe(&pdev->dev, r,
233-
"I/O memory remapping failed\n");
231+
return dev_err_probe(device, r, "I/O memory remapping failed\n");
234232

235-
dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
233+
dev = devm_kzalloc(device, sizeof(*dev), GFP_KERNEL);
236234
if (!dev)
237235
return -ENOMEM;
238236

@@ -242,7 +240,7 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
242240

243241
dev->get_clk_rate_khz = controller->get_clk_rate_khz;
244242
dev->base = pcim_iomap_table(pdev)[0];
245-
dev->dev = &pdev->dev;
243+
dev->dev = device;
246244
dev->irq = pci_irq_vector(pdev, 0);
247245
dev->flags |= controller->flags;
248246

@@ -281,26 +279,27 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
281279
if ((dev->flags & MODEL_MASK) == MODEL_AMD_NAVI_GPU) {
282280
dev->slave = i2c_new_ccgx_ucsi(&dev->adapter, dev->irq, &dgpu_node);
283281
if (IS_ERR(dev->slave))
284-
return dev_err_probe(dev->dev, PTR_ERR(dev->slave),
282+
return dev_err_probe(device, PTR_ERR(dev->slave),
285283
"register UCSI failed\n");
286284
}
287285

288-
pm_runtime_set_autosuspend_delay(&pdev->dev, 1000);
289-
pm_runtime_use_autosuspend(&pdev->dev);
290-
pm_runtime_put_autosuspend(&pdev->dev);
291-
pm_runtime_allow(&pdev->dev);
286+
pm_runtime_set_autosuspend_delay(device, 1000);
287+
pm_runtime_use_autosuspend(device);
288+
pm_runtime_put_autosuspend(device);
289+
pm_runtime_allow(device);
292290

293291
return 0;
294292
}
295293

296294
static void i2c_dw_pci_remove(struct pci_dev *pdev)
297295
{
298296
struct dw_i2c_dev *dev = pci_get_drvdata(pdev);
297+
struct device *device = &pdev->dev;
299298

300299
i2c_dw_disable(dev);
301300

302-
pm_runtime_forbid(&pdev->dev);
303-
pm_runtime_get_noresume(&pdev->dev);
301+
pm_runtime_forbid(device);
302+
pm_runtime_get_noresume(device);
304303

305304
i2c_del_adapter(&dev->adapter);
306305
}

drivers/i2c/busses/i2c-designware-platdrv.c

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ static void i2c_dw_remove_lock_support(struct dw_i2c_dev *dev)
205205

206206
static int dw_i2c_plat_probe(struct platform_device *pdev)
207207
{
208+
struct device *device = &pdev->dev;
208209
struct i2c_adapter *adap;
209210
struct dw_i2c_dev *dev;
210211
int irq, ret;
@@ -213,23 +214,23 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
213214
if (irq < 0)
214215
return irq;
215216

216-
dev = devm_kzalloc(&pdev->dev, sizeof(struct dw_i2c_dev), GFP_KERNEL);
217+
dev = devm_kzalloc(device, sizeof(*dev), GFP_KERNEL);
217218
if (!dev)
218219
return -ENOMEM;
219220

220-
dev->flags = (uintptr_t)device_get_match_data(&pdev->dev);
221-
if (device_property_present(&pdev->dev, "wx,i2c-snps-model"))
221+
dev->flags = (uintptr_t)device_get_match_data(device);
222+
if (device_property_present(device, "wx,i2c-snps-model"))
222223
dev->flags = MODEL_WANGXUN_SP | ACCESS_POLLING;
223224

224-
dev->dev = &pdev->dev;
225+
dev->dev = device;
225226
dev->irq = irq;
226227
platform_set_drvdata(pdev, dev);
227228

228229
ret = dw_i2c_plat_request_regs(dev);
229230
if (ret)
230231
return ret;
231232

232-
dev->rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL);
233+
dev->rst = devm_reset_control_get_optional_exclusive(device, NULL);
233234
if (IS_ERR(dev->rst))
234235
return PTR_ERR(dev->rst);
235236

@@ -246,13 +247,13 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
246247
i2c_dw_configure(dev);
247248

248249
/* Optional interface clock */
249-
dev->pclk = devm_clk_get_optional(&pdev->dev, "pclk");
250+
dev->pclk = devm_clk_get_optional(device, "pclk");
250251
if (IS_ERR(dev->pclk)) {
251252
ret = PTR_ERR(dev->pclk);
252253
goto exit_reset;
253254
}
254255

255-
dev->clk = devm_clk_get_optional(&pdev->dev, NULL);
256+
dev->clk = devm_clk_get_optional(device, NULL);
256257
if (IS_ERR(dev->clk)) {
257258
ret = PTR_ERR(dev->clk);
258259
goto exit_reset;
@@ -280,28 +281,24 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
280281
I2C_CLASS_HWMON : I2C_CLASS_DEPRECATED;
281282
adap->nr = -1;
282283

283-
if (dev->flags & ACCESS_NO_IRQ_SUSPEND) {
284-
dev_pm_set_driver_flags(&pdev->dev,
285-
DPM_FLAG_SMART_PREPARE);
286-
} else {
287-
dev_pm_set_driver_flags(&pdev->dev,
288-
DPM_FLAG_SMART_PREPARE |
289-
DPM_FLAG_SMART_SUSPEND);
290-
}
284+
if (dev->flags & ACCESS_NO_IRQ_SUSPEND)
285+
dev_pm_set_driver_flags(device, DPM_FLAG_SMART_PREPARE);
286+
else
287+
dev_pm_set_driver_flags(device, DPM_FLAG_SMART_PREPARE | DPM_FLAG_SMART_SUSPEND);
291288

292-
device_enable_async_suspend(&pdev->dev);
289+
device_enable_async_suspend(device);
293290

294291
/* The code below assumes runtime PM to be disabled. */
295-
WARN_ON(pm_runtime_enabled(&pdev->dev));
292+
WARN_ON(pm_runtime_enabled(device));
296293

297-
pm_runtime_set_autosuspend_delay(&pdev->dev, 1000);
298-
pm_runtime_use_autosuspend(&pdev->dev);
299-
pm_runtime_set_active(&pdev->dev);
294+
pm_runtime_set_autosuspend_delay(device, 1000);
295+
pm_runtime_use_autosuspend(device);
296+
pm_runtime_set_active(device);
300297

301298
if (dev->shared_with_punit)
302-
pm_runtime_get_noresume(&pdev->dev);
299+
pm_runtime_get_noresume(device);
303300

304-
pm_runtime_enable(&pdev->dev);
301+
pm_runtime_enable(device);
305302

306303
ret = i2c_dw_probe(dev);
307304
if (ret)
@@ -319,15 +316,16 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
319316
static void dw_i2c_plat_remove(struct platform_device *pdev)
320317
{
321318
struct dw_i2c_dev *dev = platform_get_drvdata(pdev);
319+
struct device *device = &pdev->dev;
322320

323-
pm_runtime_get_sync(&pdev->dev);
321+
pm_runtime_get_sync(device);
324322

325323
i2c_del_adapter(&dev->adapter);
326324

327325
i2c_dw_disable(dev);
328326

329-
pm_runtime_dont_use_autosuspend(&pdev->dev);
330-
pm_runtime_put_sync(&pdev->dev);
327+
pm_runtime_dont_use_autosuspend(device);
328+
pm_runtime_put_sync(device);
331329
dw_i2c_plat_pm_cleanup(dev);
332330

333331
i2c_dw_remove_lock_support(dev);

0 commit comments

Comments
 (0)