Re: [PATCH v10 5/8] Loongson: YeeLoong: add hardware monitoringdriver

From: Wu Zhangjin
Date: Wed Dec 16 2009 - 20:16:58 EST


Hi,

On Tue, 2009-12-15 at 17:24 +0800, Wu Zhangjin wrote:
> From: Wu Zhangjin <wuzhangjin@xxxxxxxxx>
>
> This can be applied between v9 4/8 and v9 6/8.
>
> Changes from v9 5/8:
>
> o ensure the fan controlling interface is compatible with the
> one described in Documentation/hwmon/sysfs-interface
[...]
> +/* hwmon subdriver */
> +
> +#define MIN_FAN_SPEED 0
> +#define MAX_FAN_SPEED 3
> +
> +static int get_fan_pwm_enable(void)
> +{
> + int level, mode;
> +
> + level = ec_read(REG_FAN_SPEED_LEVEL);
> + mode = ec_read(REG_FAN_AUTO_MAN_SWITCH);
> +
> + if (level == MAX_FAN_SPEED && mode == BIT_FAN_MANUAL)
> + mode = 0;
> + else if (mode == BIT_FAN_MANUAL)
> + mode = 1;
> + else
> + mode = 2;
> +
> + return mode;
> +}
> +
> +static void set_fan_pwm_enable(int mode)
> +{
> + switch (mode) {
> + case 0:
> + /* fullspeed */
> + ec_write(REG_FAN_AUTO_MAN_SWITCH, BIT_FAN_MANUAL);
> + ec_write(REG_FAN_SPEED_LEVEL, MAX_FAN_SPEED);
> + break;
> + case 1:
> + ec_write(REG_FAN_AUTO_MAN_SWITCH, BIT_FAN_MANUAL);
> + break;
> + case 2:
> + ec_write(REG_FAN_AUTO_MAN_SWITCH, BIT_FAN_AUTO);
> + break;
> + default:
> + break;
> + }
> +}
> +
[...]
> +
> +static int yeeloong_hwmon_init(void)
> +{
> + int ret;
> +
> + yeeloong_hwmon_dev = hwmon_device_register(NULL);
> + if (IS_ERR(yeeloong_hwmon_dev)) {
> + pr_err("Fail to register yeeloong hwmon device\n");
> + yeeloong_hwmon_dev = NULL;
> + return PTR_ERR(yeeloong_hwmon_dev);
> + }
> + ret = sysfs_create_group(&yeeloong_hwmon_dev->kobj,
> + &hwmon_attribute_group);
> + if (ret) {
> + hwmon_device_unregister(yeeloong_hwmon_dev);
> + yeeloong_hwmon_dev = NULL;
> + return ret;
> + }
> + /* ensure fan is set to auto mode */
> + set_fan_pwm_enable(BIT_FAN_AUTO);
> +

We need to change the above line to:

set_fan_pwm_enable(2);

to ensure it is compatible to the hwmon interface too.

Best Regards,
Wu Zhangjin

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/