From: Abdurrahman Hussain <abdurrahman@nexthop.ai>
Re-use dev pointer instead of referencing &pdev->dev everywhere.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai>
---
drivers/i2c/busses/i2c-xiic.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index 60d417a2266e..ade0fd66451b 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -1429,7 +1429,7 @@ static int xiic_i2c_probe(struct platform_device *pdev)
u8 i;
u32 sr;
- i2c = devm_kzalloc(&pdev->dev, sizeof(*i2c), GFP_KERNEL);
+ i2c = devm_kzalloc(dev, sizeof(*i2c), GFP_KERNEL);
if (!i2c)
return -ENOMEM;
@@ -1445,13 +1445,13 @@ static int xiic_i2c_probe(struct platform_device *pdev)
if (irq < 0)
return irq;
- pdata = dev_get_platdata(&pdev->dev);
+ pdata = dev_get_platdata(dev);
/* hook up driver to tree */
platform_set_drvdata(pdev, i2c);
i2c->adap = xiic_adapter;
i2c_set_adapdata(&i2c->adap, i2c);
- i2c->adap.dev.parent = &pdev->dev;
+ i2c->adap.dev.parent = dev;
device_set_node(&i2c->adap.dev, dev_fwnode(dev));
snprintf(i2c->adap.name, sizeof(i2c->adap.name),
DRIVER_NAME " %s", pdev->name);
@@ -1467,9 +1467,10 @@ static int xiic_i2c_probe(struct platform_device *pdev)
return dev_err_probe(&pdev->dev, PTR_ERR(i2c->clk),
"failed to enable input clock.\n");
- i2c->dev = &pdev->dev;
- pm_runtime_set_autosuspend_delay(i2c->dev, XIIC_PM_TIMEOUT);
- pm_runtime_use_autosuspend(i2c->dev);
+ i2c->dev = dev;
+
+ pm_runtime_set_autosuspend_delay(dev, XIIC_PM_TIMEOUT);
+ pm_runtime_use_autosuspend(dev);
ret = devm_pm_runtime_set_active_enabled(dev);
if (ret)
return ret;
@@ -1481,9 +1482,8 @@ static int xiic_i2c_probe(struct platform_device *pdev)
if (ret || i2c->i2c_clk > I2C_MAX_FAST_MODE_PLUS_FREQ)
i2c->i2c_clk = 0;
- ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
- xiic_process, IRQF_ONESHOT,
- pdev->name, i2c);
+ ret = devm_request_threaded_irq(dev, irq, NULL, xiic_process,
+ IRQF_ONESHOT, pdev->name, i2c);
if (ret)
return ret;
@@ -1518,7 +1518,7 @@ static int xiic_i2c_probe(struct platform_device *pdev)
i2c_new_client_device(&i2c->adap, pdata->devices + i);
}
- dev_dbg(&pdev->dev, "mmio %08lx irq %d scl clock frequency %d\n",
+ dev_dbg(dev, "mmio %08lx irq %d scl clock frequency %d\n",
(unsigned long)res->start, irq, i2c->i2c_clk);
return ret;
@@ -1526,22 +1526,22 @@ static int xiic_i2c_probe(struct platform_device *pdev)
static void xiic_i2c_remove(struct platform_device *pdev)
{
+ struct device *dev = &pdev->dev;
struct xiic_i2c *i2c = platform_get_drvdata(pdev);
int ret;
/* remove adapter & data */
i2c_del_adapter(&i2c->adap);
- ret = pm_runtime_get_sync(i2c->dev);
-
+ ret = pm_runtime_get_sync(dev);
if (ret < 0)
- dev_warn(&pdev->dev, "Failed to activate device for removal (%pe)\n",
+ dev_warn(dev, "Failed to activate device for removal (%pe)\n",
ERR_PTR(ret));
else
xiic_deinit(i2c);
- pm_runtime_put_sync(i2c->dev);
- pm_runtime_dont_use_autosuspend(&pdev->dev);
+ pm_runtime_put_sync(dev);
+ pm_runtime_dont_use_autosuspend(dev);
}
static const struct dev_pm_ops xiic_dev_pm_ops = {
--
2.52.0
On Mon, Feb 02, 2026 at 08:37:21PM +0000, Abdurrahman Hussain via B4 Relay wrote: > Re-use dev pointer instead of referencing &pdev->dev everywhere. ... > - dev_dbg(&pdev->dev, "mmio %08lx irq %d scl clock frequency %d\n", > + dev_dbg(dev, "mmio %08lx irq %d scl clock frequency %d\n", > (unsigned long)res->start, irq, i2c->i2c_clk); No need to do this here as we change the format string afterwards anyway. But I leave it up to Andi, I won't prevent this to go in, if he agrees. -- With Best Regards, Andy Shevchenko
> On Feb 3, 2026, at 7:42 AM, Andy Shevchenko <andriy.shevchenko@intel.com> wrote: > > On Mon, Feb 02, 2026 at 08:37:21PM +0000, Abdurrahman Hussain via B4 Relay wrote: > >> Re-use dev pointer instead of referencing &pdev->dev everywhere. > > ... > >> - dev_dbg(&pdev->dev, "mmio %08lx irq %d scl clock frequency %d\n", >> + dev_dbg(dev, "mmio %08lx irq %d scl clock frequency %d\n", >> (unsigned long)res->start, irq, i2c->i2c_clk); > > No need to do this here as we change the format string afterwards anyway. > > But I leave it up to Andi, I won't prevent this to go in, if he agrees. > > -- > With Best Regards, > Andy Shevchenko > > No worries, I can do this in the following patch, since there is going to be a v 10 anyways.
> >> Re-use dev pointer instead of referencing &pdev->dev everywhere. > > > > ... > > > >> - dev_dbg(&pdev->dev, "mmio %08lx irq %d scl clock frequency %d\n", > >> + dev_dbg(dev, "mmio %08lx irq %d scl clock frequency %d\n", > >> (unsigned long)res->start, irq, i2c->i2c_clk); > > > > No need to do this here as we change the format string afterwards anyway. > > > > But I leave it up to Andi, I won't prevent this to go in, if he agrees. > > > > -- > > With Best Regards, > > Andy Shevchenko > > > > > > No worries, I can do this in the following patch, since there is going to be > a v 10 anyways. This would be merged next week anyway, so, please, send a v10 as there are many little changes (if we were out of time I would have manually changed things before merging, but that's not the case, yet). Andi
© 2016 - 2026 Red Hat, Inc.