mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] hwmon: (acpi_power_meter) Fix a check for the return value of read_domain_devices().
@ 2025-01-15  7:35 Kazuhiro Abe
  2025-01-15 14:20 ` Guenter Roeck
  0 siblings, 1 reply; 3+ messages in thread
From: Kazuhiro Abe @ 2025-01-15  7:35 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck, linux-hwmon, linux-kernel,
	Huisong Li, Kazuhiro Abe

After commit fabb1f813ec0 ("hwmon: (acpi_power_meter) Fix fail to load
module on platform without _PMD method"),
the acpi_power_meter driver fails to load if the platform has _PMD method.

To address this, add a check for successful read_domain_devices().
Tested on Nvidia Grace machine.

Fixes: fabb1f813ec0 ("hwmon: (acpi_power_meter) Fix fail to load module on platform without _PMD method")
Signed-off-by: Kazuhiro Abe <fj1078ii@aa.jp.fujitsu.com>
---
 drivers/hwmon/acpi_power_meter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
index 2f1c9d97ad21..dbf2c606fe15 100644
--- a/drivers/hwmon/acpi_power_meter.c
+++ b/drivers/hwmon/acpi_power_meter.c
@@ -682,7 +682,7 @@ static int setup_attrs(struct acpi_power_meter_resource *resource)
 
 	/* _PMD method is optional. */
 	res = read_domain_devices(resource);
-	if (res != -ENODEV)
+	if ((res != 0) && (res != -ENODEV))
 		return res;
 
 	if (resource->caps.flags & POWER_METER_CAN_MEASURE) {
-- 
2.34.1


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

* Re: [PATCH] hwmon: (acpi_power_meter) Fix a check for the return value of read_domain_devices().
  2025-01-15  7:35 [PATCH] hwmon: (acpi_power_meter) Fix a check for the return value of read_domain_devices() Kazuhiro Abe
@ 2025-01-15 14:20 ` Guenter Roeck
  2025-01-16  2:18   ` Kazuhiro Abe (Fujitsu)
  0 siblings, 1 reply; 3+ messages in thread
From: Guenter Roeck @ 2025-01-15 14:20 UTC (permalink / raw)
  To: Kazuhiro Abe; +Cc: Jean Delvare, linux-hwmon, linux-kernel, Huisong Li

On Wed, Jan 15, 2025 at 07:35:32AM +0000, Kazuhiro Abe wrote:
> After commit fabb1f813ec0 ("hwmon: (acpi_power_meter) Fix fail to load
> module on platform without _PMD method"),
> the acpi_power_meter driver fails to load if the platform has _PMD method.
> 
> To address this, add a check for successful read_domain_devices().
> Tested on Nvidia Grace machine.
> 
> Fixes: fabb1f813ec0 ("hwmon: (acpi_power_meter) Fix fail to load module on platform without _PMD method")
> Signed-off-by: Kazuhiro Abe <fj1078ii@aa.jp.fujitsu.com>

Checkpatch says:

CHECK: Unnecessary parentheses around 'res != 0'
#108: FILE: drivers/hwmon/acpi_power_meter.c:685:
+	if ((res != 0) && (res != -ENODEV))

No need to resend, I'll fix that up while applying, but please keep it in mind
for the future.

Guenter

> ---
>  drivers/hwmon/acpi_power_meter.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
> index 2f1c9d97ad21..dbf2c606fe15 100644
> --- a/drivers/hwmon/acpi_power_meter.c
> +++ b/drivers/hwmon/acpi_power_meter.c
> @@ -682,7 +682,7 @@ static int setup_attrs(struct acpi_power_meter_resource *resource)
>  
>  	/* _PMD method is optional. */
>  	res = read_domain_devices(resource);
> -	if (res != -ENODEV)
> +	if ((res != 0) && (res != -ENODEV))
>  		return res;
>  
>  	if (resource->caps.flags & POWER_METER_CAN_MEASURE) {

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

* RE: [PATCH] hwmon: (acpi_power_meter) Fix a check for the return value of read_domain_devices().
  2025-01-15 14:20 ` Guenter Roeck
@ 2025-01-16  2:18   ` Kazuhiro Abe (Fujitsu)
  0 siblings, 0 replies; 3+ messages in thread
From: Kazuhiro Abe (Fujitsu) @ 2025-01-16  2:18 UTC (permalink / raw)
  To: 'Guenter Roeck'
  Cc: Jean Delvare, linux-hwmon, linux-kernel, Huisong Li

Hi, Guenter

Thanks for the comment.

> On Wed, Jan 15, 2025 at 07:35:32AM +0000, Kazuhiro Abe wrote:
> > After commit fabb1f813ec0 ("hwmon: (acpi_power_meter) Fix fail to load
> > module on platform without _PMD method"), the acpi_power_meter driver
> > fails to load if the platform has _PMD method.
> >
> > To address this, add a check for successful read_domain_devices().
> > Tested on Nvidia Grace machine.
> >
> > Fixes: fabb1f813ec0 ("hwmon: (acpi_power_meter) Fix fail to load
> > module on platform without _PMD method")
> > Signed-off-by: Kazuhiro Abe <fj1078ii@aa.jp.fujitsu.com>
> 
> Checkpatch says:
> 
> CHECK: Unnecessary parentheses around 'res != 0'
> #108: FILE: drivers/hwmon/acpi_power_meter.c:685:
> +	if ((res != 0) && (res != -ENODEV))
> 
> No need to resend, I'll fix that up while applying, but please keep it in mind for the
> future.

I will keep it in mind for the future, Thanks for review.

Best Regards,
Kazuhiro Abe

> 
> Guenter
>
> > ---
> >  drivers/hwmon/acpi_power_meter.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/hwmon/acpi_power_meter.c
> > b/drivers/hwmon/acpi_power_meter.c
> > index 2f1c9d97ad21..dbf2c606fe15 100644
> > --- a/drivers/hwmon/acpi_power_meter.c
> > +++ b/drivers/hwmon/acpi_power_meter.c
> > @@ -682,7 +682,7 @@ static int setup_attrs(struct
> > acpi_power_meter_resource *resource)
> >
> >  	/* _PMD method is optional. */
> >  	res = read_domain_devices(resource);
> > -	if (res != -ENODEV)
> > +	if ((res != 0) && (res != -ENODEV))
> >  		return res;
> >
> >  	if (resource->caps.flags & POWER_METER_CAN_MEASURE) {

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

end of thread, other threads:[~2025-01-16  2:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-15  7:35 [PATCH] hwmon: (acpi_power_meter) Fix a check for the return value of read_domain_devices() Kazuhiro Abe
2025-01-15 14:20 ` Guenter Roeck
2025-01-16  2:18   ` Kazuhiro Abe (Fujitsu)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®