* [PATCH v4 1/7] i2c: core: Drop duplicate check before calling OF APIs
2025-04-14 10:01 [PATCH v4 0/7] i2c: core: Move client towards fwnode Andy Shevchenko
@ 2025-04-14 10:01 ` Andy Shevchenko
2025-04-14 10:01 ` [PATCH v4 2/7] i2c: core: Unify the firmware node type check Andy Shevchenko
` (5 subsequent siblings)
6 siblings, 0 replies; 22+ messages in thread
From: Andy Shevchenko @ 2025-04-14 10:01 UTC (permalink / raw)
To: Andy Shevchenko, Sakari Ailus, Mauro Carvalho Chehab,
Tomi Valkeinen, Jai Luthra, Wolfram Sang, linux-i2c, linux-kernel,
linux-media
Cc: Mauro Carvalho Chehab
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 <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
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] 22+ messages in thread* [PATCH v4 2/7] i2c: core: Unify the firmware node type check
2025-04-14 10:01 [PATCH v4 0/7] i2c: core: Move client towards fwnode Andy Shevchenko
2025-04-14 10:01 ` [PATCH v4 1/7] i2c: core: Drop duplicate check before calling OF APIs Andy Shevchenko
@ 2025-04-14 10:01 ` Andy Shevchenko
2025-04-16 6:51 ` Andy Shevchenko
2025-04-14 10:01 ` [PATCH v4 3/7] i2c: core: Switch to fwnode APIs to get IRQ Andy Shevchenko
` (4 subsequent siblings)
6 siblings, 1 reply; 22+ messages in thread
From: Andy Shevchenko @ 2025-04-14 10:01 UTC (permalink / raw)
To: Andy Shevchenko, Sakari Ailus, Mauro Carvalho Chehab,
Tomi Valkeinen, Jai Luthra, Wolfram Sang, linux-i2c, linux-kernel,
linux-media
Cc: Mauro Carvalho Chehab
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.
Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/i2c-core-base.c | 14 ++++++++------
drivers/i2c/i2c-core-slave.c | 12 ++++++++----
2 files changed, 16 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..7ee6b992b835 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,18 @@ 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)) {
+ struct fwnode_handle *child __free(fwnode_handle) = NULL;
u32 reg;
- for_each_child_of_node_scoped(dev->of_node, child) {
- of_property_read_u32(child, "reg", ®);
+ fwnode_for_each_child_node(fwnode, child) {
+ fwnode_property_read_u32(child, "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] 22+ messages in thread* Re: [PATCH v4 2/7] i2c: core: Unify the firmware node type check
2025-04-14 10:01 ` [PATCH v4 2/7] i2c: core: Unify the firmware node type check Andy Shevchenko
@ 2025-04-16 6:51 ` Andy Shevchenko
2025-04-16 6:52 ` Andy Shevchenko
0 siblings, 1 reply; 22+ messages in thread
From: Andy Shevchenko @ 2025-04-16 6:51 UTC (permalink / raw)
To: Sakari Ailus, Mauro Carvalho Chehab, Tomi Valkeinen, Jai Luthra,
Wolfram Sang, linux-i2c, linux-kernel, linux-media
Cc: Mauro Carvalho Chehab
On Mon, Apr 14, 2025 at 01:01:52PM +0300, Andy Shevchenko wrote:
> 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.
Note, media CI complains on wrong {} style, but
1) it was in the original code;
2) it is gone after the whole series applied.
I suggest to ignore that report based on the above.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH v4 2/7] i2c: core: Unify the firmware node type check
2025-04-16 6:51 ` Andy Shevchenko
@ 2025-04-16 6:52 ` Andy Shevchenko
0 siblings, 0 replies; 22+ messages in thread
From: Andy Shevchenko @ 2025-04-16 6:52 UTC (permalink / raw)
To: Sakari Ailus, Mauro Carvalho Chehab, Tomi Valkeinen, Jai Luthra,
Wolfram Sang, linux-i2c, linux-kernel, linux-media
Cc: Mauro Carvalho Chehab
On Wed, Apr 16, 2025 at 09:51:24AM +0300, Andy Shevchenko wrote:
> On Mon, Apr 14, 2025 at 01:01:52PM +0300, Andy Shevchenko wrote:
> > 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.
>
> Note, media CI complains on wrong {} style, but
> 1) it was in the original code;
Ah, actually not, it was not in the original code, so I can improve that,
of course, in v5.
> 2) it is gone after the whole series applied.
>
> I suggest to ignore that report based on the above.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v4 3/7] i2c: core: Switch to fwnode APIs to get IRQ
2025-04-14 10:01 [PATCH v4 0/7] i2c: core: Move client towards fwnode Andy Shevchenko
2025-04-14 10:01 ` [PATCH v4 1/7] i2c: core: Drop duplicate check before calling OF APIs Andy Shevchenko
2025-04-14 10:01 ` [PATCH v4 2/7] i2c: core: Unify the firmware node type check Andy Shevchenko
@ 2025-04-14 10:01 ` Andy Shevchenko
2025-04-15 20:06 ` Wolfram Sang
2025-04-14 10:01 ` [PATCH v4 4/7] i2c: core: Reuse fwnode variable where it makes sense Andy Shevchenko
` (3 subsequent siblings)
6 siblings, 1 reply; 22+ messages in thread
From: Andy Shevchenko @ 2025-04-14 10:01 UTC (permalink / raw)
To: Andy Shevchenko, Sakari Ailus, Mauro Carvalho Chehab,
Tomi Valkeinen, Jai Luthra, Wolfram Sang, linux-i2c, linux-kernel,
linux-media
Cc: Mauro Carvalho Chehab
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.
Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/i2c-core-base.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index edab56e5d5e5..04985abe0e5d 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -26,14 +26,13 @@
#include <linux/idr.h>
#include <linux/init.h>
#include <linux/interrupt.h>
-#include <linux/irqflags.h>
+#include <linux/irq.h>
#include <linux/jump_label.h>
#include <linux/kernel.h>
#include <linux/module.h>
#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] 22+ messages in thread* Re: [PATCH v4 3/7] i2c: core: Switch to fwnode APIs to get IRQ
2025-04-14 10:01 ` [PATCH v4 3/7] i2c: core: Switch to fwnode APIs to get IRQ Andy Shevchenko
@ 2025-04-15 20:06 ` Wolfram Sang
2025-04-16 6:23 ` Andy Shevchenko
0 siblings, 1 reply; 22+ messages in thread
From: Wolfram Sang @ 2025-04-15 20:06 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Sakari Ailus, Mauro Carvalho Chehab, Tomi Valkeinen, Jai Luthra,
linux-i2c, linux-kernel, linux-media, Mauro Carvalho Chehab
[-- Attachment #1: Type: text/plain, Size: 350 bytes --]
On Mon, Apr 14, 2025 at 01:01:53PM +0300, Andy Shevchenko wrote:
> Switch to fwnode APIs to get IRQ. In particular this enables
> a support of the separate wakeup IRQ. The rest is converted
You mean it enables the support of wakeup irqs for ACPI? Otherwise I
wouldn't know what you mean here...
> just for the sake of consistency and fwnode reuse.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v4 3/7] i2c: core: Switch to fwnode APIs to get IRQ
2025-04-15 20:06 ` Wolfram Sang
@ 2025-04-16 6:23 ` Andy Shevchenko
0 siblings, 0 replies; 22+ messages in thread
From: Andy Shevchenko @ 2025-04-16 6:23 UTC (permalink / raw)
To: Wolfram Sang, Sakari Ailus, Mauro Carvalho Chehab, Tomi Valkeinen,
Jai Luthra, linux-i2c, linux-kernel, linux-media,
Mauro Carvalho Chehab
On Tue, Apr 15, 2025 at 10:06:06PM +0200, Wolfram Sang wrote:
> On Mon, Apr 14, 2025 at 01:01:53PM +0300, Andy Shevchenko wrote:
> > Switch to fwnode APIs to get IRQ. In particular this enables
> > a support of the separate wakeup IRQ. The rest is converted
>
> You mean it enables the support of wakeup irqs for ACPI? Otherwise I
> wouldn't know what you mean here...
Re-reading this I'm also puzzled if I was interrupted in the middle
of writing it :-) From the code perspective, yes, I meant something
like that (rather "in non-OF cases").
> > just for the sake of consistency and fwnode reuse.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v4 4/7] i2c: core: Reuse fwnode variable where it makes sense
2025-04-14 10:01 [PATCH v4 0/7] i2c: core: Move client towards fwnode Andy Shevchenko
` (2 preceding siblings ...)
2025-04-14 10:01 ` [PATCH v4 3/7] i2c: core: Switch to fwnode APIs to get IRQ Andy Shevchenko
@ 2025-04-14 10:01 ` Andy Shevchenko
2025-04-14 10:01 ` [PATCH v4 5/7] i2c: core: Do not dereference fwnode in struct device Andy Shevchenko
` (2 subsequent siblings)
6 siblings, 0 replies; 22+ messages in thread
From: Andy Shevchenko @ 2025-04-14 10:01 UTC (permalink / raw)
To: Andy Shevchenko, Sakari Ailus, Mauro Carvalho Chehab,
Tomi Valkeinen, Jai Luthra, Wolfram Sang, linux-i2c, linux-kernel,
linux-media
Cc: Mauro Carvalho Chehab
Reuse fwnode variable where it makes sense. This avoids unneeded
duplication hidden in some macros and unifies the code for different
types of fwnode.
Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
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 04985abe0e5d..9ca1ade043ed 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] 22+ messages in thread* [PATCH v4 5/7] i2c: core: Do not dereference fwnode in struct device
2025-04-14 10:01 [PATCH v4 0/7] i2c: core: Move client towards fwnode Andy Shevchenko
` (3 preceding siblings ...)
2025-04-14 10:01 ` [PATCH v4 4/7] i2c: core: Reuse fwnode variable where it makes sense Andy Shevchenko
@ 2025-04-14 10:01 ` Andy Shevchenko
2025-04-16 6:55 ` Wolfram Sang
2025-04-14 10:01 ` [PATCH v4 6/7] i2c: core: Deprecate of_node in struct i2c_board_info Andy Shevchenko
2025-04-14 10:01 ` [PATCH v4 7/7] media: i2c: ds90ub960: Remove of_node assignment Andy Shevchenko
6 siblings, 1 reply; 22+ messages in thread
From: Andy Shevchenko @ 2025-04-14 10:01 UTC (permalink / raw)
To: Andy Shevchenko, Sakari Ailus, Mauro Carvalho Chehab,
Tomi Valkeinen, Jai Luthra, Wolfram Sang, linux-i2c, linux-kernel,
linux-media
Cc: Mauro Carvalho Chehab
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.
Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
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 9ca1ade043ed..dc3c60a7d382 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] 22+ messages in thread* Re: [PATCH v4 5/7] i2c: core: Do not dereference fwnode in struct device
2025-04-14 10:01 ` [PATCH v4 5/7] i2c: core: Do not dereference fwnode in struct device Andy Shevchenko
@ 2025-04-16 6:55 ` Wolfram Sang
2025-04-16 7:02 ` Andy Shevchenko
0 siblings, 1 reply; 22+ messages in thread
From: Wolfram Sang @ 2025-04-16 6:55 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Sakari Ailus, Mauro Carvalho Chehab, Tomi Valkeinen, Jai Luthra,
linux-i2c, linux-kernel, linux-media, Mauro Carvalho Chehab
[-- Attachment #1: Type: text/plain, Size: 612 bytes --]
On Mon, Apr 14, 2025 at 01:01:55PM +0300, Andy Shevchenko wrote:
> 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.
>
> Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
I'll check this patch later today. Rest of the series looks good to me
already.
Thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v4 5/7] i2c: core: Do not dereference fwnode in struct device
2025-04-16 6:55 ` Wolfram Sang
@ 2025-04-16 7:02 ` Andy Shevchenko
2025-04-16 7:20 ` Wolfram Sang
0 siblings, 1 reply; 22+ messages in thread
From: Andy Shevchenko @ 2025-04-16 7:02 UTC (permalink / raw)
To: Wolfram Sang, Sakari Ailus, Mauro Carvalho Chehab, Tomi Valkeinen,
Jai Luthra, linux-i2c, linux-kernel, linux-media,
Mauro Carvalho Chehab
On Wed, Apr 16, 2025 at 08:55:27AM +0200, Wolfram Sang wrote:
> On Mon, Apr 14, 2025 at 01:01:55PM +0300, Andy Shevchenko wrote:
> > 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.
> >
> > Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> > Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> I'll check this patch later today. Rest of the series looks good to me
> already.
Note, I'm planning to send a v5 shortly with the style fixes and commit
messages as you suggested.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v4 5/7] i2c: core: Do not dereference fwnode in struct device
2025-04-16 7:02 ` Andy Shevchenko
@ 2025-04-16 7:20 ` Wolfram Sang
2025-04-16 7:26 ` Andy Shevchenko
0 siblings, 1 reply; 22+ messages in thread
From: Wolfram Sang @ 2025-04-16 7:20 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Sakari Ailus, Mauro Carvalho Chehab, Tomi Valkeinen, Jai Luthra,
linux-i2c, linux-kernel, linux-media, Mauro Carvalho Chehab
[-- Attachment #1: Type: text/plain, Size: 933 bytes --]
On Wed, Apr 16, 2025 at 10:02:15AM +0300, Andy Shevchenko wrote:
> On Wed, Apr 16, 2025 at 08:55:27AM +0200, Wolfram Sang wrote:
> > On Mon, Apr 14, 2025 at 01:01:55PM +0300, Andy Shevchenko wrote:
> > > 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.
> > >
> > > Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> > > Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > > Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> >
> > I'll check this patch later today. Rest of the series looks good to me
> > already.
>
> Note, I'm planning to send a v5 shortly with the style fixes and commit
> messages as you suggested.
Please wait with that like half an hour.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v4 5/7] i2c: core: Do not dereference fwnode in struct device
2025-04-16 7:20 ` Wolfram Sang
@ 2025-04-16 7:26 ` Andy Shevchenko
0 siblings, 0 replies; 22+ messages in thread
From: Andy Shevchenko @ 2025-04-16 7:26 UTC (permalink / raw)
To: Wolfram Sang, Sakari Ailus, Mauro Carvalho Chehab, Tomi Valkeinen,
Jai Luthra, linux-i2c, linux-kernel, linux-media,
Mauro Carvalho Chehab
On Wed, Apr 16, 2025 at 09:20:52AM +0200, Wolfram Sang wrote:
> On Wed, Apr 16, 2025 at 10:02:15AM +0300, Andy Shevchenko wrote:
> > On Wed, Apr 16, 2025 at 08:55:27AM +0200, Wolfram Sang wrote:
> > > On Mon, Apr 14, 2025 at 01:01:55PM +0300, Andy Shevchenko wrote:
> > > > 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.
> > > >
> > > > Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> > > > Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > > > Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > >
> > > I'll check this patch later today. Rest of the series looks good to me
> > > already.
> >
> > Note, I'm planning to send a v5 shortly with the style fixes and commit
> > messages as you suggested.
>
> Please wait with that like half an hour.
Too late, I have sent it already...
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v4 6/7] i2c: core: Deprecate of_node in struct i2c_board_info
2025-04-14 10:01 [PATCH v4 0/7] i2c: core: Move client towards fwnode Andy Shevchenko
` (4 preceding siblings ...)
2025-04-14 10:01 ` [PATCH v4 5/7] i2c: core: Do not dereference fwnode in struct device Andy Shevchenko
@ 2025-04-14 10:01 ` Andy Shevchenko
2025-04-15 20:10 ` Wolfram Sang
2025-04-14 10:01 ` [PATCH v4 7/7] media: i2c: ds90ub960: Remove of_node assignment Andy Shevchenko
6 siblings, 1 reply; 22+ messages in thread
From: Andy Shevchenko @ 2025-04-14 10:01 UTC (permalink / raw)
To: Andy Shevchenko, Sakari Ailus, Mauro Carvalho Chehab,
Tomi Valkeinen, Jai Luthra, Wolfram Sang, linux-i2c, linux-kernel,
linux-media
Cc: Mauro Carvalho Chehab
Two members of the same or quite similar semantics is quite confusing
to begin with. Moreover, 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 remove it completely.
Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
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] 22+ messages in thread* Re: [PATCH v4 6/7] i2c: core: Deprecate of_node in struct i2c_board_info
2025-04-14 10:01 ` [PATCH v4 6/7] i2c: core: Deprecate of_node in struct i2c_board_info Andy Shevchenko
@ 2025-04-15 20:10 ` Wolfram Sang
2025-04-16 6:24 ` Andy Shevchenko
0 siblings, 1 reply; 22+ messages in thread
From: Wolfram Sang @ 2025-04-15 20:10 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Sakari Ailus, Mauro Carvalho Chehab, Tomi Valkeinen, Jai Luthra,
linux-i2c, linux-kernel, linux-media, Mauro Carvalho Chehab
[-- Attachment #1: Type: text/plain, Size: 194 bytes --]
> that Linux kernel supports. Deprecate of_node in struct i2c_board_info,
> so users will be warned and in the future remove it completely.
Is there a plan or volunteer to do the conversion?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v4 6/7] i2c: core: Deprecate of_node in struct i2c_board_info
2025-04-15 20:10 ` Wolfram Sang
@ 2025-04-16 6:24 ` Andy Shevchenko
2025-04-16 6:54 ` Wolfram Sang
0 siblings, 1 reply; 22+ messages in thread
From: Andy Shevchenko @ 2025-04-16 6:24 UTC (permalink / raw)
To: Wolfram Sang, Sakari Ailus, Mauro Carvalho Chehab, Tomi Valkeinen,
Jai Luthra, linux-i2c, linux-kernel, linux-media,
Mauro Carvalho Chehab
On Tue, Apr 15, 2025 at 10:10:14PM +0200, Wolfram Sang wrote:
>
> > that Linux kernel supports. Deprecate of_node in struct i2c_board_info,
> > so users will be warned and in the future remove it completely.
>
> Is there a plan or volunteer to do the conversion?
Yes, long-term as I'm alone for many janitor works.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v4 6/7] i2c: core: Deprecate of_node in struct i2c_board_info
2025-04-16 6:24 ` Andy Shevchenko
@ 2025-04-16 6:54 ` Wolfram Sang
2025-04-16 7:05 ` Andy Shevchenko
0 siblings, 1 reply; 22+ messages in thread
From: Wolfram Sang @ 2025-04-16 6:54 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Sakari Ailus, Mauro Carvalho Chehab, Tomi Valkeinen, Jai Luthra,
linux-i2c, linux-kernel, linux-media, Mauro Carvalho Chehab
[-- Attachment #1: Type: text/plain, Size: 341 bytes --]
> > > that Linux kernel supports. Deprecate of_node in struct i2c_board_info,
> > > so users will be warned and in the future remove it completely.
> >
> > Is there a plan or volunteer to do the conversion?
>
> Yes, long-term as I'm alone for many janitor works.
I could help here if you are not keen on doing it on your own.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v4 6/7] i2c: core: Deprecate of_node in struct i2c_board_info
2025-04-16 6:54 ` Wolfram Sang
@ 2025-04-16 7:05 ` Andy Shevchenko
2025-04-16 13:00 ` Wolfram Sang
0 siblings, 1 reply; 22+ messages in thread
From: Andy Shevchenko @ 2025-04-16 7:05 UTC (permalink / raw)
To: Wolfram Sang, Sakari Ailus, Mauro Carvalho Chehab, Tomi Valkeinen,
Jai Luthra, linux-i2c, linux-kernel, linux-media,
Mauro Carvalho Chehab
On Wed, Apr 16, 2025 at 08:54:22AM +0200, Wolfram Sang wrote:
>
> > > > that Linux kernel supports. Deprecate of_node in struct i2c_board_info,
> > > > so users will be warned and in the future remove it completely.
> > >
> > > Is there a plan or volunteer to do the conversion?
> >
> > Yes, long-term as I'm alone for many janitor works.
>
> I could help here if you are not keen on doing it on your own.
Thanks!
At least the main objective is to avoid new code using of_node.
The rest can slowly rotten on itself (esp. if there is any under
arch/ for some old board files).
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v4 6/7] i2c: core: Deprecate of_node in struct i2c_board_info
2025-04-16 7:05 ` Andy Shevchenko
@ 2025-04-16 13:00 ` Wolfram Sang
2025-04-16 15:29 ` Andy Shevchenko
0 siblings, 1 reply; 22+ messages in thread
From: Wolfram Sang @ 2025-04-16 13:00 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Sakari Ailus, Mauro Carvalho Chehab, Tomi Valkeinen, Jai Luthra,
linux-i2c, linux-kernel, linux-media, Mauro Carvalho Chehab
[-- Attachment #1: Type: text/plain, Size: 329 bytes --]
> At least the main objective is to avoid new code using of_node.
> The rest can slowly rotten on itself (esp. if there is any under
> arch/ for some old board files).
Do you know of some examples? I mainly found i2c-powermac and I3C core
with my two approaches (coccinelle and grep+awk). But maybe my search
pattern is weak?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v4 6/7] i2c: core: Deprecate of_node in struct i2c_board_info
2025-04-16 13:00 ` Wolfram Sang
@ 2025-04-16 15:29 ` Andy Shevchenko
0 siblings, 0 replies; 22+ messages in thread
From: Andy Shevchenko @ 2025-04-16 15:29 UTC (permalink / raw)
To: Wolfram Sang, Sakari Ailus, Mauro Carvalho Chehab, Tomi Valkeinen,
Jai Luthra, linux-i2c, linux-kernel, linux-media,
Mauro Carvalho Chehab
On Wed, Apr 16, 2025 at 03:00:16PM +0200, Wolfram Sang wrote:
>
> > At least the main objective is to avoid new code using of_node.
> > The rest can slowly rotten on itself (esp. if there is any under
> > arch/ for some old board files).
>
> Do you know of some examples? I mainly found i2c-powermac and I3C core
> with my two approaches (coccinelle and grep+awk). But maybe my search
> pattern is weak?
At least the first one is what I have a WIP in my local tree.
I haven't checked much and I anyway forgot the results already
(it was at the time of v1, so a couple of weeks ago or so).
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v4 7/7] media: i2c: ds90ub960: Remove of_node assignment
2025-04-14 10:01 [PATCH v4 0/7] i2c: core: Move client towards fwnode Andy Shevchenko
` (5 preceding siblings ...)
2025-04-14 10:01 ` [PATCH v4 6/7] i2c: core: Deprecate of_node in struct i2c_board_info Andy Shevchenko
@ 2025-04-14 10:01 ` Andy Shevchenko
6 siblings, 0 replies; 22+ messages in thread
From: Andy Shevchenko @ 2025-04-14 10:01 UTC (permalink / raw)
To: Andy Shevchenko, Sakari Ailus, Mauro Carvalho Chehab,
Tomi Valkeinen, Jai Luthra, Wolfram Sang, linux-i2c, linux-kernel,
linux-media
Cc: Mauro Carvalho Chehab
Remove of_node assignment which duplicates fwnode in struct i2c_board_info.
In general drivers must not set both, it's quite confusing. The I²C core
will consider fwnode with a priority and of_node is subject to remove from
above mentioned data structure.
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
drivers/media/i2c/ds90ub960.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c
index 5dde8452739b..5afdbbad9ff4 100644
--- a/drivers/media/i2c/ds90ub960.c
+++ b/drivers/media/i2c/ds90ub960.c
@@ -1682,7 +1682,6 @@ static int ub960_rxport_add_serializer(struct ub960_data *priv, u8 nport)
struct device *dev = &priv->client->dev;
struct ds90ub9xx_platform_data *ser_pdata = &rxport->ser.pdata;
struct i2c_board_info ser_info = {
- .of_node = to_of_node(rxport->ser.fwnode),
.fwnode = rxport->ser.fwnode,
.platform_data = ser_pdata,
};
--
2.47.2
^ permalink raw reply related [flat|nested] 22+ messages in thread