* [PATCH v1 0/3] i2c: core: Tidy up fwnode handling
@ 2026-01-12 13:22 Andy Shevchenko
2026-01-12 13:22 ` [PATCH v1 1/3] i2c: core: Check for error pointer for fwnode Andy Shevchenko
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Andy Shevchenko @ 2026-01-12 13:22 UTC (permalink / raw)
To: Wolfram Sang, linux-i2c, linux-kernel; +Cc: Andy Shevchenko
There are a few places in i2c core that can be amended when handling
fwnode. Hence this miniseries.
Andy Shevchenko (3):
i2c: core: Check for error pointer for fwnode
i2c: core: Replace custom implementation of device_match_fwnode()
i2c: core: Use dev_fwnode()
drivers/i2c/i2c-core-base.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
--
2.50.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v1 1/3] i2c: core: Check for error pointer for fwnode
2026-01-12 13:22 [PATCH v1 0/3] i2c: core: Tidy up fwnode handling Andy Shevchenko
@ 2026-01-12 13:22 ` Andy Shevchenko
2026-01-13 16:25 ` Wolfram Sang
2026-01-12 13:22 ` [PATCH v1 2/3] i2c: core: Replace custom implementation of device_match_fwnode() Andy Shevchenko
2026-01-12 13:22 ` [PATCH v1 3/3] i2c: core: Use dev_fwnode() Andy Shevchenko
2 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2026-01-12 13:22 UTC (permalink / raw)
To: Wolfram Sang, linux-i2c, linux-kernel; +Cc: Andy Shevchenko
Theoretically it's possible that fwnode is returned by some API,
that may return an error pointer (and we have, for example,
fwnode_find_reference() which does that). If such an fwnode
is supplied to the i2c core APIs the functions will perform
unneeded loops and checks. Avoid this by preventively checking
for an error pointer and bail out immediately.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/i2c-core-base.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index ae7e9c8b65a6..41c2e46ffb24 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -1090,7 +1090,7 @@ struct i2c_client *i2c_find_device_by_fwnode(struct fwnode_handle *fwnode)
struct i2c_client *client;
struct device *dev;
- if (!fwnode)
+ if (IS_ERR_OR_NULL(fwnode))
return NULL;
dev = bus_find_device_by_fwnode(&i2c_bus_type, fwnode);
@@ -1875,7 +1875,7 @@ struct i2c_adapter *i2c_find_adapter_by_fwnode(struct fwnode_handle *fwnode)
struct i2c_adapter *adapter;
struct device *dev;
- if (!fwnode)
+ if (IS_ERR_OR_NULL(fwnode))
return NULL;
dev = bus_find_device(&i2c_bus_type, NULL, fwnode,
--
2.50.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v1 2/3] i2c: core: Replace custom implementation of device_match_fwnode()
2026-01-12 13:22 [PATCH v1 0/3] i2c: core: Tidy up fwnode handling Andy Shevchenko
2026-01-12 13:22 ` [PATCH v1 1/3] i2c: core: Check for error pointer for fwnode Andy Shevchenko
@ 2026-01-12 13:22 ` Andy Shevchenko
2026-01-13 16:25 ` Wolfram Sang
2026-01-12 13:22 ` [PATCH v1 3/3] i2c: core: Use dev_fwnode() Andy Shevchenko
2 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2026-01-12 13:22 UTC (permalink / raw)
To: Wolfram Sang, linux-i2c, linux-kernel; +Cc: Andy Shevchenko
Replace custom implementation of the device_match_fwnode().
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/i2c-core-base.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 41c2e46ffb24..b9b44bed3243 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -1852,10 +1852,10 @@ EXPORT_SYMBOL_GPL(devm_i2c_add_adapter);
static int i2c_dev_or_parent_fwnode_match(struct device *dev, const void *data)
{
- if (dev_fwnode(dev) == data)
+ if (device_match_fwnode(dev, data))
return 1;
- if (dev->parent && dev_fwnode(dev->parent) == data)
+ if (dev->parent && device_match_fwnode(dev->parent, data))
return 1;
return 0;
--
2.50.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v1 3/3] i2c: core: Use dev_fwnode()
2026-01-12 13:22 [PATCH v1 0/3] i2c: core: Tidy up fwnode handling Andy Shevchenko
2026-01-12 13:22 ` [PATCH v1 1/3] i2c: core: Check for error pointer for fwnode Andy Shevchenko
2026-01-12 13:22 ` [PATCH v1 2/3] i2c: core: Replace custom implementation of device_match_fwnode() Andy Shevchenko
@ 2026-01-12 13:22 ` Andy Shevchenko
2026-01-13 16:25 ` Wolfram Sang
2 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2026-01-12 13:22 UTC (permalink / raw)
To: Wolfram Sang, linux-i2c, linux-kernel; +Cc: Andy Shevchenko
irq_domain_create_linear() takes fwnode as the first argument. It can be
extracted from the struct device using dev_fwnode() helper instead of using
direct dereference().
So use the dev_fwnode() helper.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/i2c-core-base.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index b9b44bed3243..f0fb0cfd56e0 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -1476,7 +1476,7 @@ static int i2c_setup_host_notify_irq_domain(struct i2c_adapter *adap)
if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_HOST_NOTIFY))
return 0;
- domain = irq_domain_create_linear(adap->dev.parent->fwnode,
+ domain = irq_domain_create_linear(dev_fwnode(adap->dev.parent),
I2C_ADDR_7BITS_COUNT,
&i2c_host_notify_irq_ops, adap);
if (!domain)
--
2.50.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v1 1/3] i2c: core: Check for error pointer for fwnode
2026-01-12 13:22 ` [PATCH v1 1/3] i2c: core: Check for error pointer for fwnode Andy Shevchenko
@ 2026-01-13 16:25 ` Wolfram Sang
0 siblings, 0 replies; 7+ messages in thread
From: Wolfram Sang @ 2026-01-13 16:25 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-i2c, linux-kernel
On Mon, Jan 12, 2026 at 02:22:40PM +0100, Andy Shevchenko wrote:
> Theoretically it's possible that fwnode is returned by some API,
> that may return an error pointer (and we have, for example,
> fwnode_find_reference() which does that). If such an fwnode
> is supplied to the i2c core APIs the functions will perform
> unneeded loops and checks. Avoid this by preventively checking
> for an error pointer and bail out immediately.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Applied to for-next, thanks!
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 2/3] i2c: core: Replace custom implementation of device_match_fwnode()
2026-01-12 13:22 ` [PATCH v1 2/3] i2c: core: Replace custom implementation of device_match_fwnode() Andy Shevchenko
@ 2026-01-13 16:25 ` Wolfram Sang
0 siblings, 0 replies; 7+ messages in thread
From: Wolfram Sang @ 2026-01-13 16:25 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-i2c, linux-kernel
On Mon, Jan 12, 2026 at 02:22:41PM +0100, Andy Shevchenko wrote:
> Replace custom implementation of the device_match_fwnode().
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Applied to for-next, thanks!
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 3/3] i2c: core: Use dev_fwnode()
2026-01-12 13:22 ` [PATCH v1 3/3] i2c: core: Use dev_fwnode() Andy Shevchenko
@ 2026-01-13 16:25 ` Wolfram Sang
0 siblings, 0 replies; 7+ messages in thread
From: Wolfram Sang @ 2026-01-13 16:25 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-i2c, linux-kernel
On Mon, Jan 12, 2026 at 02:22:42PM +0100, Andy Shevchenko wrote:
> irq_domain_create_linear() takes fwnode as the first argument. It can be
> extracted from the struct device using dev_fwnode() helper instead of using
> direct dereference().
>
> So use the dev_fwnode() helper.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Applied to for-next, thanks!
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-01-13 16:25 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-12 13:22 [PATCH v1 0/3] i2c: core: Tidy up fwnode handling Andy Shevchenko
2026-01-12 13:22 ` [PATCH v1 1/3] i2c: core: Check for error pointer for fwnode Andy Shevchenko
2026-01-13 16:25 ` Wolfram Sang
2026-01-12 13:22 ` [PATCH v1 2/3] i2c: core: Replace custom implementation of device_match_fwnode() Andy Shevchenko
2026-01-13 16:25 ` Wolfram Sang
2026-01-12 13:22 ` [PATCH v1 3/3] i2c: core: Use dev_fwnode() Andy Shevchenko
2026-01-13 16:25 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox