i2c: core: Tidy up fwnode handling
Subsystems (2)
PATCH 2/3 i2c: core: Replace custom implementation of device_match_fwnode()
In reply to Andy ShevchenkoReplace custom implementation of the device_match_fwnode().
--- drivers/i2c/i2c-core-base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/i2c-core-base.c +2 -2
@@ -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 ;
Signature · 1 line
2.50.1
cover i2c: core: Tidy up fwnode handling
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(-)
Signature · 1 line
2.50.1
PATCH 1/3 i2c: core: Check for error pointer for fwnode
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.
--- drivers/i2c/i2c-core-base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/i2c-core-base.c +2 -2
@@ -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,
Signature · 1 line
2.50.1
PATCH 3/3 i2c: core: Use dev_fwnode()
In reply to Andy Shevchenkoirq_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.
--- drivers/i2c/i2c-core-base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/i2c-core-base.c +1 -1
@@ -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)
Signature · 1 line
2.50.1
Wolfram Sang
AppliedRe: [PATCH v1 1/3] i2c: core: Check for error pointer for fwnode
In reply to Andy ShevchenkoQuoted 8 lines · 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 <[email protected]>
Applied to for-next, thanks!
Wolfram Sang
AppliedRe: [PATCH v1 2/3] i2c: core: Replace custom implementation of device_match_fwnode()
In reply to Andy ShevchenkoQuoted 3 lines · Andy Shevchenko
Replace custom implementation of the
device_match_fwnode().Signed-off-by Andy Shevchenko <[email protected]>
Applied to for-next, thanks!
Wolfram Sang
AppliedRe: [PATCH v1 3/3] i2c: core: Use dev_fwnode()
In reply to Andy ShevchenkoQuoted 7 lines · Andy Shevchenko
irq_domain_create_linear()takes fwnode as the first argument. It can be extracted from the struct device usingdev_fwnode()helper instead of using directdereference().So use the
dev_fwnode()helper.Signed-off-by Andy Shevchenko <[email protected]>
Applied to for-next, thanks!