Commit 49979d09 authored by Corentin Chary's avatar Corentin Chary Committed by Matthew Garrett

asus-wmi: fix hwmon/pwm1

The code was completly broken, and should never had been sent
to the kernel. That's what happens when you write code without
hardware to test it.

Cc: stable@kernel.org
Signed-off-by: default avatarCorentin Chary <corentin.chary@gmail.com>
Signed-off-by: default avatarMatthew Garrett <mjg@redhat.com>
parent a4ecbb8a
...@@ -797,8 +797,8 @@ static int asus_wmi_rfkill_init(struct asus_wmi *asus) ...@@ -797,8 +797,8 @@ static int asus_wmi_rfkill_init(struct asus_wmi *asus)
* Hwmon device * Hwmon device
*/ */
static ssize_t asus_hwmon_pwm1(struct device *dev, static ssize_t asus_hwmon_pwm1(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct asus_wmi *asus = dev_get_drvdata(dev); struct asus_wmi *asus = dev_get_drvdata(dev);
u32 value; u32 value;
...@@ -809,7 +809,7 @@ static ssize_t asus_hwmon_pwm1(struct device *dev, ...@@ -809,7 +809,7 @@ static ssize_t asus_hwmon_pwm1(struct device *dev,
if (err < 0) if (err < 0)
return err; return err;
value |= 0xFF; value &= 0xFF;
if (value == 1) /* Low Speed */ if (value == 1) /* Low Speed */
value = 85; value = 85;
...@@ -869,7 +869,7 @@ static mode_t asus_hwmon_sysfs_is_visible(struct kobject *kobj, ...@@ -869,7 +869,7 @@ static mode_t asus_hwmon_sysfs_is_visible(struct kobject *kobj,
* - reverved bits are non-zero * - reverved bits are non-zero
* - sfun and presence bit are not set * - sfun and presence bit are not set
*/ */
if (value != ASUS_WMI_UNSUPPORTED_METHOD || value & 0xFFF80000 if (value == ASUS_WMI_UNSUPPORTED_METHOD || value & 0xFFF80000
|| (!asus->sfun && !(value & ASUS_WMI_DSTS_PRESENCE_BIT))) || (!asus->sfun && !(value & ASUS_WMI_DSTS_PRESENCE_BIT)))
ok = false; ok = false;
} }
...@@ -904,6 +904,7 @@ static int asus_wmi_hwmon_init(struct asus_wmi *asus) ...@@ -904,6 +904,7 @@ static int asus_wmi_hwmon_init(struct asus_wmi *asus)
pr_err("Could not register asus hwmon device\n"); pr_err("Could not register asus hwmon device\n");
return PTR_ERR(hwmon); return PTR_ERR(hwmon);
} }
dev_set_drvdata(hwmon, asus);
asus->hwmon_device = hwmon; asus->hwmon_device = hwmon;
result = sysfs_create_group(&hwmon->kobj, &hwmon_attribute_group); result = sysfs_create_group(&hwmon->kobj, &hwmon_attribute_group);
if (result) if (result)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment