Linux-Hwmon Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] hwmon: Convert to hwmon_device_register_with_info()
@ 2019-04-30 22:29 Alakesh Haloi
  2019-05-01  3:48 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Alakesh Haloi @ 2019-04-30 22:29 UTC (permalink / raw)
  To: linux-kernel, linux-hwmon, Guenter Roeck, Jean Delvare

Booting linux on bare metal instance type causes this warning:

hwmon_device_register() is deprecated. Please convert the driver
to use hwmon_device_register_with_info().

This patch fixes this call to deprecated function in acpi_power_meter.c

Signed-off-by: Alakesh Haloi <alakesh.haloi@gmail.com>
Cc: stable@vger.kernel.org
---
 drivers/hwmon/acpi_power_meter.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
index e98591fa2528..d1b8029d0147 100644
--- a/drivers/hwmon/acpi_power_meter.c
+++ b/drivers/hwmon/acpi_power_meter.c
@@ -898,7 +898,9 @@ static int acpi_power_meter_add(struct acpi_device *device)
 	if (res)
 		goto exit_free;
 
-	resource->hwmon_dev = hwmon_device_register(&device->dev);
+	resource->hwmon_dev = hwmon_device_register_with_info(&device->dev,
+				ACPI_POWER_METER_NAME,
+				&device->driver_data, NULL, NULL);
 	if (IS_ERR(resource->hwmon_dev)) {
 		res = PTR_ERR(resource->hwmon_dev);
 		goto exit_remove;
-- 
2.17.2


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

* Re: [PATCH] hwmon: Convert to hwmon_device_register_with_info()
  2019-04-30 22:29 [PATCH] hwmon: Convert to hwmon_device_register_with_info() Alakesh Haloi
@ 2019-05-01  3:48 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2019-05-01  3:48 UTC (permalink / raw)
  To: Alakesh Haloi, linux-kernel, linux-hwmon, Jean Delvare

On 4/30/19 3:29 PM, Alakesh Haloi wrote:
> Booting linux on bare metal instance type causes this warning:
> 
> hwmon_device_register() is deprecated. Please convert the driver
> to use hwmon_device_register_with_info().
> 
> This patch fixes this call to deprecated function in acpi_power_meter.c
> 

Changing the function name to call isn't really a conversion to the new API.

Looking into the driver, I have to say it is broken almost beyond repair.
The hwmon device is registered with no attributes present, attributes,
including the mandatory name attribute, are added and removed more or
less randomly. Various attributes (such as oem and serial number) simply
don't belong into a hwmon driver.

If you really want to convert the driver, it should be a real conversion.
It should register with a hwmon_chip_info data structure, augmented with
whatever non-standard sysfs attributes are there.
The hwmon device should only be registered together with its attributes.
If it is changed, the hwmon device should be removed and re-registered.
Anything else doesn't really make sense.

Faking the use of the new API _really_ doesn't add any value, and doesn't
make any sense. If you don't want to convert the driver for real, it is
better to leave it alone.

> Signed-off-by: Alakesh Haloi <alakesh.haloi@gmail.com>
> Cc: stable@vger.kernel.org

And, no, this is definitely not a patch to be applied to stable releases.

Guenter

> ---
>   drivers/hwmon/acpi_power_meter.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
> index e98591fa2528..d1b8029d0147 100644
> --- a/drivers/hwmon/acpi_power_meter.c
> +++ b/drivers/hwmon/acpi_power_meter.c
> @@ -898,7 +898,9 @@ static int acpi_power_meter_add(struct acpi_device *device)
>   	if (res)
>   		goto exit_free;
>   
> -	resource->hwmon_dev = hwmon_device_register(&device->dev);
> +	resource->hwmon_dev = hwmon_device_register_with_info(&device->dev,
> +				ACPI_POWER_METER_NAME,
> +				&device->driver_data, NULL, NULL);
>   	if (IS_ERR(resource->hwmon_dev)) {
>   		res = PTR_ERR(resource->hwmon_dev);
>   		goto exit_remove;
> 


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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-30 22:29 [PATCH] hwmon: Convert to hwmon_device_register_with_info() Alakesh Haloi
2019-05-01  3:48 ` Guenter Roeck

Linux-Hwmon Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-hwmon/0 linux-hwmon/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-hwmon linux-hwmon/ https://lore.kernel.org/linux-hwmon \
		linux-hwmon@vger.kernel.org linux-hwmon@archiver.kernel.org
	public-inbox-index linux-hwmon


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-hwmon


AGPL code for this site: git clone https://public-inbox.org/ public-inbox