linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwmon: occ: Fix power sensor indexing
@ 2019-03-19 21:01 Eddie James
  2019-03-20  6:15 ` Joel Stanley
  2019-03-20 13:29 ` Guenter Roeck
  0 siblings, 2 replies; 3+ messages in thread
From: Eddie James @ 2019-03-19 21:01 UTC (permalink / raw)
  To: linux-hwmon; +Cc: linux, jdelvare, linux-kernel, Eddie James

In the case of power sensor version 0xA0, the sensor indexing overlapped
with the "caps" power sensors, resulting in probe failure and kernel
warnings. Fix this by specifying the next index for each power sensor
version.

Fixes: 54076cb ("hwmon (occ): Add sensor attributes and register ...")
Signed-off-by: Eddie James <eajames@linux.ibm.com>
---
 drivers/hwmon/occ/common.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/occ/common.c b/drivers/hwmon/occ/common.c
index 391118c..c888f4a 100644
--- a/drivers/hwmon/occ/common.c
+++ b/drivers/hwmon/occ/common.c
@@ -889,6 +889,8 @@ static int occ_setup_sensor_attrs(struct occ *occ)
 				s++;
 			}
 		}
+
+		s = (sensors->power.num_sensors * 4) + 1;
 	} else {
 		for (i = 0; i < sensors->power.num_sensors; ++i) {
 			s = i + 1;
@@ -917,11 +919,11 @@ static int occ_setup_sensor_attrs(struct occ *occ)
 						     show_power, NULL, 3, i);
 			attr++;
 		}
-	}
 
-	if (sensors->caps.num_sensors >= 1) {
 		s = sensors->power.num_sensors + 1;
+	}
 
+	if (sensors->caps.num_sensors >= 1) {
 		snprintf(attr->name, sizeof(attr->name), "power%d_label", s);
 		attr->sensor = OCC_INIT_ATTR(attr->name, 0444, show_caps, NULL,
 					     0, 0);
-- 
1.8.3.1


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

* Re: [PATCH] hwmon: occ: Fix power sensor indexing
  2019-03-19 21:01 [PATCH] hwmon: occ: Fix power sensor indexing Eddie James
@ 2019-03-20  6:15 ` Joel Stanley
  2019-03-20 13:29 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Joel Stanley @ 2019-03-20  6:15 UTC (permalink / raw)
  To: Eddie James
  Cc: linux-hwmon, Guenter Roeck, Jean Delvare, Linux Kernel Mailing List

On Tue, 19 Mar 2019 at 21:04, Eddie James <eajames@linux.ibm.com> wrote:
>
> In the case of power sensor version 0xA0, the sensor indexing overlapped
> with the "caps" power sensors, resulting in probe failure and kernel
> warnings. Fix this by specifying the next index for each power sensor
> version.
>
> Fixes: 54076cb ("hwmon (occ): Add sensor attributes and register ...")
> Signed-off-by: Eddie James <eajames@linux.ibm.com>

You forgot to cc stable:

cc: stable@vger.kernel.org # 4.21

Tested-by: Joel Stanley <joel@jms.id.au>

Cheers,

Joel

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

* Re: [PATCH] hwmon: occ: Fix power sensor indexing
  2019-03-19 21:01 [PATCH] hwmon: occ: Fix power sensor indexing Eddie James
  2019-03-20  6:15 ` Joel Stanley
@ 2019-03-20 13:29 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2019-03-20 13:29 UTC (permalink / raw)
  To: Eddie James; +Cc: linux-hwmon, jdelvare, linux-kernel

On Tue, Mar 19, 2019 at 04:01:58PM -0500, Eddie James wrote:
> In the case of power sensor version 0xA0, the sensor indexing overlapped
> with the "caps" power sensors, resulting in probe failure and kernel
> warnings. Fix this by specifying the next index for each power sensor
> version.
> 
> Fixes: 54076cb ("hwmon (occ): Add sensor attributes and register ...")
> Signed-off-by: Eddie James <eajames@linux.ibm.com>
> Tested-by: Joel Stanley <joel@jms.id.au>

Applied.

Side note: There is no v4.21.

Thanks,
Guenter

> ---
>  drivers/hwmon/occ/common.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwmon/occ/common.c b/drivers/hwmon/occ/common.c
> index 391118c..c888f4a 100644
> --- a/drivers/hwmon/occ/common.c
> +++ b/drivers/hwmon/occ/common.c
> @@ -889,6 +889,8 @@ static int occ_setup_sensor_attrs(struct occ *occ)
>  				s++;
>  			}
>  		}
> +
> +		s = (sensors->power.num_sensors * 4) + 1;
>  	} else {
>  		for (i = 0; i < sensors->power.num_sensors; ++i) {
>  			s = i + 1;
> @@ -917,11 +919,11 @@ static int occ_setup_sensor_attrs(struct occ *occ)
>  						     show_power, NULL, 3, i);
>  			attr++;
>  		}
> -	}
>  
> -	if (sensors->caps.num_sensors >= 1) {
>  		s = sensors->power.num_sensors + 1;
> +	}
>  
> +	if (sensors->caps.num_sensors >= 1) {
>  		snprintf(attr->name, sizeof(attr->name), "power%d_label", s);
>  		attr->sensor = OCC_INIT_ATTR(attr->name, 0444, show_caps, NULL,
>  					     0, 0);

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

end of thread, other threads:[~2019-03-20 13:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-19 21:01 [PATCH] hwmon: occ: Fix power sensor indexing Eddie James
2019-03-20  6:15 ` Joel Stanley
2019-03-20 13:29 ` 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).