powerpc/windfarm: Improve display of fan speeds in sysfs
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Wed, 18 Apr 2012 22:16:50 +0000 (22:16 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Mon, 30 Apr 2012 05:37:20 +0000 (15:37 +1000)
Controls registered as RPM and PWM fans are now displayed
with the "RPM" or "%" suffix respectively to make it
clearer to the user what the value actually means since
the fan type isn't otherwise obvious.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
drivers/macintosh/windfarm_core.c

index ce8897933a84daeccddd318438b939face4aec8f..ebafc2543d5fcfb79d3903e7a02e108fba52aabe 100644 (file)
@@ -164,13 +164,24 @@ static ssize_t wf_show_control(struct device *dev,
                               struct device_attribute *attr, char *buf)
 {
        struct wf_control *ctrl = container_of(attr, struct wf_control, attr);
+       const char *typestr;
        s32 val = 0;
        int err;
 
        err = ctrl->ops->get_value(ctrl, &val);
        if (err < 0)
                return err;
-       return sprintf(buf, "%d\n", val);
+       switch(ctrl->type) {
+       case WF_CONTROL_RPM_FAN:
+               typestr = " RPM";
+               break;
+       case WF_CONTROL_PWM_FAN:
+               typestr = " %";
+               break;
+       default:
+               typestr = "";
+       }
+       return sprintf(buf, "%d%s\n", val, typestr);
 }
 
 /* This is really only for debugging... */