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 | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index 3578c00d6404..37a15065db60 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);
@@ -1465,13 +1465,14 @@ static int xiic_i2c_probe(struct platform_device *pdev)
if (is_of_node(dev->fwnode)) {
i2c->clk = devm_clk_get_enabled(dev, NULL);
if (IS_ERR(i2c->clk))
- return dev_err_probe(&pdev->dev, PTR_ERR(i2c->clk),
+ return dev_err_probe(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;
@@ -1483,9 +1484,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;
@@ -1520,7 +1520,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;
@@ -1528,22 +1528,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);
-
- if (ret < 0)
- dev_warn(&pdev->dev, "Failed to activate device for removal (%pe)\n",
+ ret = pm_runtime_get_sync(dev);
+ if (ret)
+ 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
Hi Abdurrahman,
kernel test robot noticed the following build warnings:
url: https://github.com/intel-lab-lkp/linux/commits/Abdurrahman-Hussain-via-B4-Relay/i2c-xiic-skip-input-clock-setup-on-non-OF-systems/20260130-054653
base: 63804fed149a6750ffd28610c5c1c98cce6bd377
patch link: https://lore.kernel.org/r/20260129-i2c-xiic-v7-5-727e434897ef%40nexthop.ai
patch subject: [PATCH v7 5/6] i2c: xiic: cosmetic cleanup
config: i386-randconfig-141-20260130 (https://download.01.org/0day-ci/archive/20260131/202601311615.10yziOui-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
smatch version: v0.5.0-8994-gd50c5a4c
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202601311615.10yziOui-lkp@intel.com/
smatch warnings:
drivers/i2c/busses/i2c-xiic.c:1539 xiic_i2c_remove() warn: pm_runtime_get_sync() also returns 1 on success
vim +1539 drivers/i2c/busses/i2c-xiic.c
e190a0c389e601 Uwe Kleine-König 2023-05-08 1529 static void xiic_i2c_remove(struct platform_device *pdev)
e1d5b6598cdc33 Richard Röjfors 2010-02-11 1530 {
2557b4ba04df79 Abdurrahman Hussain 2026-01-29 1531 struct device *dev = &pdev->dev;
e1d5b6598cdc33 Richard Röjfors 2010-02-11 1532 struct xiic_i2c *i2c = platform_get_drvdata(pdev);
36ecbcab84d023 Shubhrajyoti Datta 2016-03-02 1533 int ret;
e1d5b6598cdc33 Richard Röjfors 2010-02-11 1534
e1d5b6598cdc33 Richard Röjfors 2010-02-11 1535 /* remove adapter & data */
e1d5b6598cdc33 Richard Röjfors 2010-02-11 1536 i2c_del_adapter(&i2c->adap);
e1d5b6598cdc33 Richard Röjfors 2010-02-11 1537
2557b4ba04df79 Abdurrahman Hussain 2026-01-29 1538 ret = pm_runtime_get_sync(dev);
2557b4ba04df79 Abdurrahman Hussain 2026-01-29 @1539 if (ret)
2557b4ba04df79 Abdurrahman Hussain 2026-01-29 1540 dev_warn(dev, "Failed to activate device for removal (%pe)\n",
810199f7315604 Uwe Kleine-König 2022-10-19 1541 ERR_PTR(ret));
pm_runtime_get_sync() can return 1 on success. Perhaps use
pm_runtime_resume_and_get()?
810199f7315604 Uwe Kleine-König 2022-10-19 1542 else
e1d5b6598cdc33 Richard Röjfors 2010-02-11 1543 xiic_deinit(i2c);
810199f7315604 Uwe Kleine-König 2022-10-19 1544
2557b4ba04df79 Abdurrahman Hussain 2026-01-29 1545 pm_runtime_put_sync(dev);
2557b4ba04df79 Abdurrahman Hussain 2026-01-29 1546 pm_runtime_dont_use_autosuspend(dev);
e1d5b6598cdc33 Richard Röjfors 2010-02-11 1547 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
> On Jan 31, 2026, at 6:35 AM, Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> Hi Abdurrahman,
>
> kernel test robot noticed the following build warnings:
>
> url: https://github.com/intel-lab-lkp/linux/commits/Abdurrahman-Hussain-via-B4-Relay/i2c-xiic-skip-input-clock-setup-on-non-OF-systems/20260130-054653
> base: 63804fed149a6750ffd28610c5c1c98cce6bd377
> patch link: https://lore.kernel.org/r/20260129-i2c-xiic-v7-5-727e434897ef%40nexthop.ai
> patch subject: [PATCH v7 5/6] i2c: xiic: cosmetic cleanup
> config: i386-randconfig-141-20260130 (https://download.01.org/0day-ci/archive/20260131/202601311615.10yziOui-lkp@intel.com/config)
> compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
> smatch version: v0.5.0-8994-gd50c5a4c
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> | Closes: https://lore.kernel.org/r/202601311615.10yziOui-lkp@intel.com/
>
> smatch warnings:
> drivers/i2c/busses/i2c-xiic.c:1539 xiic_i2c_remove() warn: pm_runtime_get_sync() also returns 1 on success
>
> vim +1539 drivers/i2c/busses/i2c-xiic.c
>
> e190a0c389e601 Uwe Kleine-König 2023-05-08 1529 static void xiic_i2c_remove(struct platform_device *pdev)
> e1d5b6598cdc33 Richard Röjfors 2010-02-11 1530 {
> 2557b4ba04df79 Abdurrahman Hussain 2026-01-29 1531 struct device *dev = &pdev->dev;
> e1d5b6598cdc33 Richard Röjfors 2010-02-11 1532 struct xiic_i2c *i2c = platform_get_drvdata(pdev);
> 36ecbcab84d023 Shubhrajyoti Datta 2016-03-02 1533 int ret;
> e1d5b6598cdc33 Richard Röjfors 2010-02-11 1534
> e1d5b6598cdc33 Richard Röjfors 2010-02-11 1535 /* remove adapter & data */
> e1d5b6598cdc33 Richard Röjfors 2010-02-11 1536 i2c_del_adapter(&i2c->adap);
> e1d5b6598cdc33 Richard Röjfors 2010-02-11 1537
> 2557b4ba04df79 Abdurrahman Hussain 2026-01-29 1538 ret = pm_runtime_get_sync(dev);
> 2557b4ba04df79 Abdurrahman Hussain 2026-01-29 @1539 if (ret)
> 2557b4ba04df79 Abdurrahman Hussain 2026-01-29 1540 dev_warn(dev, "Failed to activate device for removal (%pe)\n",
> 810199f7315604 Uwe Kleine-König 2022-10-19 1541 ERR_PTR(ret));
>
>
> pm_runtime_get_sync() can return 1 on success. Perhaps use
> pm_runtime_resume_and_get()?
>
> 810199f7315604 Uwe Kleine-König 2022-10-19 1542 else
> e1d5b6598cdc33 Richard Röjfors 2010-02-11 1543 xiic_deinit(i2c);
> 810199f7315604 Uwe Kleine-König 2022-10-19 1544
> 2557b4ba04df79 Abdurrahman Hussain 2026-01-29 1545 pm_runtime_put_sync(dev);
> 2557b4ba04df79 Abdurrahman Hussain 2026-01-29 1546 pm_runtime_dont_use_autosuspend(dev);
> e1d5b6598cdc33 Richard Röjfors 2010-02-11 1547 }
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki
>
This maybe a false positive.
The following commit switched from pm_runtime_resume_and_get() to
pm_runtime_get_sync():
commit 810199f7315604b i2c: xiic: Make sure to disable clock on .remove()
Uwe, Michal, can you guys comment on this?
Regards,
Abdurrahman
Hello,
On Sat, Jan 31, 2026 at 06:14:58PM -0800, Abdurrahman Hussain wrote:
> > On Jan 31, 2026, at 6:35 AM, Dan Carpenter <dan.carpenter@linaro.org> wrote:
> > kernel test robot noticed the following build warnings:
> >
> > url: https://github.com/intel-lab-lkp/linux/commits/Abdurrahman-Hussain-via-B4-Relay/i2c-xiic-skip-input-clock-setup-on-non-OF-systems/20260130-054653
> > base: 63804fed149a6750ffd28610c5c1c98cce6bd377
> > patch link: https://lore.kernel.org/r/20260129-i2c-xiic-v7-5-727e434897ef%40nexthop.ai
> > patch subject: [PATCH v7 5/6] i2c: xiic: cosmetic cleanup
> > config: i386-randconfig-141-20260130 (https://download.01.org/0day-ci/archive/20260131/202601311615.10yziOui-lkp@intel.com/config)
> > compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
> > smatch version: v0.5.0-8994-gd50c5a4c
> >
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> > | Closes: https://lore.kernel.org/r/202601311615.10yziOui-lkp@intel.com/
> >
> > smatch warnings:
> > drivers/i2c/busses/i2c-xiic.c:1539 xiic_i2c_remove() warn: pm_runtime_get_sync() also returns 1 on success
> >
> > vim +1539 drivers/i2c/busses/i2c-xiic.c
> >
> > e190a0c389e601 Uwe Kleine-König 2023-05-08 1529 static void xiic_i2c_remove(struct platform_device *pdev)
> > e1d5b6598cdc33 Richard Röjfors 2010-02-11 1530 {
> > 2557b4ba04df79 Abdurrahman Hussain 2026-01-29 1531 struct device *dev = &pdev->dev;
> > e1d5b6598cdc33 Richard Röjfors 2010-02-11 1532 struct xiic_i2c *i2c = platform_get_drvdata(pdev);
> > 36ecbcab84d023 Shubhrajyoti Datta 2016-03-02 1533 int ret;
> > e1d5b6598cdc33 Richard Röjfors 2010-02-11 1534
> > e1d5b6598cdc33 Richard Röjfors 2010-02-11 1535 /* remove adapter & data */
> > e1d5b6598cdc33 Richard Röjfors 2010-02-11 1536 i2c_del_adapter(&i2c->adap);
> > e1d5b6598cdc33 Richard Röjfors 2010-02-11 1537
> > 2557b4ba04df79 Abdurrahman Hussain 2026-01-29 1538 ret = pm_runtime_get_sync(dev);
> > 2557b4ba04df79 Abdurrahman Hussain 2026-01-29 @1539 if (ret)
> > 2557b4ba04df79 Abdurrahman Hussain 2026-01-29 1540 dev_warn(dev, "Failed to activate device for removal (%pe)\n",
> > 810199f7315604 Uwe Kleine-König 2022-10-19 1541 ERR_PTR(ret));
> >
> >
> > pm_runtime_get_sync() can return 1 on success. Perhaps use
> > pm_runtime_resume_and_get()?
> >
> > 810199f7315604 Uwe Kleine-König 2022-10-19 1542 else
> > e1d5b6598cdc33 Richard Röjfors 2010-02-11 1543 xiic_deinit(i2c);
> > 810199f7315604 Uwe Kleine-König 2022-10-19 1544
> > 2557b4ba04df79 Abdurrahman Hussain 2026-01-29 1545 pm_runtime_put_sync(dev);
> > 2557b4ba04df79 Abdurrahman Hussain 2026-01-29 1546 pm_runtime_dont_use_autosuspend(dev);
> > e1d5b6598cdc33 Richard Röjfors 2010-02-11 1547 }
> >
> > --
> > 0-DAY CI Kernel Test Service
> > https://github.com/intel/lkp-tests/wiki
> >
>
> This maybe a false positive.
It's not.
The blamed commit 2557b4ba04df ("i2c: xiic: cosmetic cleanup") has:
- ret = pm_runtime_get_sync(i2c->dev);
-
- if (ret < 0)
- dev_warn(&pdev->dev, "Failed to activate device for removal (%pe)\n",
+ ret = pm_runtime_get_sync(dev);
+ if (ret)
+ dev_warn(dev, "Failed to activate device for removal (%pe)\n",
ERR_PTR(ret));
So we need
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index 37a15065db60..a5334b7c46d8 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -1536,7 +1536,7 @@ static void xiic_i2c_remove(struct platform_device *pdev)
i2c_del_adapter(&i2c->adap);
ret = pm_runtime_get_sync(dev);
- if (ret)
+ if (ret < 0)
dev_warn(dev, "Failed to activate device for removal (%pe)\n",
ERR_PTR(ret));
else
Best regards
Uwe
On Sun Feb 1, 2026 at 10:23 PM UTC, Uwe Kleine-König wrote:
> Hello,
>
> On Sat, Jan 31, 2026 at 06:14:58PM -0800, Abdurrahman Hussain wrote:
>> > On Jan 31, 2026, at 6:35 AM, Dan Carpenter <dan.carpenter@linaro.org> wrote:
>> > kernel test robot noticed the following build warnings:
>> >
>> > url: https://github.com/intel-lab-lkp/linux/commits/Abdurrahman-Hussain-via-B4-Relay/i2c-xiic-skip-input-clock-setup-on-non-OF-systems/20260130-054653
>> > base: 63804fed149a6750ffd28610c5c1c98cce6bd377
>> > patch link: https://lore.kernel.org/r/20260129-i2c-xiic-v7-5-727e434897ef%40nexthop.ai
>> > patch subject: [PATCH v7 5/6] i2c: xiic: cosmetic cleanup
>> > config: i386-randconfig-141-20260130 (https://download.01.org/0day-ci/archive/20260131/202601311615.10yziOui-lkp@intel.com/config)
>> > compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
>> > smatch version: v0.5.0-8994-gd50c5a4c
>> >
>> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
>> > the same patch/commit), kindly add following tags
>> > | Reported-by: kernel test robot <lkp@intel.com>
>> > | Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
>> > | Closes: https://lore.kernel.org/r/202601311615.10yziOui-lkp@intel.com/
>> >
>> > smatch warnings:
>> > drivers/i2c/busses/i2c-xiic.c:1539 xiic_i2c_remove() warn: pm_runtime_get_sync() also returns 1 on success
>> >
>> > vim +1539 drivers/i2c/busses/i2c-xiic.c
>> >
>> > e190a0c389e601 Uwe Kleine-König 2023-05-08 1529 static void xiic_i2c_remove(struct platform_device *pdev)
>> > e1d5b6598cdc33 Richard Röjfors 2010-02-11 1530 {
>> > 2557b4ba04df79 Abdurrahman Hussain 2026-01-29 1531 struct device *dev = &pdev->dev;
>> > e1d5b6598cdc33 Richard Röjfors 2010-02-11 1532 struct xiic_i2c *i2c = platform_get_drvdata(pdev);
>> > 36ecbcab84d023 Shubhrajyoti Datta 2016-03-02 1533 int ret;
>> > e1d5b6598cdc33 Richard Röjfors 2010-02-11 1534
>> > e1d5b6598cdc33 Richard Röjfors 2010-02-11 1535 /* remove adapter & data */
>> > e1d5b6598cdc33 Richard Röjfors 2010-02-11 1536 i2c_del_adapter(&i2c->adap);
>> > e1d5b6598cdc33 Richard Röjfors 2010-02-11 1537
>> > 2557b4ba04df79 Abdurrahman Hussain 2026-01-29 1538 ret = pm_runtime_get_sync(dev);
>> > 2557b4ba04df79 Abdurrahman Hussain 2026-01-29 @1539 if (ret)
>> > 2557b4ba04df79 Abdurrahman Hussain 2026-01-29 1540 dev_warn(dev, "Failed to activate device for removal (%pe)\n",
>> > 810199f7315604 Uwe Kleine-König 2022-10-19 1541 ERR_PTR(ret));
>> >
>> >
>> > pm_runtime_get_sync() can return 1 on success. Perhaps use
>> > pm_runtime_resume_and_get()?
>> >
>> > 810199f7315604 Uwe Kleine-König 2022-10-19 1542 else
>> > e1d5b6598cdc33 Richard Röjfors 2010-02-11 1543 xiic_deinit(i2c);
>> > 810199f7315604 Uwe Kleine-König 2022-10-19 1544
>> > 2557b4ba04df79 Abdurrahman Hussain 2026-01-29 1545 pm_runtime_put_sync(dev);
>> > 2557b4ba04df79 Abdurrahman Hussain 2026-01-29 1546 pm_runtime_dont_use_autosuspend(dev);
>> > e1d5b6598cdc33 Richard Röjfors 2010-02-11 1547 }
>> >
>> > --
>> > 0-DAY CI Kernel Test Service
>> > https://github.com/intel/lkp-tests/wiki
>> >
>>
>> This maybe a false positive.
>
> It's not.
>
> The blamed commit 2557b4ba04df ("i2c: xiic: cosmetic cleanup") has:
>
> - ret = pm_runtime_get_sync(i2c->dev);
> -
> - if (ret < 0)
> - dev_warn(&pdev->dev, "Failed to activate device for removal (%pe)\n",
> + ret = pm_runtime_get_sync(dev);
> + if (ret)
> + dev_warn(dev, "Failed to activate device for removal (%pe)\n",
> ERR_PTR(ret));
>
> So we need
>
> diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
> index 37a15065db60..a5334b7c46d8 100644
> --- a/drivers/i2c/busses/i2c-xiic.c
> +++ b/drivers/i2c/busses/i2c-xiic.c
> @@ -1536,7 +1536,7 @@ static void xiic_i2c_remove(struct platform_device *pdev)
> i2c_del_adapter(&i2c->adap);
>
> ret = pm_runtime_get_sync(dev);
> - if (ret)
> + if (ret < 0)
> dev_warn(dev, "Failed to activate device for removal (%pe)\n",
> ERR_PTR(ret));
> else
>
> Best regards
> Uwe
Hi Uwe,
Yes, indeed, I missed that. Thanks for pointing it out!
Best regards,
Abdurrahman
© 2016 - 2026 Red Hat, Inc.