linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] iio: adc: ina2xx: Improve device identification
@ 2019-08-20 14:11 Michal Simek
  2019-08-20 14:11 ` [PATCH 1/4] iio: adc: ina2xx: Define *device_node only once Michal Simek
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Michal Simek @ 2019-08-20 14:11 UTC (permalink / raw)
  To: linux-kernel, monstr, michal.simek, linux
  Cc: linux-hwmon, devicetree, Colin Ian King, linux-iio,
	Stefan Brüns, Rob Herring, Lars-Peter Clausen, Jean Delvare,
	Mark Rutland, Jonathan Cameron, Peter Meerwald-Stadler,
	Hartmut Knaack

Hi,

the purpose of this series is to improve ina226 identification. On systems
like Xilinx ZynqMP zcu102 (check dt in the tree) you can find out almost 20
ina226 chips and it is impossible to find out based on simple ina226 which
chip is repsonsible for what.
The series is adding two ways how to improve device identification.
Please let me know what you think I am happy to do changes in it.

Thanks,
Michal


Michal Simek (4):
  iio: adc: ina2xx: Define *device_node only once
  iio: adc: ina2xx: Setup better name then simple ina2xx
  dt-bindings: Add optional label property for ina2xx
  iio: adc: ina2xx: Use label proper for device identification

 .../devicetree/bindings/hwmon/ina2xx.txt          |  2 ++
 drivers/iio/adc/ina2xx-adc.c                      | 15 +++++++++++----
 2 files changed, 13 insertions(+), 4 deletions(-)

-- 
2.17.1


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

* [PATCH 1/4] iio: adc: ina2xx: Define *device_node only once
  2019-08-20 14:11 [PATCH 0/4] iio: adc: ina2xx: Improve device identification Michal Simek
@ 2019-08-20 14:11 ` Michal Simek
  2019-08-21  1:56   ` Phil Reid
  2019-08-20 14:11 ` [PATCH 2/4] iio: adc: ina2xx: Setup better name then simple ina2xx Michal Simek
  2019-08-20 14:11 ` [PATCH 4/4] iio: adc: ina2xx: Use label proper for device identification Michal Simek
  2 siblings, 1 reply; 12+ messages in thread
From: Michal Simek @ 2019-08-20 14:11 UTC (permalink / raw)
  To: linux-kernel, monstr, michal.simek, linux
  Cc: Colin Ian King, linux-iio, Stefan Brüns, Lars-Peter Clausen,
	Jonathan Cameron, Peter Meerwald-Stadler, Hartmut Knaack

There is no reason to c&p full client->dev.of_node link when simple
variable can keep it.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 drivers/iio/adc/ina2xx-adc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c
index bdd7cba6f6b0..37058d9c2054 100644
--- a/drivers/iio/adc/ina2xx-adc.c
+++ b/drivers/iio/adc/ina2xx-adc.c
@@ -951,6 +951,7 @@ static int ina2xx_probe(struct i2c_client *client,
 	struct ina2xx_chip_info *chip;
 	struct iio_dev *indio_dev;
 	struct iio_buffer *buffer;
+	struct device_node *np = client->dev.of_node;
 	unsigned int val;
 	enum ina2xx_ids type;
 	int ret;
@@ -970,7 +971,7 @@ static int ina2xx_probe(struct i2c_client *client,
 		return PTR_ERR(chip->regmap);
 	}
 
-	if (client->dev.of_node)
+	if (np)
 		type = (enum ina2xx_ids)of_device_get_match_data(&client->dev);
 	else
 		type = id->driver_data;
@@ -978,7 +979,7 @@ static int ina2xx_probe(struct i2c_client *client,
 
 	mutex_init(&chip->state_lock);
 
-	if (of_property_read_u32(client->dev.of_node,
+	if (of_property_read_u32(np,
 				 "shunt-resistor", &val) < 0) {
 		struct ina2xx_platform_data *pdata =
 		    dev_get_platdata(&client->dev);
@@ -1016,7 +1017,7 @@ static int ina2xx_probe(struct i2c_client *client,
 
 	indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE;
 	indio_dev->dev.parent = &client->dev;
-	indio_dev->dev.of_node = client->dev.of_node;
+	indio_dev->dev.of_node = np;
 	if (id->driver_data == ina226) {
 		indio_dev->channels = ina226_channels;
 		indio_dev->num_channels = ARRAY_SIZE(ina226_channels);
-- 
2.17.1


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

* [PATCH 2/4] iio: adc: ina2xx: Setup better name then simple ina2xx
  2019-08-20 14:11 [PATCH 0/4] iio: adc: ina2xx: Improve device identification Michal Simek
  2019-08-20 14:11 ` [PATCH 1/4] iio: adc: ina2xx: Define *device_node only once Michal Simek
@ 2019-08-20 14:11 ` Michal Simek
  2019-08-21  2:10   ` Phil Reid
  2019-08-20 14:11 ` [PATCH 4/4] iio: adc: ina2xx: Use label proper for device identification Michal Simek
  2 siblings, 1 reply; 12+ messages in thread
From: Michal Simek @ 2019-08-20 14:11 UTC (permalink / raw)
  To: linux-kernel, monstr, michal.simek, linux
  Cc: Colin Ian King, linux-iio, Stefan Brüns, Lars-Peter Clausen,
	Jonathan Cameron, Peter Meerwald-Stadler, Hartmut Knaack

On systems with multiple ina2xx chips it is impossible to find out which
iio device is which one based on probe order. That's why it is necessary to
setup better name based on possition.
The patch is reusing dev_name which is setup by core with client->name.

name char array was setup to 128 byte length to correspond the same name
length by HID device.

Before this patch:
iio:device9: ina226 (buffer capable)
After:
iio:device9: ina226-3-004a (buffer capable)

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Also id->name can be used as prefix. On ina226 output is the same.

Also I am happy to change that space for name will be dynamicky allocated
to save a space if needed.
---
 drivers/iio/adc/ina2xx-adc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c
index 37058d9c2054..7c7c63677bf4 100644
--- a/drivers/iio/adc/ina2xx-adc.c
+++ b/drivers/iio/adc/ina2xx-adc.c
@@ -146,6 +146,7 @@ struct ina2xx_chip_info {
 	int range_vbus; /* Bus voltage maximum in V */
 	int pga_gain_vshunt; /* Shunt voltage PGA gain */
 	bool allow_async_readout;
+	char name[128];
 };
 
 static const struct ina2xx_config ina2xx_config[] = {
@@ -1027,7 +1028,12 @@ static int ina2xx_probe(struct i2c_client *client,
 		indio_dev->num_channels = ARRAY_SIZE(ina219_channels);
 		indio_dev->info = &ina219_info;
 	}
-	indio_dev->name = id->name;
+
+	/* Compose chip name to unified i2c format */
+	snprintf(chip->name, sizeof(chip->name), "%s-%s",
+		 client->name, dev_name(&client->dev));
+
+	indio_dev->name = chip->name;
 	indio_dev->setup_ops = &ina2xx_setup_ops;
 
 	buffer = devm_iio_kfifo_allocate(&indio_dev->dev);
-- 
2.17.1


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

* [PATCH 4/4] iio: adc: ina2xx: Use label proper for device identification
  2019-08-20 14:11 [PATCH 0/4] iio: adc: ina2xx: Improve device identification Michal Simek
  2019-08-20 14:11 ` [PATCH 1/4] iio: adc: ina2xx: Define *device_node only once Michal Simek
  2019-08-20 14:11 ` [PATCH 2/4] iio: adc: ina2xx: Setup better name then simple ina2xx Michal Simek
@ 2019-08-20 14:11 ` Michal Simek
  2019-08-21  2:11   ` Phil Reid
  2 siblings, 1 reply; 12+ messages in thread
From: Michal Simek @ 2019-08-20 14:11 UTC (permalink / raw)
  To: linux-kernel, monstr, michal.simek, linux
  Cc: Colin Ian King, linux-iio, Stefan Brüns, Lars-Peter Clausen,
	Jonathan Cameron, Peter Meerwald-Stadler, Hartmut Knaack

Add support for using label property for easier device identification via
iio framework.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 drivers/iio/adc/ina2xx-adc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c
index 7c7c63677bf4..077c54915f70 100644
--- a/drivers/iio/adc/ina2xx-adc.c
+++ b/drivers/iio/adc/ina2xx-adc.c
@@ -1033,7 +1033,7 @@ static int ina2xx_probe(struct i2c_client *client,
 	snprintf(chip->name, sizeof(chip->name), "%s-%s",
 		 client->name, dev_name(&client->dev));
 
-	indio_dev->name = chip->name;
+	indio_dev->name = of_get_property(np, "label", NULL) ? : chip->name;
 	indio_dev->setup_ops = &ina2xx_setup_ops;
 
 	buffer = devm_iio_kfifo_allocate(&indio_dev->dev);
-- 
2.17.1


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

* Re: [PATCH 1/4] iio: adc: ina2xx: Define *device_node only once
  2019-08-20 14:11 ` [PATCH 1/4] iio: adc: ina2xx: Define *device_node only once Michal Simek
@ 2019-08-21  1:56   ` Phil Reid
  0 siblings, 0 replies; 12+ messages in thread
From: Phil Reid @ 2019-08-21  1:56 UTC (permalink / raw)
  To: Michal Simek, linux-kernel, monstr, linux
  Cc: Colin Ian King, linux-iio, Stefan Brüns, Lars-Peter Clausen,
	Jonathan Cameron, Peter Meerwald-Stadler, Hartmut Knaack

On 20/08/2019 22:11, Michal Simek wrote:
> There is no reason to c&p full client->dev.of_node link when simple
> variable can keep it.
One comment

> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
>   drivers/iio/adc/ina2xx-adc.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c
> index bdd7cba6f6b0..37058d9c2054 100644
> --- a/drivers/iio/adc/ina2xx-adc.c
> +++ b/drivers/iio/adc/ina2xx-adc.c
> @@ -951,6 +951,7 @@ static int ina2xx_probe(struct i2c_client *client,
>   	struct ina2xx_chip_info *chip;
>   	struct iio_dev *indio_dev;
>   	struct iio_buffer *buffer;
> +	struct device_node *np = client->dev.of_node;
>   	unsigned int val;
>   	enum ina2xx_ids type;
>   	int ret;
> @@ -970,7 +971,7 @@ static int ina2xx_probe(struct i2c_client *client,
>   		return PTR_ERR(chip->regmap);
>   	}
>   
> -	if (client->dev.of_node)
> +	if (np)
>   		type = (enum ina2xx_ids)of_device_get_match_data(&client->dev);
>   	else
>   		type = id->driver_data;
> @@ -978,7 +979,7 @@ static int ina2xx_probe(struct i2c_client *client,
>   
>   	mutex_init(&chip->state_lock);
>   
> -	if (of_property_read_u32(client->dev.of_node,
> +	if (of_property_read_u32(np,
>   				 "shunt-resistor", &val) < 0) {

This will fit on one line <80 now.

>   		struct ina2xx_platform_data *pdata =
>   		    dev_get_platdata(&client->dev);
> @@ -1016,7 +1017,7 @@ static int ina2xx_probe(struct i2c_client *client,
>   
>   	indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE;
>   	indio_dev->dev.parent = &client->dev;
> -	indio_dev->dev.of_node = client->dev.of_node;
> +	indio_dev->dev.of_node = np;
>   	if (id->driver_data == ina226) {
>   		indio_dev->channels = ina226_channels;
>   		indio_dev->num_channels = ARRAY_SIZE(ina226_channels);
> 


-- 
Regards
Phil Reid

ElectroMagnetic Imaging Technology Pty Ltd
Development of Geophysical Instrumentation & Software
www.electromag.com.au

3 The Avenue, Midland WA 6056, AUSTRALIA
Ph: +61 8 9250 8100
Fax: +61 8 9250 7100
Email: preid@electromag.com.au

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

* Re: [PATCH 2/4] iio: adc: ina2xx: Setup better name then simple ina2xx
  2019-08-20 14:11 ` [PATCH 2/4] iio: adc: ina2xx: Setup better name then simple ina2xx Michal Simek
@ 2019-08-21  2:10   ` Phil Reid
  2019-08-21  8:36     ` Michal Simek
  0 siblings, 1 reply; 12+ messages in thread
From: Phil Reid @ 2019-08-21  2:10 UTC (permalink / raw)
  To: Michal Simek, linux-kernel, monstr, linux
  Cc: Colin Ian King, linux-iio, Stefan Brüns, Lars-Peter Clausen,
	Jonathan Cameron, Peter Meerwald-Stadler, Hartmut Knaack

On 20/08/2019 22:11, Michal Simek wrote:
> On systems with multiple ina2xx chips it is impossible to find out which
> iio device is which one based on probe order. That's why it is necessary to
> setup better name based on possition.
> The patch is reusing dev_name which is setup by core with client->name.
> 
> name char array was setup to 128 byte length to correspond the same name
> length by HID device.
> 
> Before this patch:
> iio:device9: ina226 (buffer capable)
> After:
> iio:device9: ina226-3-004a (buffer capable)

Could this break existing user space code that's just looking for just ina226.
I2c bus numbers aren't all that great at id'ing devices either. It's better than
nothing but depending on what cards we have plugged into our system the same device gets
a different bus number.


> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
> Also id->name can be used as prefix. On ina226 output is the same.
> 
> Also I am happy to change that space for name will be dynamicky allocated
> to save a space if needed.
> ---
>   drivers/iio/adc/ina2xx-adc.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c
> index 37058d9c2054..7c7c63677bf4 100644
> --- a/drivers/iio/adc/ina2xx-adc.c
> +++ b/drivers/iio/adc/ina2xx-adc.c
> @@ -146,6 +146,7 @@ struct ina2xx_chip_info {
>   	int range_vbus; /* Bus voltage maximum in V */
>   	int pga_gain_vshunt; /* Shunt voltage PGA gain */
>   	bool allow_async_readout;
> +	char name[128];
>   };
>   
>   static const struct ina2xx_config ina2xx_config[] = {
> @@ -1027,7 +1028,12 @@ static int ina2xx_probe(struct i2c_client *client,
>   		indio_dev->num_channels = ARRAY_SIZE(ina219_channels);
>   		indio_dev->info = &ina219_info;
>   	}
> -	indio_dev->name = id->name;
> +
> +	/* Compose chip name to unified i2c format */
> +	snprintf(chip->name, sizeof(chip->name), "%s-%s",
> +		 client->name, dev_name(&client->dev));
> +
> +	indio_dev->name = chip->name;
>   	indio_dev->setup_ops = &ina2xx_setup_ops;
>   
>   	buffer = devm_iio_kfifo_allocate(&indio_dev->dev);
> 


-- 
Regards
Phil Reid

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

* Re: [PATCH 4/4] iio: adc: ina2xx: Use label proper for device identification
  2019-08-20 14:11 ` [PATCH 4/4] iio: adc: ina2xx: Use label proper for device identification Michal Simek
@ 2019-08-21  2:11   ` Phil Reid
  2019-08-21  9:12     ` Michal Simek
  0 siblings, 1 reply; 12+ messages in thread
From: Phil Reid @ 2019-08-21  2:11 UTC (permalink / raw)
  To: Michal Simek, linux-kernel, monstr, linux
  Cc: Colin Ian King, linux-iio, Stefan Brüns, Lars-Peter Clausen,
	Jonathan Cameron, Peter Meerwald-Stadler, Hartmut Knaack

On 20/08/2019 22:11, Michal Simek wrote:
> Add support for using label property for easier device identification via
> iio framework.
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
>   drivers/iio/adc/ina2xx-adc.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c
> index 7c7c63677bf4..077c54915f70 100644
> --- a/drivers/iio/adc/ina2xx-adc.c
> +++ b/drivers/iio/adc/ina2xx-adc.c
> @@ -1033,7 +1033,7 @@ static int ina2xx_probe(struct i2c_client *client,
>   	snprintf(chip->name, sizeof(chip->name), "%s-%s",
>   		 client->name, dev_name(&client->dev));
>   
> -	indio_dev->name = chip->name;
> +	indio_dev->name = of_get_property(np, "label", NULL) ? : chip->name;
>   	indio_dev->setup_ops = &ina2xx_setup_ops;
>   
>   	buffer = devm_iio_kfifo_allocate(&indio_dev->dev);
> 
I like this personally. It'd be nice if it was a core function so
it could be an opt in to any iio device.

Don't know how well received that'd be thou.


-- 
Regards
Phil Reid


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

* Re: [PATCH 2/4] iio: adc: ina2xx: Setup better name then simple ina2xx
  2019-08-21  2:10   ` Phil Reid
@ 2019-08-21  8:36     ` Michal Simek
  0 siblings, 0 replies; 12+ messages in thread
From: Michal Simek @ 2019-08-21  8:36 UTC (permalink / raw)
  To: Phil Reid, Michal Simek, linux-kernel, monstr, linux
  Cc: Colin Ian King, linux-iio, Stefan Brüns, Lars-Peter Clausen,
	Jonathan Cameron, Peter Meerwald-Stadler, Hartmut Knaack

On 21. 08. 19 4:10, Phil Reid wrote:
> On 20/08/2019 22:11, Michal Simek wrote:
>> On systems with multiple ina2xx chips it is impossible to find out which
>> iio device is which one based on probe order. That's why it is
>> necessary to
>> setup better name based on possition.
>> The patch is reusing dev_name which is setup by core with client->name.
>>
>> name char array was setup to 128 byte length to correspond the same name
>> length by HID device.
>>
>> Before this patch:
>> iio:device9: ina226 (buffer capable)
>> After:
>> iio:device9: ina226-3-004a (buffer capable)
> 
> Could this break existing user space code that's just looking for just
> ina226.
> I2c bus numbers aren't all that great at id'ing devices either. It's
> better than
> nothing but depending on what cards we have plugged into our system the
> same device gets
> a different bus number.

Fair point. Let's wait what dt guys say about label property.
I can simply drop this patch and use just this.

indio_dev->name = of_get_property(np, "label", NULL) ? : id->name;

Thanks,
Michal

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

* Re: [PATCH 4/4] iio: adc: ina2xx: Use label proper for device identification
  2019-08-21  2:11   ` Phil Reid
@ 2019-08-21  9:12     ` Michal Simek
  2019-08-25 18:07       ` Jonathan Cameron
  0 siblings, 1 reply; 12+ messages in thread
From: Michal Simek @ 2019-08-21  9:12 UTC (permalink / raw)
  To: Phil Reid, Michal Simek, linux-kernel, monstr, linux
  Cc: Colin Ian King, linux-iio, Stefan Brüns, Lars-Peter Clausen,
	Jonathan Cameron, Peter Meerwald-Stadler, Hartmut Knaack

On 21. 08. 19 4:11, Phil Reid wrote:
> On 20/08/2019 22:11, Michal Simek wrote:
>> Add support for using label property for easier device identification via
>> iio framework.
>>
>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>> ---
>>
>>   drivers/iio/adc/ina2xx-adc.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c
>> index 7c7c63677bf4..077c54915f70 100644
>> --- a/drivers/iio/adc/ina2xx-adc.c
>> +++ b/drivers/iio/adc/ina2xx-adc.c
>> @@ -1033,7 +1033,7 @@ static int ina2xx_probe(struct i2c_client *client,
>>       snprintf(chip->name, sizeof(chip->name), "%s-%s",
>>            client->name, dev_name(&client->dev));
>>   -    indio_dev->name = chip->name;
>> +    indio_dev->name = of_get_property(np, "label", NULL) ? : chip->name;
>>       indio_dev->setup_ops = &ina2xx_setup_ops;
>>         buffer = devm_iio_kfifo_allocate(&indio_dev->dev);
>>
> I like this personally. It'd be nice if it was a core function so
> it could be an opt in to any iio device.
> 
> Don't know how well received that'd be thou.
> 

Something like this?

diff --git a/drivers/iio/industrialio-core.c
b/drivers/iio/industrialio-core.c
index 524a686077ca..d21b495d36a1 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -1647,6 +1647,9 @@ int __iio_device_register(struct iio_dev
*indio_dev, struct module *this_mod)
        if (!indio_dev->dev.of_node && indio_dev->dev.parent)
                indio_dev->dev.of_node = indio_dev->dev.parent->of_node;

+       indio_dev->name = of_get_property(indio_dev->dev.of_node,
"label", NULL) ? :
+                                         indio_dev->name;
+
        ret = iio_check_unique_scan_index(indio_dev);
        if (ret < 0)
                return ret;


M

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

* Re: [PATCH 4/4] iio: adc: ina2xx: Use label proper for device identification
  2019-08-21  9:12     ` Michal Simek
@ 2019-08-25 18:07       ` Jonathan Cameron
  2019-08-27  3:55         ` Phil Reid
  0 siblings, 1 reply; 12+ messages in thread
From: Jonathan Cameron @ 2019-08-25 18:07 UTC (permalink / raw)
  To: Michal Simek
  Cc: Phil Reid, linux-kernel, monstr, linux, Colin Ian King,
	linux-iio, Stefan Brüns, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Hartmut Knaack

On Wed, 21 Aug 2019 11:12:00 +0200
Michal Simek <michal.simek@xilinx.com> wrote:

> On 21. 08. 19 4:11, Phil Reid wrote:
> > On 20/08/2019 22:11, Michal Simek wrote:  
> >> Add support for using label property for easier device identification via
> >> iio framework.
> >>
> >> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> >> ---
> >>
> >>   drivers/iio/adc/ina2xx-adc.c | 2 +-
> >>   1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c
> >> index 7c7c63677bf4..077c54915f70 100644
> >> --- a/drivers/iio/adc/ina2xx-adc.c
> >> +++ b/drivers/iio/adc/ina2xx-adc.c
> >> @@ -1033,7 +1033,7 @@ static int ina2xx_probe(struct i2c_client *client,
> >>       snprintf(chip->name, sizeof(chip->name), "%s-%s",
> >>            client->name, dev_name(&client->dev));
> >>   -    indio_dev->name = chip->name;
> >> +    indio_dev->name = of_get_property(np, "label", NULL) ? : chip->name;
> >>       indio_dev->setup_ops = &ina2xx_setup_ops;
> >>         buffer = devm_iio_kfifo_allocate(&indio_dev->dev);
> >>  
> > I like this personally. It'd be nice if it was a core function so
> > it could be an opt in to any iio device.
> > 
> > Don't know how well received that'd be thou.
> >   
I'm not particularly keen on changing the semantics of existing
ABI, but how about adding new ABI to provide this?

/sys/bus/iio/devices/iio\:device0/label for example?

I haven't thought about it in depth yet though.  If you spin
a patch with that and the DT docs we'll be more likely to get
a view from DT maintainers if this is acceptable use of label.

Thanks

Jonathan

> 
> Something like this?
> 
> diff --git a/drivers/iio/industrialio-core.c
> b/drivers/iio/industrialio-core.c
> index 524a686077ca..d21b495d36a1 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -1647,6 +1647,9 @@ int __iio_device_register(struct iio_dev
> *indio_dev, struct module *this_mod)
>         if (!indio_dev->dev.of_node && indio_dev->dev.parent)
>                 indio_dev->dev.of_node = indio_dev->dev.parent->of_node;
> 
> +       indio_dev->name = of_get_property(indio_dev->dev.of_node,
> "label", NULL) ? :
> +                                         indio_dev->name;
> +
>         ret = iio_check_unique_scan_index(indio_dev);
>         if (ret < 0)
>                 return ret;
> 
> 
> M


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

* Re: [PATCH 4/4] iio: adc: ina2xx: Use label proper for device identification
  2019-08-25 18:07       ` Jonathan Cameron
@ 2019-08-27  3:55         ` Phil Reid
  2019-08-27  6:14           ` Michal Simek
  0 siblings, 1 reply; 12+ messages in thread
From: Phil Reid @ 2019-08-27  3:55 UTC (permalink / raw)
  To: Jonathan Cameron, Michal Simek
  Cc: linux-kernel, monstr, linux, Colin Ian King, linux-iio,
	Stefan Brüns, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Hartmut Knaack

On 26/08/2019 02:07, Jonathan Cameron wrote:
> On Wed, 21 Aug 2019 11:12:00 +0200
> Michal Simek <michal.simek@xilinx.com> wrote:
> 
>> On 21. 08. 19 4:11, Phil Reid wrote:
>>> On 20/08/2019 22:11, Michal Simek wrote:
>>>> Add support for using label property for easier device identification via
>>>> iio framework.
>>>>
>>>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>>>> ---
>>>>
>>>>    drivers/iio/adc/ina2xx-adc.c | 2 +-
>>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c
>>>> index 7c7c63677bf4..077c54915f70 100644
>>>> --- a/drivers/iio/adc/ina2xx-adc.c
>>>> +++ b/drivers/iio/adc/ina2xx-adc.c
>>>> @@ -1033,7 +1033,7 @@ static int ina2xx_probe(struct i2c_client *client,
>>>>        snprintf(chip->name, sizeof(chip->name), "%s-%s",
>>>>             client->name, dev_name(&client->dev));
>>>>    -    indio_dev->name = chip->name;
>>>> +    indio_dev->name = of_get_property(np, "label", NULL) ? : chip->name;
>>>>        indio_dev->setup_ops = &ina2xx_setup_ops;
>>>>          buffer = devm_iio_kfifo_allocate(&indio_dev->dev);
>>>>   
>>> I like this personally. It'd be nice if it was a core function so
>>> it could be an opt in to any iio device.
>>>
>>> Don't know how well received that'd be thou.
>>>    
> I'm not particularly keen on changing the semantics of existing
> ABI, but how about adding new ABI to provide this?
> 
> /sys/bus/iio/devices/iio\:device0/label for example?
> 
> I haven't thought about it in depth yet though.  If you spin
> a patch with that and the DT docs we'll be more likely to get
> a view from DT maintainers if this is acceptable use of label.
> 

I've sent "iio: core: Add optional symbolic label to device attributes"
for further discussion.


> Thanks
> 
> Jonathan
> 
>>
>> Something like this?
>>
>> diff --git a/drivers/iio/industrialio-core.c
>> b/drivers/iio/industrialio-core.c
>> index 524a686077ca..d21b495d36a1 100644
>> --- a/drivers/iio/industrialio-core.c
>> +++ b/drivers/iio/industrialio-core.c
>> @@ -1647,6 +1647,9 @@ int __iio_device_register(struct iio_dev
>> *indio_dev, struct module *this_mod)
>>          if (!indio_dev->dev.of_node && indio_dev->dev.parent)
>>                  indio_dev->dev.of_node = indio_dev->dev.parent->of_node;
>>
>> +       indio_dev->name = of_get_property(indio_dev->dev.of_node,
>> "label", NULL) ? :
>> +                                         indio_dev->name;
>> +
>>          ret = iio_check_unique_scan_index(indio_dev);
>>          if (ret < 0)
>>                  return ret;
>>
>>
>> M
> 
> 
> 


-- 
Regards
Phil Reid

ElectroMagnetic Imaging Technology Pty Ltd
Development of Geophysical Instrumentation & Software
www.electromag.com.au

3 The Avenue, Midland WA 6056, AUSTRALIA
Ph: +61 8 9250 8100
Fax: +61 8 9250 7100
Email: preid@electromag.com.au

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

* Re: [PATCH 4/4] iio: adc: ina2xx: Use label proper for device identification
  2019-08-27  3:55         ` Phil Reid
@ 2019-08-27  6:14           ` Michal Simek
  0 siblings, 0 replies; 12+ messages in thread
From: Michal Simek @ 2019-08-27  6:14 UTC (permalink / raw)
  To: Phil Reid, Jonathan Cameron, Michal Simek
  Cc: linux-kernel, monstr, linux, Colin Ian King, linux-iio,
	Stefan Brüns, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Hartmut Knaack

On 27. 08. 19 5:55, Phil Reid wrote:
> On 26/08/2019 02:07, Jonathan Cameron wrote:
>> On Wed, 21 Aug 2019 11:12:00 +0200
>> Michal Simek <michal.simek@xilinx.com> wrote:
>>
>>> On 21. 08. 19 4:11, Phil Reid wrote:
>>>> On 20/08/2019 22:11, Michal Simek wrote:
>>>>> Add support for using label property for easier device
>>>>> identification via
>>>>> iio framework.
>>>>>
>>>>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>>>>> ---
>>>>>
>>>>>    drivers/iio/adc/ina2xx-adc.c | 2 +-
>>>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/drivers/iio/adc/ina2xx-adc.c
>>>>> b/drivers/iio/adc/ina2xx-adc.c
>>>>> index 7c7c63677bf4..077c54915f70 100644
>>>>> --- a/drivers/iio/adc/ina2xx-adc.c
>>>>> +++ b/drivers/iio/adc/ina2xx-adc.c
>>>>> @@ -1033,7 +1033,7 @@ static int ina2xx_probe(struct i2c_client
>>>>> *client,
>>>>>        snprintf(chip->name, sizeof(chip->name), "%s-%s",
>>>>>             client->name, dev_name(&client->dev));
>>>>>    -    indio_dev->name = chip->name;
>>>>> +    indio_dev->name = of_get_property(np, "label", NULL) ? :
>>>>> chip->name;
>>>>>        indio_dev->setup_ops = &ina2xx_setup_ops;
>>>>>          buffer = devm_iio_kfifo_allocate(&indio_dev->dev);
>>>>>   
>>>> I like this personally. It'd be nice if it was a core function so
>>>> it could be an opt in to any iio device.
>>>>
>>>> Don't know how well received that'd be thou.
>>>>    
>> I'm not particularly keen on changing the semantics of existing
>> ABI, but how about adding new ABI to provide this?
>>
>> /sys/bus/iio/devices/iio\:device0/label for example?
>>
>> I haven't thought about it in depth yet though.  If you spin
>> a patch with that and the DT docs we'll be more likely to get
>> a view from DT maintainers if this is acceptable use of label.
>>
> 
> I've sent "iio: core: Add optional symbolic label to device attributes"
> for further discussion.

Series looks good. I expect that there will be also update in libiio if
this is accepted.

Thanks,
Michal

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

end of thread, other threads:[~2019-08-27  6:15 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-20 14:11 [PATCH 0/4] iio: adc: ina2xx: Improve device identification Michal Simek
2019-08-20 14:11 ` [PATCH 1/4] iio: adc: ina2xx: Define *device_node only once Michal Simek
2019-08-21  1:56   ` Phil Reid
2019-08-20 14:11 ` [PATCH 2/4] iio: adc: ina2xx: Setup better name then simple ina2xx Michal Simek
2019-08-21  2:10   ` Phil Reid
2019-08-21  8:36     ` Michal Simek
2019-08-20 14:11 ` [PATCH 4/4] iio: adc: ina2xx: Use label proper for device identification Michal Simek
2019-08-21  2:11   ` Phil Reid
2019-08-21  9:12     ` Michal Simek
2019-08-25 18:07       ` Jonathan Cameron
2019-08-27  3:55         ` Phil Reid
2019-08-27  6:14           ` Michal Simek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).