linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] hwmon: Make name attribute mandatory for new APIs
@ 2017-01-24 16:57 Guenter Roeck
  2017-01-25  9:04 ` Jean Delvare
  0 siblings, 1 reply; 3+ messages in thread
From: Guenter Roeck @ 2017-01-24 16:57 UTC (permalink / raw)
  To: Hardware Monitoring; +Cc: Jean Delvare, Guenter Roeck

It does not make sense to use one of the the new APIs when not
even providing a name attribute. Make it mandatory.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v2: One should use ERR_PTR where appropriate

 drivers/hwmon/hwmon.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index 0c5660ccdbf4..a408b10d9a86 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -651,6 +651,9 @@ hwmon_device_register_with_groups(struct device *dev, const char *name,
 				  void *drvdata,
 				  const struct attribute_group **groups)
 {
+	if (!name)
+		return ERR_PTR(-EINVAL);
+
 	return __hwmon_device_register(dev, name, drvdata, NULL, groups);
 }
 EXPORT_SYMBOL_GPL(hwmon_device_register_with_groups);
@@ -674,6 +677,9 @@ hwmon_device_register_with_info(struct device *dev, const char *name,
 				const struct hwmon_chip_info *chip,
 				const struct attribute_group **extra_groups)
 {
+	if (!name)
+		return ERR_PTR(-EINVAL);
+
 	if (chip && (!chip->ops || !chip->ops->is_visible || !chip->info))
 		return ERR_PTR(-EINVAL);
 
-- 
2.7.4


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

* Re: [PATCH v2] hwmon: Make name attribute mandatory for new APIs
  2017-01-24 16:57 [PATCH v2] hwmon: Make name attribute mandatory for new APIs Guenter Roeck
@ 2017-01-25  9:04 ` Jean Delvare
  2017-01-25  9:33   ` Guenter Roeck
  0 siblings, 1 reply; 3+ messages in thread
From: Jean Delvare @ 2017-01-25  9:04 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: Hardware Monitoring

Hi Guenter,

On Tue, 24 Jan 2017 08:57:14 -0800, Guenter Roeck wrote:
> It does not make sense to use one of the the new APIs when not
> even providing a name attribute. Make it mandatory.

Fully agreed, but...

> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> v2: One should use ERR_PTR where appropriate
> 
>  drivers/hwmon/hwmon.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
> index 0c5660ccdbf4..a408b10d9a86 100644
> --- a/drivers/hwmon/hwmon.c
> +++ b/drivers/hwmon/hwmon.c
> @@ -651,6 +651,9 @@ hwmon_device_register_with_groups(struct device *dev, const char *name,
>  				  void *drvdata,
>  				  const struct attribute_group **groups)
>  {
> +	if (!name)
> +		return ERR_PTR(-EINVAL);
> +
>  	return __hwmon_device_register(dev, name, drvdata, NULL, groups);
>  }
>  EXPORT_SYMBOL_GPL(hwmon_device_register_with_groups);
> @@ -674,6 +677,9 @@ hwmon_device_register_with_info(struct device *dev, const char *name,
>  				const struct hwmon_chip_info *chip,
>  				const struct attribute_group **extra_groups)
>  {
> +	if (!name)
> +		return ERR_PTR(-EINVAL);
> +
>  	if (chip && (!chip->ops || !chip->ops->is_visible || !chip->info))
>  		return ERR_PTR(-EINVAL);
>  

... this breaks hwmon_device_register(), which calls:

	return hwmon_device_register_with_groups(dev, NULL, NULL, NULL);
	                                              ^^^^
	                                              name

So you would have to change hwmon_device_register() to call
__hwmon_device_register() directly first.

Thanks,
-- 
Jean Delvare
SUSE L3 Support

-- 
Jean Delvare
SUSE L3 Support

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

* Re: [PATCH v2] hwmon: Make name attribute mandatory for new APIs
  2017-01-25  9:04 ` Jean Delvare
@ 2017-01-25  9:33   ` Guenter Roeck
  0 siblings, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2017-01-25  9:33 UTC (permalink / raw)
  To: Jean Delvare; +Cc: Hardware Monitoring

On 01/25/2017 01:04 AM, Jean Delvare wrote:
> Hi Guenter,
>
> On Tue, 24 Jan 2017 08:57:14 -0800, Guenter Roeck wrote:
>> It does not make sense to use one of the the new APIs when not
>> even providing a name attribute. Make it mandatory.
>
> Fully agreed, but...
>
>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>> ---
>> v2: One should use ERR_PTR where appropriate
>>
>>  drivers/hwmon/hwmon.c | 6 ++++++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
>> index 0c5660ccdbf4..a408b10d9a86 100644
>> --- a/drivers/hwmon/hwmon.c
>> +++ b/drivers/hwmon/hwmon.c
>> @@ -651,6 +651,9 @@ hwmon_device_register_with_groups(struct device *dev, const char *name,
>>  				  void *drvdata,
>>  				  const struct attribute_group **groups)
>>  {
>> +	if (!name)
>> +		return ERR_PTR(-EINVAL);
>> +
>>  	return __hwmon_device_register(dev, name, drvdata, NULL, groups);
>>  }
>>  EXPORT_SYMBOL_GPL(hwmon_device_register_with_groups);
>> @@ -674,6 +677,9 @@ hwmon_device_register_with_info(struct device *dev, const char *name,
>>  				const struct hwmon_chip_info *chip,
>>  				const struct attribute_group **extra_groups)
>>  {
>> +	if (!name)
>> +		return ERR_PTR(-EINVAL);
>> +
>>  	if (chip && (!chip->ops || !chip->ops->is_visible || !chip->info))
>>  		return ERR_PTR(-EINVAL);
>>
>
> ... this breaks hwmon_device_register(), which calls:
>
> 	return hwmon_device_register_with_groups(dev, NULL, NULL, NULL);
> 	                                              ^^^^
> 	                                              name
>
> So you would have to change hwmon_device_register() to call
> __hwmon_device_register() directly first.
>
Thanks!

Guenter


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

end of thread, other threads:[~2017-01-25  9:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-24 16:57 [PATCH v2] hwmon: Make name attribute mandatory for new APIs Guenter Roeck
2017-01-25  9:04 ` Jean Delvare
2017-01-25  9:33   ` 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).