Message ID | 0542b562a813c5c22c42484ac24bbb626ac3c022.1566310292.git.michal.simek@xilinx.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | iio: adc: ina2xx: Improve device identification | expand |
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.
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
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
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 > > >
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
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);
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(-)