Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5193988yba; Wed, 10 Apr 2019 13:32:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqyhSJ6DJ6p4HFNhZhovicltnJXZqCFzoYxkftMS3zhyxWObsvK/9gzTZf7q0kec1rfwIDre X-Received: by 2002:aa7:943b:: with SMTP id y27mr21810503pfo.59.1554928357150; Wed, 10 Apr 2019 13:32:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554928357; cv=none; d=google.com; s=arc-20160816; b=wfgjQnL6YUf1TE9dsz16SP8CTJ/YFTMlYjcWxbIs1vZkTyiF6YmwPy87e7DUzS4wp8 FXI/fM9QTd7/PvYBlOdYhz5AAnCwnUAJqWbv1JgmsNYyTc6lLbowWMUp6CMpXHa0ovaz 37DlDC+oEgFxSoptZ4BFXDSCvv0UBZPaz9pPrp2un3joYYRF28mXKzQDzWhOIGOcTfEJ wzsOLY+zuRBaDwkTAD0VhFuYQB2UsH+KaPNk0hU9M1PiLQ0j96eIvqT6134hQDKxjZCr Tq4RG158yivFx+iQhhPyg9z+z8ovnhglt7kp5bfft3f+e3QnZF5Picv19Uxda/iXhr1j Brjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:from:subject:dkim-signature; bh=BaaVZ2QVpoe+imPNuDOah2SZLBIpVXWP6D7DIlgBEhM=; b=Exiw5rbo5ldOvDLvak96kaFoArySWRWvLJ/NH8HSV2TSEvDxanQxsozObRqhEvKWev UHXeC4bRvaFDm3t4n9L6CPMqtMqTThLanHMayIjgSxboQfhs4wywEGrqp6XX/5+P59Sy kyfH4wgaEa41d3YbwrmYyf3l3qhoNgAmS1HLIlbkT8K1grendtbVd1hb0/y8q34fG8q5 RLiGvpaQmd8L/aYn34XWRpwkDq9WeOM/uoAKjbmbRrrUofkq887K4PuQ4li/y/qujlJy Dw+R5aqyknFALAVo7r+U9Dp3s/L/ugTmXbYfWf6AYIvpUpmTqnt7I/oe6D8Ic9U5j/w8 EjOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dDB7yzBZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g1si24008029pgd.269.2019.04.10.13.32.21; Wed, 10 Apr 2019 13:32:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dDB7yzBZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726615AbfDJUbk (ORCPT + 99 others); Wed, 10 Apr 2019 16:31:40 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:55920 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726014AbfDJUbj (ORCPT ); Wed, 10 Apr 2019 16:31:39 -0400 Received: by mail-wm1-f65.google.com with SMTP id o25so3998908wmf.5; Wed, 10 Apr 2019 13:31:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:cc:references:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=BaaVZ2QVpoe+imPNuDOah2SZLBIpVXWP6D7DIlgBEhM=; b=dDB7yzBZN5yVttirCq8wB5K6V7ViN+awlgg0rTzqdPWI0hg0HfPSXn9QdbtECbKsgM 3nDvu11xULWSeXShacE0DHmnS4vi61g4yAL46vCAqKmxTPzItKeL4hRHhtmYPjm8Qlvr MGSuygvLxYqX7K/M736t67nz8YvdKHF11P9YbcXQRcIcOk+fR2ix51mMJWVSpbXG9IIJ PPhFPh0ufS6QFKSFxHEZqJi4veBGUZ0+DwMc7OoU6EmkNk4+tMdiyRSzyjLIXmOF/Uli nwM0xytxd+SpXgwCCK6LmIcyBMS1w5w3AAVBLbsGb8tsF1MZw2HfvwdLvmHTmbIYe2Mk Wi7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=BaaVZ2QVpoe+imPNuDOah2SZLBIpVXWP6D7DIlgBEhM=; b=PSJjGqNKPSaa3M5XuC8ktEw9OvO2dQq99dRtUiNS6vxvMaQjw4r/bnGfNZTE/HzniX j26GESnqoC0pwtDw6L0pARpxB8Vm8lJywXEJh53BP9gKyLFRuyh9enDoYbUzfrvZx22q KtbZZG5GcCSqA0arb7HUgE1bkUYvUrVwky/c6acihNV0EKjEk4f7JUvTdhPcMAtBiWbu rg1b5Fw4EwpX5zNOx9Du6puJZfRwc0n1+gGdYub9++yE2uwuYVmy9hhMFmkn38MuDF9F ioqZmu0as+nQPpdkiioQWOOiHcwntecazmpphNPjrqj+XAYVBAqsBfuq0gKm6BjS+Wud /kkg== X-Gm-Message-State: APjAAAUK95EvLBkeiiN4St895OCYm+utESPho2Vl3JcZcHl7SDaTz7KE K62Y87I1c/U3aUWKL9B9ZvpPwyeAwcc= X-Received: by 2002:a1c:6455:: with SMTP id y82mr3911070wmb.104.1554928296871; Wed, 10 Apr 2019 13:31:36 -0700 (PDT) Received: from [192.168.20.141] ([194.99.104.18]) by smtp.gmail.com with ESMTPSA id z140sm8928067wmc.27.2019.04.10.13.31.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 13:31:36 -0700 (PDT) Subject: [PATCH 07/11] platform/x86: asus-wmi: Organize code into sections From: Yurii Pavlovskyi Cc: Corentin Chary , Darren Hart , Andy Shevchenko , Daniel Drake , acpi4asus-user@lists.sourceforge.net, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org References: Message-ID: <300d9410-1de5-a4ab-a55a-378ec8c4d5b9@gmail.com> Date: Wed, 10 Apr 2019 22:31:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The driver has grown (and will more) pretty big 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: Yurii Pavlovskyi --- drivers/platform/x86/asus-wmi.c | 94 ++++++++++++++++----------------- 1 file changed, 46 insertions(+), 48 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index e0a710c64dea..b9a6dc224e08 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -191,6 +191,8 @@ struct asus_wmi { struct asus_wmi_driver *driver; }; +/* Input **********************************************************************/ + static int asus_wmi_input_init(struct asus_wmi *asus) { int err; @@ -228,6 +230,8 @@ static void asus_wmi_input_exit(struct asus_wmi *asus) asus->inputdev = NULL; } +/* WMI ************************************************************************/ + static int asus_wmi_evaluate_method_3dw(u32 method_id, u32 arg0, u32 arg1, u32 arg2, u32 *retval) { @@ -246,7 +250,7 @@ static int asus_wmi_evaluate_method_3dw(u32 method_id, u32 arg0, u32 arg1, &input, &output); if (ACPI_FAILURE(status)) - goto exit; + return -EIO; obj = (union acpi_object *)output.pointer; if (obj && obj->type == ACPI_TYPE_INTEGER) @@ -257,10 +261,6 @@ static int asus_wmi_evaluate_method_3dw(u32 method_id, u32 arg0, u32 arg1, kfree(obj); -exit: - if (ACPI_FAILURE(status)) - return -EIO; - if (tmp == ASUS_WMI_UNSUPPORTED_METHOD) return -ENODEV; @@ -344,9 +344,8 @@ static int asus_wmi_get_devstate_simple(struct asus_wmi *asus, u32 dev_id) ASUS_WMI_DSTS_STATUS_BIT); } -/* - * LEDs - */ +/* LEDs ***********************************************************************/ + /* * These functions actually update the LED's, and are called from a * workqueue. By doing this as separate work rather than when the LED @@ -656,6 +655,7 @@ static int asus_wmi_led_init(struct asus_wmi *asus) return rv; } +/* RF *************************************************************************/ /* * PCI hotplug (for wlan rfkill) @@ -1078,6 +1078,8 @@ static int asus_wmi_rfkill_init(struct asus_wmi *asus) return result; } +/* Quirks *********************************************************************/ + static void asus_wmi_set_xusb2pr(struct asus_wmi *asus) { struct pci_dev *xhci_pdev; @@ -1110,9 +1112,8 @@ static void asus_wmi_set_als(void) 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, int *speed) { @@ -1388,7 +1389,6 @@ static umode_t asus_hwmon_sysfs_is_visible(struct kobject *kobj, else if (attr == &dev_attr_temp1_input.attr) dev_id = ASUS_WMI_DEVID_THERMAL_CTRL; - if (attr == &dev_attr_fan1_input.attr || attr == &dev_attr_fan1_label.attr || attr == &dev_attr_pwm1.attr @@ -1460,9 +1460,27 @@ static void asus_wmi_hwmon_exit(struct asus_wmi *asus) } } -/* - * Backlight - */ +static int asus_wmi_fan_init(struct asus_wmi *asus) +{ + 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) { int ret; @@ -1644,6 +1662,8 @@ static int is_display_toggle(int code) return 0; } +/* WMI events *****************************************************************/ + static int asus_poll_wmi_event(u32 value) { struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; @@ -1766,9 +1786,8 @@ static int asus_wmi_notify_queue_flush(struct asus_wmi *asus) return -EIO; } -/* - * Sys helpers - */ +/* Sysfs **********************************************************************/ + static int parse_arg(const char *buf, unsigned long count, int *val) { if (!count) @@ -1907,9 +1926,8 @@ static int asus_wmi_sysfs_init(struct platform_device *device) return sysfs_create_group(&device->dev.kobj, &platform_attribute_group); } -/* - * Platform device - */ +/* Platform device ************************************************************/ + static int asus_wmi_platform_init(struct asus_wmi *asus) { int rv; @@ -1971,9 +1989,8 @@ static void asus_wmi_platform_exit(struct asus_wmi *asus) asus_wmi_sysfs_exit(asus->platform_device); } -/* - * debugfs - */ +/* debugfs ********************************************************************/ + struct asus_wmi_debugfs_node { struct asus_wmi *asus; char *name; @@ -2120,28 +2137,8 @@ static int asus_wmi_debugfs_init(struct asus_wmi *asus) return -ENOMEM; } -static int asus_wmi_fan_init(struct asus_wmi *asus) -{ - 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; -} +/* Init / exit ****************************************************************/ -/* - * WMI Driver - */ static int asus_wmi_add(struct platform_device *pdev) { struct platform_driver *pdrv = to_platform_driver(pdev->dev.driver); @@ -2279,9 +2276,8 @@ static int asus_wmi_remove(struct platform_device *device) return 0; } -/* - * Platform driver - hibernate/resume callbacks - */ +/* Platform driver - hibernate/resume callbacks *******************************/ + static int asus_hotk_thaw(struct device *device) { struct asus_wmi *asus = dev_get_drvdata(device); @@ -2353,6 +2349,8 @@ static const struct dev_pm_ops asus_pm_ops = { .resume = asus_hotk_resume, }; +/* Registration ***************************************************************/ + static int asus_wmi_probe(struct platform_device *pdev) { struct platform_driver *pdrv = to_platform_driver(pdev->dev.driver); -- 2.17.1