diff mbox series

[v2,08/12] iio:adc:mcp3911: Switch to generic firmware properties.

Message ID 20211204171237.2769210-9-jic23@kernel.org (mailing list archive)
State Superseded
Headers show
Series IIO: More of to generic fw conversions. | expand

Commit Message

Jonathan Cameron Dec. 4, 2021, 5:12 p.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

This allows use of the driver with other types of firmware such as ACPI
PRP0001 based probing.

Also part of a general attempt to remove direct use of of_ specific
accessors from IIO.

Added an include for mod_devicetable.h whilst here to cover the
struct of_device_id definition.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Kent Gustavsson <kent@minoris.se>
Cc: Marcus Folkesson <marcus.folkesson@gmail.com>
---
 drivers/iio/adc/mcp3911.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Andy Shevchenko Dec. 5, 2021, 3:07 p.m. UTC | #1
On Sat, Dec 4, 2021 at 7:07 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> This allows use of the driver with other types of firmware such as ACPI
> PRP0001 based probing.
>
> Also part of a general attempt to remove direct use of of_ specific
> accessors from IIO.
>
> Added an include for mod_devicetable.h whilst here to cover the
> struct of_device_id definition.

...

> -static int mcp3911_config(struct mcp3911 *adc, struct device_node *of_node)
> +static int mcp3911_config(struct mcp3911 *adc, struct device *dev)

I am wondering if the device pointer is already embedded in the mpc3911.
It might require assignment reordering in the ->probe(). though
(haven't checked).
Jonathan Cameron Dec. 5, 2021, 4:19 p.m. UTC | #2
On Sun, 5 Dec 2021 17:07:37 +0200
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Sat, Dec 4, 2021 at 7:07 PM Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> >
> > This allows use of the driver with other types of firmware such as ACPI
> > PRP0001 based probing.
> >
> > Also part of a general attempt to remove direct use of of_ specific
> > accessors from IIO.
> >
> > Added an include for mod_devicetable.h whilst here to cover the
> > struct of_device_id definition.  
> 
> ...
> 
> > -static int mcp3911_config(struct mcp3911 *adc, struct device_node *of_node)
> > +static int mcp3911_config(struct mcp3911 *adc, struct device *dev)  
> 
> I am wondering if the device pointer is already embedded in the mpc3911.
> It might require assignment reordering in the ->probe(). though
> (haven't checked).
> 
Good point. adc->spi->dev is available and is the same pointer so might as well use
that to keep things a little more tidy.

Thanks,

Jonathan
diff mbox series

Patch

diff --git a/drivers/iio/adc/mcp3911.c b/drivers/iio/adc/mcp3911.c
index e573da5397bb..f6895acb8838 100644
--- a/drivers/iio/adc/mcp3911.c
+++ b/drivers/iio/adc/mcp3911.c
@@ -10,6 +10,8 @@ 
 #include <linux/err.h>
 #include <linux/iio/iio.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/property.h>
 #include <linux/regulator/consumer.h>
 #include <linux/spi/spi.h>
 
@@ -200,12 +202,12 @@  static const struct iio_info mcp3911_info = {
 	.write_raw = mcp3911_write_raw,
 };
 
-static int mcp3911_config(struct mcp3911 *adc, struct device_node *of_node)
+static int mcp3911_config(struct mcp3911 *adc, struct device *dev)
 {
 	u32 configreg;
 	int ret;
 
-	of_property_read_u32(of_node, "device-addr", &adc->dev_addr);
+	device_property_read_u32(dev, "device-addr", &adc->dev_addr);
 	if (adc->dev_addr > 3) {
 		dev_err(&adc->spi->dev,
 			"invalid device address (%i). Must be in range 0-3.\n",
@@ -289,7 +291,7 @@  static int mcp3911_probe(struct spi_device *spi)
 		}
 	}
 
-	ret = mcp3911_config(adc, spi->dev.of_node);
+	ret = mcp3911_config(adc, &spi->dev);
 	if (ret)
 		goto clk_disable;