All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/2] iio: adc: nau7802: Convert driver to use ->probe_new()
@ 2022-05-31 21:39 Andy Shevchenko
  2022-05-31 21:39 ` [PATCH v1 2/2] iio: adc: nau7802: Make use of device properties Andy Shevchenko
  2022-06-03 17:35 ` [PATCH v1 1/2] iio: adc: nau7802: Convert driver to use ->probe_new() Jonathan Cameron
  0 siblings, 2 replies; 3+ messages in thread
From: Andy Shevchenko @ 2022-05-31 21:39 UTC (permalink / raw)
  To: Alexandru Ardelean, linux-iio, linux-kernel
  Cc: Jonathan Cameron, Lars-Peter Clausen, Andy Shevchenko

Use the ->probe_new() callback.

The driver does not use const struct i2c_device_id * argument,
so convert it to utilise the simplified I²C driver registration.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/iio/adc/nau7802.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/adc/nau7802.c b/drivers/iio/adc/nau7802.c
index 976c235f3079..2d71cdbcd82f 100644
--- a/drivers/iio/adc/nau7802.c
+++ b/drivers/iio/adc/nau7802.c
@@ -407,8 +407,7 @@ static const struct iio_info nau7802_info = {
 	.attrs = &nau7802_attribute_group,
 };
 
-static int nau7802_probe(struct i2c_client *client,
-			const struct i2c_device_id *id)
+static int nau7802_probe(struct i2c_client *client)
 {
 	struct iio_dev *indio_dev;
 	struct nau7802_state *st;
@@ -417,11 +416,6 @@ static int nau7802_probe(struct i2c_client *client,
 	u8 data;
 	u32 tmp = 0;
 
-	if (!client->dev.of_node) {
-		dev_err(&client->dev, "No device tree node available.\n");
-		return -EINVAL;
-	}
-
 	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st));
 	if (indio_dev == NULL)
 		return -ENOMEM;
@@ -550,7 +544,7 @@ static const struct of_device_id nau7802_dt_ids[] = {
 MODULE_DEVICE_TABLE(of, nau7802_dt_ids);
 
 static struct i2c_driver nau7802_driver = {
-	.probe = nau7802_probe,
+	.probe_new = nau7802_probe,
 	.id_table = nau7802_i2c_id,
 	.driver = {
 		   .name = "nau7802",
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v1 2/2] iio: adc: nau7802: Make use of device properties
  2022-05-31 21:39 [PATCH v1 1/2] iio: adc: nau7802: Convert driver to use ->probe_new() Andy Shevchenko
@ 2022-05-31 21:39 ` Andy Shevchenko
  2022-06-03 17:35 ` [PATCH v1 1/2] iio: adc: nau7802: Convert driver to use ->probe_new() Jonathan Cameron
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2022-05-31 21:39 UTC (permalink / raw)
  To: Alexandru Ardelean, linux-iio, linux-kernel
  Cc: Jonathan Cameron, Lars-Peter Clausen, Andy Shevchenko

Convert the module to be property provider agnostic and allow
it to be used on non-OF platforms.

Add mod_devicetable.h include.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/iio/adc/nau7802.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/adc/nau7802.c b/drivers/iio/adc/nau7802.c
index 2d71cdbcd82f..c1261ecd400c 100644
--- a/drivers/iio/adc/nau7802.c
+++ b/drivers/iio/adc/nau7802.c
@@ -8,10 +8,11 @@
 #include <linux/delay.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
+#include <linux/property.h>
 #include <linux/wait.h>
 #include <linux/log2.h>
-#include <linux/of.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
@@ -411,7 +412,6 @@ static int nau7802_probe(struct i2c_client *client)
 {
 	struct iio_dev *indio_dev;
 	struct nau7802_state *st;
-	struct device_node *np = client->dev.of_node;
 	int i, ret;
 	u8 data;
 	u32 tmp = 0;
@@ -451,7 +451,7 @@ static int nau7802_probe(struct i2c_client *client)
 	if (!(ret & NAU7802_PUCTRL_PUR_BIT))
 		return ret;
 
-	of_property_read_u32(np, "nuvoton,vldo", &tmp);
+	device_property_read_u32(&client->dev, "nuvoton,vldo", &tmp);
 	st->vref_mv = tmp;
 
 	data = NAU7802_PUCTRL_PUD_BIT | NAU7802_PUCTRL_PUA_BIT |
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/2] iio: adc: nau7802: Convert driver to use ->probe_new()
  2022-05-31 21:39 [PATCH v1 1/2] iio: adc: nau7802: Convert driver to use ->probe_new() Andy Shevchenko
  2022-05-31 21:39 ` [PATCH v1 2/2] iio: adc: nau7802: Make use of device properties Andy Shevchenko
@ 2022-06-03 17:35 ` Jonathan Cameron
  1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2022-06-03 17:35 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Alexandru Ardelean, linux-iio, linux-kernel, Lars-Peter Clausen

On Wed,  1 Jun 2022 00:39:21 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> Use the ->probe_new() callback.
> 
> The driver does not use const struct i2c_device_id * argument,
> so convert it to utilise the simplified I²C driver registration.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Series applied,

Thanks for all these cleanups btw.

Jonathan

> ---
>  drivers/iio/adc/nau7802.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/iio/adc/nau7802.c b/drivers/iio/adc/nau7802.c
> index 976c235f3079..2d71cdbcd82f 100644
> --- a/drivers/iio/adc/nau7802.c
> +++ b/drivers/iio/adc/nau7802.c
> @@ -407,8 +407,7 @@ static const struct iio_info nau7802_info = {
>  	.attrs = &nau7802_attribute_group,
>  };
>  
> -static int nau7802_probe(struct i2c_client *client,
> -			const struct i2c_device_id *id)
> +static int nau7802_probe(struct i2c_client *client)
>  {
>  	struct iio_dev *indio_dev;
>  	struct nau7802_state *st;
> @@ -417,11 +416,6 @@ static int nau7802_probe(struct i2c_client *client,
>  	u8 data;
>  	u32 tmp = 0;
>  
> -	if (!client->dev.of_node) {
> -		dev_err(&client->dev, "No device tree node available.\n");
> -		return -EINVAL;
> -	}
> -
>  	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st));
>  	if (indio_dev == NULL)
>  		return -ENOMEM;
> @@ -550,7 +544,7 @@ static const struct of_device_id nau7802_dt_ids[] = {
>  MODULE_DEVICE_TABLE(of, nau7802_dt_ids);
>  
>  static struct i2c_driver nau7802_driver = {
> -	.probe = nau7802_probe,
> +	.probe_new = nau7802_probe,
>  	.id_table = nau7802_i2c_id,
>  	.driver = {
>  		   .name = "nau7802",


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-03 17:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-31 21:39 [PATCH v1 1/2] iio: adc: nau7802: Convert driver to use ->probe_new() Andy Shevchenko
2022-05-31 21:39 ` [PATCH v1 2/2] iio: adc: nau7802: Make use of device properties Andy Shevchenko
2022-06-03 17:35 ` [PATCH v1 1/2] iio: adc: nau7802: Convert driver to use ->probe_new() Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.