devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/3] Allow iio_hwmon to accept hypen in node names
@ 2016-02-16  5:00 Sanchayan Maity
       [not found] ` <cover.1455597464.git.maitysanchayan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Sanchayan Maity @ 2016-02-16  5:00 UTC (permalink / raw)
  To: linux-0h96xk9xTtrk1uMJSBkQmQ, shawnguo-DgEjT+Ai2ygdnm+yROfE0A
  Cc: jdelvare-IBi9RG/b67k, stefan-XLVq0VzYD2Y,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	lm-sensors-GZX6beZjE8VD60Wz+7aTrA, Sanchayan Maity

Hello,

Initial versions of the patchset intended to introduce the use of
iio_hwmon for Vybrid SoC's. Currently the iio_hwmon driver has two
users and as per the binding documentation, the node names use the
underscore. Use of hypen in device tree node names is acceptable,
however currently the hwmon core code rejects it due to perhaps user
space not liking the hypen and getting confused.

As per Guenter Roeck's suggestion, the first patch looks for a hypen
and replaces it with a underscore in the probe call of iio_hwmon driver
before calling hwmon_device_register_with_groups for registration. Any
users of iio_hwmon driver can now use hypen in the node name.

As per Shawn's suggestion, the existing users have been changed to use
the hypen instead of the underscore and the iio-bindings document
updated. Third patch introduces the usage for Vybrid itself.

Patchset is based on top of shawn's for-next branch.

Feedbacks and comments most welcome. Thank you for feedbacks.

@Guenter
I hope I understood and implemented correctly what you had in mind.

Sample Output from Toradex Colibri VF50 module
root@colibri-vf:/sys/class/hwmon/hwmon0# ls
device       name         of_node      power        subsystem    temp1_input  temp2_input  uevent
root@colibri-vf:/sys/class/hwmon/hwmon0# cat name
iio_hwmon
root@colibri-vf:/sys/class/hwmon/hwmon0# uname -a
Linux colibri-vf 4.5.0-rc1-12868-g88b677c #48 SMP Tue Feb 16 10:05:28 IST 2016 armv7l GNU/Linux

v1:
https://lkml.org/lkml/2015/9/16/932

v2:
https://lkml.org/lkml/2016/2/12/168

Thanks & Regards,
Sanchayan Maity.

Sanchayan Maity (3):
  hwmon: iio_hwmon: Allow the driver to accept hypen in device tree node names
  ARM: dts: Change iio_hwmon nodes to use hypen in node names
  ARM: dts: vfxxx: Add iio_hwmon node for ADC temperature channel

 Documentation/devicetree/bindings/iio/iio-bindings.txt |  2 +-
 arch/arm/boot/dts/imx23.dtsi                           |  2 +-
 arch/arm/boot/dts/imx28.dtsi                           |  2 +-
 arch/arm/boot/dts/vfxxx.dtsi                           |  5 +++++
 drivers/hwmon/iio_hwmon.c                              | 11 ++++++++++-
 5 files changed, 18 insertions(+), 4 deletions(-)

-- 
2.7.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v3 1/3] hwmon: iio_hwmon: Allow the driver to accept hypen in device tree node names
       [not found] ` <cover.1455597464.git.maitysanchayan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2016-02-16  5:00   ` Sanchayan Maity
  0 siblings, 0 replies; 7+ messages in thread
From: Sanchayan Maity @ 2016-02-16  5:00 UTC (permalink / raw)
  To: linux-0h96xk9xTtrk1uMJSBkQmQ, shawnguo-DgEjT+Ai2ygdnm+yROfE0A
  Cc: jdelvare-IBi9RG/b67k, stefan-XLVq0VzYD2Y,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	lm-sensors-GZX6beZjE8VD60Wz+7aTrA, Sanchayan Maity

Currently the driver calls hwmon_device_register_with_groups which
does not accept hypen in node name and returns EINVAL. Use of hypen
in device tree node name results in probe failure., however use of
hypen in device tree node name is perfectly acceptable.

Change this by allocating a duplicate managed string, replacing
hypen with underscore and then calling hwmon_device_register_with_groups.
This allows the use of hypen in device tree node name while maintaining
backwards compatibility and preventing any possible regressions with
user space.

Signed-off-by: Sanchayan Maity <maitysanchayan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/hwmon/iio_hwmon.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
index 17ae2eb..b550ba5 100644
--- a/drivers/hwmon/iio_hwmon.c
+++ b/drivers/hwmon/iio_hwmon.c
@@ -67,6 +67,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
 	enum iio_chan_type type;
 	struct iio_channel *channels;
 	const char *name = "iio_hwmon";
+	char *sname;
 
 	if (dev->of_node && dev->of_node->name)
 		name = dev->of_node->name;
@@ -144,7 +145,15 @@ static int iio_hwmon_probe(struct platform_device *pdev)
 
 	st->attr_group.attrs = st->attrs;
 	st->groups[0] = &st->attr_group;
-	st->hwmon_dev = hwmon_device_register_with_groups(dev, name, st,
+
+	sname = devm_kstrdup(dev, name, GFP_KERNEL);
+	if (!sname) {
+		ret = -ENOMEM;
+		goto error_release_channels;
+	}
+
+	strreplace(sname, '-', '_');
+	st->hwmon_dev = hwmon_device_register_with_groups(dev, sname, st,
 							  st->groups);
 	if (IS_ERR(st->hwmon_dev)) {
 		ret = PTR_ERR(st->hwmon_dev);
-- 
2.7.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v3 2/3] ARM: dts: Change iio_hwmon nodes to use hypen in node names
  2016-02-16  5:00 [PATCH v3 0/3] Allow iio_hwmon to accept hypen in node names Sanchayan Maity
       [not found] ` <cover.1455597464.git.maitysanchayan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2016-02-16  5:00 ` Sanchayan Maity
  2016-02-22  2:53   ` Rob Herring
  2016-02-16  5:00 ` [PATCH v3 3/3] ARM: dts: vfxxx: Add iio_hwmon node for ADC temperature channel Sanchayan Maity
  2016-02-17  3:37 ` [PATCH v3 0/3] Allow iio_hwmon to accept hypen in node names Guenter Roeck
  3 siblings, 1 reply; 7+ messages in thread
From: Sanchayan Maity @ 2016-02-16  5:00 UTC (permalink / raw)
  To: linux, shawnguo
  Cc: jdelvare, stefan, linux-arm-kernel, devicetree, linux-kernel,
	lm-sensors, Sanchayan Maity

Change iio_hwmon nodes to use hypen in node names instead of
underscore.

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
---
 Documentation/devicetree/bindings/iio/iio-bindings.txt | 2 +-
 arch/arm/boot/dts/imx23.dtsi                           | 2 +-
 arch/arm/boot/dts/imx28.dtsi                           | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/iio/iio-bindings.txt b/Documentation/devicetree/bindings/iio/iio-bindings.txt
index 0b447d9..68d6f8c 100644
--- a/Documentation/devicetree/bindings/iio/iio-bindings.txt
+++ b/Documentation/devicetree/bindings/iio/iio-bindings.txt
@@ -82,7 +82,7 @@ vdd channel is connected to output 0 of the &ref device.
 
 	...
 
-	iio_hwmon {
+	iio-hwmon {
 		compatible = "iio-hwmon";
 		io-channels = <&adc 0>, <&adc 1>, <&adc 2>,
 			<&adc 3>, <&adc 4>, <&adc 5>,
diff --git a/arch/arm/boot/dts/imx23.dtsi b/arch/arm/boot/dts/imx23.dtsi
index 1c6c075..302d116 100644
--- a/arch/arm/boot/dts/imx23.dtsi
+++ b/arch/arm/boot/dts/imx23.dtsi
@@ -569,7 +569,7 @@
 		};
 	};
 
-	iio_hwmon {
+	iio-hwmon {
 		compatible = "iio-hwmon";
 		io-channels = <&lradc 8>;
 	};
diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi
index fae7b90..f637ec9 100644
--- a/arch/arm/boot/dts/imx28.dtsi
+++ b/arch/arm/boot/dts/imx28.dtsi
@@ -1256,7 +1256,7 @@
 		};
 	};
 
-	iio_hwmon {
+	iio-hwmon {
 		compatible = "iio-hwmon";
 		io-channels = <&lradc 8>;
 	};
-- 
2.7.1

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

* [PATCH v3 3/3] ARM: dts: vfxxx: Add iio_hwmon node for ADC temperature channel
  2016-02-16  5:00 [PATCH v3 0/3] Allow iio_hwmon to accept hypen in node names Sanchayan Maity
       [not found] ` <cover.1455597464.git.maitysanchayan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2016-02-16  5:00 ` [PATCH v3 2/3] ARM: dts: Change iio_hwmon nodes to use hypen in " Sanchayan Maity
@ 2016-02-16  5:00 ` Sanchayan Maity
  2016-02-16 17:50   ` Stefan Agner
  2016-02-17  3:37 ` [PATCH v3 0/3] Allow iio_hwmon to accept hypen in node names Guenter Roeck
  3 siblings, 1 reply; 7+ messages in thread
From: Sanchayan Maity @ 2016-02-16  5:00 UTC (permalink / raw)
  To: linux, shawnguo
  Cc: jdelvare, stefan, linux-arm-kernel, devicetree, linux-kernel,
	lm-sensors, Sanchayan Maity

Add iio-hwmon node to expose the temperature channel on Vybrid as
hardware monitor device using the iio_hwmon driver.

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
---
 arch/arm/boot/dts/vfxxx.dtsi | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/boot/dts/vfxxx.dtsi b/arch/arm/boot/dts/vfxxx.dtsi
index a5f07e3..24ac5b1 100644
--- a/arch/arm/boot/dts/vfxxx.dtsi
+++ b/arch/arm/boot/dts/vfxxx.dtsi
@@ -673,5 +673,10 @@
 				status = "disabled";
 			};
 		};
+
+		iio-hwmon {
+			compatible = "iio-hwmon";
+			io-channels = <&adc0 16>, <&adc1 16>;
+		};
 	};
 };
-- 
2.7.1

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

* Re: [PATCH v3 3/3] ARM: dts: vfxxx: Add iio_hwmon node for ADC temperature channel
  2016-02-16  5:00 ` [PATCH v3 3/3] ARM: dts: vfxxx: Add iio_hwmon node for ADC temperature channel Sanchayan Maity
@ 2016-02-16 17:50   ` Stefan Agner
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Agner @ 2016-02-16 17:50 UTC (permalink / raw)
  To: Sanchayan Maity
  Cc: linux, shawnguo, jdelvare, linux-arm-kernel, devicetree,
	linux-kernel, lm-sensors

On 2016-02-15 21:00, Sanchayan Maity wrote:
> Add iio-hwmon node to expose the temperature channel on Vybrid as
> hardware monitor device using the iio_hwmon driver.
> 
> Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>

Acked-by: Stefan Agner <stefan@agner.ch>

> ---
>  arch/arm/boot/dts/vfxxx.dtsi | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/vfxxx.dtsi b/arch/arm/boot/dts/vfxxx.dtsi
> index a5f07e3..24ac5b1 100644
> --- a/arch/arm/boot/dts/vfxxx.dtsi
> +++ b/arch/arm/boot/dts/vfxxx.dtsi
> @@ -673,5 +673,10 @@
>  				status = "disabled";
>  			};
>  		};
> +
> +		iio-hwmon {
> +			compatible = "iio-hwmon";
> +			io-channels = <&adc0 16>, <&adc1 16>;
> +		};
>  	};
>  };

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

* Re: [PATCH v3 0/3] Allow iio_hwmon to accept hypen in node names
  2016-02-16  5:00 [PATCH v3 0/3] Allow iio_hwmon to accept hypen in node names Sanchayan Maity
                   ` (2 preceding siblings ...)
  2016-02-16  5:00 ` [PATCH v3 3/3] ARM: dts: vfxxx: Add iio_hwmon node for ADC temperature channel Sanchayan Maity
@ 2016-02-17  3:37 ` Guenter Roeck
  3 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2016-02-17  3:37 UTC (permalink / raw)
  To: Sanchayan Maity, shawnguo
  Cc: jdelvare, stefan, linux-arm-kernel, devicetree, linux-kernel,
	lm-sensors

On 02/15/2016 09:00 PM, Sanchayan Maity wrote:
> Hello,
>
> Initial versions of the patchset intended to introduce the use of
> iio_hwmon for Vybrid SoC's. Currently the iio_hwmon driver has two
> users and as per the binding documentation, the node names use the
> underscore. Use of hypen in device tree node names is acceptable,
> however currently the hwmon core code rejects it due to perhaps user
> space not liking the hypen and getting confused.
>
> As per Guenter Roeck's suggestion, the first patch looks for a hypen
> and replaces it with a underscore in the probe call of iio_hwmon driver
> before calling hwmon_device_register_with_groups for registration. Any
> users of iio_hwmon driver can now use hypen in the node name.
>
> As per Shawn's suggestion, the existing users have been changed to use
> the hypen instead of the underscore and the iio-bindings document
> updated. Third patch introduces the usage for Vybrid itself.
>
> Patchset is based on top of shawn's for-next branch.
>
> Feedbacks and comments most welcome. Thank you for feedbacks.
>
> @Guenter
> I hope I understood and implemented correctly what you had in mind.
>
Yes.

Series applied to hwmon-next (if the dts changes also end up in an arm branch,
no harm done).

Thanks,
Guenter

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

* Re: [PATCH v3 2/3] ARM: dts: Change iio_hwmon nodes to use hypen in node names
  2016-02-16  5:00 ` [PATCH v3 2/3] ARM: dts: Change iio_hwmon nodes to use hypen in " Sanchayan Maity
@ 2016-02-22  2:53   ` Rob Herring
  0 siblings, 0 replies; 7+ messages in thread
From: Rob Herring @ 2016-02-22  2:53 UTC (permalink / raw)
  To: Sanchayan Maity
  Cc: linux, shawnguo, jdelvare, stefan, linux-arm-kernel, devicetree,
	linux-kernel, lm-sensors

On Tue, Feb 16, 2016 at 10:30:54AM +0530, Sanchayan Maity wrote:
> Change iio_hwmon nodes to use hypen in node names instead of
> underscore.
> 
> Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
> ---
>  Documentation/devicetree/bindings/iio/iio-bindings.txt | 2 +-
>  arch/arm/boot/dts/imx23.dtsi                           | 2 +-
>  arch/arm/boot/dts/imx28.dtsi                           | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)

No real objection here though I don't think this is really necessary. 
While we prefer '-' to '_' it's not really strong enough to change. It 
bothers me more that the node name leaks to userspace.

Rob

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

end of thread, other threads:[~2016-02-22  2:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-16  5:00 [PATCH v3 0/3] Allow iio_hwmon to accept hypen in node names Sanchayan Maity
     [not found] ` <cover.1455597464.git.maitysanchayan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-02-16  5:00   ` [PATCH v3 1/3] hwmon: iio_hwmon: Allow the driver to accept hypen in device tree " Sanchayan Maity
2016-02-16  5:00 ` [PATCH v3 2/3] ARM: dts: Change iio_hwmon nodes to use hypen in " Sanchayan Maity
2016-02-22  2:53   ` Rob Herring
2016-02-16  5:00 ` [PATCH v3 3/3] ARM: dts: vfxxx: Add iio_hwmon node for ADC temperature channel Sanchayan Maity
2016-02-16 17:50   ` Stefan Agner
2016-02-17  3:37 ` [PATCH v3 0/3] Allow iio_hwmon to accept hypen in node names Guenter Roeck

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