[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <bca73b6d-87ae-f8cc-b9f4-3b0a558942d9@xilinx.com>
Date: Wed, 21 Aug 2019 11:12:00 +0200
From: Michal Simek <michal.simek@...inx.com>
To: Phil Reid <preid@...ctromag.com.au>,
Michal Simek <michal.simek@...inx.com>,
linux-kernel@...r.kernel.org, monstr@...str.eu, linux@...ck-us.net
Cc: Colin Ian King <colin.king@...onical.com>,
linux-iio@...r.kernel.org,
Stefan Brüns <stefan.bruens@...h-aachen.de>,
Lars-Peter Clausen <lars@...afoo.de>,
Jonathan Cameron <jic23@...nel.org>,
Peter Meerwald-Stadler <pmeerw@...erw.net>,
Hartmut Knaack <knaack.h@....de>
Subject: Re: [PATCH 4/4] iio: adc: ina2xx: Use label proper for device
identification
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@...inx.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
Powered by blists - more mailing lists