Commit 54a3121f authored by Yurii Pavlovskyi's avatar Yurii Pavlovskyi Committed by Andy Shevchenko

platform/x86: asus-wmi: Organize code into sections

The driver has grown pretty big and will grow more, which makes it hard to
navigate and understand. Add uniform comments to the code and ensure that
it is sorted into logical sections.
Signed-off-by: default avatarYurii Pavlovskyi <yurii.pavlovskyi@gmail.com>
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
parent 1827f3f0
...@@ -200,6 +200,8 @@ struct asus_wmi { ...@@ -200,6 +200,8 @@ struct asus_wmi {
struct asus_wmi_driver *driver; struct asus_wmi_driver *driver;
}; };
/* Input **********************************************************************/
static int asus_wmi_input_init(struct asus_wmi *asus) static int asus_wmi_input_init(struct asus_wmi *asus)
{ {
int err; int err;
...@@ -237,6 +239,8 @@ static void asus_wmi_input_exit(struct asus_wmi *asus) ...@@ -237,6 +239,8 @@ static void asus_wmi_input_exit(struct asus_wmi *asus)
asus->inputdev = NULL; asus->inputdev = NULL;
} }
/* WMI ************************************************************************/
static int asus_wmi_evaluate_method3(u32 method_id, static int asus_wmi_evaluate_method3(u32 method_id,
u32 arg0, u32 arg1, u32 arg2, u32 *retval) u32 arg0, u32 arg1, u32 arg2, u32 *retval)
{ {
...@@ -349,9 +353,8 @@ static int asus_wmi_get_devstate_simple(struct asus_wmi *asus, u32 dev_id) ...@@ -349,9 +353,8 @@ static int asus_wmi_get_devstate_simple(struct asus_wmi *asus, u32 dev_id)
ASUS_WMI_DSTS_STATUS_BIT); ASUS_WMI_DSTS_STATUS_BIT);
} }
/* /* LEDs ***********************************************************************/
* LEDs
*/
/* /*
* These functions actually update the LED's, and are called from a * These functions actually update the LED's, and are called from a
* workqueue. By doing this as separate work rather than when the LED * workqueue. By doing this as separate work rather than when the LED
...@@ -661,6 +664,7 @@ static int asus_wmi_led_init(struct asus_wmi *asus) ...@@ -661,6 +664,7 @@ static int asus_wmi_led_init(struct asus_wmi *asus)
return rv; return rv;
} }
/* RF *************************************************************************/
/* /*
* PCI hotplug (for wlan rfkill) * PCI hotplug (for wlan rfkill)
...@@ -1083,6 +1087,8 @@ static int asus_wmi_rfkill_init(struct asus_wmi *asus) ...@@ -1083,6 +1087,8 @@ static int asus_wmi_rfkill_init(struct asus_wmi *asus)
return result; return result;
} }
/* Quirks *********************************************************************/
static void asus_wmi_set_xusb2pr(struct asus_wmi *asus) static void asus_wmi_set_xusb2pr(struct asus_wmi *asus)
{ {
struct pci_dev *xhci_pdev; struct pci_dev *xhci_pdev;
...@@ -1115,9 +1121,8 @@ static void asus_wmi_set_als(void) ...@@ -1115,9 +1121,8 @@ static void asus_wmi_set_als(void)
asus_wmi_set_devstate(ASUS_WMI_DEVID_ALS_ENABLE, 1, NULL); asus_wmi_set_devstate(ASUS_WMI_DEVID_ALS_ENABLE, 1, NULL);
} }
/* /* Hwmon device ***************************************************************/
* Hwmon device
*/
static int asus_hwmon_agfn_fan_speed_read(struct asus_wmi *asus, int fan, static int asus_hwmon_agfn_fan_speed_read(struct asus_wmi *asus, int fan,
int *speed) int *speed)
{ {
...@@ -1456,9 +1461,27 @@ static int asus_wmi_hwmon_init(struct asus_wmi *asus) ...@@ -1456,9 +1461,27 @@ static int asus_wmi_hwmon_init(struct asus_wmi *asus)
return 0; return 0;
} }
/* static int asus_wmi_fan_init(struct asus_wmi *asus)
* Backlight {
*/ int status;
asus->asus_hwmon_pwm = -1;
asus->asus_hwmon_num_fans = -1;
asus->asus_hwmon_fan_manual_mode = false;
status = asus_hwmon_get_fan_number(asus, &asus->asus_hwmon_num_fans);
if (status) {
asus->asus_hwmon_num_fans = 0;
pr_warn("Could not determine number of fans: %d\n", status);
return -ENXIO;
}
pr_info("Number of fans: %d\n", asus->asus_hwmon_num_fans);
return 0;
}
/* Backlight ******************************************************************/
static int read_backlight_power(struct asus_wmi *asus) static int read_backlight_power(struct asus_wmi *asus)
{ {
int ret; int ret;
...@@ -1640,6 +1663,8 @@ static int is_display_toggle(int code) ...@@ -1640,6 +1663,8 @@ static int is_display_toggle(int code)
return 0; return 0;
} }
/* Fn-lock ********************************************************************/
static bool asus_wmi_has_fnlock_key(struct asus_wmi *asus) static bool asus_wmi_has_fnlock_key(struct asus_wmi *asus)
{ {
u32 result; u32 result;
...@@ -1657,6 +1682,8 @@ static void asus_wmi_fnlock_update(struct asus_wmi *asus) ...@@ -1657,6 +1682,8 @@ static void asus_wmi_fnlock_update(struct asus_wmi *asus)
asus_wmi_set_devstate(ASUS_WMI_DEVID_FNLOCK, mode, NULL); asus_wmi_set_devstate(ASUS_WMI_DEVID_FNLOCK, mode, NULL);
} }
/* WMI events *****************************************************************/
static int asus_wmi_get_event_code(u32 value) static int asus_wmi_get_event_code(u32 value)
{ {
struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL }; struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
...@@ -1790,9 +1817,8 @@ static int asus_wmi_notify_queue_flush(struct asus_wmi *asus) ...@@ -1790,9 +1817,8 @@ static int asus_wmi_notify_queue_flush(struct asus_wmi *asus)
return -EIO; return -EIO;
} }
/* /* Sysfs **********************************************************************/
* Sys helpers
*/
static int parse_arg(const char *buf, unsigned long count, int *val) static int parse_arg(const char *buf, unsigned long count, int *val)
{ {
if (!count) if (!count)
...@@ -1931,9 +1957,8 @@ static int asus_wmi_sysfs_init(struct platform_device *device) ...@@ -1931,9 +1957,8 @@ static int asus_wmi_sysfs_init(struct platform_device *device)
return sysfs_create_group(&device->dev.kobj, &platform_attribute_group); return sysfs_create_group(&device->dev.kobj, &platform_attribute_group);
} }
/* /* Platform device ************************************************************/
* Platform device
*/
static int asus_wmi_platform_init(struct asus_wmi *asus) static int asus_wmi_platform_init(struct asus_wmi *asus)
{ {
struct device *dev = &asus->platform_device->dev; struct device *dev = &asus->platform_device->dev;
...@@ -2017,9 +2042,8 @@ static void asus_wmi_platform_exit(struct asus_wmi *asus) ...@@ -2017,9 +2042,8 @@ static void asus_wmi_platform_exit(struct asus_wmi *asus)
asus_wmi_sysfs_exit(asus->platform_device); asus_wmi_sysfs_exit(asus->platform_device);
} }
/* /* debugfs ********************************************************************/
* debugfs
*/
struct asus_wmi_debugfs_node { struct asus_wmi_debugfs_node {
struct asus_wmi *asus; struct asus_wmi *asus;
char *name; char *name;
...@@ -2145,28 +2169,8 @@ static void asus_wmi_debugfs_init(struct asus_wmi *asus) ...@@ -2145,28 +2169,8 @@ static void asus_wmi_debugfs_init(struct asus_wmi *asus)
} }
} }
static int asus_wmi_fan_init(struct asus_wmi *asus) /* Init / exit ****************************************************************/
{
int status;
asus->asus_hwmon_pwm = -1;
asus->asus_hwmon_num_fans = -1;
asus->asus_hwmon_fan_manual_mode = false;
status = asus_hwmon_get_fan_number(asus, &asus->asus_hwmon_num_fans);
if (status) {
asus->asus_hwmon_num_fans = 0;
pr_warn("Could not determine number of fans: %d\n", status);
return -ENXIO;
}
pr_info("Number of fans: %d\n", asus->asus_hwmon_num_fans);
return 0;
}
/*
* WMI Driver
*/
static int asus_wmi_add(struct platform_device *pdev) static int asus_wmi_add(struct platform_device *pdev)
{ {
struct platform_driver *pdrv = to_platform_driver(pdev->dev.driver); struct platform_driver *pdrv = to_platform_driver(pdev->dev.driver);
...@@ -2294,9 +2298,8 @@ static int asus_wmi_remove(struct platform_device *device) ...@@ -2294,9 +2298,8 @@ static int asus_wmi_remove(struct platform_device *device)
return 0; return 0;
} }
/* /* Platform driver - hibernate/resume callbacks *******************************/
* Platform driver - hibernate/resume callbacks
*/
static int asus_hotk_thaw(struct device *device) static int asus_hotk_thaw(struct device *device)
{ {
struct asus_wmi *asus = dev_get_drvdata(device); struct asus_wmi *asus = dev_get_drvdata(device);
...@@ -2372,6 +2375,8 @@ static const struct dev_pm_ops asus_pm_ops = { ...@@ -2372,6 +2375,8 @@ static const struct dev_pm_ops asus_pm_ops = {
.resume = asus_hotk_resume, .resume = asus_hotk_resume,
}; };
/* Registration ***************************************************************/
static int asus_wmi_probe(struct platform_device *pdev) static int asus_wmi_probe(struct platform_device *pdev)
{ {
struct platform_driver *pdrv = to_platform_driver(pdev->dev.driver); struct platform_driver *pdrv = to_platform_driver(pdev->dev.driver);
......
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