linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] iio: core: Add optional symbolic label to device attributes
@ 2019-09-19 14:36 Phil Reid
  2019-09-19 14:36 ` [PATCH v2 1/2] dt-binding: iio: Add optional label property Phil Reid
  2019-09-19 14:36 ` [PATCH v2 2/2] iio: core: Add optional symbolic label to device attributes Phil Reid
  0 siblings, 2 replies; 9+ messages in thread
From: Phil Reid @ 2019-09-19 14:36 UTC (permalink / raw)
  To: jic23, knaack.h, lars, pmeerw, robh+dt, mark.rutland, preid,
	linux-iio, devicetree, michal.simek

If a label is defined in the device tree for this device add that
to the device specific attributes. This is useful for userspace to
be able to identify an individual device when multiple identical
chips are present in the system.

Similar to leds, display labels etc.

Changes from V1:
- Update commit message for dt_bind commit
- Update example label for dt-binding

I haven't added Rob's reviewed-by from V1. Wasnt't
sure if the changes are minor enough to keep that.

Phil Reid (2):
  dt-binding: iio: Add optional label property
  iio: core: Add optional symbolic label to device attributes

 Documentation/devicetree/bindings/iio/iio-bindings.txt |  5 +++++
 drivers/iio/industrialio-core.c                        | 17 +++++++++++++++++
 include/linux/iio/iio.h                                |  1 +
 3 files changed, 23 insertions(+)

-- 
1.8.3.1


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

* [PATCH v2 1/2] dt-binding: iio: Add optional label property
  2019-09-19 14:36 [PATCH v2 0/2] iio: core: Add optional symbolic label to device attributes Phil Reid
@ 2019-09-19 14:36 ` Phil Reid
  2019-09-27 14:44   ` Rob Herring
  2019-09-19 14:36 ` [PATCH v2 2/2] iio: core: Add optional symbolic label to device attributes Phil Reid
  1 sibling, 1 reply; 9+ messages in thread
From: Phil Reid @ 2019-09-19 14:36 UTC (permalink / raw)
  To: jic23, knaack.h, lars, pmeerw, robh+dt, mark.rutland, preid,
	linux-iio, devicetree, michal.simek

This optional property defines a symbolic name for the device.
This helps to distinguish between more than one iio device
of the same type.

Suggested-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Phil Reid <preid@electromag.com.au>
---
 Documentation/devicetree/bindings/iio/iio-bindings.txt | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/iio-bindings.txt b/Documentation/devicetree/bindings/iio/iio-bindings.txt
index 68d6f8ce063b..af33267727f4 100644
--- a/Documentation/devicetree/bindings/iio/iio-bindings.txt
+++ b/Documentation/devicetree/bindings/iio/iio-bindings.txt
@@ -18,12 +18,17 @@ Required properties:
 		   with a single IIO output and 1 for nodes with multiple
 		   IIO outputs.
 
+Optional properties:
+label:		   A symbolic name for the device.
+
+
 Example for a simple configuration with no trigger:
 
 	adc: voltage-sensor@35 {
 		compatible = "maxim,max1139";
 		reg = <0x35>;
 		#io-channel-cells = <1>;
+		label = "voltage_feedback_group1";
 	};
 
 Example for a configuration with trigger:
-- 
1.8.3.1


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

* [PATCH v2 2/2] iio: core: Add optional symbolic label to device attributes
  2019-09-19 14:36 [PATCH v2 0/2] iio: core: Add optional symbolic label to device attributes Phil Reid
  2019-09-19 14:36 ` [PATCH v2 1/2] dt-binding: iio: Add optional label property Phil Reid
@ 2019-09-19 14:36 ` Phil Reid
  2019-10-05 14:59   ` Jonathan Cameron
  1 sibling, 1 reply; 9+ messages in thread
From: Phil Reid @ 2019-09-19 14:36 UTC (permalink / raw)
  To: jic23, knaack.h, lars, pmeerw, robh+dt, mark.rutland, preid,
	linux-iio, devicetree, michal.simek

If a label is defined in the device tree for this device add that
to the device specific attributes. This is useful for userspace to
be able to identify an individual device when multiple identical
chips are present in the system.

Tested-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Phil Reid <preid@electromag.com.au>
---
 drivers/iio/industrialio-core.c | 17 +++++++++++++++++
 include/linux/iio/iio.h         |  1 +
 2 files changed, 18 insertions(+)

diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 524a686077ca..f72c2dc5f703 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -1238,6 +1238,16 @@ static ssize_t iio_show_dev_name(struct device *dev,
 
 static DEVICE_ATTR(name, S_IRUGO, iio_show_dev_name, NULL);
 
+static ssize_t iio_show_dev_label(struct device *dev,
+				 struct device_attribute *attr,
+				 char *buf)
+{
+	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+	return snprintf(buf, PAGE_SIZE, "%s\n", indio_dev->label);
+}
+
+static DEVICE_ATTR(label, S_IRUGO, iio_show_dev_label, NULL);
+
 static ssize_t iio_show_timestamp_clock(struct device *dev,
 					struct device_attribute *attr,
 					char *buf)
@@ -1354,6 +1364,8 @@ static int iio_device_register_sysfs(struct iio_dev *indio_dev)
 
 	if (indio_dev->name)
 		attrcount++;
+	if (indio_dev->label)
+		attrcount++;
 	if (clk)
 		attrcount++;
 
@@ -1376,6 +1388,8 @@ static int iio_device_register_sysfs(struct iio_dev *indio_dev)
 		indio_dev->chan_attr_group.attrs[attrn++] = &p->dev_attr.attr;
 	if (indio_dev->name)
 		indio_dev->chan_attr_group.attrs[attrn++] = &dev_attr_name.attr;
+	if (indio_dev->label)
+		indio_dev->chan_attr_group.attrs[attrn++] = &dev_attr_label.attr;
 	if (clk)
 		indio_dev->chan_attr_group.attrs[attrn++] = clk;
 
@@ -1647,6 +1661,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->label = of_get_property(indio_dev->dev.of_node, "label",
+					   NULL);
+
 	ret = iio_check_unique_scan_index(indio_dev);
 	if (ret < 0)
 		return ret;
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 8e132cf819e4..a2527c7ab934 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -553,6 +553,7 @@ struct iio_dev {
 	struct list_head		channel_attr_list;
 	struct attribute_group		chan_attr_group;
 	const char			*name;
+	const char			*label;
 	const struct iio_info		*info;
 	clockid_t			clock_id;
 	struct mutex			info_exist_lock;
-- 
1.8.3.1


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

* Re: [PATCH v2 1/2] dt-binding: iio: Add optional label property
  2019-09-19 14:36 ` [PATCH v2 1/2] dt-binding: iio: Add optional label property Phil Reid
@ 2019-09-27 14:44   ` Rob Herring
  2019-10-05 14:58     ` Jonathan Cameron
  0 siblings, 1 reply; 9+ messages in thread
From: Rob Herring @ 2019-09-27 14:44 UTC (permalink / raw)
  To: Phil Reid
  Cc: jic23, knaack.h, lars, pmeerw, mark.rutland, linux-iio,
	devicetree, michal.simek

On Thu, Sep 19, 2019 at 10:36:07PM +0800, Phil Reid wrote:
> This optional property defines a symbolic name for the device.
> This helps to distinguish between more than one iio device
> of the same type.
> 
> Suggested-by: Michal Simek <michal.simek@xilinx.com>
> Signed-off-by: Phil Reid <preid@electromag.com.au>
> ---
>  Documentation/devicetree/bindings/iio/iio-bindings.txt | 5 +++++
>  1 file changed, 5 insertions(+)

Reviewed-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH v2 1/2] dt-binding: iio: Add optional label property
  2019-09-27 14:44   ` Rob Herring
@ 2019-10-05 14:58     ` Jonathan Cameron
  0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2019-10-05 14:58 UTC (permalink / raw)
  To: Rob Herring
  Cc: Phil Reid, knaack.h, lars, pmeerw, mark.rutland, linux-iio,
	devicetree, michal.simek

On Fri, 27 Sep 2019 09:44:19 -0500
Rob Herring <robh@kernel.org> wrote:

> On Thu, Sep 19, 2019 at 10:36:07PM +0800, Phil Reid wrote:
> > This optional property defines a symbolic name for the device.
> > This helps to distinguish between more than one iio device
> > of the same type.
> > 
> > Suggested-by: Michal Simek <michal.simek@xilinx.com>
> > Signed-off-by: Phil Reid <preid@electromag.com.au>
> > ---
> >  Documentation/devicetree/bindings/iio/iio-bindings.txt | 5 +++++
> >  1 file changed, 5 insertions(+)  
> 
> Reviewed-by: Rob Herring <robh@kernel.org>

Applied to the togreg branch of iio.git and pushed out as testing
for nothing much to happen to it.

Thanks,

Jonathan

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

* Re: [PATCH v2 2/2] iio: core: Add optional symbolic label to device attributes
  2019-09-19 14:36 ` [PATCH v2 2/2] iio: core: Add optional symbolic label to device attributes Phil Reid
@ 2019-10-05 14:59   ` Jonathan Cameron
  2019-10-07 20:32     ` Jonathan Cameron
  0 siblings, 1 reply; 9+ messages in thread
From: Jonathan Cameron @ 2019-10-05 14:59 UTC (permalink / raw)
  To: Phil Reid
  Cc: knaack.h, lars, pmeerw, robh+dt, mark.rutland, linux-iio,
	devicetree, michal.simek

On Thu, 19 Sep 2019 22:36:08 +0800
Phil Reid <preid@electromag.com.au> wrote:

> If a label is defined in the device tree for this device add that
> to the device specific attributes. This is useful for userspace to
> be able to identify an individual device when multiple identical
> chips are present in the system.
> 
> Tested-by: Michal Simek <michal.simek@xilinx.com>
> Signed-off-by: Phil Reid <preid@electromag.com.au>

Glad to see this going in given I thought I'd already applied it
and told someone they should be using it early today (oops ;)

Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

Thanks for doing this.

Jonathan

> ---
>  drivers/iio/industrialio-core.c | 17 +++++++++++++++++
>  include/linux/iio/iio.h         |  1 +
>  2 files changed, 18 insertions(+)
> 
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index 524a686077ca..f72c2dc5f703 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -1238,6 +1238,16 @@ static ssize_t iio_show_dev_name(struct device *dev,
>  
>  static DEVICE_ATTR(name, S_IRUGO, iio_show_dev_name, NULL);
>  
> +static ssize_t iio_show_dev_label(struct device *dev,
> +				 struct device_attribute *attr,
> +				 char *buf)
> +{
> +	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> +	return snprintf(buf, PAGE_SIZE, "%s\n", indio_dev->label);
> +}
> +
> +static DEVICE_ATTR(label, S_IRUGO, iio_show_dev_label, NULL);
> +
>  static ssize_t iio_show_timestamp_clock(struct device *dev,
>  					struct device_attribute *attr,
>  					char *buf)
> @@ -1354,6 +1364,8 @@ static int iio_device_register_sysfs(struct iio_dev *indio_dev)
>  
>  	if (indio_dev->name)
>  		attrcount++;
> +	if (indio_dev->label)
> +		attrcount++;
>  	if (clk)
>  		attrcount++;
>  
> @@ -1376,6 +1388,8 @@ static int iio_device_register_sysfs(struct iio_dev *indio_dev)
>  		indio_dev->chan_attr_group.attrs[attrn++] = &p->dev_attr.attr;
>  	if (indio_dev->name)
>  		indio_dev->chan_attr_group.attrs[attrn++] = &dev_attr_name.attr;
> +	if (indio_dev->label)
> +		indio_dev->chan_attr_group.attrs[attrn++] = &dev_attr_label.attr;
>  	if (clk)
>  		indio_dev->chan_attr_group.attrs[attrn++] = clk;
>  
> @@ -1647,6 +1661,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->label = of_get_property(indio_dev->dev.of_node, "label",
> +					   NULL);
> +
>  	ret = iio_check_unique_scan_index(indio_dev);
>  	if (ret < 0)
>  		return ret;
> diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
> index 8e132cf819e4..a2527c7ab934 100644
> --- a/include/linux/iio/iio.h
> +++ b/include/linux/iio/iio.h
> @@ -553,6 +553,7 @@ struct iio_dev {
>  	struct list_head		channel_attr_list;
>  	struct attribute_group		chan_attr_group;
>  	const char			*name;
> +	const char			*label;
>  	const struct iio_info		*info;
>  	clockid_t			clock_id;
>  	struct mutex			info_exist_lock;


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

* Re: [PATCH v2 2/2] iio: core: Add optional symbolic label to device attributes
  2019-10-05 14:59   ` Jonathan Cameron
@ 2019-10-07 20:32     ` Jonathan Cameron
  2019-10-08  7:06       ` Phil Reid
  0 siblings, 1 reply; 9+ messages in thread
From: Jonathan Cameron @ 2019-10-07 20:32 UTC (permalink / raw)
  To: Phil Reid
  Cc: knaack.h, lars, pmeerw, robh+dt, mark.rutland, linux-iio,
	devicetree, michal.simek

On Sat, 5 Oct 2019 15:59:05 +0100
Jonathan Cameron <jic23@kernel.org> wrote:

> On Thu, 19 Sep 2019 22:36:08 +0800
> Phil Reid <preid@electromag.com.au> wrote:
> 
> > If a label is defined in the device tree for this device add that
> > to the device specific attributes. This is useful for userspace to
> > be able to identify an individual device when multiple identical
> > chips are present in the system.
> > 
> > Tested-by: Michal Simek <michal.simek@xilinx.com>
> > Signed-off-by: Phil Reid <preid@electromag.com.au>  
> 
> Glad to see this going in given I thought I'd already applied it
> and told someone they should be using it early today (oops ;)
> 
> Applied to the togreg branch of iio.git and pushed out as testing
> for the autobuilders to play with it.

0-day picked up that there were no docs for this new field.
I've added some and re pushed out.

Thanks,

Jonathan

> 
> Thanks for doing this.
> 
> Jonathan
> 
> > ---
> >  drivers/iio/industrialio-core.c | 17 +++++++++++++++++
> >  include/linux/iio/iio.h         |  1 +
> >  2 files changed, 18 insertions(+)
> > 
> > diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> > index 524a686077ca..f72c2dc5f703 100644
> > --- a/drivers/iio/industrialio-core.c
> > +++ b/drivers/iio/industrialio-core.c
> > @@ -1238,6 +1238,16 @@ static ssize_t iio_show_dev_name(struct device *dev,
> >  
> >  static DEVICE_ATTR(name, S_IRUGO, iio_show_dev_name, NULL);
> >  
> > +static ssize_t iio_show_dev_label(struct device *dev,
> > +				 struct device_attribute *attr,
> > +				 char *buf)
> > +{
> > +	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> > +	return snprintf(buf, PAGE_SIZE, "%s\n", indio_dev->label);
> > +}
> > +
> > +static DEVICE_ATTR(label, S_IRUGO, iio_show_dev_label, NULL);
> > +
> >  static ssize_t iio_show_timestamp_clock(struct device *dev,
> >  					struct device_attribute *attr,
> >  					char *buf)
> > @@ -1354,6 +1364,8 @@ static int iio_device_register_sysfs(struct iio_dev *indio_dev)
> >  
> >  	if (indio_dev->name)
> >  		attrcount++;
> > +	if (indio_dev->label)
> > +		attrcount++;
> >  	if (clk)
> >  		attrcount++;
> >  
> > @@ -1376,6 +1388,8 @@ static int iio_device_register_sysfs(struct iio_dev *indio_dev)
> >  		indio_dev->chan_attr_group.attrs[attrn++] = &p->dev_attr.attr;
> >  	if (indio_dev->name)
> >  		indio_dev->chan_attr_group.attrs[attrn++] = &dev_attr_name.attr;
> > +	if (indio_dev->label)
> > +		indio_dev->chan_attr_group.attrs[attrn++] = &dev_attr_label.attr;
> >  	if (clk)
> >  		indio_dev->chan_attr_group.attrs[attrn++] = clk;
> >  
> > @@ -1647,6 +1661,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->label = of_get_property(indio_dev->dev.of_node, "label",
> > +					   NULL);
> > +
> >  	ret = iio_check_unique_scan_index(indio_dev);
> >  	if (ret < 0)
> >  		return ret;
> > diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
> > index 8e132cf819e4..a2527c7ab934 100644
> > --- a/include/linux/iio/iio.h
> > +++ b/include/linux/iio/iio.h
> > @@ -553,6 +553,7 @@ struct iio_dev {
> >  	struct list_head		channel_attr_list;
> >  	struct attribute_group		chan_attr_group;
> >  	const char			*name;
> > +	const char			*label;
> >  	const struct iio_info		*info;
> >  	clockid_t			clock_id;
> >  	struct mutex			info_exist_lock;  
> 


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

* Re: [PATCH v2 2/2] iio: core: Add optional symbolic label to device attributes
  2019-10-07 20:32     ` Jonathan Cameron
@ 2019-10-08  7:06       ` Phil Reid
  2019-10-08 12:40         ` Jonathan Cameron
  0 siblings, 1 reply; 9+ messages in thread
From: Phil Reid @ 2019-10-08  7:06 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: knaack.h, lars, pmeerw, robh+dt, mark.rutland, linux-iio,
	devicetree, michal.simek

On 8/10/2019 04:32, Jonathan Cameron wrote:
> On Sat, 5 Oct 2019 15:59:05 +0100
> Jonathan Cameron <jic23@kernel.org> wrote:
> 
>> On Thu, 19 Sep 2019 22:36:08 +0800
>> Phil Reid <preid@electromag.com.au> wrote:
>>
>>> If a label is defined in the device tree for this device add that
>>> to the device specific attributes. This is useful for userspace to
>>> be able to identify an individual device when multiple identical
>>> chips are present in the system.
>>>
>>> Tested-by: Michal Simek <michal.simek@xilinx.com>
>>> Signed-off-by: Phil Reid <preid@electromag.com.au>
>>
>> Glad to see this going in given I thought I'd already applied it
>> and told someone they should be using it early today (oops ;)
>>
>> Applied to the togreg branch of iio.git and pushed out as testing
>> for the autobuilders to play with it.
> 
> 0-day picked up that there were no docs for this new field.
> I've added some and re pushed out.

Thanks.
Just for my info what should I be doing to check for that.
Don't remember getting any warnings for that.


> 
> Thanks,
> 
> Jonathan
> 
>>
>> Thanks for doing this.
>>
>> Jonathan
>>
>>> ---
>>>   drivers/iio/industrialio-core.c | 17 +++++++++++++++++
>>>   include/linux/iio/iio.h         |  1 +
>>>   2 files changed, 18 insertions(+)
>>>
>>> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
>>> index 524a686077ca..f72c2dc5f703 100644
>>> --- a/drivers/iio/industrialio-core.c
>>> +++ b/drivers/iio/industrialio-core.c
>>> @@ -1238,6 +1238,16 @@ static ssize_t iio_show_dev_name(struct device *dev,
>>>   
>>>   static DEVICE_ATTR(name, S_IRUGO, iio_show_dev_name, NULL);
>>>   
>>> +static ssize_t iio_show_dev_label(struct device *dev,
>>> +				 struct device_attribute *attr,
>>> +				 char *buf)
>>> +{
>>> +	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>>> +	return snprintf(buf, PAGE_SIZE, "%s\n", indio_dev->label);
>>> +}
>>> +
>>> +static DEVICE_ATTR(label, S_IRUGO, iio_show_dev_label, NULL);
>>> +
>>>   static ssize_t iio_show_timestamp_clock(struct device *dev,
>>>   					struct device_attribute *attr,
>>>   					char *buf)
>>> @@ -1354,6 +1364,8 @@ static int iio_device_register_sysfs(struct iio_dev *indio_dev)
>>>   
>>>   	if (indio_dev->name)
>>>   		attrcount++;
>>> +	if (indio_dev->label)
>>> +		attrcount++;
>>>   	if (clk)
>>>   		attrcount++;
>>>   
>>> @@ -1376,6 +1388,8 @@ static int iio_device_register_sysfs(struct iio_dev *indio_dev)
>>>   		indio_dev->chan_attr_group.attrs[attrn++] = &p->dev_attr.attr;
>>>   	if (indio_dev->name)
>>>   		indio_dev->chan_attr_group.attrs[attrn++] = &dev_attr_name.attr;
>>> +	if (indio_dev->label)
>>> +		indio_dev->chan_attr_group.attrs[attrn++] = &dev_attr_label.attr;
>>>   	if (clk)
>>>   		indio_dev->chan_attr_group.attrs[attrn++] = clk;
>>>   
>>> @@ -1647,6 +1661,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->label = of_get_property(indio_dev->dev.of_node, "label",
>>> +					   NULL);
>>> +
>>>   	ret = iio_check_unique_scan_index(indio_dev);
>>>   	if (ret < 0)
>>>   		return ret;
>>> diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
>>> index 8e132cf819e4..a2527c7ab934 100644
>>> --- a/include/linux/iio/iio.h
>>> +++ b/include/linux/iio/iio.h
>>> @@ -553,6 +553,7 @@ struct iio_dev {
>>>   	struct list_head		channel_attr_list;
>>>   	struct attribute_group		chan_attr_group;
>>>   	const char			*name;
>>> +	const char			*label;
>>>   	const struct iio_info		*info;
>>>   	clockid_t			clock_id;
>>>   	struct mutex			info_exist_lock;
>>
> 
> 
> 


-- 
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] 9+ messages in thread

* Re: [PATCH v2 2/2] iio: core: Add optional symbolic label to device attributes
  2019-10-08  7:06       ` Phil Reid
@ 2019-10-08 12:40         ` Jonathan Cameron
  0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2019-10-08 12:40 UTC (permalink / raw)
  To: Phil Reid
  Cc: Jonathan Cameron, knaack.h, lars, pmeerw, robh+dt, mark.rutland,
	linux-iio, devicetree, michal.simek

On Tue, 8 Oct 2019 15:06:44 +0800
Phil Reid <preid@electromag.com.au> wrote:

> On 8/10/2019 04:32, Jonathan Cameron wrote:
> > On Sat, 5 Oct 2019 15:59:05 +0100
> > Jonathan Cameron <jic23@kernel.org> wrote:
> >   
> >> On Thu, 19 Sep 2019 22:36:08 +0800
> >> Phil Reid <preid@electromag.com.au> wrote:
> >>  
> >>> If a label is defined in the device tree for this device add that
> >>> to the device specific attributes. This is useful for userspace to
> >>> be able to identify an individual device when multiple identical
> >>> chips are present in the system.
> >>>
> >>> Tested-by: Michal Simek <michal.simek@xilinx.com>
> >>> Signed-off-by: Phil Reid <preid@electromag.com.au>  
> >>
> >> Glad to see this going in given I thought I'd already applied it
> >> and told someone they should be using it early today (oops ;)
> >>
> >> Applied to the togreg branch of iio.git and pushed out as testing
> >> for the autobuilders to play with it.  
> > 
> > 0-day picked up that there were no docs for this new field.
> > I've added some and re pushed out.  
> 
> Thanks.
> Just for my info what should I be doing to check for that.
> Don't remember getting any warnings for that.

./scripts/kernel-doc htmldocs

or similar

https://www.kernel.org/doc/Documentation/kernel-doc-nano-HOWTO.txt
includes how to test individual files.

Thanks,

Jonathan

> 
> 
> > 
> > Thanks,
> > 
> > Jonathan
> >   
> >>
> >> Thanks for doing this.
> >>
> >> Jonathan
> >>  
> >>> ---
> >>>   drivers/iio/industrialio-core.c | 17 +++++++++++++++++
> >>>   include/linux/iio/iio.h         |  1 +
> >>>   2 files changed, 18 insertions(+)
> >>>
> >>> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> >>> index 524a686077ca..f72c2dc5f703 100644
> >>> --- a/drivers/iio/industrialio-core.c
> >>> +++ b/drivers/iio/industrialio-core.c
> >>> @@ -1238,6 +1238,16 @@ static ssize_t iio_show_dev_name(struct device *dev,
> >>>   
> >>>   static DEVICE_ATTR(name, S_IRUGO, iio_show_dev_name, NULL);
> >>>   
> >>> +static ssize_t iio_show_dev_label(struct device *dev,
> >>> +				 struct device_attribute *attr,
> >>> +				 char *buf)
> >>> +{
> >>> +	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> >>> +	return snprintf(buf, PAGE_SIZE, "%s\n", indio_dev->label);
> >>> +}
> >>> +
> >>> +static DEVICE_ATTR(label, S_IRUGO, iio_show_dev_label, NULL);
> >>> +
> >>>   static ssize_t iio_show_timestamp_clock(struct device *dev,
> >>>   					struct device_attribute *attr,
> >>>   					char *buf)
> >>> @@ -1354,6 +1364,8 @@ static int iio_device_register_sysfs(struct iio_dev *indio_dev)
> >>>   
> >>>   	if (indio_dev->name)
> >>>   		attrcount++;
> >>> +	if (indio_dev->label)
> >>> +		attrcount++;
> >>>   	if (clk)
> >>>   		attrcount++;
> >>>   
> >>> @@ -1376,6 +1388,8 @@ static int iio_device_register_sysfs(struct iio_dev *indio_dev)
> >>>   		indio_dev->chan_attr_group.attrs[attrn++] = &p->dev_attr.attr;
> >>>   	if (indio_dev->name)
> >>>   		indio_dev->chan_attr_group.attrs[attrn++] = &dev_attr_name.attr;
> >>> +	if (indio_dev->label)
> >>> +		indio_dev->chan_attr_group.attrs[attrn++] = &dev_attr_label.attr;
> >>>   	if (clk)
> >>>   		indio_dev->chan_attr_group.attrs[attrn++] = clk;
> >>>   
> >>> @@ -1647,6 +1661,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->label = of_get_property(indio_dev->dev.of_node, "label",
> >>> +					   NULL);
> >>> +
> >>>   	ret = iio_check_unique_scan_index(indio_dev);
> >>>   	if (ret < 0)
> >>>   		return ret;
> >>> diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
> >>> index 8e132cf819e4..a2527c7ab934 100644
> >>> --- a/include/linux/iio/iio.h
> >>> +++ b/include/linux/iio/iio.h
> >>> @@ -553,6 +553,7 @@ struct iio_dev {
> >>>   	struct list_head		channel_attr_list;
> >>>   	struct attribute_group		chan_attr_group;
> >>>   	const char			*name;
> >>> +	const char			*label;
> >>>   	const struct iio_info		*info;
> >>>   	clockid_t			clock_id;
> >>>   	struct mutex			info_exist_lock;  
> >>  
> > 
> > 
> >   
> 
> 



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

end of thread, other threads:[~2019-10-08 12:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-19 14:36 [PATCH v2 0/2] iio: core: Add optional symbolic label to device attributes Phil Reid
2019-09-19 14:36 ` [PATCH v2 1/2] dt-binding: iio: Add optional label property Phil Reid
2019-09-27 14:44   ` Rob Herring
2019-10-05 14:58     ` Jonathan Cameron
2019-09-19 14:36 ` [PATCH v2 2/2] iio: core: Add optional symbolic label to device attributes Phil Reid
2019-10-05 14:59   ` Jonathan Cameron
2019-10-07 20:32     ` Jonathan Cameron
2019-10-08  7:06       ` Phil Reid
2019-10-08 12:40         ` Jonathan Cameron

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).