From: Andy Shevchenko Date: Wed, 16 Apr 2025 07:01:31 +0000 (+0300) Subject: i2c: core: Drop duplicate check before calling OF APIs X-Git-Tag: v6.16-rc1~112^2~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7de3fb3c2252d885c470939bae72ff9b4c820e8;p=thirdparty%2Fkernel%2Flinux.git i2c: core: Drop duplicate check before calling OF APIs OF APIs are usually NULL-aware and return an error in case when device node is not present or supported. We already have a check for the returned value, no need to check for the parameter. Tested-by: Tomi Valkeinen Reviewed-by: Sakari Ailus Acked-by: Sakari Ailus Signed-off-by: Andy Shevchenko Signed-off-by: Wolfram Sang --- diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 7ad1ad5c8c3f5..c14ffd6190d33 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -1209,11 +1209,9 @@ struct i2c_client *i2c_new_ancillary_device(struct i2c_client *client, u32 addr = default_addr; int i; - if (np) { - i = of_property_match_string(np, "reg-names", name); - if (i >= 0) - of_property_read_u32_index(np, "reg", i, &addr); - } + i = of_property_match_string(np, "reg-names", name); + if (i >= 0) + of_property_read_u32_index(np, "reg", i, &addr); dev_dbg(&client->adapter->dev, "Address for %s : 0x%x\n", name, addr); return i2c_new_dummy_device(client->adapter, addr); @@ -1651,12 +1649,10 @@ int i2c_add_adapter(struct i2c_adapter *adapter) struct device *dev = &adapter->dev; int id; - if (dev->of_node) { - id = of_alias_get_id(dev->of_node, "i2c"); - if (id >= 0) { - adapter->nr = id; - return __i2c_add_numbered_adapter(adapter); - } + id = of_alias_get_id(dev->of_node, "i2c"); + if (id >= 0) { + adapter->nr = id; + return __i2c_add_numbered_adapter(adapter); } mutex_lock(&core_lock);