From patchwork Wed Feb 3 21:55:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 12065451 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A269C433E0 for ; Wed, 3 Feb 2021 21:56:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3482464E4E for ; Wed, 3 Feb 2021 21:56:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232366AbhBCV4v (ORCPT ); Wed, 3 Feb 2021 16:56:51 -0500 Received: from mail-40131.protonmail.ch ([185.70.40.131]:59151 "EHLO mail-40131.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231318AbhBCV4t (ORCPT ); Wed, 3 Feb 2021 16:56:49 -0500 Date: Wed, 03 Feb 2021 21:55:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1612389367; bh=gGyzy6J413D8Goh69tP/efDGaWYPLVeIpXBnutcEtvg=; h=Date:To:From:Reply-To:Subject:From; b=njEo/rQvK6GD+kwNa5vSwRlcTynD13s0pXSVkDCGzVwSr/FoU0G8/R9aY9D67jj5/ eCCPyGfI218akpuYAP+mx4oxFtdBYdn45YrgzBLLqmijmGk0FNti4H/ZWK/fvq4pEB Yy/Rs6Y5eXzLc3wE6YeDeEuk0fiLiFKM1N05X3ZE= To: platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Gross , Ike Panhc , Andy Shevchenko From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v3 16/29] platform/x86: ideapad-laptop: group and separate (un)related constants into enums Message-ID: <20210203215403.290792-17-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Group and rename constants depending on which ACPI interface they pertain to, and rename CFG_X constants to CFG_CAP_X. Signed-off-by: Barnabás Pőcze Reviewed-by: Hans de Goede Reviewed-by: Andy Shevchenko diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 00d9e23a0310..e74f25ec4a27 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -34,14 +34,6 @@ #define IDEAPAD_RFKILL_DEV_NUM (3) -#define BM_CONSERVATION_BIT (5) -#define HA_FNLOCK_BIT (10) - -#define CFG_BT_BIT (16) -#define CFG_3G_BIT (17) -#define CFG_WIFI_BIT (18) -#define CFG_CAMERA_BIT (19) - #if IS_ENABLED(CONFIG_ACPI_WMI) static const char *const ideapad_wmi_fnesc_events[] = { "26CAB2E5-5CF1-46AE-AAC3-4A12B6BA50E6", /* Yoga 3 */ @@ -50,10 +42,28 @@ static const char *const ideapad_wmi_fnesc_events[] = { #endif enum { - BMCMD_CONSERVATION_ON = 3, - BMCMD_CONSERVATION_OFF = 5, - HACMD_FNLOCK_ON = 0xe, - HACMD_FNLOCK_OFF = 0xf, + CFG_CAP_BT_BIT = 16, + CFG_CAP_3G_BIT = 17, + CFG_CAP_WIFI_BIT = 18, + CFG_CAP_CAM_BIT = 19, +}; + +enum { + GBMD_CONSERVATION_STATE_BIT = 5, +}; + +enum { + SMBC_CONSERVATION_ON = 3, + SMBC_CONSERVATION_OFF = 5, +}; + +enum { + HALS_FNLOCK_STATE_BIT = 10, +}; + +enum { + SALS_FNLOCK_ON = 0xe, + SALS_FNLOCK_OFF = 0xf, }; enum { @@ -309,7 +319,7 @@ static int debugfs_status_show(struct seq_file *s, void *data) if (!method_gbmd(priv->adev->handle, &value)) { seq_printf(s, "Conservation mode:\t%s(%lu)\n", - test_bit(BM_CONSERVATION_BIT, &value) ? "On" : "Off", + test_bit(GBMD_CONSERVATION_STATE_BIT, &value) ? "On" : "Off", value); } @@ -323,13 +333,13 @@ static int debugfs_cfg_show(struct seq_file *s, void *data) seq_printf(s, "cfg: 0x%.8lX\n\nCapability: ", priv->cfg); - if (test_bit(CFG_BT_BIT, &priv->cfg)) + if (test_bit(CFG_CAP_BT_BIT, &priv->cfg)) seq_printf(s, "Bluetooth "); - if (test_bit(CFG_3G_BIT, &priv->cfg)) + if (test_bit(CFG_CAP_3G_BIT, &priv->cfg)) seq_printf(s, "3G "); - if (test_bit(CFG_WIFI_BIT, &priv->cfg)) + if (test_bit(CFG_CAP_WIFI_BIT, &priv->cfg)) seq_printf(s, "Wireless "); - if (test_bit(CFG_CAMERA_BIT, &priv->cfg)) + if (test_bit(CFG_CAP_CAM_BIT, &priv->cfg)) seq_printf(s, "Camera "); seq_printf(s, "\nGraphic: "); switch ((priv->cfg)&0x700) { @@ -491,7 +501,7 @@ static ssize_t conservation_mode_show(struct device *dev, err = method_gbmd(priv->adev->handle, &result); if (err) return err; - return sysfs_emit(buf, "%d\n", !!test_bit(BM_CONSERVATION_BIT, &result)); + return sysfs_emit(buf, "%d\n", !!test_bit(GBMD_CONSERVATION_STATE_BIT, &result)); } static ssize_t conservation_mode_store(struct device *dev, @@ -507,8 +517,8 @@ static ssize_t conservation_mode_store(struct device *dev, return ret; ret = method_int1(priv->adev->handle, "SBMC", state ? - BMCMD_CONSERVATION_ON : - BMCMD_CONSERVATION_OFF); + SMBC_CONSERVATION_ON : + SMBC_CONSERVATION_OFF); if (ret) return ret; return count; @@ -529,7 +539,7 @@ static ssize_t fn_lock_show(struct device *dev, return fail; result = hals; - return sysfs_emit(buf, "%d\n", !!test_bit(HA_FNLOCK_BIT, &result)); + return sysfs_emit(buf, "%d\n", !!test_bit(HALS_FNLOCK_STATE_BIT, &result)); } static ssize_t fn_lock_store(struct device *dev, @@ -545,8 +555,8 @@ static ssize_t fn_lock_store(struct device *dev, return ret; ret = method_int1(priv->adev->handle, "SALS", state ? - HACMD_FNLOCK_ON : - HACMD_FNLOCK_OFF); + SALS_FNLOCK_ON : + SALS_FNLOCK_OFF); if (ret) return ret; return count; @@ -573,7 +583,7 @@ static umode_t ideapad_is_visible(struct kobject *kobj, bool supported; if (attr == &dev_attr_camera_power.attr) - supported = test_bit(CFG_CAMERA_BIT, &(priv->cfg)); + supported = test_bit(CFG_CAP_CAM_BIT, &priv->cfg); else if (attr == &dev_attr_fan_mode.attr) { unsigned long value; supported = !read_ec_data(priv->adev->handle, VPCCMD_R_FAN, @@ -859,9 +869,9 @@ struct ideapad_rfk_data { }; static const struct ideapad_rfk_data ideapad_rfk_data[] = { - { "ideapad_wlan", CFG_WIFI_BIT, VPCCMD_W_WIFI, RFKILL_TYPE_WLAN }, - { "ideapad_bluetooth", CFG_BT_BIT, VPCCMD_W_BT, RFKILL_TYPE_BLUETOOTH }, - { "ideapad_3g", CFG_3G_BIT, VPCCMD_W_3G, RFKILL_TYPE_WWAN }, + { "ideapad_wlan", CFG_CAP_WIFI_BIT, VPCCMD_W_WIFI, RFKILL_TYPE_WLAN }, + { "ideapad_bluetooth", CFG_CAP_BT_BIT, VPCCMD_W_BT, RFKILL_TYPE_BLUETOOTH }, + { "ideapad_3g", CFG_CAP_3G_BIT, VPCCMD_W_3G, RFKILL_TYPE_WWAN }, }; static int ideapad_rfk_set(void *data, bool blocked)