* [lm-sensors] [PATCH] sensors: Fix power interval output
@ 2012-01-13 16:32 Guenter Roeck
2012-01-13 18:14 ` Guenter Roeck
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Guenter Roeck @ 2012-01-13 16:32 UTC (permalink / raw)
To: lm-sensors
Power interval is measured in seconds, not Watt.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
Untested. Maybe a bit kludgy but should work.
prog/sensors/chips.c | 22 ++++++++++++++++++----
1 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/prog/sensors/chips.c b/prog/sensors/chips.c
index 677a617..fde33f6 100644
--- a/prog/sensors/chips.c
+++ b/prog/sensors/chips.c
@@ -574,11 +574,25 @@ static void print_chip_power(const sensors_chip_name *name,
} else
printf(" N/A ");
- for (i = 0; i < sensor_count; i++)
- scale_value(&sensors[i].value, &sensors[i].unit);
-
+ for (i = 0; i < sensor_count; i++) {
+ /*
+ * Unit is W and needs to be scaled for all attributes except
+ * interval, which does not need to be scaled and is reported in
+ * seconds.
+ */
+ if (strcmp(sensors[i].name, "interval")) {
+ char *tmpstr;
+
+ tmpstr = alloca(4);
+ scale_value(&sensors[i].value, &unit);
+ snprintf(tmpstr, 4, "%sW", unit);
+ sensors[i].unit = tmpstr;
+ } else {
+ sensors[i].unit = "s";
+ }
+ }
print_limits(sensors, sensor_count, alarms, alarm_count,
- label_size, "%s = %6.2f %sW");
+ label_size, "%s = %6.2f %s");
printf("\n");
}
--
1.7.5.4
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [lm-sensors] [PATCH] sensors: Fix power interval output
2012-01-13 16:32 [lm-sensors] [PATCH] sensors: Fix power interval output Guenter Roeck
@ 2012-01-13 18:14 ` Guenter Roeck
2012-03-04 13:11 ` Jean Delvare
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2012-01-13 18:14 UTC (permalink / raw)
To: lm-sensors
On Fri, 2012-01-13 at 11:32 -0500, Guenter Roeck wrote:
> Power interval is measured in seconds, not Watt.
>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> Untested. Maybe a bit kludgy but should work.
>
> prog/sensors/chips.c | 22 ++++++++++++++++++----
> 1 files changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/prog/sensors/chips.c b/prog/sensors/chips.c
> index 677a617..fde33f6 100644
> --- a/prog/sensors/chips.c
> +++ b/prog/sensors/chips.c
> @@ -574,11 +574,25 @@ static void print_chip_power(const sensors_chip_name *name,
> } else
> printf(" N/A ");
>
> - for (i = 0; i < sensor_count; i++)
> - scale_value(&sensors[i].value, &sensors[i].unit);
> -
> + for (i = 0; i < sensor_count; i++) {
> + /*
> + * Unit is W and needs to be scaled for all attributes except
> + * interval, which does not need to be scaled and is reported in
> + * seconds.
> + */
> + if (strcmp(sensors[i].name, "interval")) {
> + char *tmpstr;
> +
> + tmpstr = alloca(4);
> + scale_value(&sensors[i].value, &unit);
> + snprintf(tmpstr, 4, "%sW", unit);
> + sensors[i].unit = tmpstr;
> + } else {
> + sensors[i].unit = "s";
> + }
> + }
> print_limits(sensors, sensor_count, alarms, alarm_count,
> - label_size, "%s = %6.2f %sW");
> + label_size, "%s = %6.2f %s");
>
> printf("\n");
> }
Side note: Another more generic option would have been to add a "unit"
field to struct sensor_subfeature_list, but that seemed to be (much)
more expensive.
Guenter
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [lm-sensors] [PATCH] sensors: Fix power interval output
2012-01-13 16:32 [lm-sensors] [PATCH] sensors: Fix power interval output Guenter Roeck
2012-01-13 18:14 ` Guenter Roeck
@ 2012-03-04 13:11 ` Jean Delvare
2012-03-04 15:16 ` Guenter Roeck
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Jean Delvare @ 2012-03-04 13:11 UTC (permalink / raw)
To: lm-sensors
Hi Guenter,
Sorry for the very late reply. D'oh, I can't believe it has been 7
weeks already :(
On Fri, 13 Jan 2012 08:32:22 -0800, Guenter Roeck wrote:
> Power interval is measured in seconds, not Watt.
>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> Untested. Maybe a bit kludgy but should work.
I recall testing it with a fake driver and it was working. But I don't
like it much. It's sad to have defined data structures to abstract
things as much as possible and then end up with a hack like this one. I
would prefer a more generic solution if we can come up with one. OTOH
delaying lm-sensors 3.3.2 further just for this makes little sense. So,
if you don't hear from me in the next 2 days, please just commit this
fix and I'll release 3.3.2.
> prog/sensors/chips.c | 22 ++++++++++++++++++----
> 1 files changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/prog/sensors/chips.c b/prog/sensors/chips.c
> index 677a617..fde33f6 100644
> --- a/prog/sensors/chips.c
> +++ b/prog/sensors/chips.c
> @@ -574,11 +574,25 @@ static void print_chip_power(const sensors_chip_name *name,
> } else
> printf(" N/A ");
>
> - for (i = 0; i < sensor_count; i++)
> - scale_value(&sensors[i].value, &sensors[i].unit);
> -
> + for (i = 0; i < sensor_count; i++) {
> + /*
> + * Unit is W and needs to be scaled for all attributes except
> + * interval, which does not need to be scaled and is reported in
> + * seconds.
> + */
> + if (strcmp(sensors[i].name, "interval")) {
> + char *tmpstr;
> +
> + tmpstr = alloca(4);
I didn't even know about this function. Interesting one. I'm not sure
how portable it is, but that shouldn't be an issue for lm-sensors.
> + scale_value(&sensors[i].value, &unit);
> + snprintf(tmpstr, 4, "%sW", unit);
> + sensors[i].unit = tmpstr;
> + } else {
> + sensors[i].unit = "s";
> + }
> + }
> print_limits(sensors, sensor_count, alarms, alarm_count,
> - label_size, "%s = %6.2f %sW");
> + label_size, "%s = %6.2f %s");
>
> printf("\n");
> }
--
Jean Delvare
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [lm-sensors] [PATCH] sensors: Fix power interval output
2012-01-13 16:32 [lm-sensors] [PATCH] sensors: Fix power interval output Guenter Roeck
2012-01-13 18:14 ` Guenter Roeck
2012-03-04 13:11 ` Jean Delvare
@ 2012-03-04 15:16 ` Guenter Roeck
2012-03-07 16:18 ` Guenter Roeck
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2012-03-04 15:16 UTC (permalink / raw)
To: lm-sensors
On Sun, Mar 04, 2012 at 08:11:21AM -0500, Jean Delvare wrote:
> Hi Guenter,
>
> Sorry for the very late reply. D'oh, I can't believe it has been 7
> weeks already :(
>
Time goes by ...
> On Fri, 13 Jan 2012 08:32:22 -0800, Guenter Roeck wrote:
> > Power interval is measured in seconds, not Watt.
> >
> > Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> > ---
> > Untested. Maybe a bit kludgy but should work.
>
> I recall testing it with a fake driver and it was working. But I don't
> like it much. It's sad to have defined data structures to abstract
> things as much as possible and then end up with a hack like this one. I
> would prefer a more generic solution if we can come up with one. OTOH
> delaying lm-sensors 3.3.2 further just for this makes little sense. So,
> if you don't hear from me in the next 2 days, please just commit this
> fix and I'll release 3.3.2.
>
Ok. I wasn't too happy with it either, but I didn't find a better solution.
> > prog/sensors/chips.c | 22 ++++++++++++++++++----
> > 1 files changed, 18 insertions(+), 4 deletions(-)
> >
> > diff --git a/prog/sensors/chips.c b/prog/sensors/chips.c
> > index 677a617..fde33f6 100644
> > --- a/prog/sensors/chips.c
> > +++ b/prog/sensors/chips.c
> > @@ -574,11 +574,25 @@ static void print_chip_power(const sensors_chip_name *name,
> > } else
> > printf(" N/A ");
> >
> > - for (i = 0; i < sensor_count; i++)
> > - scale_value(&sensors[i].value, &sensors[i].unit);
> > -
> > + for (i = 0; i < sensor_count; i++) {
> > + /*
> > + * Unit is W and needs to be scaled for all attributes except
> > + * interval, which does not need to be scaled and is reported in
> > + * seconds.
> > + */
> > + if (strcmp(sensors[i].name, "interval")) {
> > + char *tmpstr;
> > +
> > + tmpstr = alloca(4);
>
> I didn't even know about this function. Interesting one. I'm not sure
> how portable it is, but that shouldn't be an issue for lm-sensors.
>
Been there forever. I didn't know that its usage is discouraged nowadays.
Looks like it was in C90, but was removed from C99. It is perfect for situations
like this, but one has to be careful (which I guess is why its use is discouraged).
Guenter
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [lm-sensors] [PATCH] sensors: Fix power interval output
2012-01-13 16:32 [lm-sensors] [PATCH] sensors: Fix power interval output Guenter Roeck
` (2 preceding siblings ...)
2012-03-04 15:16 ` Guenter Roeck
@ 2012-03-07 16:18 ` Guenter Roeck
2012-03-08 7:50 ` Jean Delvare
2012-03-08 7:53 ` Guenter Roeck
5 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2012-03-07 16:18 UTC (permalink / raw)
To: lm-sensors
Hi Jean,
On Sun, 2012-03-04 at 08:11 -0500, Jean Delvare wrote:
> Hi Guenter,
>
> Sorry for the very late reply. D'oh, I can't believe it has been 7
> weeks already :(
>
> On Fri, 13 Jan 2012 08:32:22 -0800, Guenter Roeck wrote:
> > Power interval is measured in seconds, not Watt.
> >
> > Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> > ---
> > Untested. Maybe a bit kludgy but should work.
>
> I recall testing it with a fake driver and it was working. But I don't
> like it much. It's sad to have defined data structures to abstract
> things as much as possible and then end up with a hack like this one. I
> would prefer a more generic solution if we can come up with one. OTOH
> delaying lm-sensors 3.3.2 further just for this makes little sense. So,
> if you don't hear from me in the next 2 days, please just commit this
> fix and I'll release 3.3.2.
>
More than two days, and I didn't hear anything, so I went ahead and
committed it.
Guenter
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [lm-sensors] [PATCH] sensors: Fix power interval output
2012-01-13 16:32 [lm-sensors] [PATCH] sensors: Fix power interval output Guenter Roeck
` (3 preceding siblings ...)
2012-03-07 16:18 ` Guenter Roeck
@ 2012-03-08 7:50 ` Jean Delvare
2012-03-08 7:53 ` Guenter Roeck
5 siblings, 0 replies; 7+ messages in thread
From: Jean Delvare @ 2012-03-08 7:50 UTC (permalink / raw)
To: lm-sensors
On Wed, 7 Mar 2012 08:18:58 -0800, Guenter Roeck wrote:
> On Sun, 2012-03-04 at 08:11 -0500, Jean Delvare wrote:
> > I recall testing it with a fake driver and it was working. But I don't
> > like it much. It's sad to have defined data structures to abstract
> > things as much as possible and then end up with a hack like this one. I
> > would prefer a more generic solution if we can come up with one. OTOH
> > delaying lm-sensors 3.3.2 further just for this makes little sense. So,
> > if you don't hear from me in the next 2 days, please just commit this
> > fix and I'll release 3.3.2.
>
> More than two days, and I didn't hear anything, so I went ahead and
> committed it.
Thanks. This means we're about ready to release lm-sensors 3.3.2. If
you have more pending patches, please commit them today. Tomorrow the
repository will be considered frozen and we start the testing phase.
Let's schedule the release for Monday, March 12th if this is OK with
you.
--
Jean Delvare
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [lm-sensors] [PATCH] sensors: Fix power interval output
2012-01-13 16:32 [lm-sensors] [PATCH] sensors: Fix power interval output Guenter Roeck
` (4 preceding siblings ...)
2012-03-08 7:50 ` Jean Delvare
@ 2012-03-08 7:53 ` Guenter Roeck
5 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2012-03-08 7:53 UTC (permalink / raw)
To: lm-sensors
At 11:50 PM 3/7/2012, Jean Delvare wrote:
>On Wed, 7 Mar 2012 08:18:58 -0800, Guenter Roeck wrote:
> > On Sun, 2012-03-04 at 08:11 -0500, Jean Delvare wrote:
> > > I recall testing it with a fake driver and it was working. But I don't
> > > like it much. It's sad to have defined data structures to abstract
> > > things as much as possible and then end up with a hack like this one. I
> > > would prefer a more generic solution if we can come up with one. OTOH
> > > delaying lm-sensors 3.3.2 further just for this makes little sense. So,
> > > if you don't hear from me in the next 2 days, please just commit this
> > > fix and I'll release 3.3.2.
> >
> > More than two days, and I didn't hear anything, so I went ahead and
> > committed it.
>
>Thanks. This means we're about ready to release lm-sensors 3.3.2. If
>you have more pending patches, please commit them today. Tomorrow the
>repository will be considered frozen and we start the testing phase.
>Let's schedule the release for Monday, March 12th if this is OK with
>you.
Hi Jean,
I am all done with commits, and March 12 is definitely ok with me.
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-03-08 7:53 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-13 16:32 [lm-sensors] [PATCH] sensors: Fix power interval output Guenter Roeck
2012-01-13 18:14 ` Guenter Roeck
2012-03-04 13:11 ` Jean Delvare
2012-03-04 15:16 ` Guenter Roeck
2012-03-07 16:18 ` Guenter Roeck
2012-03-08 7:50 ` Jean Delvare
2012-03-08 7:53 ` Guenter Roeck
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.