From: Jonathan Cameron <jic23@kernel.org>
To: Phil Reid <preid@electromag.com.au>
Cc: knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net,
robh+dt@kernel.org, mark.rutland@arm.com,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
michal.simek@xilinx.com
Subject: Re: [PATCH 2/2] iio: core: Add optional symbolic label to device attributes
Date: Sun, 8 Sep 2019 13:17:08 +0100 [thread overview]
Message-ID: <20190908131708.79bfbc60@archlinux> (raw)
In-Reply-To: <1566876924-63608-3-git-send-email-preid@electromag.com.au>
On Tue, 27 Aug 2019 11:35:24 +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.
>
> Signed-off-by: Phil Reid <preid@electromag.com.au>
Looks good to me. I like this as it finally gets us around some
perhaps slightly dubious decisions I made about the name attribute
a long time ago and the bunch of uses that don't actually conform
even to what I had in mind back then.
I'll pick it up for the 5.5 cycle once you've respun to give
more example friendly names in patch 1 and Rob is happy with it.
Thanks,
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 8303639963d7..2d7fb7629095 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -1300,6 +1300,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)
> @@ -1416,6 +1426,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++;
>
> @@ -1438,6 +1450,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;
>
> @@ -1709,6 +1723,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 a74cb177dc6f..3f89db50d3f6 100644
> --- a/include/linux/iio/iio.h
> +++ b/include/linux/iio/iio.h
> @@ -556,6 +556,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;
next prev parent reply other threads:[~2019-09-08 12:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-27 3:35 [PATCH 0/2] iio: core: Add optional symbolic label to device attributes Phil Reid
2019-08-27 3:35 ` [PATCH 1/2] dt-binding: iio: Add optional label property Phil Reid
2019-08-27 6:10 ` Michal Simek
2019-08-28 6:09 ` Michal Simek
2019-08-29 23:02 ` Rob Herring
2019-08-30 1:01 ` Phil Reid
2019-08-30 12:34 ` Rob Herring
2019-08-31 10:19 ` Phil Reid
2019-09-08 12:14 ` Jonathan Cameron
2019-08-27 3:35 ` [PATCH 2/2] iio: core: Add optional symbolic label to device attributes Phil Reid
2019-09-08 12:17 ` Jonathan Cameron [this message]
2019-09-09 7:45 ` Michal Simek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190908131708.79bfbc60@archlinux \
--to=jic23@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=michal.simek@xilinx.com \
--cc=pmeerw@pmeerw.net \
--cc=preid@electromag.com.au \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).