public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/6] i2c: core: Move client towards fwnode
@ 2025-04-07  9:55 Andy Shevchenko
  2025-04-07  9:55 ` [PATCH v2 1/6] i2c: core: Drop duplicate check before calling OF APIs Andy Shevchenko
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Andy Shevchenko @ 2025-04-07  9:55 UTC (permalink / raw)
  To: Andy Shevchenko, Wolfram Sang, linux-i2c, linux-kernel; +Cc: Tomi Valkeinen

The struct i2c_board_info has of_node and fwnode members. This is
quite confusing as they are of the same semantics and it's tend
to have an issue if user assigns both. Luckily there is only a
single driver that does this and fix was sent today. Nevertheless
the series moves the client handling code to use fwnode and deprecates
the of_node member in the respective documentation.

Tomi, can you test this series + the patch we discussed earlier so it works as
expected?

In v2:
- covered i2c-core-slave.c where it makes sense
- covered i2c-core-of.c where it makes sense
- rebased on top of the latest code base

Andy Shevchenko (6):
  i2c: core: Drop duplicate check before calling OF APIs
  i2c: core: Unify the firmware node type check
  i2c: core: Switch to fwnode APIs to get IRQ
  i2c: core: Reuse fwnode variable where it makes sense
  i2c: core: Do not dereference fwnode in struct device
  i2c: core: Deprecate of_node in struct i2c_board_info

 drivers/i2c/i2c-core-base.c  | 59 ++++++++++++++++++------------------
 drivers/i2c/i2c-core-of.c    |  1 -
 drivers/i2c/i2c-core-slave.c | 11 ++++---
 include/linux/i2c.h          |  2 +-
 4 files changed, 37 insertions(+), 36 deletions(-)

-- 
2.47.2


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v2 1/6] i2c: core: Drop duplicate check before calling OF APIs
  2025-04-07  9:55 [PATCH v2 0/6] i2c: core: Move client towards fwnode Andy Shevchenko
@ 2025-04-07  9:55 ` Andy Shevchenko
  2025-04-07  9:55 ` [PATCH v2 2/6] i2c: core: Unify the firmware node type check Andy Shevchenko
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Andy Shevchenko @ 2025-04-07  9:55 UTC (permalink / raw)
  To: Andy Shevchenko, Wolfram Sang, linux-i2c, linux-kernel; +Cc: Tomi Valkeinen

OF APIs are usually NULL-aware and returns 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.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/i2c-core-base.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 7ad1ad5c8c3f..c14ffd6190d3 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);
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 2/6] i2c: core: Unify the firmware node type check
  2025-04-07  9:55 [PATCH v2 0/6] i2c: core: Move client towards fwnode Andy Shevchenko
  2025-04-07  9:55 ` [PATCH v2 1/6] i2c: core: Drop duplicate check before calling OF APIs Andy Shevchenko
@ 2025-04-07  9:55 ` Andy Shevchenko
  2025-04-07 12:45   ` kernel test robot
  2025-04-07 13:47   ` kernel test robot
  2025-04-07  9:55 ` [PATCH v2 3/6] i2c: core: Switch to fwnode APIs to get IRQ Andy Shevchenko
                   ` (4 subsequent siblings)
  6 siblings, 2 replies; 13+ messages in thread
From: Andy Shevchenko @ 2025-04-07  9:55 UTC (permalink / raw)
  To: Andy Shevchenko, Wolfram Sang, linux-i2c, linux-kernel; +Cc: Tomi Valkeinen

OF and ACPI currently are using asymmetrical APIs to check
for the firmware node type. Unify them by using is_*_node()
against struct fwnode_handle pointer.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/i2c-core-base.c  | 14 ++++++++------
 drivers/i2c/i2c-core-slave.c | 11 +++++++----
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index c14ffd6190d3..edab56e5d5e5 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -490,6 +490,7 @@ static int i2c_smbus_host_notify_to_irq(const struct i2c_client *client)
 
 static int i2c_device_probe(struct device *dev)
 {
+	struct fwnode_handle	*fwnode = dev_fwnode(dev);
 	struct i2c_client	*client = i2c_verify_client(dev);
 	struct i2c_driver	*driver;
 	bool do_power_on;
@@ -508,11 +509,11 @@ static int i2c_device_probe(struct device *dev)
 			/* Keep adapter active when Host Notify is required */
 			pm_runtime_get_sync(&client->adapter->dev);
 			irq = i2c_smbus_host_notify_to_irq(client);
-		} else if (dev->of_node) {
+		} else if (is_of_node(fwnode)) {
 			irq = of_irq_get_byname(dev->of_node, "irq");
 			if (irq == -EINVAL || irq == -ENODATA)
 				irq = of_irq_get(dev->of_node, 0);
-		} else if (ACPI_COMPANION(dev)) {
+		} else if (is_acpi_device_node(fwnode)) {
 			bool wake_capable;
 
 			irq = i2c_acpi_get_irq(client, &wake_capable);
@@ -1054,15 +1055,16 @@ EXPORT_SYMBOL_GPL(i2c_new_client_device);
  */
 void i2c_unregister_device(struct i2c_client *client)
 {
+	struct fwnode_handle *fwnode;
+
 	if (IS_ERR_OR_NULL(client))
 		return;
 
-	if (client->dev.of_node) {
+	fwnode = dev_fwnode(&client->dev);
+	if (is_of_node(fwnode)) {
 		of_node_clear_flag(client->dev.of_node, OF_POPULATED);
 		of_node_put(client->dev.of_node);
-	}
-
-	if (ACPI_COMPANION(&client->dev))
+	} else if (is_acpi_device_node(fwnode))
 		acpi_device_clear_enumerated(ACPI_COMPANION(&client->dev));
 
 	device_remove_software_node(&client->dev);
diff --git a/drivers/i2c/i2c-core-slave.c b/drivers/i2c/i2c-core-slave.c
index faefe1dfa8e5..3c5cb61b8c39 100644
--- a/drivers/i2c/i2c-core-slave.c
+++ b/drivers/i2c/i2c-core-slave.c
@@ -11,6 +11,7 @@
 #include <linux/err.h>
 #include <linux/i2c.h>
 #include <linux/of.h>
+#include <linux/property.h>
 
 #include "i2c-core.h"
 
@@ -108,15 +109,17 @@ EXPORT_SYMBOL_GPL(i2c_slave_event);
  */
 bool i2c_detect_slave_mode(struct device *dev)
 {
-	if (IS_BUILTIN(CONFIG_OF) && dev->of_node) {
+	struct fwnode_handle *fwnode = dev_fwnode(dev);
+
+	if (is_of_node(fwnode)) {
 		u32 reg;
 
-		for_each_child_of_node_scoped(dev->of_node, child) {
-			of_property_read_u32(child, "reg", &reg);
+		for_each_child_node_scoped(fwnode, child) {
+			fwnode_property_read_u32(child, "reg", &reg);
 			if (reg & I2C_OWN_SLAVE_ADDRESS)
 				return true;
 		}
-	} else if (IS_BUILTIN(CONFIG_ACPI) && ACPI_HANDLE(dev)) {
+	} else if (is_acpi_device_node(fwnode)) {
 		dev_dbg(dev, "ACPI slave is not supported yet\n");
 	}
 	return false;
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 3/6] i2c: core: Switch to fwnode APIs to get IRQ
  2025-04-07  9:55 [PATCH v2 0/6] i2c: core: Move client towards fwnode Andy Shevchenko
  2025-04-07  9:55 ` [PATCH v2 1/6] i2c: core: Drop duplicate check before calling OF APIs Andy Shevchenko
  2025-04-07  9:55 ` [PATCH v2 2/6] i2c: core: Unify the firmware node type check Andy Shevchenko
@ 2025-04-07  9:55 ` Andy Shevchenko
  2025-04-07 13:47   ` kernel test robot
  2025-04-07  9:55 ` [PATCH v2 4/6] i2c: core: Reuse fwnode variable where it makes sense Andy Shevchenko
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: Andy Shevchenko @ 2025-04-07  9:55 UTC (permalink / raw)
  To: Andy Shevchenko, Wolfram Sang, linux-i2c, linux-kernel; +Cc: Tomi Valkeinen

Switch to fwnode APIs to get IRQ. In particular this enables
a support of the separate wakeup IRQ. The rest is converted
just for the sake of consistency and fwnode reuse.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/i2c-core-base.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index edab56e5d5e5..196b29e5924b 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -33,7 +33,6 @@
 #include <linux/mutex.h>
 #include <linux/of_device.h>
 #include <linux/of.h>
-#include <linux/of_irq.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/pinctrl/devinfo.h>
 #include <linux/pm_domain.h>
@@ -510,9 +509,9 @@ static int i2c_device_probe(struct device *dev)
 			pm_runtime_get_sync(&client->adapter->dev);
 			irq = i2c_smbus_host_notify_to_irq(client);
 		} else if (is_of_node(fwnode)) {
-			irq = of_irq_get_byname(dev->of_node, "irq");
+			irq = fwnode_irq_get_byname(fwnode, "irq");
 			if (irq == -EINVAL || irq == -ENODATA)
-				irq = of_irq_get(dev->of_node, 0);
+				irq = fwnode_irq_get(fwnode, 0);
 		} else if (is_acpi_device_node(fwnode)) {
 			bool wake_capable;
 
@@ -547,7 +546,7 @@ static int i2c_device_probe(struct device *dev)
 	if (client->flags & I2C_CLIENT_WAKE) {
 		int wakeirq;
 
-		wakeirq = of_irq_get_byname(dev->of_node, "wakeup");
+		wakeirq = fwnode_irq_get_byname(fwnode, "wakeup");
 		if (wakeirq == -EPROBE_DEFER) {
 			status = wakeirq;
 			goto put_sync_adapter;
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 4/6] i2c: core: Reuse fwnode variable where it makes sense
  2025-04-07  9:55 [PATCH v2 0/6] i2c: core: Move client towards fwnode Andy Shevchenko
                   ` (2 preceding siblings ...)
  2025-04-07  9:55 ` [PATCH v2 3/6] i2c: core: Switch to fwnode APIs to get IRQ Andy Shevchenko
@ 2025-04-07  9:55 ` Andy Shevchenko
  2025-04-07  9:55 ` [PATCH v2 5/6] i2c: core: Do not dereference fwnode in struct device Andy Shevchenko
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Andy Shevchenko @ 2025-04-07  9:55 UTC (permalink / raw)
  To: Andy Shevchenko, Wolfram Sang, linux-i2c, linux-kernel; +Cc: Tomi Valkeinen

Reuse fwnode variable where it makes sense. This avoids unneeded
duplication hidden in some macros and unifies the code for different
types of fwnode.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/i2c-core-base.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 196b29e5924b..a0d3aec6c00e 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -567,7 +567,7 @@ static int i2c_device_probe(struct device *dev)
 
 	dev_dbg(dev, "probe\n");
 
-	status = of_clk_set_defaults(dev->of_node, false);
+	status = of_clk_set_defaults(to_of_node(fwnode), false);
 	if (status < 0)
 		goto err_clear_wakeup_irq;
 
@@ -1061,10 +1061,10 @@ void i2c_unregister_device(struct i2c_client *client)
 
 	fwnode = dev_fwnode(&client->dev);
 	if (is_of_node(fwnode)) {
-		of_node_clear_flag(client->dev.of_node, OF_POPULATED);
+		of_node_clear_flag(to_of_node(fwnode), OF_POPULATED);
 		of_node_put(client->dev.of_node);
 	} else if (is_acpi_device_node(fwnode))
-		acpi_device_clear_enumerated(ACPI_COMPANION(&client->dev));
+		acpi_device_clear_enumerated(to_acpi_device_node(fwnode));
 
 	device_remove_software_node(&client->dev);
 	device_unregister(&client->dev);
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 5/6] i2c: core: Do not dereference fwnode in struct device
  2025-04-07  9:55 [PATCH v2 0/6] i2c: core: Move client towards fwnode Andy Shevchenko
                   ` (3 preceding siblings ...)
  2025-04-07  9:55 ` [PATCH v2 4/6] i2c: core: Reuse fwnode variable where it makes sense Andy Shevchenko
@ 2025-04-07  9:55 ` Andy Shevchenko
  2025-04-07  9:55 ` [PATCH v2 6/6] i2c: core: Deprecate of_node in struct i2c_board_info Andy Shevchenko
  2025-04-07 11:34 ` [PATCH v2 0/6] i2c: core: Move client towards fwnode Tomi Valkeinen
  6 siblings, 0 replies; 13+ messages in thread
From: Andy Shevchenko @ 2025-04-07  9:55 UTC (permalink / raw)
  To: Andy Shevchenko, Wolfram Sang, linux-i2c, linux-kernel; +Cc: Tomi Valkeinen

In order to make the underneath API easier to change in the future,
prevent users from dereferencing fwnode from struct device.
Instead, use the specific device_set_node() API for that.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/i2c-core-base.c | 18 ++++++++++--------
 drivers/i2c/i2c-core-of.c   |  1 -
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index a0d3aec6c00e..c0df67619364 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -961,6 +961,7 @@ static void i2c_unlock_addr(struct i2c_adapter *adap, unsigned short addr,
 struct i2c_client *
 i2c_new_client_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
 {
+	struct fwnode_handle *fwnode;
 	struct i2c_client *client;
 	bool need_put = false;
 	int status;
@@ -1001,18 +1002,19 @@ i2c_new_client_device(struct i2c_adapter *adap, struct i2c_board_info const *inf
 	client->dev.parent = &client->adapter->dev;
 	client->dev.bus = &i2c_bus_type;
 	client->dev.type = &i2c_client_type;
-	client->dev.of_node = of_node_get(info->of_node);
-	client->dev.fwnode = info->fwnode;
 
 	device_enable_async_suspend(&client->dev);
 
+	fwnode = info->fwnode ?: of_fwnode_handle(info->of_node);
+	device_set_node(&client->dev, fwnode_handle_get(fwnode));
+
 	if (info->swnode) {
 		status = device_add_software_node(&client->dev, info->swnode);
 		if (status) {
 			dev_err(&adap->dev,
 				"Failed to add software node to client %s: %d\n",
 				client->name, status);
-			goto out_err_put_of_node;
+			goto out_err_put_fwnode;
 		}
 	}
 
@@ -1031,8 +1033,8 @@ i2c_new_client_device(struct i2c_adapter *adap, struct i2c_board_info const *inf
 out_remove_swnode:
 	device_remove_software_node(&client->dev);
 	need_put = true;
-out_err_put_of_node:
-	of_node_put(info->of_node);
+out_err_put_fwnode:
+	fwnode_handle_put(fwnode);
 out_err:
 	dev_err(&adap->dev,
 		"Failed to register i2c client %s at 0x%02x (%d)\n",
@@ -1060,11 +1062,11 @@ void i2c_unregister_device(struct i2c_client *client)
 		return;
 
 	fwnode = dev_fwnode(&client->dev);
-	if (is_of_node(fwnode)) {
+	if (is_of_node(fwnode))
 		of_node_clear_flag(to_of_node(fwnode), OF_POPULATED);
-		of_node_put(client->dev.of_node);
-	} else if (is_acpi_device_node(fwnode))
+	else if (is_acpi_device_node(fwnode))
 		acpi_device_clear_enumerated(to_acpi_device_node(fwnode));
+	fwnode_handle_put(fwnode);
 
 	device_remove_software_node(&client->dev);
 	device_unregister(&client->dev);
diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c
index 02feee6c9ba9..eb7fb202355f 100644
--- a/drivers/i2c/i2c-core-of.c
+++ b/drivers/i2c/i2c-core-of.c
@@ -49,7 +49,6 @@ int of_i2c_get_board_info(struct device *dev, struct device_node *node,
 	}
 
 	info->addr = addr;
-	info->of_node = node;
 	info->fwnode = of_fwnode_handle(node);
 
 	if (of_property_read_bool(node, "host-notify"))
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 6/6] i2c: core: Deprecate of_node in struct i2c_board_info
  2025-04-07  9:55 [PATCH v2 0/6] i2c: core: Move client towards fwnode Andy Shevchenko
                   ` (4 preceding siblings ...)
  2025-04-07  9:55 ` [PATCH v2 5/6] i2c: core: Do not dereference fwnode in struct device Andy Shevchenko
@ 2025-04-07  9:55 ` Andy Shevchenko
  2025-04-07 11:34 ` [PATCH v2 0/6] i2c: core: Move client towards fwnode Tomi Valkeinen
  6 siblings, 0 replies; 13+ messages in thread
From: Andy Shevchenko @ 2025-04-07  9:55 UTC (permalink / raw)
  To: Andy Shevchenko, Wolfram Sang, linux-i2c, linux-kernel; +Cc: Tomi Valkeinen

Two members of the same or similar semantics is quite confusing to begin with.
Moreover, the fwnode covers all possible firmware descriptions that Linux kernel
supports. Deprecate of_node in struct i2c_board_info, so users will be warned
and in the future remote it completely.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/i2c.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 2e4903b7f7bc..cc1437f29823 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -405,7 +405,7 @@ static inline bool i2c_detect_slave_mode(struct device *dev) { return false; }
  * @addr: stored in i2c_client.addr
  * @dev_name: Overrides the default <busnr>-<addr> dev_name if set
  * @platform_data: stored in i2c_client.dev.platform_data
- * @of_node: pointer to OpenFirmware device node
+ * @of_node: **DEPRECATED** - use @fwnode for this
  * @fwnode: device node supplied by the platform firmware
  * @swnode: software node for the device
  * @resources: resources associated with the device
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 0/6] i2c: core: Move client towards fwnode
  2025-04-07  9:55 [PATCH v2 0/6] i2c: core: Move client towards fwnode Andy Shevchenko
                   ` (5 preceding siblings ...)
  2025-04-07  9:55 ` [PATCH v2 6/6] i2c: core: Deprecate of_node in struct i2c_board_info Andy Shevchenko
@ 2025-04-07 11:34 ` Tomi Valkeinen
  2025-04-07 12:23   ` Andy Shevchenko
  6 siblings, 1 reply; 13+ messages in thread
From: Tomi Valkeinen @ 2025-04-07 11:34 UTC (permalink / raw)
  To: Andy Shevchenko, Wolfram Sang, linux-i2c, linux-kernel

Hi Andy,

On 07/04/2025 12:55, Andy Shevchenko wrote:
> The struct i2c_board_info has of_node and fwnode members. This is
> quite confusing as they are of the same semantics and it's tend
> to have an issue if user assigns both. Luckily there is only a
> single driver that does this and fix was sent today. Nevertheless
> the series moves the client handling code to use fwnode and deprecates
> the of_node member in the respective documentation.
> 
> Tomi, can you test this series + the patch we discussed earlier so it works as
> expected?

I tested this series, and then tested this series + "[PATCH v1 1/1] 
media: i2c: ds90ub960: Remove of_node assignment". I didn't see anything 
amiss in either case.

Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

I assume the ds90ub960 patch is the "single driver that does this and 
fix was sent today"? If so, I think that patch could have been included 
in this series as well, there's hardly a chance of conflicts with the 
one liner. And if applied separately, we probably need to apply the 
ub960 patch one kernel version later than this series.

  Tomi

> 
> In v2:
> - covered i2c-core-slave.c where it makes sense
> - covered i2c-core-of.c where it makes sense
> - rebased on top of the latest code base
> 
> Andy Shevchenko (6):
>    i2c: core: Drop duplicate check before calling OF APIs
>    i2c: core: Unify the firmware node type check
>    i2c: core: Switch to fwnode APIs to get IRQ
>    i2c: core: Reuse fwnode variable where it makes sense
>    i2c: core: Do not dereference fwnode in struct device
>    i2c: core: Deprecate of_node in struct i2c_board_info
> 
>   drivers/i2c/i2c-core-base.c  | 59 ++++++++++++++++++------------------
>   drivers/i2c/i2c-core-of.c    |  1 -
>   drivers/i2c/i2c-core-slave.c | 11 ++++---
>   include/linux/i2c.h          |  2 +-
>   4 files changed, 37 insertions(+), 36 deletions(-)
> 


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 0/6] i2c: core: Move client towards fwnode
  2025-04-07 11:34 ` [PATCH v2 0/6] i2c: core: Move client towards fwnode Tomi Valkeinen
@ 2025-04-07 12:23   ` Andy Shevchenko
  0 siblings, 0 replies; 13+ messages in thread
From: Andy Shevchenko @ 2025-04-07 12:23 UTC (permalink / raw)
  To: Tomi Valkeinen; +Cc: Wolfram Sang, linux-i2c, linux-kernel

On Mon, Apr 07, 2025 at 02:34:48PM +0300, Tomi Valkeinen wrote:
> On 07/04/2025 12:55, Andy Shevchenko wrote:
> > The struct i2c_board_info has of_node and fwnode members. This is
> > quite confusing as they are of the same semantics and it's tend
> > to have an issue if user assigns both. Luckily there is only a
> > single driver that does this and fix was sent today. Nevertheless
> > the series moves the client handling code to use fwnode and deprecates
> > the of_node member in the respective documentation.
> > 
> > Tomi, can you test this series + the patch we discussed earlier so it works as
> > expected?
> 
> I tested this series, and then tested this series + "[PATCH v1 1/1] media:
> i2c: ds90ub960: Remove of_node assignment". I didn't see anything amiss in
> either case.
> 
> Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

Thank you very much for the testing!

> I assume the ds90ub960 patch is the "single driver that does this and fix
> was sent today"? If so, I think that patch could have been included in this
> series as well, there's hardly a chance of conflicts with the one liner. And
> if applied separately, we probably need to apply the ub960 patch one kernel
> version later than this series.

Yeah, I forgot to update the cover letter to point to that one out.
I agree on everything you said above. But let's wait a bit for Wolfram
to comment on / apply this first. It would be nice to have it in, so
we prevent new ambiguous users from appearing.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 2/6] i2c: core: Unify the firmware node type check
  2025-04-07  9:55 ` [PATCH v2 2/6] i2c: core: Unify the firmware node type check Andy Shevchenko
@ 2025-04-07 12:45   ` kernel test robot
  2025-04-07 13:48     ` Andy Shevchenko
  2025-04-07 13:47   ` kernel test robot
  1 sibling, 1 reply; 13+ messages in thread
From: kernel test robot @ 2025-04-07 12:45 UTC (permalink / raw)
  To: Andy Shevchenko, Wolfram Sang, linux-i2c, linux-kernel
  Cc: oe-kbuild-all, Tomi Valkeinen

Hi Andy,

kernel test robot noticed the following build errors:

[auto build test ERROR on wsa/i2c/for-next]
[also build test ERROR on linus/master v6.15-rc1 next-20250407]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/i2c-core-Drop-duplicate-check-before-calling-OF-APIs/20250407-180528
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
patch link:    https://lore.kernel.org/r/20250407095852.215809-3-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v2 2/6] i2c: core: Unify the firmware node type check
config: arc-randconfig-002-20250407 (https://download.01.org/0day-ci/archive/20250407/202504072041.Bv9mOk4o-lkp@intel.com/config)
compiler: arc-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250407/202504072041.Bv9mOk4o-lkp@intel.com/reproduce)

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>
| Closes: https://lore.kernel.org/oe-kbuild-all/202504072041.Bv9mOk4o-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   drivers/i2c/i2c-core-slave.c: In function 'i2c_detect_slave_mode':
>> drivers/i2c/i2c-core-slave.c:117:17: error: implicit declaration of function 'for_each_child_node_scoped'; did you mean 'for_each_child_of_node_scoped'? [-Wimplicit-function-declaration]
     117 |                 for_each_child_node_scoped(fwnode, child) {
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~
         |                 for_each_child_of_node_scoped
>> drivers/i2c/i2c-core-slave.c:117:52: error: 'child' undeclared (first use in this function)
     117 |                 for_each_child_node_scoped(fwnode, child) {
         |                                                    ^~~~~
   drivers/i2c/i2c-core-slave.c:117:52: note: each undeclared identifier is reported only once for each function it appears in
>> drivers/i2c/i2c-core-slave.c:117:58: error: expected ';' before '{' token
     117 |                 for_each_child_node_scoped(fwnode, child) {
         |                                                          ^~
         |                                                          ;
>> drivers/i2c/i2c-core-slave.c:115:21: warning: unused variable 'reg' [-Wunused-variable]
     115 |                 u32 reg;
         |                     ^~~


vim +117 drivers/i2c/i2c-core-slave.c

    97	
    98	/**
    99	 * i2c_detect_slave_mode - detect operation mode
   100	 * @dev: The device owning the bus
   101	 *
   102	 * This checks the device nodes for an I2C slave by checking the address
   103	 * used in the reg property. If the address match the I2C_OWN_SLAVE_ADDRESS
   104	 * flag this means the device is configured to act as a I2C slave and it will
   105	 * be listening at that address.
   106	 *
   107	 * Returns true if an I2C own slave address is detected, otherwise returns
   108	 * false.
   109	 */
   110	bool i2c_detect_slave_mode(struct device *dev)
   111	{
   112		struct fwnode_handle *fwnode = dev_fwnode(dev);
   113	
   114		if (is_of_node(fwnode)) {
 > 115			u32 reg;
   116	
 > 117			for_each_child_node_scoped(fwnode, child) {

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 3/6] i2c: core: Switch to fwnode APIs to get IRQ
  2025-04-07  9:55 ` [PATCH v2 3/6] i2c: core: Switch to fwnode APIs to get IRQ Andy Shevchenko
@ 2025-04-07 13:47   ` kernel test robot
  0 siblings, 0 replies; 13+ messages in thread
From: kernel test robot @ 2025-04-07 13:47 UTC (permalink / raw)
  To: Andy Shevchenko, Wolfram Sang, linux-i2c, linux-kernel
  Cc: oe-kbuild-all, Tomi Valkeinen

Hi Andy,

kernel test robot noticed the following build errors:

[auto build test ERROR on wsa/i2c/for-next]
[also build test ERROR on linus/master v6.15-rc1 next-20250407]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/i2c-core-Drop-duplicate-check-before-calling-OF-APIs/20250407-180528
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
patch link:    https://lore.kernel.org/r/20250407095852.215809-4-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v2 3/6] i2c: core: Switch to fwnode APIs to get IRQ
config: i386-buildonly-randconfig-002-20250407 (https://download.01.org/0day-ci/archive/20250407/202504072135.1Uy3AQ3g-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250407/202504072135.1Uy3AQ3g-lkp@intel.com/reproduce)

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>
| Closes: https://lore.kernel.org/oe-kbuild-all/202504072135.1Uy3AQ3g-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   drivers/i2c/i2c-core-base.c: In function 'i2c_dev_irq_from_resources':
>> drivers/i2c/i2c-core-base.c:911:32: error: implicit declaration of function 'irq_get_irq_data'; did you mean 'irq_set_irq_wake'? [-Werror=implicit-function-declaration]
     911 |                         irqd = irq_get_irq_data(r->start);
         |                                ^~~~~~~~~~~~~~~~
         |                                irq_set_irq_wake
>> drivers/i2c/i2c-core-base.c:911:30: warning: assignment to 'struct irq_data *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     911 |                         irqd = irq_get_irq_data(r->start);
         |                              ^
>> drivers/i2c/i2c-core-base.c:915:25: error: implicit declaration of function 'irqd_set_trigger_type' [-Werror=implicit-function-declaration]
     915 |                         irqd_set_trigger_type(irqd, r->flags & IORESOURCE_BITS);
         |                         ^~~~~~~~~~~~~~~~~~~~~
   drivers/i2c/i2c-core-base.c: In function 'i2c_host_notify_irq_map':
>> drivers/i2c/i2c-core-base.c:1458:9: error: implicit declaration of function 'irq_set_chip_and_handler' [-Werror=implicit-function-declaration]
    1458 |         irq_set_chip_and_handler(virq, &dummy_irq_chip, handle_simple_irq);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/i2c/i2c-core-base.c:1458:41: error: 'dummy_irq_chip' undeclared (first use in this function)
    1458 |         irq_set_chip_and_handler(virq, &dummy_irq_chip, handle_simple_irq);
         |                                         ^~~~~~~~~~~~~~
   drivers/i2c/i2c-core-base.c:1458:41: note: each undeclared identifier is reported only once for each function it appears in
>> drivers/i2c/i2c-core-base.c:1458:57: error: 'handle_simple_irq' undeclared (first use in this function)
    1458 |         irq_set_chip_and_handler(virq, &dummy_irq_chip, handle_simple_irq);
         |                                                         ^~~~~~~~~~~~~~~~~
   drivers/i2c/i2c-core-base.c: In function 'i2c_handle_smbus_host_notify':
>> drivers/i2c/i2c-core-base.c:1508:9: error: implicit declaration of function 'generic_handle_irq_safe' [-Werror=implicit-function-declaration]
    1508 |         generic_handle_irq_safe(irq);
         |         ^~~~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors


vim +911 drivers/i2c/i2c-core-base.c

70762abb9f89d97 drivers/i2c/i2c-core.c      Jarkko Nikula   2013-11-14  897  
1d7534b6adcd3e4 drivers/i2c/i2c-core-base.c Charles Keepax  2019-06-27  898  int i2c_dev_irq_from_resources(const struct resource *resources,
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  899  			       unsigned int num_resources)
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  900  {
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  901  	struct irq_data *irqd;
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  902  	int i;
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  903  
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  904  	for (i = 0; i < num_resources; i++) {
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  905  		const struct resource *r = &resources[i];
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  906  
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  907  		if (resource_type(r) != IORESOURCE_IRQ)
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  908  			continue;
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  909  
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  910  		if (r->flags & IORESOURCE_BITS) {
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01 @911  			irqd = irq_get_irq_data(r->start);
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  912  			if (!irqd)
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  913  				break;
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  914  
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01 @915  			irqd_set_trigger_type(irqd, r->flags & IORESOURCE_BITS);
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  916  		}
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  917  
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  918  		return r->start;
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  919  	}
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  920  
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  921  	return 0;
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  922  }
4124c4eba40256b drivers/i2c/i2c-core.c      Dmitry Torokhov 2017-03-01  923  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 2/6] i2c: core: Unify the firmware node type check
  2025-04-07  9:55 ` [PATCH v2 2/6] i2c: core: Unify the firmware node type check Andy Shevchenko
  2025-04-07 12:45   ` kernel test robot
@ 2025-04-07 13:47   ` kernel test robot
  1 sibling, 0 replies; 13+ messages in thread
From: kernel test robot @ 2025-04-07 13:47 UTC (permalink / raw)
  To: Andy Shevchenko, Wolfram Sang, linux-i2c, linux-kernel
  Cc: llvm, oe-kbuild-all, Tomi Valkeinen

Hi Andy,

kernel test robot noticed the following build errors:

[auto build test ERROR on wsa/i2c/for-next]
[also build test ERROR on linus/master v6.15-rc1 next-20250407]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/i2c-core-Drop-duplicate-check-before-calling-OF-APIs/20250407-180528
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
patch link:    https://lore.kernel.org/r/20250407095852.215809-3-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v2 2/6] i2c: core: Unify the firmware node type check
config: arm-randconfig-002-20250407 (https://download.01.org/0day-ci/archive/20250407/202504072133.J8njROAD-lkp@intel.com/config)
compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project 92c93f5286b9ff33f27ff694d2dc33da1c07afdd)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250407/202504072133.J8njROAD-lkp@intel.com/reproduce)

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>
| Closes: https://lore.kernel.org/oe-kbuild-all/202504072133.J8njROAD-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/i2c/i2c-core-slave.c:117:3: error: call to undeclared function 'for_each_child_node_scoped'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     117 |                 for_each_child_node_scoped(fwnode, child) {
         |                 ^
>> drivers/i2c/i2c-core-slave.c:117:44: error: expected ';' after expression
     117 |                 for_each_child_node_scoped(fwnode, child) {
         |                                                          ^
         |                                                          ;
>> drivers/i2c/i2c-core-slave.c:117:38: error: use of undeclared identifier 'child'; did you mean 'ihold'?
     117 |                 for_each_child_node_scoped(fwnode, child) {
         |                                                    ^~~~~
         |                                                    ihold
   include/linux/fs.h:2758:13: note: 'ihold' declared here
    2758 | extern void ihold(struct inode * inode);
         |             ^
   drivers/i2c/i2c-core-slave.c:118:29: error: use of undeclared identifier 'child'; did you mean 'ihold'?
     118 |                         fwnode_property_read_u32(child, "reg", &reg);
         |                                                  ^~~~~
         |                                                  ihold
   include/linux/fs.h:2758:13: note: 'ihold' declared here
    2758 | extern void ihold(struct inode * inode);
         |             ^
   4 errors generated.


vim +/for_each_child_node_scoped +117 drivers/i2c/i2c-core-slave.c

    97	
    98	/**
    99	 * i2c_detect_slave_mode - detect operation mode
   100	 * @dev: The device owning the bus
   101	 *
   102	 * This checks the device nodes for an I2C slave by checking the address
   103	 * used in the reg property. If the address match the I2C_OWN_SLAVE_ADDRESS
   104	 * flag this means the device is configured to act as a I2C slave and it will
   105	 * be listening at that address.
   106	 *
   107	 * Returns true if an I2C own slave address is detected, otherwise returns
   108	 * false.
   109	 */
   110	bool i2c_detect_slave_mode(struct device *dev)
   111	{
   112		struct fwnode_handle *fwnode = dev_fwnode(dev);
   113	
   114		if (is_of_node(fwnode)) {
   115			u32 reg;
   116	
 > 117			for_each_child_node_scoped(fwnode, child) {

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 2/6] i2c: core: Unify the firmware node type check
  2025-04-07 12:45   ` kernel test robot
@ 2025-04-07 13:48     ` Andy Shevchenko
  0 siblings, 0 replies; 13+ messages in thread
From: Andy Shevchenko @ 2025-04-07 13:48 UTC (permalink / raw)
  To: kernel test robot
  Cc: Wolfram Sang, linux-i2c, linux-kernel, oe-kbuild-all,
	Tomi Valkeinen

On Mon, Apr 07, 2025 at 08:45:14PM +0800, kernel test robot wrote:
> Hi Andy,
> 
> kernel test robot noticed the following build errors:
> 
> [auto build test ERROR on wsa/i2c/for-next]
> [also build test ERROR on linus/master v6.15-rc1 next-20250407]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/i2c-core-Drop-duplicate-check-before-calling-OF-APIs/20250407-180528
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
> patch link:    https://lore.kernel.org/r/20250407095852.215809-3-andriy.shevchenko%40linux.intel.com
> patch subject: [PATCH v2 2/6] i2c: core: Unify the firmware node type check
> config: arc-randconfig-002-20250407 (https://download.01.org/0day-ci/archive/20250407/202504072041.Bv9mOk4o-lkp@intel.com/config)
> compiler: arc-linux-gcc (GCC) 14.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250407/202504072041.Bv9mOk4o-lkp@intel.com/reproduce)
> 
> 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>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202504072041.Bv9mOk4o-lkp@intel.com/
> 

> All error/warnings (new ones prefixed by >>):

Ah, I should compile-test the slave part as well...
Will be fixed in v3. Since v3 is required, Tomi, I'm going to add the media
patch to its end.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-04-07 13:48 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-07  9:55 [PATCH v2 0/6] i2c: core: Move client towards fwnode Andy Shevchenko
2025-04-07  9:55 ` [PATCH v2 1/6] i2c: core: Drop duplicate check before calling OF APIs Andy Shevchenko
2025-04-07  9:55 ` [PATCH v2 2/6] i2c: core: Unify the firmware node type check Andy Shevchenko
2025-04-07 12:45   ` kernel test robot
2025-04-07 13:48     ` Andy Shevchenko
2025-04-07 13:47   ` kernel test robot
2025-04-07  9:55 ` [PATCH v2 3/6] i2c: core: Switch to fwnode APIs to get IRQ Andy Shevchenko
2025-04-07 13:47   ` kernel test robot
2025-04-07  9:55 ` [PATCH v2 4/6] i2c: core: Reuse fwnode variable where it makes sense Andy Shevchenko
2025-04-07  9:55 ` [PATCH v2 5/6] i2c: core: Do not dereference fwnode in struct device Andy Shevchenko
2025-04-07  9:55 ` [PATCH v2 6/6] i2c: core: Deprecate of_node in struct i2c_board_info Andy Shevchenko
2025-04-07 11:34 ` [PATCH v2 0/6] i2c: core: Move client towards fwnode Tomi Valkeinen
2025-04-07 12:23   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox