提交 f1fc0321 编写于 作者: D Daniel Drake 提交者: Andy Shevchenko

platform/x86: asus-wmi: add a helper for device presence

Factor out the WLAN LED and lightbar LED presence checks into a
helper function, which will also be used by the upcoming CPU fan device
support.
Signed-off-by: NDaniel Drake <drake@endlessm.com>
Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
上级 2889ffcf
...@@ -358,6 +358,14 @@ static int asus_wmi_get_devstate_simple(struct asus_wmi *asus, u32 dev_id) ...@@ -358,6 +358,14 @@ static int asus_wmi_get_devstate_simple(struct asus_wmi *asus, u32 dev_id)
ASUS_WMI_DSTS_STATUS_BIT); ASUS_WMI_DSTS_STATUS_BIT);
} }
static bool asus_wmi_dev_is_present(struct asus_wmi *asus, u32 dev_id)
{
u32 retval;
int status = asus_wmi_get_devstate(asus, dev_id, &retval);
return status == 0 && (retval & ASUS_WMI_DSTS_PRESENCE_BIT);
}
/* LEDs ***********************************************************************/ /* LEDs ***********************************************************************/
/* /*
...@@ -503,15 +511,6 @@ static int wlan_led_unknown_state(struct asus_wmi *asus) ...@@ -503,15 +511,6 @@ static int wlan_led_unknown_state(struct asus_wmi *asus)
return result & ASUS_WMI_DSTS_UNKNOWN_BIT; return result & ASUS_WMI_DSTS_UNKNOWN_BIT;
} }
static int wlan_led_presence(struct asus_wmi *asus)
{
u32 result;
asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_WIRELESS_LED, &result);
return result & ASUS_WMI_DSTS_PRESENCE_BIT;
}
static void wlan_led_update(struct work_struct *work) static void wlan_led_update(struct work_struct *work)
{ {
int ctrl_param; int ctrl_param;
...@@ -578,15 +577,6 @@ static enum led_brightness lightbar_led_get(struct led_classdev *led_cdev) ...@@ -578,15 +577,6 @@ static enum led_brightness lightbar_led_get(struct led_classdev *led_cdev)
return result & ASUS_WMI_DSTS_LIGHTBAR_MASK; return result & ASUS_WMI_DSTS_LIGHTBAR_MASK;
} }
static int lightbar_led_presence(struct asus_wmi *asus)
{
u32 result;
asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_LIGHTBAR, &result);
return result & ASUS_WMI_DSTS_PRESENCE_BIT;
}
static void asus_wmi_led_exit(struct asus_wmi *asus) static void asus_wmi_led_exit(struct asus_wmi *asus)
{ {
if (!IS_ERR_OR_NULL(asus->kbd_led.dev)) if (!IS_ERR_OR_NULL(asus->kbd_led.dev))
...@@ -637,7 +627,8 @@ static int asus_wmi_led_init(struct asus_wmi *asus) ...@@ -637,7 +627,8 @@ static int asus_wmi_led_init(struct asus_wmi *asus)
goto error; goto error;
} }
if (wlan_led_presence(asus) && (asus->driver->quirks->wapf > 0)) { if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_WIRELESS_LED)
&& (asus->driver->quirks->wapf > 0)) {
INIT_WORK(&asus->wlan_led_work, wlan_led_update); INIT_WORK(&asus->wlan_led_work, wlan_led_update);
asus->wlan_led.name = "asus::wlan"; asus->wlan_led.name = "asus::wlan";
...@@ -654,7 +645,7 @@ static int asus_wmi_led_init(struct asus_wmi *asus) ...@@ -654,7 +645,7 @@ static int asus_wmi_led_init(struct asus_wmi *asus)
goto error; goto error;
} }
if (lightbar_led_presence(asus)) { if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_LIGHTBAR)) {
INIT_WORK(&asus->lightbar_led_work, lightbar_led_update); INIT_WORK(&asus->lightbar_led_work, lightbar_led_update);
asus->lightbar_led.name = "asus::lightbar"; asus->lightbar_led.name = "asus::lightbar";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册