Skip to contentSkip to conversation

iio: health: max30100: use generic property handler

PATCH Superseded Rohit Sarkar 4 participants 5 messages Mar 13, 2020 – Mar 16, 2020 IIO

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: health: max30100: use generic property handler

Instead of of_property_read_xxx use device_property_read_xxx as it is compatible with ACPI too as opposed to only device tree.

---
 drivers/iio/health/max30100.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/iio/health/max30100.c +2 -3
index 84010501762d..8249c6b36818 100644
@@ -16,7 +16,7 @@
 #include <linux/irq.h>
 #include <linux/i2c.h>
 #include <linux/mutex.h>
-#include <linux/of.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/buffer.h>
@@ -267,11 +267,10 @@ static int max30100_get_current_idx(unsigned int val, int *reg)
 static int max30100_led_init(struct max30100_data *data)
 {
 	struct device *dev = &data->client->dev;
-	struct device_node *np = dev->of_node;
 	unsigned int val[2];
 	int reg, ret;
 
-	ret = of_property_read_u32_array(np, "maxim,led-current-microamp",
+	ret = device_property_read_u32_array(dev, "maxim,led-current-microamp",
 					(unsigned int *) &val, 2);
 	if (ret) {
 		/* Default to 24 mA RED LED, 50 mA IR LED */
Signature · 1 line
2.23.0.385.gbc12974a89
maintainer
#1 lore raw
Quoted 4 lines · On Fri, 13 Mar 2020 08:59:13 +0530 Rohit Sarkar <[email protected]>…

Instead of of_property_read_xxx use device_property_read_xxx as it is compatible with ACPI too as opposed to only device tree.

Look at how this driver is probing from DT. There is another thing you need to do to make it possible to use PRP001 ACPI based bindings.

(check what Andy Shevchenko did in a similar patch)

I'm being deliberately vague as useful for you to understand what is going on here for yourself :)

Also, make sure to check you have cc'd everyone relevant. Here you are missing the driver author. +cc Matt
Jonathan

Quoted 30 lines
---
 drivers/iio/health/max30100.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/iio/health/max30100.c +2 -3
index 84010501762d..8249c6b36818 100644
@@ -16,7 +16,7 @@
 #include <linux/irq.h>
 #include <linux/i2c.h>
 #include <linux/mutex.h>
-#include <linux/of.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/buffer.h>
@@ -267,11 +267,10 @@ static int max30100_get_current_idx(unsigned int val, int *reg)
 static int max30100_led_init(struct max30100_data *data)
 {
 	struct device *dev = &data->client->dev;
-	struct device_node *np = dev->of_node;
 	unsigned int val[2];
 	int reg, ret;
 
-	ret = of_property_read_u32_array(np, "maxim,led-current-microamp",
+	ret = device_property_read_u32_array(dev, "maxim,led-current-microamp",
 					(unsigned int *) &val, 2);
 	if (ret) {
 		/* Default to 24 mA RED LED, 50 mA IR LED */
#2 lore raw
Quoted 11 lines · Jonathan Cameron
Quoted 4 lines · On Fri, 13 Mar 2020 08:59:13 +0530 Rohit Sarkar <[email protected]>…

Instead of of_property_read_xxx use device_property_read_xxx as it is compatible with ACPI too as opposed to only device tree.

Look at how this driver is probing from DT. There is another thing you need to do to make it possible to use PRP001 ACPI based bindings.

Quoted 8 lines

(check what Andy Shevchenko did in a similar patch)

I'm being deliberately vague as useful for you to understand what is going on here for yourself :)

Also, make sure to check you have cc'd everyone relevant. Here you are missing the driver author. +cc Matt
Jonathan

Have sent out a v2 with the required correction, although I still dont completely understand how this ACPI magic works. In the process of going over
https://www.kernel.org/doc/Documentation/acpi/enumeration.txt get a better picture.

Thanks,
Rohit

#3 lore raw
In reply to Jonathan Cameron
Quoted 12 lines · Jonathan Cameron
Quoted 4 lines · On Fri, 13 Mar 2020 08:59:13 +0530 Rohit Sarkar <[email protected]>…

Instead of of_property_read_xxx use device_property_read_xxx as it is compatible with ACPI too as opposed to only device tree.

Look at how this driver is probing from DT. There is another thing you need to do to make it possible to use PRP001 ACPI based bindings.

Quoted 9 lines

(check what Andy Shevchenko did in a similar patch)

I'm being deliberately vague as useful for you to understand what is going on here for yourself :)

Also, make sure to check you have cc'd everyone relevant. Here you are missing the driver author. +cc Matt
Jonathan

Highly doubt anyone is using this in an ACPI setting. Am I missing something though?

- Matt

Quoted 31 lines
Quoted 30 lines
---
 drivers/iio/health/max30100.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/iio/health/max30100.c +2 -3
index 84010501762d..8249c6b36818 100644
@@ -16,7 +16,7 @@
 #include <linux/irq.h>
 #include <linux/i2c.h>
 #include <linux/mutex.h>
-#include <linux/of.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/buffer.h>
@@ -267,11 +267,10 @@ static int max30100_get_current_idx(unsigned int val, int *reg)
 static int max30100_led_init(struct max30100_data *data)
 {
      struct device *dev = &data->client->dev;
-     struct device_node *np = dev->of_node;
      unsigned int val[2];
      int reg, ret;
 
-     ret = of_property_read_u32_array(np, "maxim,led-current-microamp",
+     ret = device_property_read_u32_array(dev, "maxim,led-current-microamp",
                                      (unsigned int *) &val, 2);
      if (ret) {
              /* Default to 24 mA RED LED, 50 mA IR LED */
#4 lore raw
Quoted 18 lines · On Mon, 16 Mar 2020 01:08:20 -0700 Matt Ranostay <[email protected]>…
Quoted 17 lines · Jonathan Cameron
Quoted 4 lines · On Fri, 13 Mar 2020 08:59:13 +0530 Rohit Sarkar <[email protected]>…

Instead of of_property_read_xxx use device_property_read_xxx as it is compatible with ACPI too as opposed to only device tree.

Look at how this driver is probing from DT. There is another thing you need to do to make it possible to use PRP001 ACPI based bindings.

(check what Andy Shevchenko did in a similar patch)

I'm being deliberately vague as useful for you to understand what is going on here for yourself :)

Quoted 7 lines
Quoted 4 lines

Also, make sure to check you have cc'd everyone relevant. Here you are missing the driver author. +cc Matt
Jonathan

Highly doubt anyone is using this in an ACPI setting. Am I missing something though?

The 'new' wonder that is the ACPI ID PRP001. It lets you instantiate a device with a DT binding but using a chunk of DSDT.

Where it comes in handy is if you happen to have an X86 machine that you are using to test and do it by overriding the DSDT (easy to do) to add whatever controller you are using and the device. Basically it is the ACPI equivalent of hacking the dt file for a board.

Very convenient for testing device drivers.

Jonathan

Quoted 34 lines

- Matt

Quoted 31 lines
Quoted 30 lines
---
 drivers/iio/health/max30100.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/iio/health/max30100.c +2 -3
index 84010501762d..8249c6b36818 100644
@@ -16,7 +16,7 @@
 #include <linux/irq.h>
 #include <linux/i2c.h>
 #include <linux/mutex.h>
-#include <linux/of.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/buffer.h>
@@ -267,11 +267,10 @@ static int max30100_get_current_idx(unsigned int val, int *reg)
 static int max30100_led_init(struct max30100_data *data)
 {
      struct device *dev = &data->client->dev;
-     struct device_node *np = dev->of_node;
      unsigned int val[2];
      int reg, ret;
 
-     ret = of_property_read_u32_array(np, "maxim,led-current-microamp",
+     ret = device_property_read_u32_array(dev, "maxim,led-current-microamp",
                                      (unsigned int *) &val, 2);
      if (ret) {
              /* Default to 24 mA RED LED, 50 mA IR LED */