media: i2c: rdacm2x: Make use of device properties
Subsystems (3)
PATCH 1/1 media: i2c: rdacm2x: Make use of device properties
Convert the module to be property provider agnostic and allow it to be used on non-OF platforms.
--- drivers/media/i2c/rdacm20.c | 5 ++--- drivers/media/i2c/rdacm21.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-)
drivers/media/i2c/rdacm20.c +2 -3
@@ -16,10 +16,10 @@*/ #include <linux/delay.h> -#include <linux/fwnode.h> #include <linux/init.h> #include <linux/i2c.h> #include <linux/module.h> +#include <linux/property.h> #include <linux/slab.h> #include <linux/videodev2.h>
@@ -575,8 +575,7 @@ static int rdacm20_probe(struct i2c_client *client) dev->dev = &client->dev; dev->serializer.client = client; - ret =of_property_read_u32_array (client->dev.of_node,"reg" , - dev->addrs,2 ); + ret =device_property_read_u32_array (&client->dev,"reg" , dev->addrs,2 );if (ret <0 ) {dev_err (dev->dev,"Invalid DT reg property: %d\n" , ret);return -EINVAL ;
drivers/media/i2c/rdacm21.c +2 -3
@@ -11,10 +11,10 @@*/ #include <linux/delay.h> -#include <linux/fwnode.h> #include <linux/init.h> #include <linux/i2c.h> #include <linux/module.h> +#include <linux/property.h> #include <linux/slab.h> #include <linux/videodev2.h>
@@ -551,8 +551,7 @@ static int rdacm21_probe(struct i2c_client *client) dev->dev = &client->dev; dev->serializer.client = client; - ret =of_property_read_u32_array (client->dev.of_node,"reg" , - dev->addrs,2 ); + ret =device_property_read_u32_array (&client->dev,"reg" , dev->addrs,2 );if (ret <0 ) {dev_err (dev->dev,"Invalid DT reg property: %d\n" , ret);return -EINVAL ;
Signature · 1 line
2.47.2
Quoting Andy Shevchenko (2025-03-31 08:34:35)
Quoted 3 lines
Convert the module to be property provider agnostic and allow it to be used on non-OF platforms.
Looks reasonable to me.
Quoted 23 lines
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/media/i2c/rdacm20.c | 5 ++--- drivers/media/i2c/rdacm21.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-)drivers/media/i2c/rdacm20.c +1
-1@@ -16,10 +16,10 @@*/ #include <linux/delay.h> -#include <linux/fwnode.h> #include <linux/init.h> #include <linux/i2c.h> #include <linux/module.h> +#include <linux/property.h> #include <linux/slab.h> #include <linux/videodev2.h>
drivers/media/i2c/rdacm20.c static int rdacm20_probe(struct i2c_client *client) · line 580
Quoted 8 lines
drivers/media/i2c/rdacm20.c +1
-2@@ -575,8 +575,7 @@ static int rdacm20_probe(struct i2c_client *client) dev->dev = &client->dev; dev->serializer.client = client; - ret =of_property_read_u32_array (client->dev.of_node,"reg" , - dev->addrs,2 ); + ret =device_property_read_u32_array (&client->dev,"reg" , dev->addrs,2 );if (ret <0 ) {dev_err (dev->dev,"Invalid DT reg property: %d\n" , ret);
But this is no longer a DT reg property ?
Quoted 18 lines
drivers/media/i2c/rdacm20.c +0
-0return -EINVAL ;drivers/media/i2c/rdacm21.c +1
-1@@ -11,10 +11,10 @@*/ #include <linux/delay.h> -#include <linux/fwnode.h> #include <linux/init.h> #include <linux/i2c.h> #include <linux/module.h> +#include <linux/property.h> #include <linux/slab.h> #include <linux/videodev2.h>
drivers/media/i2c/rdacm21.c static int rdacm21_probe(struct i2c_client *client) · line 556
Quoted 8 lines
drivers/media/i2c/rdacm21.c +1
-2@@ -551,8 +551,7 @@ static int rdacm21_probe(struct i2c_client *client) dev->dev = &client->dev; dev->serializer.client = client; - ret =of_property_read_u32_array (client->dev.of_node,"reg" , - dev->addrs,2 ); + ret =device_property_read_u32_array (&client->dev,"reg" , dev->addrs,2 );if (ret <0 ) {dev_err (dev->dev,"Invalid DT reg property: %d\n" , ret);
Same here ...
With those fixed,
Quoted 4 lines
drivers/media/i2c/rdacm21.c +0
-0return -EINVAL ;Signature · 1 line
2.47.2
Quoted 5 lines · Kieran Bingham
Quoting Andy Shevchenko (2025-03-31 08:34:35)
Quoted 2 lines
Convert the module to be property provider agnostic and allow it to be used on non-OF platforms.
Looks reasonable to me.
Is that going to work out of the box though ? The calls below read the "reg" property to get the device I2C addresses. AFAIK, ACPI handles I2C addresses using ACPI-specific methods.
Andy, have you tested this patch on an ACPI system ?
Quoted 68 lines
Quoted 23 lines
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/media/i2c/rdacm20.c | 5 ++--- drivers/media/i2c/rdacm21.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-)drivers/media/i2c/rdacm20.c +1
-1@@ -16,10 +16,10 @@*/ #include <linux/delay.h> -#include <linux/fwnode.h> #include <linux/init.h> #include <linux/i2c.h> #include <linux/module.h> +#include <linux/property.h> #include <linux/slab.h> #include <linux/videodev2.h> drivers/media/i2c/rdacm20.c static int rdacm20_probe(struct i2c_client *client) · line 580
Quoted 8 lines
drivers/media/i2c/rdacm20.c +1
-2@@ -575,8 +575,7 @@ static int rdacm20_probe(struct i2c_client *client) dev->dev = &client->dev; dev->serializer.client = client; - ret =of_property_read_u32_array (client->dev.of_node,"reg" , - dev->addrs,2 ); + ret =device_property_read_u32_array (&client->dev,"reg" , dev->addrs,2 );if (ret <0 ) {dev_err (dev->dev,"Invalid DT reg property: %d\n" , ret);But this is no longer a DT reg property ?
Quoted 18 lines
drivers/media/i2c/rdacm20.c +0
-0return -EINVAL ;drivers/media/i2c/rdacm21.c +1
-1@@ -11,10 +11,10 @@*/ #include <linux/delay.h> -#include <linux/fwnode.h> #include <linux/init.h> #include <linux/i2c.h> #include <linux/module.h> +#include <linux/property.h> #include <linux/slab.h> #include <linux/videodev2.h> drivers/media/i2c/rdacm21.c static int rdacm21_probe(struct i2c_client *client) · line 556
Quoted 8 lines
drivers/media/i2c/rdacm21.c +1
-2@@ -551,8 +551,7 @@ static int rdacm21_probe(struct i2c_client *client) dev->dev = &client->dev; dev->serializer.client = client; - ret =of_property_read_u32_array (client->dev.of_node,"reg" , - dev->addrs,2 ); + ret =device_property_read_u32_array (&client->dev,"reg" , dev->addrs,2 );if (ret <0 ) {dev_err (dev->dev,"Invalid DT reg property: %d\n" , ret);Same here ...
With those fixed,
Reviewed-by Kieran Bingham <[email protected]>Quoted 1 line
drivers/media/i2c/rdacm21.c +0
-0return -EINVAL ;
Signature · 3 lines
Regards, Laurent Pinchart
Quoted 5 lines · Laurent Pinchart
Quoted 4 lines · Kieran Bingham
Quoting Andy Shevchenko (2025-03-31 08:34:35)
Quoted 2 lines
Convert the module to be property provider agnostic and allow it to be used on non-OF platforms.
Quoted 7 lines
Quoted 1 line
Looks reasonable to me.
Is that going to work out of the box though ? The calls below read the "reg" property to get the device I2C addresses. AFAIK, ACPI handles I2C addresses using ACPI-specific methods.
Andy, have you tested this patch on an ACPI system ?
Only compile-tested. But you are right, this is something different here between OF and ACPI.
I can rephrase the commit message to just point out that fwnode.h shouldn't be in the drivers and either converting to device property in an assumption that later it can be easier to support non-OF cases, or using of.h.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 12 lines · Andy Shevchenko
Quoted 11 lines · Laurent Pinchart
Quoted 5 lines · Kieran Bingham
Quoting Andy Shevchenko (2025-03-31 08:34:35)
Quoted 2 lines
Convert the module to be property provider agnostic and allow it to be used on non-OF platforms.
Looks reasonable to me.
Is that going to work out of the box though ? The calls below read the "reg" property to get the device I2C addresses. AFAIK, ACPI handles I2C addresses using ACPI-specific methods.
Quoted 8 lines
Quoted 1 line
Andy, have you tested this patch on an ACPI system ?
Only compile-tested. But you are right, this is something different here between OF and ACPI.
I can rephrase the commit message to just point out that
fwnode.hshouldn't be in the drivers and either converting to device property in an assumption that later it can be easier to support non-OF cases, or usingof.h.
I wasn't aware that fwnode.h shouldn't be used in drivers, could you explain that ?
If this patch is part of an effort to eliminate usage of some APIs from all drivers, I'm fine with it. Otherwise, I'm not sure it's worth modifying the driver.
Signature · 3 lines
Regards, Laurent Pinchart
Quoted 18 lines · Laurent Pinchart
Quoted 17 lines · Andy Shevchenko
Quoted 5 lines · Laurent Pinchart
Quoted 4 lines · Kieran Bingham
Quoting Andy Shevchenko (2025-03-31 08:34:35)
Quoted 2 lines
Convert the module to be property provider agnostic and allow it to be used on non-OF platforms.
Quoted 7 lines
Quoted 1 line
Looks reasonable to me.
Is that going to work out of the box though ? The calls below read the "reg" property to get the device I2C addresses. AFAIK, ACPI handles I2C addresses using ACPI-specific methods.
Andy, have you tested this patch on an ACPI system ?
Only compile-tested. But you are right, this is something different here between OF and ACPI.
Quoted 6 lines
Quoted 3 lines
I can rephrase the commit message to just point out that
fwnode.hshouldn't be in the drivers and either converting to device property in an assumption that later it can be easier to support non-OF cases, or usingof.h.I wasn't aware that
fwnode.hshouldn't be used in drivers, could you explain that ?
The fwnode.h provides the data types and definitions that are meant to be used by the fwnode / device property API providers. The leaf drivers shouldn't have any business with those definitions. Everything the drivers need should be provided via property.h. property.h guarantees the necessary data types to be visible to the users, when required (mostly think of struct fwnode_reference_args). Yes, I am aware of v4l2-fwnode.h and it seems it falls into the category of special device property API provider.
Quoted 3 lines
If this patch is part of an effort to eliminate usage of some APIs from all drivers, I'm fine with it. Otherwise, I'm not sure it's worth modifying the driver.
These drivers basically include the wrong header.
If you insist, I can patch fwnode.h to add a comment summarizing the above.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 34 lines · Andy Shevchenko
Quoted 18 lines · Laurent Pinchart
Quoted 17 lines · Andy Shevchenko
Quoted 5 lines · Laurent Pinchart
Quoted 4 lines · Kieran Bingham
Quoting Andy Shevchenko (2025-03-31 08:34:35)
Quoted 2 lines
Convert the module to be property provider agnostic and allow it to be used on non-OF platforms.
Quoted 7 lines
Quoted 1 line
Looks reasonable to me.
Is that going to work out of the box though ? The calls below read the "reg" property to get the device I2C addresses. AFAIK, ACPI handles I2C addresses using ACPI-specific methods.
Andy, have you tested this patch on an ACPI system ?
Only compile-tested. But you are right, this is something different here between OF and ACPI.
Quoted 6 lines
Quoted 3 lines
I can rephrase the commit message to just point out that
fwnode.hshouldn't be in the drivers and either converting to device property in an assumption that later it can be easier to support non-OF cases, or usingof.h.I wasn't aware that
fwnode.hshouldn't be used in drivers, could you explain that ?The
fwnode.hprovides the data types and definitions that are meant to be used by the fwnode / device property API providers. The leaf drivers shouldn't have any business with those definitions. Everything the drivers need should be provided viaproperty.h.property.hguarantees the necessary data types to be visible to the users, when required (mostly think of structfwnode_reference_args). Yes, I am aware ofv4l2-fwnode.hand it seems it falls into the category of special device property API provider.
Quoted 6 lines
Quoted 3 lines
If this patch is part of an effort to eliminate usage of some APIs from all drivers, I'm fine with it. Otherwise, I'm not sure it's worth modifying the driver.
These drivers basically include the wrong header.
If you insist, I can patchfwnode.hto add a comment summarizing the above.
No, it's fine. I mixed fwnode.h and property.h when writing my previous reply, but I don't think it's a matter of lack of documentation, more likely lack of sleep :-)
Signature · 3 lines
Regards, Laurent Pinchart
Quoted 39 lines · Laurent Pinchart
Quoted 38 lines · Andy Shevchenko
Quoted 18 lines · Laurent Pinchart
Quoted 17 lines · Andy Shevchenko
Quoted 5 lines · Laurent Pinchart
Quoted 4 lines · Kieran Bingham
Quoting Andy Shevchenko (2025-03-31 08:34:35)
Quoted 2 lines
Convert the module to be property provider agnostic and allow it to be used on non-OF platforms.
Quoted 7 lines
Quoted 1 line
Looks reasonable to me.
Is that going to work out of the box though ? The calls below read the "reg" property to get the device I2C addresses. AFAIK, ACPI handles I2C addresses using ACPI-specific methods.
Andy, have you tested this patch on an ACPI system ?
Only compile-tested. But you are right, this is something different here between OF and ACPI.
Quoted 6 lines
Quoted 3 lines
I can rephrase the commit message to just point out that
fwnode.hshouldn't be in the drivers and either converting to device property in an assumption that later it can be easier to support non-OF cases, or usingof.h.I wasn't aware that
fwnode.hshouldn't be used in drivers, could you explain that ?The
fwnode.hprovides the data types and definitions that are meant to be used by the fwnode / device property API providers. The leaf drivers shouldn't have any business with those definitions. Everything the drivers need should be provided viaproperty.h.property.hguarantees the necessary data types to be visible to the users, when required (mostly think of structfwnode_reference_args). Yes, I am aware ofv4l2-fwnode.hand it seems it falls into the category of special device property API provider.Quoted 3 lines
If this patch is part of an effort to eliminate usage of some APIs from all drivers, I'm fine with it. Otherwise, I'm not sure it's worth modifying the driver.
Quoted 6 lines
Quoted 2 lines
These drivers basically include the wrong header.
If you insist, I can patchfwnode.hto add a comment summarizing the above.No, it's fine. I mixed
fwnode.handproperty.hwhen writing my previous reply, but I don't think it's a matter of lack of documentation, more likely lack of sleep :-)
NP. but here we are: [email protected]
The bottom line, can you give a tag for this patch and perhaps others of the same matter against drivers/media/* I sent today?
Signature · 2 lines
With Best Regards, Andy Shevchenko