[PATCH 5.4 042/120] iio:adc:mcp3911: Switch to generic firmware properties.

Greg Kroah-Hartman posted 120 patches 3 years, 6 months ago
[PATCH 5.4 042/120] iio:adc:mcp3911: Switch to generic firmware properties.
Posted by Greg Kroah-Hartman 3 years, 6 months ago
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

[ Upstream commit 4efc1c614d334883cce09c38aa3fe74d3fb0bbf0 ]

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>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Kent Gustavsson <kent@minoris.se>
Reviewed-by: Marcus Folkesson <marcus.folkesson@gmail.com>
Stable-dep-of: cfbd76d5c9c4 ("iio: adc: mcp3911: correct "microchip,device-addr" property")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/iio/adc/mcp3911.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/adc/mcp3911.c b/drivers/iio/adc/mcp3911.c
index 4e2e8e819b1e..cd8b1bab9cf0 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>
 
@@ -209,12 +211,13 @@ 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 = &adc->spi->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",
@@ -298,7 +301,7 @@ static int mcp3911_probe(struct spi_device *spi)
 		}
 	}
 
-	ret = mcp3911_config(adc, spi->dev.of_node);
+	ret = mcp3911_config(adc);
 	if (ret)
 		goto clk_disable;
 
-- 
2.35.1
Re: [PATCH 5.4 042/120] iio:adc:mcp3911: Switch to generic firmware properties.
Posted by Jonathan Cameron 3 years, 6 months ago
On Mon, 26 Sep 2022 12:11:15 +0200
Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:

> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> [ Upstream commit 4efc1c614d334883cce09c38aa3fe74d3fb0bbf0 ]
> 
> 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.

I'd treat this a feature enabling rather than a fix.
It's small however, so if someone has a sent a backport request I'm fine
with it going in stable. If not, probably just unnecessary noise for stable.

Jonathan

> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Cc: Kent Gustavsson <kent@minoris.se>
> Reviewed-by: Marcus Folkesson <marcus.folkesson@gmail.com>
> Stable-dep-of: cfbd76d5c9c4 ("iio: adc: mcp3911: correct "microchip,device-addr" property")
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
>  drivers/iio/adc/mcp3911.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/adc/mcp3911.c b/drivers/iio/adc/mcp3911.c
> index 4e2e8e819b1e..cd8b1bab9cf0 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>
>  
> @@ -209,12 +211,13 @@ 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 = &adc->spi->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",
> @@ -298,7 +301,7 @@ static int mcp3911_probe(struct spi_device *spi)
>  		}
>  	}
>  
> -	ret = mcp3911_config(adc, spi->dev.of_node);
> +	ret = mcp3911_config(adc);
>  	if (ret)
>  		goto clk_disable;
>
Re: [PATCH 5.4 042/120] iio:adc:mcp3911: Switch to generic firmware properties.
Posted by Greg Kroah-Hartman 3 years, 6 months ago
On Mon, Sep 26, 2022 at 12:50:12PM +0100, Jonathan Cameron wrote:
> On Mon, 26 Sep 2022 12:11:15 +0200
> Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:
> 
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > 
> > [ Upstream commit 4efc1c614d334883cce09c38aa3fe74d3fb0bbf0 ]
> > 
> > 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.
> 
> I'd treat this a feature enabling rather than a fix.
> It's small however, so if someone has a sent a backport request I'm fine
> with it going in stable. If not, probably just unnecessary noise for stable.

Now dropped, and the follow-on patch for this driver, from 5.4, 5.10,
and 5.15.

thanks,

greg k-h