All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging/iio: iio_hwmon: Use device tree node name for hwmon name attribute
@ 2013-03-20 15:52 Guenter Roeck
  2013-03-20 18:28 ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Guenter Roeck @ 2013-03-20 15:52 UTC (permalink / raw)
  To: linux-iio, Jonathan Cameron
  Cc: linux-kernel, devel, Greg Kroah-Hartman, Guenter Roeck

So far, all instances of iio_hwmon set their hwmon name attribute
to "iio_hwmon", which is not very descriptive. Set it to the device tree
node name if available, and only revert to iio_hwmon otherwise.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---

Jonathan, can we move this driver out of staging ?
I would like to see it in 3.10 if possible.

 drivers/staging/iio/iio_hwmon.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/iio/iio_hwmon.c b/drivers/staging/iio/iio_hwmon.c
index 93af756..aafa453 100644
--- a/drivers/staging/iio/iio_hwmon.c
+++ b/drivers/staging/iio/iio_hwmon.c
@@ -13,6 +13,7 @@
 #include <linux/err.h>
 #include <linux/platform_device.h>
 #include <linux/hwmon.h>
+#include <linux/of.h>
 #include <linux/hwmon-sysfs.h>
 #include <linux/iio/consumer.h>
 #include <linux/iio/types.h>
@@ -58,7 +59,12 @@ static ssize_t iio_hwmon_read_val(struct device *dev,
 static ssize_t show_name(struct device *dev, struct device_attribute *attr,
 			 char *buf)
 {
-	return sprintf(buf, "iio_hwmon\n");
+	const char *name = "iio_hwmon";
+
+	if (dev->of_node && dev->of_node->name)
+		name = dev->of_node->name;
+
+	return sprintf(buf, "%s\n", name);
 }
 
 static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
-- 
1.7.9.7


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

* Re: [PATCH] staging/iio: iio_hwmon: Use device tree node name for hwmon name attribute
  2013-03-20 15:52 [PATCH] staging/iio: iio_hwmon: Use device tree node name for hwmon name attribute Guenter Roeck
@ 2013-03-20 18:28 ` Jonathan Cameron
  2013-03-20 19:22   ` Guenter Roeck
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Cameron @ 2013-03-20 18:28 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: linux-iio, linux-kernel, devel, Greg Kroah-Hartman

On 03/20/2013 03:52 PM, Guenter Roeck wrote:
> So far, all instances of iio_hwmon set their hwmon name attribute
> to "iio_hwmon", which is not very descriptive. Set it to the device tree
> node name if available, and only revert to iio_hwmon otherwise.
> 
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> 
> Jonathan, can we move this driver out of staging ?
> I would like to see it in 3.10 if possible.

Certainly. Now you've cleaned it up nicely it's ready
to go as far as I am concerned.  I'll put together a patch
on top of this sometime in the next couple of days and
post to the relevant lists etc and if no one shouts I'll
send it in a pull request to Greg around next weekend....

Thanks for all your hard work!

Jonathan

(This patch is fine, I'll apply it to iio.git shortly.)

> 
>  drivers/staging/iio/iio_hwmon.c |    8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/iio/iio_hwmon.c b/drivers/staging/iio/iio_hwmon.c
> index 93af756..aafa453 100644
> --- a/drivers/staging/iio/iio_hwmon.c
> +++ b/drivers/staging/iio/iio_hwmon.c
> @@ -13,6 +13,7 @@
>  #include <linux/err.h>
>  #include <linux/platform_device.h>
>  #include <linux/hwmon.h>
> +#include <linux/of.h>
>  #include <linux/hwmon-sysfs.h>
>  #include <linux/iio/consumer.h>
>  #include <linux/iio/types.h>
> @@ -58,7 +59,12 @@ static ssize_t iio_hwmon_read_val(struct device *dev,
>  static ssize_t show_name(struct device *dev, struct device_attribute *attr,
>  			 char *buf)
>  {
> -	return sprintf(buf, "iio_hwmon\n");
> +	const char *name = "iio_hwmon";
> +
> +	if (dev->of_node && dev->of_node->name)
> +		name = dev->of_node->name;
> +
> +	return sprintf(buf, "%s\n", name);
>  }
>  
>  static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
> 

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

* Re: [PATCH] staging/iio: iio_hwmon: Use device tree node name for hwmon name attribute
  2013-03-20 18:28 ` Jonathan Cameron
@ 2013-03-20 19:22   ` Guenter Roeck
  0 siblings, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2013-03-20 19:22 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, linux-kernel, devel, Greg Kroah-Hartman

On Wed, Mar 20, 2013 at 06:28:21PM +0000, Jonathan Cameron wrote:
> On 03/20/2013 03:52 PM, Guenter Roeck wrote:
> > So far, all instances of iio_hwmon set their hwmon name attribute
> > to "iio_hwmon", which is not very descriptive. Set it to the device tree
> > node name if available, and only revert to iio_hwmon otherwise.
> > 
> > Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> > ---
> > 
> > Jonathan, can we move this driver out of staging ?
> > I would like to see it in 3.10 if possible.
> 
> Certainly. Now you've cleaned it up nicely it's ready
> to go as far as I am concerned.  I'll put together a patch
> on top of this sometime in the next couple of days and
> post to the relevant lists etc and if no one shouts I'll
> send it in a pull request to Greg around next weekend....
> 

Sounds good.

> Thanks for all your hard work!
> 
My pleasure.

Thanks,
Guenter

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

end of thread, other threads:[~2013-03-20 19:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-20 15:52 [PATCH] staging/iio: iio_hwmon: Use device tree node name for hwmon name attribute Guenter Roeck
2013-03-20 18:28 ` Jonathan Cameron
2013-03-20 19:22   ` Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.