From patchwork Wed Jan 13 18:20:27 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: 12017499 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.8 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 026A2C433DB for ; Wed, 13 Jan 2021 18:21:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C2D0523436 for ; Wed, 13 Jan 2021 18:21:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727808AbhAMSVP (ORCPT ); Wed, 13 Jan 2021 13:21:15 -0500 Received: from mail1.protonmail.ch ([185.70.40.18]:31119 "EHLO mail1.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726429AbhAMSVP (ORCPT ); Wed, 13 Jan 2021 13:21:15 -0500 Date: Wed, 13 Jan 2021 18:20:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1610562032; bh=kOOM095IMtzoJ1/WBEBj/i6B1lSB1htCOopO0HDGtVY=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=bfHqgcaylkEb4Wvyl7At6SRDjreG00FS3UE5iUtxyeT5/SpXAPurRDvEQ2WHDC7+E uyxc1RMKuPMHPxJs1WCVDl/5cRCBiXeQlsdMwJOAGrU4k8/LSsD29MIqseTrdA+LSb Ht/MKlfgzF8KllWPVOzQOReE8X5QJU5HNHqZIClI= To: platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Gross , Ike Panhc From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v2 01/24] platform/x86: ideapad-laptop: remove unnecessary dev_set_drvdata() call Message-ID: <20210113182016.166049-2-pobrn@protonmail.com> In-Reply-To: <20210113182016.166049-1-pobrn@protonmail.com> References: <20210113182016.166049-1-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org The driver core already sets the driver specific data on bind failure or removal. Thus the call is unnecessary. Signed-off-by: Barnabás Pőcze Reviewed-by: Hans de Goede diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 5b81bafa5c16..c96fd60ec7d2 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1084,7 +1084,6 @@ static int ideapad_acpi_remove(struct platform_device *pdev) ideapad_input_exit(priv); ideapad_debugfs_exit(priv); ideapad_sysfs_exit(priv); - dev_set_drvdata(&pdev->dev, NULL); return 0; } From patchwork Wed Jan 13 18:20:31 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: 12017501 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.8 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 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 C7F8BC433E0 for ; Wed, 13 Jan 2021 18:21:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 803D723436 for ; Wed, 13 Jan 2021 18:21:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727809AbhAMSVS (ORCPT ); Wed, 13 Jan 2021 13:21:18 -0500 Received: from mail1.protonmail.ch ([185.70.40.18]:60222 "EHLO mail1.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726429AbhAMSVS (ORCPT ); Wed, 13 Jan 2021 13:21:18 -0500 Date: Wed, 13 Jan 2021 18:20:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1610562035; bh=p/RmxgzjPFuwTZGWTX148bvreK8r1y3X6OlrhmokIi0=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=xhBlPL//BBdCYdMcdIMa/zwjxMEbGsBl7A/UCzwQz7f5uMLvF+3dIDWBcsx9cMDBB dU6nVte7354JbhmNLAmEvclzrmzbf/ChL47Y4NcSx02Fhi5Moc4QfdsYByLGi4h+sn 2t9GoAkitvitCMPboK4o7pxbRazlup/aanql/VD4= To: platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Gross , Ike Panhc From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v2 02/24] platform/x86: ideapad-laptop: use appropriately typed variable to store the return value of ACPI methods Message-ID: <20210113182016.166049-3-pobrn@protonmail.com> In-Reply-To: <20210113182016.166049-1-pobrn@protonmail.com> References: <20210113182016.166049-1-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Use a variable with type `acpi_status` to store the return value of ACPI methods instead of a plain `int`. And use ACPI_{SUCCESS,FAILURE} macros where possible instead of direct comparison. Signed-off-by: Barnabás Pőcze Reviewed-by: Hans de Goede diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index c96fd60ec7d2..fbaf8d3f4792 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -977,6 +977,7 @@ static int ideapad_acpi_add(struct platform_device *pdev) int cfg; struct ideapad_private *priv; struct acpi_device *adev; + acpi_status acpi_err; ret = acpi_bus_get_device(ACPI_HANDLE(&pdev->dev), &adev); if (ret) @@ -1031,22 +1032,26 @@ static int ideapad_acpi_add(struct platform_device *pdev) if (ret && ret != -ENODEV) goto backlight_failed; } - ret = acpi_install_notify_handler(adev->handle, - ACPI_DEVICE_NOTIFY, ideapad_acpi_notify, priv); - if (ret) + acpi_err = acpi_install_notify_handler(adev->handle, + ACPI_DEVICE_NOTIFY, ideapad_acpi_notify, priv); + if (ACPI_FAILURE(acpi_err)) { + ret = -EIO; goto notification_failed; + } #if IS_ENABLED(CONFIG_ACPI_WMI) for (i = 0; i < ARRAY_SIZE(ideapad_wmi_fnesc_events); i++) { - ret = wmi_install_notify_handler(ideapad_wmi_fnesc_events[i], - ideapad_wmi_notify, priv); - if (ret == AE_OK) { + acpi_err = wmi_install_notify_handler(ideapad_wmi_fnesc_events[i], + ideapad_wmi_notify, priv); + if (ACPI_SUCCESS(acpi_err)) { priv->fnesc_guid = ideapad_wmi_fnesc_events[i]; break; } } - if (ret != AE_OK && ret != AE_NOT_EXIST) + if (ACPI_FAILURE(acpi_err) && acpi_err != AE_NOT_EXIST) { + ret = -EIO; goto notification_failed_wmi; + } #endif return 0; From patchwork Wed Jan 13 18:20:36 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: 12017503 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.8 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 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 1633CC433E0 for ; Wed, 13 Jan 2021 18:21:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C9B9523436 for ; Wed, 13 Jan 2021 18:21:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727827AbhAMSV2 (ORCPT ); Wed, 13 Jan 2021 13:21:28 -0500 Received: from mail-40131.protonmail.ch ([185.70.40.131]:19520 "EHLO mail-40131.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726429AbhAMSV2 (ORCPT ); Wed, 13 Jan 2021 13:21:28 -0500 Date: Wed, 13 Jan 2021 18:20:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1610562044; bh=QxZoSSn4vJAFzWA8ldV4HrL5vzLpbF2pOA2Z50GPnIQ=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=karPq8lzJM/ApXmlDDSp6eeKZbLZgtCSvQQVhXfL6whuLi3NFxxhj+kBebncHwMsa V48Wid1d5lMCqGDnuc+qv+EdsY41N9jI7AQ1RsqIfhaXZ5bLjXphkD9g1THcdn5bP3 ZU0dd46ZqdlYMw4l+3MKTO1BLB72e8M469HoEEI8= To: platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Gross , Ike Panhc From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v2 03/24] platform/x86: ideapad-laptop: sort includes lexicographically Message-ID: <20210113182016.166049-4-pobrn@protonmail.com> In-Reply-To: <20210113182016.166049-1-pobrn@protonmail.com> References: <20210113182016.166049-1-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Managing includes is easier when they are sorted, so sort them lexicographically. Signed-off-by: Barnabás Pőcze diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index fbaf8d3f4792..d92d96fe4aa1 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -8,22 +8,23 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt -#include -#include -#include -#include #include -#include -#include -#include -#include #include -#include #include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include #define IDEAPAD_RFKILL_DEV_NUM (3) From patchwork Wed Jan 13 18:20:46 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: 12017507 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=-10.0 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,UNWANTED_LANGUAGE_BODY 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 5B9F5C433E0 for ; Wed, 13 Jan 2021 18:21:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1AC1A23436 for ; Wed, 13 Jan 2021 18:21:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726429AbhAMSVh (ORCPT ); Wed, 13 Jan 2021 13:21:37 -0500 Received: from mail2.protonmail.ch ([185.70.40.22]:37832 "EHLO mail2.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727851AbhAMSVh (ORCPT ); Wed, 13 Jan 2021 13:21:37 -0500 Date: Wed, 13 Jan 2021 18:20:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1610562054; bh=yPu3zaxASDXPmW4yGer/30+Sel6k1sYSKQa4g1z9RUw=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=Kwqe7sPvN3wk+WQxJV0dH/SRxE6it3Te4RB67ScWD8KEB1YMDK8Zvd5EWo85GxqJ7 UcQ06xifdewiViY6YV+GxxRhXS/PKx3Z4rQnVDpR9z+6IO4jyJsZe9ch+9FZtVs+VA 4PTZYtDocYPKAZzlOj3QD4WIdGYOCRAtUD2mQA5o= To: platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Gross , Ike Panhc From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v2 04/24] platform/x86: ideapad-laptop: use sysfs_emit() Message-ID: <20210113182016.166049-5-pobrn@protonmail.com> In-Reply-To: <20210113182016.166049-1-pobrn@protonmail.com> References: <20210113182016.166049-1-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org sysfs_emit() has been introduced to make it less ambiguous which function is preferred when writing to the output buffer in a device attribute's show() callback. Convert the ideapad-laptop module to utilize this new helper function. Signed-off-by: Barnabás Pőcze Reviewed-by: Hans de Goede diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index d92d96fe4aa1..61ea70602256 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -346,8 +347,8 @@ static ssize_t show_ideapad_cam(struct device *dev, struct ideapad_private *priv = dev_get_drvdata(dev); if (read_ec_data(priv->adev->handle, VPCCMD_R_CAMERA, &result)) - return sprintf(buf, "-1\n"); - return sprintf(buf, "%lu\n", result); + return sysfs_emit(buf, "-1\n"); + return sysfs_emit(buf, "%lu\n", result); } static ssize_t store_ideapad_cam(struct device *dev, @@ -377,8 +378,8 @@ static ssize_t show_ideapad_fan(struct device *dev, struct ideapad_private *priv = dev_get_drvdata(dev); if (read_ec_data(priv->adev->handle, VPCCMD_R_FAN, &result)) - return sprintf(buf, "-1\n"); - return sprintf(buf, "%lu\n", result); + return sysfs_emit(buf, "-1\n"); + return sysfs_emit(buf, "%lu\n", result); } static ssize_t store_ideapad_fan(struct device *dev, @@ -410,8 +411,8 @@ static ssize_t touchpad_show(struct device *dev, unsigned long result; if (read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &result)) - return sprintf(buf, "-1\n"); - return sprintf(buf, "%lu\n", result); + return sysfs_emit(buf, "-1\n"); + return sysfs_emit(buf, "%lu\n", result); } /* Switch to RO for now: It might be revisited in the future */ @@ -443,8 +444,8 @@ static ssize_t conservation_mode_show(struct device *dev, unsigned long result; if (method_gbmd(priv->adev->handle, &result)) - return sprintf(buf, "-1\n"); - return sprintf(buf, "%u\n", test_bit(BM_CONSERVATION_BIT, &result)); + return sysfs_emit(buf, "-1\n"); + return sysfs_emit(buf, "%u\n", test_bit(BM_CONSERVATION_BIT, &result)); } static ssize_t conservation_mode_store(struct device *dev, @@ -479,10 +480,10 @@ static ssize_t fn_lock_show(struct device *dev, int fail = read_method_int(priv->adev->handle, "HALS", &hals); if (fail) - return sprintf(buf, "-1\n"); + return sysfs_emit(buf, "-1\n"); result = hals; - return sprintf(buf, "%u\n", test_bit(HA_FNLOCK_BIT, &result)); + return sysfs_emit(buf, "%u\n", test_bit(HA_FNLOCK_BIT, &result)); } static ssize_t fn_lock_store(struct device *dev, From patchwork Wed Jan 13 18:20:52 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: 12017505 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.8 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 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 B6DC3C433DB for ; Wed, 13 Jan 2021 18:21:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6D2AC23436 for ; Wed, 13 Jan 2021 18:21:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727852AbhAMSVh (ORCPT ); Wed, 13 Jan 2021 13:21:37 -0500 Received: from mail2.protonmail.ch ([185.70.40.22]:40382 "EHLO mail2.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726429AbhAMSVg (ORCPT ); Wed, 13 Jan 2021 13:21:36 -0500 Date: Wed, 13 Jan 2021 18:20:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1610562053; bh=0Ze2QmLGbCrv9BWPO/WaZ71bDw3SNlV74bqNhcfzNIA=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=J2HTCyF3WE7SHgidokdUMcrm91FhtBFZs1PAzyhAL8at7QEsBUraUul7/Lk5rWJfj LYsDyMmdp+zSFrGoLFQpL3EL3byjhkZ9gOmUMCe1tGJXfzT0VMk0HgP1ILWBBbtwdR t9uR8gjxgFvehbKiDVHpBY6UuI2J1+SdBuh/ekO8= To: platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Gross , Ike Panhc From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v2 05/24] platform/x86: ideapad-laptop: use for_each_set_bit() helper to simplify event processing Message-ID: <20210113182016.166049-6-pobrn@protonmail.com> In-Reply-To: <20210113182016.166049-1-pobrn@protonmail.com> References: <20210113182016.166049-1-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org The current code used the combination of a for loop + test_bit, which can be simplified using for_each_set_bit(), so utilize that. Signed-off-by: Barnabás Pőcze Reviewed-by: Hans de Goede diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 61ea70602256..29e91942c756 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -742,22 +743,20 @@ static void ideapad_check_special_buttons(struct ideapad_private *priv) read_ec_data(priv->adev->handle, VPCCMD_R_SPECIAL_BUTTONS, &value); - for (bit = 0; bit < 16; bit++) { - if (test_bit(bit, &value)) { - switch (bit) { - case 0: /* Z580 */ - case 6: /* Z570 */ - /* Thermal Management button */ - ideapad_input_report(priv, 65); - break; - case 1: - /* OneKey Theater button */ - ideapad_input_report(priv, 64); - break; - default: - pr_info("Unknown special button: %lu\n", bit); - break; - } + for_each_set_bit(bit, &value, 16) { + switch (bit) { + case 0: /* Z580 */ + case 6: /* Z570 */ + /* Thermal Management button */ + ideapad_input_report(priv, 65); + break; + case 1: + /* OneKey Theater button */ + ideapad_input_report(priv, 64); + break; + default: + pr_info("Unknown special button: %lu\n", bit); + break; } } } @@ -891,7 +890,7 @@ static void ideapad_sync_touchpad_state(struct ideapad_private *priv) static void ideapad_acpi_notify(acpi_handle handle, u32 event, void *data) { struct ideapad_private *priv = data; - unsigned long vpc1, vpc2, vpc_bit; + unsigned long vpc1, vpc2, bit; if (read_ec_data(handle, VPCCMD_R_VPC1, &vpc1)) return; @@ -899,44 +898,42 @@ static void ideapad_acpi_notify(acpi_handle handle, u32 event, void *data) return; vpc1 = (vpc2 << 8) | vpc1; - for (vpc_bit = 0; vpc_bit < 16; vpc_bit++) { - if (test_bit(vpc_bit, &vpc1)) { - switch (vpc_bit) { - case 9: - ideapad_sync_rfk_state(priv); - break; - case 13: - case 11: - case 8: - case 7: - case 6: - ideapad_input_report(priv, vpc_bit); - break; - case 5: - ideapad_sync_touchpad_state(priv); - break; - case 4: - ideapad_backlight_notify_brightness(priv); - break; - case 3: - ideapad_input_novokey(priv); - break; - case 2: - ideapad_backlight_notify_power(priv); - break; - case 0: - ideapad_check_special_buttons(priv); - break; - case 1: - /* Some IdeaPads report event 1 every ~20 - * seconds while on battery power; some - * report this when changing to/from tablet - * mode. Squelch this event. - */ - break; - default: - pr_info("Unknown event: %lu\n", vpc_bit); - } + for_each_set_bit(bit, &vpc1, 16) { + switch (bit) { + case 9: + ideapad_sync_rfk_state(priv); + break; + case 13: + case 11: + case 8: + case 7: + case 6: + ideapad_input_report(priv, bit); + break; + case 5: + ideapad_sync_touchpad_state(priv); + break; + case 4: + ideapad_backlight_notify_brightness(priv); + break; + case 3: + ideapad_input_novokey(priv); + break; + case 2: + ideapad_backlight_notify_power(priv); + break; + case 0: + ideapad_check_special_buttons(priv); + break; + case 1: + /* Some IdeaPads report event 1 every ~20 + * seconds while on battery power; some + * report this when changing to/from tablet + * mode. Squelch this event. + */ + break; + default: + pr_info("Unknown event: %lu\n", bit); } } } From patchwork Wed Jan 13 18:20:57 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: 12017509 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.8 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 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 18135C433DB for ; Wed, 13 Jan 2021 18:21:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C5D8F23436 for ; Wed, 13 Jan 2021 18:21:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727963AbhAMSVr (ORCPT ); Wed, 13 Jan 2021 13:21:47 -0500 Received: from mail-40134.protonmail.ch ([185.70.40.134]:22598 "EHLO mail-40134.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727851AbhAMSVr (ORCPT ); Wed, 13 Jan 2021 13:21:47 -0500 Date: Wed, 13 Jan 2021 18:20:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1610562065; bh=MEcMsH5SPU91xLKxQanVZutXXkK5HhSF/dd5d5D2Ce0=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=UPf8fcxr/X+Otb5//dw9SthhPcWYT0PNhnrbaZmD21L2qspuelt115sExP+pWuczI 4CTL8bEHRxOO8MoB2/9kMTQGOrf4sauGwDFsZ2nEjEUMMcgYFk0Hl2shFC+SSmWdyI DSnn75TtGM4b/ZAovAexuCfKuz1HcdOXFFWigD10= To: platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Gross , Ike Panhc From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v2 06/24] platform/x86: ideapad-laptop: use msecs_to_jiffies() helper instead of hand-crafted formula Message-ID: <20210113182016.166049-7-pobrn@protonmail.com> In-Reply-To: <20210113182016.166049-1-pobrn@protonmail.com> References: <20210113182016.166049-1-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org The current code used a hand-crafted formulate to convert milliseconds to jiffies, replace it with the msecs_to_jiffies() function. Signed-off-by: Barnabás Pőcze Reviewed-by: Hans de Goede diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 29e91942c756..174edbfc52dc 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -190,7 +191,7 @@ static int read_ec_data(acpi_handle handle, int cmd, unsigned long *data) if (method_vpcw(handle, 1, cmd)) return -1; - for (end_jiffies = jiffies+(HZ)*IDEAPAD_EC_TIMEOUT/1000+1; + for (end_jiffies = jiffies + msecs_to_jiffies(IDEAPAD_EC_TIMEOUT) + 1; time_before(jiffies, end_jiffies);) { schedule(); if (method_vpcr(handle, 1, &val)) @@ -216,7 +217,7 @@ static int write_ec_cmd(acpi_handle handle, int cmd, unsigned long data) if (method_vpcw(handle, 1, cmd)) return -1; - for (end_jiffies = jiffies+(HZ)*IDEAPAD_EC_TIMEOUT/1000+1; + for (end_jiffies = jiffies + msecs_to_jiffies(IDEAPAD_EC_TIMEOUT) + 1; time_before(jiffies, end_jiffies);) { schedule(); if (method_vpcr(handle, 1, &val)) From patchwork Wed Jan 13 18:21:08 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: 12017511 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.8 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 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 3D554C433DB for ; Wed, 13 Jan 2021 18:22:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 014DF23436 for ; Wed, 13 Jan 2021 18:22:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728118AbhAMSWE (ORCPT ); Wed, 13 Jan 2021 13:22:04 -0500 Received: from mail-40131.protonmail.ch ([185.70.40.131]:16718 "EHLO mail-40131.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728110AbhAMSWD (ORCPT ); Wed, 13 Jan 2021 13:22:03 -0500 Date: Wed, 13 Jan 2021 18:21:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1610562080; bh=vBkONu6Jei4xIWcqx5RgdZRGm18rGH/qDkfVBKqoJjQ=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=VsySn14zOsVFYMn9/IHGpL3yuolkJgHz4sWbeFLceG9MfIs8d510ueUey0Gn4EU9n DPYGPHTFuoHaiKlWdUySkFSFTOM5+fqS7mpV+4734gKGtfQzTLtk1S0kdJOLsRKoqv DkcCly3Ku59Qrn0oaThQZOu9jkPfXfNm3OWX+Unc= To: platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Gross , Ike Panhc From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v2 07/24] platform/x86: ideapad-laptop: use dev_{err,warn} or appropriate variant to display log messages Message-ID: <20210113182016.166049-8-pobrn@protonmail.com> In-Reply-To: <20210113182016.166049-1-pobrn@protonmail.com> References: <20210113182016.166049-1-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Having the device name in the log message makes it easier to determine in the context of which device the message was printed, so utilize the appropriate variants of dev_{err,warn,...} when printing log messages. Signed-off-by: Barnabás Pőcze Reviewed-by: Hans de Goede diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 174edbfc52dc..b0d8e332b48a 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -203,7 +203,7 @@ static int read_ec_data(acpi_handle handle, int cmd, unsigned long *data) return 0; } } - pr_err("timeout in %s\n", __func__); + acpi_handle_err(handle, "timeout in %s\n", __func__); return -1; } @@ -225,7 +225,7 @@ static int write_ec_cmd(acpi_handle handle, int cmd, unsigned long data) if (val == 0) return 0; } - pr_err("timeout in %s\n", __func__); + acpi_handle_err(handle, "timeout in %s\n", __func__); return -1; } @@ -696,13 +696,15 @@ static int ideapad_input_init(struct ideapad_private *priv) error = sparse_keymap_setup(inputdev, ideapad_keymap, NULL); if (error) { - pr_err("Unable to setup input device keymap\n"); + dev_err(&priv->platform_device->dev, + "Unable to setup input device keymap\n"); goto err_free_dev; } error = input_register_device(inputdev); if (error) { - pr_err("Unable to register input device\n"); + dev_err(&priv->platform_device->dev, + "Unable to register input device\n"); goto err_free_dev; } @@ -756,7 +758,8 @@ static void ideapad_check_special_buttons(struct ideapad_private *priv) ideapad_input_report(priv, 64); break; default: - pr_info("Unknown special button: %lu\n", bit); + dev_warn(&priv->platform_device->dev, + "Unknown special button: %lu\n", bit); break; } } @@ -822,7 +825,8 @@ static int ideapad_backlight_init(struct ideapad_private *priv) &ideapad_backlight_ops, &props); if (IS_ERR(blightdev)) { - pr_err("Could not register backlight device\n"); + dev_warn(&priv->platform_device->dev, + "Could not register backlight device\n"); return PTR_ERR(blightdev); } @@ -934,7 +938,8 @@ static void ideapad_acpi_notify(acpi_handle handle, u32 event, void *data) */ break; default: - pr_info("Unknown event: %lu\n", bit); + dev_warn(&priv->platform_device->dev, + "Unknown event: %lu\n", bit); } } } @@ -942,12 +947,15 @@ static void ideapad_acpi_notify(acpi_handle handle, u32 event, void *data) #if IS_ENABLED(CONFIG_ACPI_WMI) static void ideapad_wmi_notify(u32 value, void *context) { + struct ideapad_private *priv = context; + switch (value) { case 128: - ideapad_input_report(context, value); + ideapad_input_report(priv, value); break; default: - pr_info("Unknown WMI event %u\n", value); + dev_warn(&priv->platform_device->dev, + "Unknown WMI event: %u\n", value); } } #endif From patchwork Wed Jan 13 18:21:18 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: 12017513 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.8 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 AD543C433DB for ; Wed, 13 Jan 2021 18:22:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 662AF23436 for ; Wed, 13 Jan 2021 18:22:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728110AbhAMSWF (ORCPT ); Wed, 13 Jan 2021 13:22:05 -0500 Received: from mail-40134.protonmail.ch ([185.70.40.134]:32265 "EHLO mail-40134.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728117AbhAMSWF (ORCPT ); Wed, 13 Jan 2021 13:22:05 -0500 Date: Wed, 13 Jan 2021 18:21:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1610562080; bh=eJJIwzlS0il/1ITNvxntXc58+a8umAqjQ5OzcNCbq9w=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=oTeVD+ABFh76VdxexrH+Ldl6ImdyDAn2q1cqet+28lecvsv6JYqeS+uRS+/hnpP0P eTx5NOL3vC9A+bG5Zm5n1q7bXF5w77Gj1Ef19huAB/1zybtpQEQhTfbuJFizDUQ48s qXtfcApqKSQ9rvQ8IZNG5+RsHpHfzRbt6iJhtFcY= To: platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Gross , Ike Panhc From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v2 08/24] platform/x86: ideapad-laptop: convert ACPI helpers to return -EIO in case of failure Message-ID: <20210113182016.166049-9-pobrn@protonmail.com> In-Reply-To: <20210113182016.166049-1-pobrn@protonmail.com> References: <20210113182016.166049-1-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org ACPI helpers returned -1 in case of failure. Convert these functions to return appropriate error codes, and convert their users to propagate these error codes accordingly. Signed-off-by: Barnabás Pőcze Reviewed-by: Hans de Goede diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index b0d8e332b48a..9bc6c7340876 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -117,7 +117,7 @@ static int read_method_int(acpi_handle handle, const char *method, int *val) status = acpi_evaluate_integer(handle, (char *)method, NULL, &result); if (ACPI_FAILURE(status)) { *val = -1; - return -1; + return -EIO; } *val = result; return 0; @@ -138,7 +138,7 @@ static int method_int1(acpi_handle handle, char *method, int cmd) acpi_status status; status = acpi_execute_simple_method(handle, method, cmd); - return ACPI_FAILURE(status) ? -1 : 0; + return ACPI_FAILURE(status) ? -EIO : 0; } static int method_vpcr(acpi_handle handle, int cmd, int *ret) @@ -157,7 +157,7 @@ static int method_vpcr(acpi_handle handle, int cmd, int *ret) if (ACPI_FAILURE(status)) { *ret = -1; - return -1; + return -EIO; } *ret = result; return 0; @@ -179,54 +179,60 @@ static int method_vpcw(acpi_handle handle, int cmd, int data) status = acpi_evaluate_object(handle, "VPCW", ¶ms, NULL); if (status != AE_OK) - return -1; + return -EIO; return 0; } static int read_ec_data(acpi_handle handle, int cmd, unsigned long *data) { - int val; + int val, err; unsigned long int end_jiffies; - if (method_vpcw(handle, 1, cmd)) - return -1; + err = method_vpcw(handle, 1, cmd); + if (err) + return err; for (end_jiffies = jiffies + msecs_to_jiffies(IDEAPAD_EC_TIMEOUT) + 1; time_before(jiffies, end_jiffies);) { schedule(); - if (method_vpcr(handle, 1, &val)) - return -1; + err = method_vpcr(handle, 1, &val); + if (err) + return err; if (val == 0) { - if (method_vpcr(handle, 0, &val)) - return -1; + err = method_vpcr(handle, 0, &val); + if (err) + return err; *data = val; return 0; } } acpi_handle_err(handle, "timeout in %s\n", __func__); - return -1; + return -ETIMEDOUT; } static int write_ec_cmd(acpi_handle handle, int cmd, unsigned long data) { - int val; + int val, err; unsigned long int end_jiffies; - if (method_vpcw(handle, 0, data)) - return -1; - if (method_vpcw(handle, 1, cmd)) - return -1; + err = method_vpcw(handle, 0, data); + if (err) + return err; + err = method_vpcw(handle, 1, cmd); + if (err) + return err; for (end_jiffies = jiffies + msecs_to_jiffies(IDEAPAD_EC_TIMEOUT) + 1; time_before(jiffies, end_jiffies);) { schedule(); - if (method_vpcr(handle, 1, &val)) - return -1; + err = method_vpcr(handle, 1, &val); + if (err) + return err; if (val == 0) return 0; } acpi_handle_err(handle, "timeout in %s\n", __func__); - return -1; + return -ETIMEDOUT; } /* @@ -365,8 +371,8 @@ static ssize_t store_ideapad_cam(struct device *dev, if (sscanf(buf, "%i", &state) != 1) return -EINVAL; ret = write_ec_cmd(priv->adev->handle, VPCCMD_W_CAMERA, state); - if (ret < 0) - return -EIO; + if (ret) + return ret; return count; } @@ -398,8 +404,8 @@ static ssize_t store_ideapad_fan(struct device *dev, if (state < 0 || state > 4 || state == 3) return -EINVAL; ret = write_ec_cmd(priv->adev->handle, VPCCMD_W_FAN, state); - if (ret < 0) - return -EIO; + if (ret) + return ret; return count; } @@ -431,8 +437,8 @@ static ssize_t __maybe_unused touchpad_store(struct device *dev, return ret; ret = write_ec_cmd(priv->adev->handle, VPCCMD_W_TOUCHPAD, state); - if (ret < 0) - return -EIO; + if (ret) + return ret; return count; } @@ -465,8 +471,8 @@ static ssize_t conservation_mode_store(struct device *dev, ret = method_int1(priv->adev->handle, "SBMC", state ? BMCMD_CONSERVATION_ON : BMCMD_CONSERVATION_OFF); - if (ret < 0) - return -EIO; + if (ret) + return ret; return count; } @@ -503,8 +509,8 @@ static ssize_t fn_lock_store(struct device *dev, ret = method_int1(priv->adev->handle, "SALS", state ? HACMD_FNLOCK_ON : HACMD_FNLOCK_OFF); - if (ret < 0) - return -EIO; + if (ret) + return ret; return count; } @@ -744,7 +750,8 @@ static void ideapad_check_special_buttons(struct ideapad_private *priv) { unsigned long bit, value; - read_ec_data(priv->adev->handle, VPCCMD_R_SPECIAL_BUTTONS, &value); + if (read_ec_data(priv->adev->handle, VPCCMD_R_SPECIAL_BUTTONS, &value)) + return; for_each_set_bit(bit, &value, 16) { switch (bit) { @@ -772,28 +779,33 @@ static int ideapad_backlight_get_brightness(struct backlight_device *blightdev) { struct ideapad_private *priv = bl_get_data(blightdev); unsigned long now; + int err; if (!priv) return -EINVAL; - if (read_ec_data(priv->adev->handle, VPCCMD_R_BL, &now)) - return -EIO; + err = read_ec_data(priv->adev->handle, VPCCMD_R_BL, &now); + if (err) + return err; return now; } static int ideapad_backlight_update_status(struct backlight_device *blightdev) { struct ideapad_private *priv = bl_get_data(blightdev); + int err; if (!priv) return -EINVAL; - if (write_ec_cmd(priv->adev->handle, VPCCMD_W_BL, - blightdev->props.brightness)) - return -EIO; - if (write_ec_cmd(priv->adev->handle, VPCCMD_W_BL_POWER, - blightdev->props.power == FB_BLANK_POWERDOWN ? 0 : 1)) - return -EIO; + err = write_ec_cmd(priv->adev->handle, VPCCMD_W_BL, + blightdev->props.brightness); + if (err) + return err; + err = write_ec_cmd(priv->adev->handle, VPCCMD_W_BL_POWER, + blightdev->props.power != FB_BLANK_POWERDOWN); + if (err) + return err; return 0; } @@ -808,13 +820,17 @@ static int ideapad_backlight_init(struct ideapad_private *priv) struct backlight_device *blightdev; struct backlight_properties props; unsigned long max, now, power; - - if (read_ec_data(priv->adev->handle, VPCCMD_R_BL_MAX, &max)) - return -EIO; - if (read_ec_data(priv->adev->handle, VPCCMD_R_BL, &now)) - return -EIO; - if (read_ec_data(priv->adev->handle, VPCCMD_R_BL_POWER, &power)) - return -EIO; + int err; + + err = read_ec_data(priv->adev->handle, VPCCMD_R_BL_MAX, &max); + if (err) + return err; + err = read_ec_data(priv->adev->handle, VPCCMD_R_BL, &now); + if (err) + return err; + err = read_ec_data(priv->adev->handle, VPCCMD_R_BL_POWER, &power); + if (err) + return err; memset(&props, 0, sizeof(struct backlight_properties)); props.max_brightness = max; From patchwork Wed Jan 13 18:21:25 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: 12017517 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.8 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 ECDB5C433E0 for ; Wed, 13 Jan 2021 18:22:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B57EE2343F for ; Wed, 13 Jan 2021 18:22:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728111AbhAMSWR (ORCPT ); Wed, 13 Jan 2021 13:22:17 -0500 Received: from mail-40131.protonmail.ch ([185.70.40.131]:34521 "EHLO mail-40131.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728117AbhAMSWR (ORCPT ); Wed, 13 Jan 2021 13:22:17 -0500 Date: Wed, 13 Jan 2021 18:21:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1610562095; bh=cmL6QOuVjVjAGANZm7IFV2R6nniMbDOQF2GAOhbnkC4=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=B4bgQb/FxgO7LEYBLmLd2pmdU2zC44Q4NPmM66rWXH6xDvMBbk7kXToIztzyh8bu5 8E17bg9jWsdbIz7xZaquHydPbcNrbdyf0bYY9WYl0fJA3GtM8BAIhn9ePtl/C048kJ DNwm5a9S0st7jf09QNLIpqvagTCIrY06ECH7BuX0= To: platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Gross , Ike Panhc From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v2 09/24] platform/x86: ideapad-laptop: always propagate error codes from device attributes' show() callback Message-ID: <20210113182016.166049-10-pobrn@protonmail.com> In-Reply-To: <20210113182016.166049-1-pobrn@protonmail.com> References: <20210113182016.166049-1-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Consumers can differentiate an error from a successful read much more easily if the read() call fails with the appropriate errno instead of returning a magic string like "-1". Signed-off-by: Barnabás Pőcze Reviewed-by: Hans de Goede diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 9bc6c7340876..677d4e10352e 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -353,9 +353,11 @@ static ssize_t show_ideapad_cam(struct device *dev, { unsigned long result; struct ideapad_private *priv = dev_get_drvdata(dev); + int err; - if (read_ec_data(priv->adev->handle, VPCCMD_R_CAMERA, &result)) - return sysfs_emit(buf, "-1\n"); + err = read_ec_data(priv->adev->handle, VPCCMD_R_CAMERA, &result); + if (err) + return err; return sysfs_emit(buf, "%lu\n", result); } @@ -384,9 +386,11 @@ static ssize_t show_ideapad_fan(struct device *dev, { unsigned long result; struct ideapad_private *priv = dev_get_drvdata(dev); + int err; - if (read_ec_data(priv->adev->handle, VPCCMD_R_FAN, &result)) - return sysfs_emit(buf, "-1\n"); + err = read_ec_data(priv->adev->handle, VPCCMD_R_FAN, &result); + if (err) + return err; return sysfs_emit(buf, "%lu\n", result); } @@ -417,9 +421,11 @@ static ssize_t touchpad_show(struct device *dev, { struct ideapad_private *priv = dev_get_drvdata(dev); unsigned long result; + int err; - if (read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &result)) - return sysfs_emit(buf, "-1\n"); + err = read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &result); + if (err) + return err; return sysfs_emit(buf, "%lu\n", result); } @@ -450,9 +456,11 @@ static ssize_t conservation_mode_show(struct device *dev, { struct ideapad_private *priv = dev_get_drvdata(dev); unsigned long result; + int err; - if (method_gbmd(priv->adev->handle, &result)) - return sysfs_emit(buf, "-1\n"); + err = method_gbmd(priv->adev->handle, &result); + if (err) + return err; return sysfs_emit(buf, "%u\n", test_bit(BM_CONSERVATION_BIT, &result)); } @@ -488,7 +496,7 @@ static ssize_t fn_lock_show(struct device *dev, int fail = read_method_int(priv->adev->handle, "HALS", &hals); if (fail) - return sysfs_emit(buf, "-1\n"); + return fail; result = hals; return sysfs_emit(buf, "%u\n", test_bit(HA_FNLOCK_BIT, &result)); From patchwork Wed Jan 13 18:21:30 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: 12017515 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.8 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 C4B2BC433E6 for ; Wed, 13 Jan 2021 18:22:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E1022343E for ; Wed, 13 Jan 2021 18:22:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728146AbhAMSWQ (ORCPT ); Wed, 13 Jan 2021 13:22:16 -0500 Received: from mail2.protonmail.ch ([185.70.40.22]:38090 "EHLO mail2.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728111AbhAMSWQ (ORCPT ); Wed, 13 Jan 2021 13:22:16 -0500 Date: Wed, 13 Jan 2021 18:21:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1610562092; bh=qwOcPHx8CghzjRJLnaroNCyPJmkDiZo+MrHBCOEZaww=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=m7CSAdY13oqDJpXZaPDQIvDbVskdY+kGAl//yhjyyuK83J1Pnq5iszqTsrTdjxKTT JVE8Al0+U1tJgJotKBGiqUNm22wBxmoaFEd0Qeunt9V8G0EjrzV5BSnIDr9asRMhlz vbbXYG//UXrMscZQ+HY0VjeoUdmfPoVghh3FK5Vg= To: platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Gross , Ike Panhc From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v2 10/24] platform/x86: ideapad-laptop: misc. device attribute changes Message-ID: <20210113182016.166049-11-pobrn@protonmail.com> In-Reply-To: <20210113182016.166049-1-pobrn@protonmail.com> References: <20210113182016.166049-1-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Do not handle zero length buffer separately. Use kstrtouint() instead of sscanf(). Signed-off-by: Barnabás Pőcze Reviewed-by: Hans de Goede diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 677d4e10352e..cba3d9419f52 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -365,13 +365,13 @@ static ssize_t store_ideapad_cam(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - int ret, state; + int ret; struct ideapad_private *priv = dev_get_drvdata(dev); + unsigned int state; - if (!count) - return 0; - if (sscanf(buf, "%i", &state) != 1) - return -EINVAL; + ret = kstrtouint(buf, 0, &state); + if (ret) + return ret; ret = write_ec_cmd(priv->adev->handle, VPCCMD_W_CAMERA, state); if (ret) return ret; @@ -398,14 +398,14 @@ static ssize_t store_ideapad_fan(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - int ret, state; + int ret; struct ideapad_private *priv = dev_get_drvdata(dev); + unsigned int state; - if (!count) - return 0; - if (sscanf(buf, "%i", &state) != 1) - return -EINVAL; - if (state < 0 || state > 4 || state == 3) + ret = kstrtouint(buf, 0, &state); + if (ret) + return ret; + if (state > 4 || state == 3) return -EINVAL; ret = write_ec_cmd(priv->adev->handle, VPCCMD_W_FAN, state); if (ret) From patchwork Wed Jan 13 18:21:35 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: 12017519 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.8 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 809DAC433E9 for ; Wed, 13 Jan 2021 18:22:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D5CB23436 for ; Wed, 13 Jan 2021 18:22:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728152AbhAMSWY (ORCPT ); Wed, 13 Jan 2021 13:22:24 -0500 Received: from mail2.protonmail.ch ([185.70.40.22]:39244 "EHLO mail2.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728117AbhAMSWX (ORCPT ); Wed, 13 Jan 2021 13:22:23 -0500 Date: Wed, 13 Jan 2021 18:21:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1610562101; bh=EnZuNMH7q1iKYXqK67NYqRBHD0iessAfjOpE2E/Sxsg=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=l89WuHcjRugPvABniAjeePla6rNbt1262lPEhBBqD/yalhPRJVO1ZXtUB9fsZGzcj 6wmejoJlg4ab+dX/sF2sShsbnRmtAx1JQV4YwcdkdYuNUpl4FrJNdvQ4XxEeqKz4FA XiRc9Jtj0m3znk7xo03rVs7JUoyPCTMCybEdKqFo= To: platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Gross , Ike Panhc From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v2 11/24] platform/x86: ideapad-laptop: group and separate (un)related constants into enums Message-ID: <20210113182016.166049-12-pobrn@protonmail.com> In-Reply-To: <20210113182016.166049-1-pobrn@protonmail.com> References: <20210113182016.166049-1-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 diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index cba3d9419f52..5f36e77d9058 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -32,14 +32,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 */ @@ -48,10 +40,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 { @@ -278,7 +288,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); } @@ -295,13 +305,13 @@ static int debugfs_cfg_show(struct seq_file *s, void *data) } else { 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) { @@ -461,7 +471,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, "%u\n", test_bit(BM_CONSERVATION_BIT, &result)); + return sysfs_emit(buf, "%u\n", test_bit(GBMD_CONSERVATION_STATE_BIT, &result)); } static ssize_t conservation_mode_store(struct device *dev, @@ -477,8 +487,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; @@ -499,7 +509,7 @@ static ssize_t fn_lock_show(struct device *dev, return fail; result = hals; - return sysfs_emit(buf, "%u\n", test_bit(HA_FNLOCK_BIT, &result)); + return sysfs_emit(buf, "%u\n", test_bit(HALS_FNLOCK_STATE_BIT, &result)); } static ssize_t fn_lock_store(struct device *dev, @@ -515,8 +525,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; @@ -543,7 +553,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, @@ -578,9 +588,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) From patchwork Wed Jan 13 18:21:44 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: 12017521 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.8 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 8BBCFC433DB for ; Wed, 13 Jan 2021 18:22:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4DE2F23441 for ; Wed, 13 Jan 2021 18:22:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727851AbhAMSWd (ORCPT ); Wed, 13 Jan 2021 13:22:33 -0500 Received: from mail2.protonmail.ch ([185.70.40.22]:26280 "EHLO mail2.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726385AbhAMSWc (ORCPT ); Wed, 13 Jan 2021 13:22:32 -0500 Date: Wed, 13 Jan 2021 18:21:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1610562108; bh=WypS/mQ7Bcw5YU+gDNdIXzxr4CA5eWGEajvvrVc38z0=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=h9i6LkOTYACQC1sus5AWnEd8/8el+srV1VIVg+7AHL/mENam7teOraUOn1PzKNSRK F3COafQazhrxuI/ZgLAlAdTedjxkc9un+fEFufk0txSEfjG72UBoxORJPUn/5oOiPw 2hBNeawr0SeeuLl5Bd2Lw+Q7iPesMxKuIjrOOZp8= To: platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Gross , Ike Panhc From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v2 12/24] platform/x86: ideapad-laptop: rework and create new ACPI helpers Message-ID: <20210113182016.166049-13-pobrn@protonmail.com> In-Reply-To: <20210113182016.166049-1-pobrn@protonmail.com> References: <20210113182016.166049-1-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Create dedicated helper functions for accessing the main ACPI methods: GBMD, SMBC, HALS, SALS; and utilize them. Use `unsigned long` consistently in every ACPI helper wherever possible. Change names to better express purpose. Do not assign values to output parameters in case of failure. Signed-off-by: Barnabás Pőcze Reviewed-by: Hans de Goede diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 5f36e77d9058..c3234e0931a9 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -119,41 +119,47 @@ MODULE_PARM_DESC(no_bt_rfkill, "No rfkill for bluetooth."); */ #define IDEAPAD_EC_TIMEOUT (200) /* in ms */ -static int read_method_int(acpi_handle handle, const char *method, int *val) +static int eval_int(acpi_handle handle, const char *method, unsigned long *val) { - acpi_status status; + acpi_status acpi_err; unsigned long long result; - status = acpi_evaluate_integer(handle, (char *)method, NULL, &result); - if (ACPI_FAILURE(status)) { - *val = -1; + acpi_err = acpi_evaluate_integer(handle, (char *)method, NULL, &result); + if (ACPI_FAILURE(acpi_err)) return -EIO; - } *val = result; return 0; +} +static int eval_simple_method(acpi_handle handle, char *method, u64 arg) +{ + acpi_status acpi_err = acpi_execute_simple_method(handle, method, arg); + return ACPI_FAILURE(acpi_err) ? -EIO : 0; } -static int method_gbmd(acpi_handle handle, unsigned long *ret) +static int eval_gbmd(acpi_handle handle, unsigned long *val) { - int result, val; + return eval_int(handle, "GBMD", val); +} - result = read_method_int(handle, "GBMD", &val); - *ret = val; - return result; +static int eval_smbc(acpi_handle handle, unsigned long arg) +{ + return eval_simple_method(handle, "SMBC", arg); } -static int method_int1(acpi_handle handle, char *method, int cmd) +static int eval_hals(acpi_handle handle, unsigned long *val) { - acpi_status status; + return eval_int(handle, "HALS", val); +} - status = acpi_execute_simple_method(handle, method, cmd); - return ACPI_FAILURE(status) ? -EIO : 0; +static int eval_sals(acpi_handle handle, unsigned long arg) +{ + return eval_simple_method(handle, "SALS", arg); } -static int method_vpcr(acpi_handle handle, int cmd, int *ret) +static int eval_vpcr(acpi_handle handle, unsigned long cmd, unsigned long *val) { - acpi_status status; + acpi_status acpi_err; unsigned long long result; struct acpi_object_list params; union acpi_object in_obj; @@ -163,22 +169,20 @@ static int method_vpcr(acpi_handle handle, int cmd, int *ret) in_obj.type = ACPI_TYPE_INTEGER; in_obj.integer.value = cmd; - status = acpi_evaluate_integer(handle, "VPCR", ¶ms, &result); + acpi_err = acpi_evaluate_integer(handle, "VPCR", ¶ms, &result); - if (ACPI_FAILURE(status)) { - *ret = -1; + if (ACPI_FAILURE(acpi_err)) return -EIO; - } - *ret = result; + *val = result; return 0; } -static int method_vpcw(acpi_handle handle, int cmd, int data) +static int eval_vpcw(acpi_handle handle, unsigned long cmd, unsigned long data) { struct acpi_object_list params; union acpi_object in_obj[2]; - acpi_status status; + acpi_status acpi_err; params.count = 2; params.pointer = in_obj; @@ -187,55 +191,50 @@ static int method_vpcw(acpi_handle handle, int cmd, int data) in_obj[1].type = ACPI_TYPE_INTEGER; in_obj[1].integer.value = data; - status = acpi_evaluate_object(handle, "VPCW", ¶ms, NULL); - if (status != AE_OK) + acpi_err = acpi_evaluate_object(handle, "VPCW", ¶ms, NULL); + if (ACPI_FAILURE(acpi_err)) return -EIO; return 0; } -static int read_ec_data(acpi_handle handle, int cmd, unsigned long *data) +static int read_ec_data(acpi_handle handle, unsigned long cmd, unsigned long *data) { - int val, err; - unsigned long int end_jiffies; + int err; + unsigned long int end_jiffies, val; - err = method_vpcw(handle, 1, cmd); + err = eval_vpcw(handle, 1, cmd); if (err) return err; for (end_jiffies = jiffies + msecs_to_jiffies(IDEAPAD_EC_TIMEOUT) + 1; time_before(jiffies, end_jiffies);) { schedule(); - err = method_vpcr(handle, 1, &val); + err = eval_vpcr(handle, 1, &val); if (err) return err; - if (val == 0) { - err = method_vpcr(handle, 0, &val); - if (err) - return err; - *data = val; - return 0; - } + if (val == 0) + return eval_vpcr(handle, 0, data); } acpi_handle_err(handle, "timeout in %s\n", __func__); return -ETIMEDOUT; } -static int write_ec_cmd(acpi_handle handle, int cmd, unsigned long data) +static int write_ec_cmd(acpi_handle handle, unsigned long cmd, unsigned long data) { - int val, err; - unsigned long int end_jiffies; + int err; + unsigned long end_jiffies, val; - err = method_vpcw(handle, 0, data); + err = eval_vpcw(handle, 0, data); if (err) return err; - err = method_vpcw(handle, 1, cmd); + err = eval_vpcw(handle, 1, cmd); if (err) return err; for (end_jiffies = jiffies + msecs_to_jiffies(IDEAPAD_EC_TIMEOUT) + 1; time_before(jiffies, end_jiffies);) { schedule(); - err = method_vpcr(handle, 1, &val); + err = eval_vpcr(handle, 1, &val); if (err) return err; if (val == 0) @@ -286,7 +285,7 @@ static int debugfs_status_show(struct seq_file *s, void *data) value ? "On" : "Off", value); seq_puts(s, "=====================\n"); - if (!method_gbmd(priv->adev->handle, &value)) { + if (!eval_gbmd(priv->adev->handle, &value)) { seq_printf(s, "Conservation mode:\t%s(%lu)\n", test_bit(GBMD_CONSERVATION_STATE_BIT, &value) ? "On" : "Off", value); @@ -468,7 +467,7 @@ static ssize_t conservation_mode_show(struct device *dev, unsigned long result; int err; - err = method_gbmd(priv->adev->handle, &result); + err = eval_gbmd(priv->adev->handle, &result); if (err) return err; return sysfs_emit(buf, "%u\n", test_bit(GBMD_CONSERVATION_STATE_BIT, &result)); @@ -486,9 +485,8 @@ static ssize_t conservation_mode_store(struct device *dev, if (ret) return ret; - ret = method_int1(priv->adev->handle, "SBMC", state ? - SMBC_CONSERVATION_ON : - SMBC_CONSERVATION_OFF); + ret = eval_smbc(priv->adev->handle, + state ? SMBC_CONSERVATION_ON : SMBC_CONSERVATION_OFF); if (ret) return ret; return count; @@ -501,15 +499,13 @@ static ssize_t fn_lock_show(struct device *dev, char *buf) { struct ideapad_private *priv = dev_get_drvdata(dev); - unsigned long result; - int hals; - int fail = read_method_int(priv->adev->handle, "HALS", &hals); + unsigned long hals; + int fail = eval_hals(priv->adev->handle, &hals); if (fail) return fail; - result = hals; - return sysfs_emit(buf, "%u\n", test_bit(HALS_FNLOCK_STATE_BIT, &result)); + return sysfs_emit(buf, "%u\n", test_bit(HALS_FNLOCK_STATE_BIT, &hals)); } static ssize_t fn_lock_store(struct device *dev, @@ -524,9 +520,8 @@ static ssize_t fn_lock_store(struct device *dev, if (ret) return ret; - ret = method_int1(priv->adev->handle, "SALS", state ? - SALS_FNLOCK_ON : - SALS_FNLOCK_OFF); + ret = eval_sals(priv->adev->handle, + state ? SALS_FNLOCK_ON : SALS_FNLOCK_OFF); if (ret) return ret; return count; @@ -1016,7 +1011,7 @@ static const struct dmi_system_id hw_rfkill_list[] = { static int ideapad_acpi_add(struct platform_device *pdev) { int ret, i; - int cfg; + unsigned long cfg; struct ideapad_private *priv; struct acpi_device *adev; acpi_status acpi_err; @@ -1025,7 +1020,7 @@ static int ideapad_acpi_add(struct platform_device *pdev) if (ret) return -ENODEV; - if (read_method_int(adev->handle, "_CFG", &cfg)) + if (eval_int(adev->handle, "_CFG", &cfg)) return -ENODEV; priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); From patchwork Wed Jan 13 18:21:49 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: 12017525 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.8 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 E8BABC433DB for ; Wed, 13 Jan 2021 18:22:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B75082343E for ; Wed, 13 Jan 2021 18:22:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727785AbhAMSW6 (ORCPT ); Wed, 13 Jan 2021 13:22:58 -0500 Received: from mail2.protonmail.ch ([185.70.40.22]:52658 "EHLO mail2.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726385AbhAMSW6 (ORCPT ); Wed, 13 Jan 2021 13:22:58 -0500 Date: Wed, 13 Jan 2021 18:21:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1610562111; bh=vp9uEKkUhqrTJs6wmjxS71ZUosdJefwI9tYJ9zSNYuQ=; h=Date:To:From:Reply-To:Subject:From; b=r2iekdHIOod1x5AzV51lXsxpaCSzfMAPZlWuFdduAiCxDwl4rtBK2gnuTefgLu5oq 5UGVvySWbt6O0jM6IRKESEQx0AJJX7TRuywbFaUuR1B8eFX+/LMA78D4Niufib08Nz 2aSP+opVnMO+KXc70XGnLvxO3Fu+0d7Yo4Pk9s3g= To: platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Gross , Ike Panhc From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v2 13/24] platform/x86: ideapad-laptop: rework is_visible() logic Message-ID: <20210113182016.166049-14-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Store the supported features in the driver private data, and modify the is_visible() callback to use it, and create ideapad_check_features() to populate it. Signed-off-by: Barnabás Pőcze diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index c3234e0931a9..15d070b503dc 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -105,9 +105,14 @@ struct ideapad_private { struct backlight_device *blightdev; struct dentry *debug; unsigned long cfg; - bool has_hw_rfkill_switch; - bool has_touchpad_switch; const char *fnesc_guid; + struct { + bool hw_rfkill_switch : 1, + fan_mode : 1, + touchpad_ctrl_via_ec : 1, + conservation_mode : 1, + fn_lock : 1; + } features; }; static bool no_bt_rfkill; @@ -545,24 +550,18 @@ static umode_t ideapad_is_visible(struct kobject *kobj, { struct device *dev = container_of(kobj, struct device, kobj); struct ideapad_private *priv = dev_get_drvdata(dev); - bool supported; + bool supported = true; if (attr == &dev_attr_camera_power.attr) 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, - &value); - } else if (attr == &dev_attr_conservation_mode.attr) { - supported = acpi_has_method(priv->adev->handle, "GBMD") && - acpi_has_method(priv->adev->handle, "SBMC"); - } else if (attr == &dev_attr_fn_lock.attr) { - supported = acpi_has_method(priv->adev->handle, "HALS") && - acpi_has_method(priv->adev->handle, "SALS"); - } else if (attr == &dev_attr_touchpad.attr) - supported = priv->has_touchpad_switch; - else - supported = true; + else if (attr == &dev_attr_fan_mode.attr) + supported = priv->features.fan_mode; + else if (attr == &dev_attr_touchpad.attr) + supported = priv->features.touchpad_ctrl_via_ec; + else if (attr == &dev_attr_conservation_mode.attr) + supported = priv->features.conservation_mode; + else if (attr == &dev_attr_fn_lock.attr) + supported = priv->features.fn_lock; return supported ? attr->mode : 0; } @@ -605,7 +604,7 @@ static void ideapad_sync_rfk_state(struct ideapad_private *priv) unsigned long hw_blocked = 0; int i; - if (priv->has_hw_rfkill_switch) { + if (priv->features.hw_rfkill_switch) { if (read_ec_data(priv->adev->handle, VPCCMD_R_RF, &hw_blocked)) return; hw_blocked = !hw_blocked; @@ -905,7 +904,7 @@ static void ideapad_sync_touchpad_state(struct ideapad_private *priv) { unsigned long value; - if (!priv->has_touchpad_switch) + if (!priv->features.touchpad_ctrl_via_ec) return; /* Without reading from EC touchpad LED doesn't switch state */ @@ -1008,6 +1007,26 @@ static const struct dmi_system_id hw_rfkill_list[] = { {} }; +static void ideapad_check_features(struct ideapad_private *priv) +{ + acpi_handle handle = priv->adev->handle; + unsigned long val; + + priv->features.hw_rfkill_switch = dmi_check_system(hw_rfkill_list); + + if (!read_ec_data(handle, VPCCMD_R_FAN, &val)) + priv->features.fan_mode = true; + + /* Most ideapads with ELAN0634 touchpad don't use EC touchpad switch */ + priv->features.touchpad_ctrl_via_ec = !acpi_dev_present("ELAN0634", NULL, -1); + + if (acpi_has_method(handle, "GBMD") && acpi_has_method(handle, "SBMC")) + priv->features.conservation_mode = true; + + if (acpi_has_method(handle, "HALS") && acpi_has_method(handle, "SALS")) + priv->features.fn_lock = true; +} + static int ideapad_acpi_add(struct platform_device *pdev) { int ret, i; @@ -1031,10 +1050,8 @@ static int ideapad_acpi_add(struct platform_device *pdev) priv->cfg = cfg; priv->adev = adev; priv->platform_device = pdev; - priv->has_hw_rfkill_switch = dmi_check_system(hw_rfkill_list); - /* Most ideapads with ELAN0634 touchpad don't use EC touchpad switch */ - priv->has_touchpad_switch = !acpi_dev_present("ELAN0634", NULL, -1); + ideapad_check_features(priv); ret = ideapad_sysfs_init(priv); if (ret) @@ -1050,11 +1067,11 @@ static int ideapad_acpi_add(struct platform_device *pdev) * On some models without a hw-switch (the yoga 2 13 at least) * VPCCMD_W_RF must be explicitly set to 1 for the wifi to work. */ - if (!priv->has_hw_rfkill_switch) + if (!priv->features.hw_rfkill_switch) write_ec_cmd(priv->adev->handle, VPCCMD_W_RF, 1); /* The same for Touchpad */ - if (!priv->has_touchpad_switch) + if (!priv->features.touchpad_ctrl_via_ec) write_ec_cmd(priv->adev->handle, VPCCMD_W_TOUCHPAD, 1); for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++) From patchwork Wed Jan 13 18:22:01 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: 12017529 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.8 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 9631FC433DB for ; Wed, 13 Jan 2021 18:23:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1AA622343E for ; Wed, 13 Jan 2021 18:23:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727789AbhAMSXF (ORCPT ); Wed, 13 Jan 2021 13:23:05 -0500 Received: from mail2.protonmail.ch ([185.70.40.22]:60685 "EHLO mail2.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727560AbhAMSXF (ORCPT ); Wed, 13 Jan 2021 13:23:05 -0500 Date: Wed, 13 Jan 2021 18:22:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1610562126; bh=DJg0p2SesxIsj7ExXZMMDkIhyjP0Fg/9Hp2COjQjT8U=; h=Date:To:From:Reply-To:Subject:From; b=veokDkvujO2N9a4xU3309eOQDGF9ZtK847yAa4o1xE4VBGC7lNT1sCezGtWqvLmF0 WbG03UGGHWwbZZ/ZZORo9Gwx9zqbjwah8E9VcWUKuamz4/8hjZsePJOAXBxZs6rUlS s7PBSaNbrZgOK7e410QYweS/Z9qSKDhAeB+JfoW8= To: platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Gross , Ike Panhc From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v2 14/24] platform/x86: ideapad-laptop: check for Fn-lock support in HALS Message-ID: <20210113182016.166049-15-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Bit 9 in the return value of the HALS ACPI method is set if Fn-lock is supported. Change ideapad_check_features() to check it. Signed-off-by: Barnabás Pőcze Reviewed-by: Hans de Goede diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 15d070b503dc..640a00cc3944 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -56,7 +56,9 @@ enum { }; enum { - HALS_FNLOCK_STATE_BIT = 10, + HALS_FNLOCK_SUPPORT_BIT = 9, + HALS_FNLOCK_STATE_BIT = 10, + HALS_HOTKEYS_PRIMARY_BIT = 11, }; enum { @@ -1023,8 +1025,11 @@ static void ideapad_check_features(struct ideapad_private *priv) if (acpi_has_method(handle, "GBMD") && acpi_has_method(handle, "SBMC")) priv->features.conservation_mode = true; - if (acpi_has_method(handle, "HALS") && acpi_has_method(handle, "SALS")) - priv->features.fn_lock = true; + if (acpi_has_method(handle, "HALS") && acpi_has_method(handle, "SALS")) { + if (!eval_hals(handle, &val)) + if (test_bit(HALS_FNLOCK_SUPPORT_BIT, &val)) + priv->features.fn_lock = true; + } } static int ideapad_acpi_add(struct platform_device *pdev) From patchwork Wed Jan 13 18:22:08 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: 12017523 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.8 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 64920C433DB for ; Wed, 13 Jan 2021 18:22:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 019462343E for ; Wed, 13 Jan 2021 18:22:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727254AbhAMSWx (ORCPT ); Wed, 13 Jan 2021 13:22:53 -0500 Received: from mail-40136.protonmail.ch ([185.70.40.136]:19163 "EHLO mail-40136.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726385AbhAMSWx (ORCPT ); Wed, 13 Jan 2021 13:22:53 -0500 Date: Wed, 13 Jan 2021 18:22:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1610562130; bh=+Umh2lh5adR8/pbRvi/Z2y7HSwLc7Tl+ieu9qagxOA4=; h=Date:To:From:Reply-To:Subject:From; b=lpSuHPzQy3COJ4c0LUgUphCRace739X/FRPYCqlPhkQG+OOB/KX0/+7fb3Hh1iVmV yqicAdW3tqRWiKTf240LMvuB5tLGyILgTiYOEwebEULORFCrB2plJt9I5kuB+mVfZh pzb2XfIteQV+tC0zlpTCQPeAYhRjmIZ/SZqvK2XE= To: platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Gross , Ike Panhc From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v2 15/24] platform/x86: ideapad-laptop: check for touchpad support in _CFG Message-ID: <20210113182016.166049-16-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Bit 30 of _CFG is set if the device has a touchpad, check that in is_visible() for the touchpad attribute. Show 'touchpad', if supported, in the list of capabilities in the 'cfg' debugfs file. Signed-off-by: Barnabás Pőcze diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 640a00cc3944..057426729536 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -40,10 +40,11 @@ static const char *const ideapad_wmi_fnesc_events[] = { #endif enum { - CFG_CAP_BT_BIT = 16, - CFG_CAP_3G_BIT = 17, - CFG_CAP_WIFI_BIT = 18, - CFG_CAP_CAM_BIT = 19, + CFG_CAP_BT_BIT = 16, + CFG_CAP_3G_BIT = 17, + CFG_CAP_WIFI_BIT = 18, + CFG_CAP_CAM_BIT = 19, + CFG_CAP_TOUCHPAD_BIT = 30, }; enum { @@ -319,6 +320,8 @@ static int debugfs_cfg_show(struct seq_file *s, void *data) seq_printf(s, "Wireless "); if (test_bit(CFG_CAP_CAM_BIT, &priv->cfg)) seq_printf(s, "Camera "); + if (test_bit(CFG_CAP_TOUCHPAD_BIT, &priv->cfg)) + seq_printf(s, "Touchpad "); seq_printf(s, "\nGraphic: "); switch ((priv->cfg)&0x700) { case 0x100: @@ -559,7 +562,8 @@ static umode_t ideapad_is_visible(struct kobject *kobj, else if (attr == &dev_attr_fan_mode.attr) supported = priv->features.fan_mode; else if (attr == &dev_attr_touchpad.attr) - supported = priv->features.touchpad_ctrl_via_ec; + supported = priv->features.touchpad_ctrl_via_ec + && test_bit(CFG_CAP_TOUCHPAD_BIT, &priv->cfg); else if (attr == &dev_attr_conservation_mode.attr) supported = priv->features.conservation_mode; else if (attr == &dev_attr_fn_lock.attr) From patchwork Wed Jan 13 18:22:13 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: 12017527 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.8 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 F2AE1C433DB for ; Wed, 13 Jan 2021 18:23:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C1B742343E for ; Wed, 13 Jan 2021 18:23:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726385AbhAMSXA (ORCPT ); Wed, 13 Jan 2021 13:23:00 -0500 Received: from mail-40136.protonmail.ch ([185.70.40.136]:51336 "EHLO mail-40136.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727560AbhAMSXA (ORCPT ); Wed, 13 Jan 2021 13:23:00 -0500 Date: Wed, 13 Jan 2021 18:22:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1610562137; bh=eXIYyDfjxzvjzxc0grGny/O4Ti+83xM/pWez4F/9rfw=; h=Date:To:From:Reply-To:Subject:From; b=gjbZ75zMqZ9ai/Fb4sd7hgeLqEAC1enuL4StRTWPSa32d+Pj34dI0hZT/ovniKuAf d5XzOSACW+q+DVp382uojC0LZz+PS0sujhC4d/luP7ra7fbZA3Wh/RLXyBK6tTJSSR bpM99/ZDDDdOcFbiOGhuW8xClE/PFPQD5jyUOD0g= To: platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Gross , Ike Panhc From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v2 16/24] platform/x86: ideapad-laptop: change 'status' debugfs file format Message-ID: <20210113182016.166049-17-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Remove conservation mode reporting since it is already reported via the appropriate device attribute, and its state can be deduced from the value of GBMD. Add the return value of the GBMD and HALS ACPI methods to the output. Change the return value to -ENODATA when the driver-specific data is not available. Use seq_puts() where possible. Signed-off-by: Barnabás Pőcze Reviewed-by: Hans de Goede diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 057426729536..c72e967e9ac2 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -261,43 +261,36 @@ static int debugfs_status_show(struct seq_file *s, void *data) unsigned long value; if (!priv) - return -EINVAL; + return -ENODATA; if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL_MAX, &value)) seq_printf(s, "Backlight max:\t%lu\n", value); if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL, &value)) seq_printf(s, "Backlight now:\t%lu\n", value); if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL_POWER, &value)) - seq_printf(s, "BL power value:\t%s\n", value ? "On" : "Off"); - seq_printf(s, "=====================\n"); + seq_printf(s, "BL power value:\t%s (%lu)\n", value ? "on" : "off", value); + seq_puts(s, "=====================\n"); if (!read_ec_data(priv->adev->handle, VPCCMD_R_RF, &value)) - seq_printf(s, "Radio status:\t%s(%lu)\n", - value ? "On" : "Off", value); + seq_printf(s, "Radio status:\t%s (%lu)\n", value ? "on" : "off", value); if (!read_ec_data(priv->adev->handle, VPCCMD_R_WIFI, &value)) - seq_printf(s, "Wifi status:\t%s(%lu)\n", - value ? "On" : "Off", value); + seq_printf(s, "Wifi status:\t%s (%lu)\n", value ? "on" : "off", value); if (!read_ec_data(priv->adev->handle, VPCCMD_R_BT, &value)) - seq_printf(s, "BT status:\t%s(%lu)\n", - value ? "On" : "Off", value); + seq_printf(s, "BT status:\t%s (%lu)\n", value ? "on" : "off", value); if (!read_ec_data(priv->adev->handle, VPCCMD_R_3G, &value)) - seq_printf(s, "3G status:\t%s(%lu)\n", - value ? "On" : "Off", value); - seq_printf(s, "=====================\n"); + seq_printf(s, "3G status:\t%s (%lu)\n", value ? "on" : "off", value); + seq_puts(s, "=====================\n"); if (!read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &value)) - seq_printf(s, "Touchpad status:%s(%lu)\n", - value ? "On" : "Off", value); + seq_printf(s, "Touchpad status:\t%s (%lu)\n", value ? "on" : "off", value); if (!read_ec_data(priv->adev->handle, VPCCMD_R_CAMERA, &value)) - seq_printf(s, "Camera status:\t%s(%lu)\n", - value ? "On" : "Off", value); + seq_printf(s, "Camera status:\t%s (%lu)\n", value ? "on" : "off", value); seq_puts(s, "=====================\n"); - if (!eval_gbmd(priv->adev->handle, &value)) { - seq_printf(s, "Conservation mode:\t%s(%lu)\n", - test_bit(GBMD_CONSERVATION_STATE_BIT, &value) ? "On" : "Off", - value); - } + if (!eval_gbmd(priv->adev->handle, &value)) + seq_printf(s, "GBMD: %#010lx\n", value); + if (!eval_hals(priv->adev->handle, &value)) + seq_printf(s, "HALS: %#010lx\n", value); return 0; } From patchwork Wed Jan 13 18:22:18 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: 12017531 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.8 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 3FFE6C433DB for ; Wed, 13 Jan 2021 18:23:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C36F2343E for ; Wed, 13 Jan 2021 18:23:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728073AbhAMSXH (ORCPT ); Wed, 13 Jan 2021 13:23:07 -0500 Received: from mail-40136.protonmail.ch ([185.70.40.136]:22149 "EHLO mail-40136.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727896AbhAMSXH (ORCPT ); Wed, 13 Jan 2021 13:23:07 -0500 Date: Wed, 13 Jan 2021 18:22:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1610562145; bh=K2o8TvzMdYiUQqqneSHCCAo3Araw2IxZIDIwcE1UEbE=; h=Date:To:From:Reply-To:Subject:From; b=vwiDx2n+9YZ6zXdu5k/VvowV7UkbdcAg3et5TrxtubCGbvIiNBvCEAjgZVxP4uqzf W8e3qODhca34le2t+Z/jO2ImskHAWsKIgiYbJC79TvDo+Dcxt73k10/prjWRHohhr4 oBJkWCDxEwjQV0fCRDHS6PdcVVWFy+Pvtqwl/26M= To: platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Gross , Ike Panhc From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v2 17/24] platform/x86: ideapad-laptop: change 'cfg' debugfs file format Message-ID: <20210113182016.166049-18-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Return -ENODATA when the driver-specific data is not available. Minor formatting changes. Use seq_puts() where possible. Signed-off-by: Barnabás Pőcze Reviewed-by: Hans de Goede diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index c72e967e9ac2..cd4dc4048d71 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -300,41 +300,44 @@ static int debugfs_cfg_show(struct seq_file *s, void *data) { struct ideapad_private *priv = s->private; - if (!priv) { - seq_printf(s, "cfg: N/A\n"); - } else { - seq_printf(s, "cfg: 0x%.8lX\n\nCapability: ", - priv->cfg); - if (test_bit(CFG_CAP_BT_BIT, &priv->cfg)) - seq_printf(s, "Bluetooth "); - if (test_bit(CFG_CAP_3G_BIT, &priv->cfg)) - seq_printf(s, "3G "); - if (test_bit(CFG_CAP_WIFI_BIT, &priv->cfg)) - seq_printf(s, "Wireless "); - if (test_bit(CFG_CAP_CAM_BIT, &priv->cfg)) - seq_printf(s, "Camera "); - if (test_bit(CFG_CAP_TOUCHPAD_BIT, &priv->cfg)) - seq_printf(s, "Touchpad "); - seq_printf(s, "\nGraphic: "); - switch ((priv->cfg)&0x700) { - case 0x100: - seq_printf(s, "Intel"); - break; - case 0x200: - seq_printf(s, "ATI"); - break; - case 0x300: - seq_printf(s, "Nvidia"); - break; - case 0x400: - seq_printf(s, "Intel and ATI"); - break; - case 0x500: - seq_printf(s, "Intel and Nvidia"); - break; - } - seq_printf(s, "\n"); + if (!priv) + return -ENODATA; + + seq_printf(s, "_CFG: %#010lx\n\n", priv->cfg); + + seq_puts(s, "Capabilities:"); + if (test_bit(CFG_CAP_BT_BIT, &priv->cfg)) + seq_puts(s, " bluetooth"); + if (test_bit(CFG_CAP_3G_BIT, &priv->cfg)) + seq_puts(s, " 3G"); + if (test_bit(CFG_CAP_WIFI_BIT, &priv->cfg)) + seq_puts(s, " wifi"); + if (test_bit(CFG_CAP_CAM_BIT, &priv->cfg)) + seq_puts(s, " camera"); + if (test_bit(CFG_CAP_TOUCHPAD_BIT, &priv->cfg)) + seq_puts(s, " touchpad"); + seq_puts(s, "\n"); + + seq_puts(s, "Graphics:"); + switch (priv->cfg & 0x700) { + case 0x100: + seq_puts(s, "Intel"); + break; + case 0x200: + seq_puts(s, "ATI"); + break; + case 0x300: + seq_puts(s, "Nvidia"); + break; + case 0x400: + seq_puts(s, "Intel and ATI"); + break; + case 0x500: + seq_puts(s, "Intel and Nvidia"); + break; } + seq_puts(s, "\n"); + return 0; } DEFINE_SHOW_ATTRIBUTE(debugfs_cfg); From patchwork Wed Jan 13 18:22:23 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: 12017533 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.8 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 7CE5DC433E0 for ; Wed, 13 Jan 2021 18:23:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3BF632343E for ; Wed, 13 Jan 2021 18:23:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728054AbhAMSXQ (ORCPT ); Wed, 13 Jan 2021 13:23:16 -0500 Received: from mail-40131.protonmail.ch ([185.70.40.131]:24771 "EHLO mail-40131.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727560AbhAMSXQ (ORCPT ); Wed, 13 Jan 2021 13:23:16 -0500 Date: Wed, 13 Jan 2021 18:22:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1610562153; bh=irL3OTLg4sUHgNV7EnPTtaM9+SXU6zi+Ps/fCuATgm8=; h=Date:To:From:Reply-To:Subject:From; b=BDXHpPR9ZYj41Rj1D3SCS8X17/J4b/4jzb9TU9wn50V2zxqCRSQA0B13qzyw0FP46 npe4lIOtW9TlI4n+aJ2plRnwRVu6W3t6SJNodk1Vx62EpaXYE3rBfYoRd4hEZIvNgP 9DbmXZwoJRRxOkmK5ZV3WaFumPrj2UfL903trQAk= To: platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Gross , Ike Panhc From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v2 18/24] Revert "platform/x86: ideapad-laptop: Switch touchpad attribute to be RO" Message-ID: <20210113182016.166049-19-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org The touchpad can be enabled/disabled via this attribute on a Lenovo Yoga 520-14IKB. Allow writing as it provides legitimate functionality. This reverts commit 7f363145992cebf4ea760447f1cfdf6f81459683. Signed-off-by: Barnabás Pőcze Reviewed-by: Hans de Goede diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index cd4dc4048d71..83ad82b21b59 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -444,10 +444,9 @@ static ssize_t touchpad_show(struct device *dev, return sysfs_emit(buf, "%lu\n", result); } -/* Switch to RO for now: It might be revisited in the future */ -static ssize_t __maybe_unused touchpad_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t touchpad_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { struct ideapad_private *priv = dev_get_drvdata(dev); bool state; @@ -463,7 +462,7 @@ static ssize_t __maybe_unused touchpad_store(struct device *dev, return count; } -static DEVICE_ATTR_RO(touchpad); +static DEVICE_ATTR_RW(touchpad); static ssize_t conservation_mode_show(struct device *dev, struct device_attribute *attr, From patchwork Wed Jan 13 18:22:28 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: 12017541 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=-9.9 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,UNWANTED_LANGUAGE_BODY, 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 0841FC433E0 for ; Wed, 13 Jan 2021 18:24:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A403A2343E for ; Wed, 13 Jan 2021 18:24:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728016AbhAMSXh (ORCPT ); Wed, 13 Jan 2021 13:23:37 -0500 Received: from mail-40136.protonmail.ch ([185.70.40.136]:56961 "EHLO mail-40136.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727984AbhAMSXh (ORCPT ); Wed, 13 Jan 2021 13:23:37 -0500 Date: Wed, 13 Jan 2021 18:22:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1610562153; bh=uR32sQic+qTSoA+P5UGUjcZ3uTGtvVRgURiw4806O3s=; h=Date:To:From:Reply-To:Subject:From; b=DrPWZ3HFLweR9Lo4kDmmXZ3reVGVknX+ewApuhGYTKWWA9a7uB7R/j4iVB3scSZi4 YneV5XVnl70vScCoGclrbeSWD3/y8KJ6aQqdy2N67cy6fDip6kh7bxG/wQsvg7WHYJ Ckzx1O/+L+j9yZJImOx4uuVxPlHswmjCE0K1SRQk= To: platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Gross , Ike Panhc From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v2 19/24] platform/x86: ideapad-laptop: fix checkpatch warnings, more consistent style Message-ID: <20210113182016.166049-20-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Fix (almost all) checkpatch warnings. Reorder variable definitions from longest to shortest. Add more whitespaces for better readability. Rename variables named `ret` to `err` where appropriate. Signed-off-by: Barnabás Pőcze Reviewed-by: Hans de Goede diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 83ad82b21b59..0e50969bd194 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -129,13 +129,15 @@ MODULE_PARM_DESC(no_bt_rfkill, "No rfkill for bluetooth."); static int eval_int(acpi_handle handle, const char *method, unsigned long *val) { - acpi_status acpi_err; unsigned long long result; + acpi_status acpi_err; acpi_err = acpi_evaluate_integer(handle, (char *)method, NULL, &result); if (ACPI_FAILURE(acpi_err)) return -EIO; + *val = result; + return 0; } @@ -167,10 +169,10 @@ static int eval_sals(acpi_handle handle, unsigned long arg) static int eval_vpcr(acpi_handle handle, unsigned long cmd, unsigned long *val) { - acpi_status acpi_err; - unsigned long long result; struct acpi_object_list params; + unsigned long long result; union acpi_object in_obj; + acpi_status acpi_err; params.count = 1; params.pointer = &in_obj; @@ -178,12 +180,12 @@ static int eval_vpcr(acpi_handle handle, unsigned long cmd, unsigned long *val) in_obj.integer.value = cmd; acpi_err = acpi_evaluate_integer(handle, "VPCR", ¶ms, &result); - if (ACPI_FAILURE(acpi_err)) return -EIO; + *val = result; - return 0; + return 0; } static int eval_vpcw(acpi_handle handle, unsigned long cmd, unsigned long data) @@ -202,13 +204,14 @@ static int eval_vpcw(acpi_handle handle, unsigned long cmd, unsigned long data) acpi_err = acpi_evaluate_object(handle, "VPCW", ¶ms, NULL); if (ACPI_FAILURE(acpi_err)) return -EIO; + return 0; } static int read_ec_data(acpi_handle handle, unsigned long cmd, unsigned long *data) { + unsigned long end_jiffies, val; int err; - unsigned long int end_jiffies, val; err = eval_vpcw(handle, 1, cmd); if (err) @@ -216,39 +219,51 @@ static int read_ec_data(acpi_handle handle, unsigned long cmd, unsigned long *da for (end_jiffies = jiffies + msecs_to_jiffies(IDEAPAD_EC_TIMEOUT) + 1; time_before(jiffies, end_jiffies);) { + schedule(); + err = eval_vpcr(handle, 1, &val); + if (err) return err; + if (val == 0) return eval_vpcr(handle, 0, data); } + acpi_handle_err(handle, "timeout in %s\n", __func__); + return -ETIMEDOUT; } static int write_ec_cmd(acpi_handle handle, unsigned long cmd, unsigned long data) { - int err; unsigned long end_jiffies, val; + int err; err = eval_vpcw(handle, 0, data); if (err) return err; + err = eval_vpcw(handle, 1, cmd); if (err) return err; for (end_jiffies = jiffies + msecs_to_jiffies(IDEAPAD_EC_TIMEOUT) + 1; time_before(jiffies, end_jiffies);) { + schedule(); + err = eval_vpcr(handle, 1, &val); if (err) return err; + if (val == 0) return 0; } + acpi_handle_err(handle, "timeout in %s\n", __func__); + return -ETIMEDOUT; } @@ -265,30 +280,40 @@ static int debugfs_status_show(struct seq_file *s, void *data) if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL_MAX, &value)) seq_printf(s, "Backlight max:\t%lu\n", value); + if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL, &value)) seq_printf(s, "Backlight now:\t%lu\n", value); + if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL_POWER, &value)) seq_printf(s, "BL power value:\t%s (%lu)\n", value ? "on" : "off", value); + seq_puts(s, "=====================\n"); if (!read_ec_data(priv->adev->handle, VPCCMD_R_RF, &value)) seq_printf(s, "Radio status:\t%s (%lu)\n", value ? "on" : "off", value); + if (!read_ec_data(priv->adev->handle, VPCCMD_R_WIFI, &value)) seq_printf(s, "Wifi status:\t%s (%lu)\n", value ? "on" : "off", value); + if (!read_ec_data(priv->adev->handle, VPCCMD_R_BT, &value)) seq_printf(s, "BT status:\t%s (%lu)\n", value ? "on" : "off", value); + if (!read_ec_data(priv->adev->handle, VPCCMD_R_3G, &value)) seq_printf(s, "3G status:\t%s (%lu)\n", value ? "on" : "off", value); + seq_puts(s, "=====================\n"); if (!read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &value)) seq_printf(s, "Touchpad status:\t%s (%lu)\n", value ? "on" : "off", value); + if (!read_ec_data(priv->adev->handle, VPCCMD_R_CAMERA, &value)) seq_printf(s, "Camera status:\t%s (%lu)\n", value ? "on" : "off", value); + seq_puts(s, "=====================\n"); if (!eval_gbmd(priv->adev->handle, &value)) seq_printf(s, "GBMD: %#010lx\n", value); + if (!eval_hals(priv->adev->handle, &value)) seq_printf(s, "HALS: %#010lx\n", value); @@ -349,8 +374,8 @@ static void ideapad_debugfs_init(struct ideapad_private *priv) dir = debugfs_create_dir("ideapad", NULL); priv->debug = dir; - debugfs_create_file("cfg", S_IRUGO, dir, priv, &debugfs_cfg_fops); - debugfs_create_file("status", S_IRUGO, dir, priv, &debugfs_status_fops); + debugfs_create_file("cfg", 0444, dir, priv, &debugfs_cfg_fops); + debugfs_create_file("status", 0444, dir, priv, &debugfs_status_fops); } static void ideapad_debugfs_exit(struct ideapad_private *priv) @@ -362,73 +387,80 @@ static void ideapad_debugfs_exit(struct ideapad_private *priv) /* * sysfs */ -static ssize_t show_ideapad_cam(struct device *dev, - struct device_attribute *attr, - char *buf) +static ssize_t camera_power_show(struct device *dev, + struct device_attribute *attr, + char *buf) { - unsigned long result; struct ideapad_private *priv = dev_get_drvdata(dev); + unsigned long result; int err; err = read_ec_data(priv->adev->handle, VPCCMD_R_CAMERA, &result); if (err) return err; + return sysfs_emit(buf, "%lu\n", result); } -static ssize_t store_ideapad_cam(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t camera_power_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { - int ret; struct ideapad_private *priv = dev_get_drvdata(dev); unsigned int state; + int err; + + err = kstrtouint(buf, 0, &state); + if (err) + return err; + + err = write_ec_cmd(priv->adev->handle, VPCCMD_W_CAMERA, state); + if (err) + return err; - ret = kstrtouint(buf, 0, &state); - if (ret) - return ret; - ret = write_ec_cmd(priv->adev->handle, VPCCMD_W_CAMERA, state); - if (ret) - return ret; return count; } -static DEVICE_ATTR(camera_power, 0644, show_ideapad_cam, store_ideapad_cam); +static DEVICE_ATTR_RW(camera_power); -static ssize_t show_ideapad_fan(struct device *dev, - struct device_attribute *attr, - char *buf) +static ssize_t fan_mode_show(struct device *dev, + struct device_attribute *attr, + char *buf) { - unsigned long result; struct ideapad_private *priv = dev_get_drvdata(dev); + unsigned long result; int err; err = read_ec_data(priv->adev->handle, VPCCMD_R_FAN, &result); if (err) return err; + return sysfs_emit(buf, "%lu\n", result); } -static ssize_t store_ideapad_fan(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t fan_mode_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { - int ret; struct ideapad_private *priv = dev_get_drvdata(dev); unsigned int state; + int err; + + err = kstrtouint(buf, 0, &state); + if (err) + return err; - ret = kstrtouint(buf, 0, &state); - if (ret) - return ret; if (state > 4 || state == 3) return -EINVAL; - ret = write_ec_cmd(priv->adev->handle, VPCCMD_W_FAN, state); - if (ret) - return ret; + + err = write_ec_cmd(priv->adev->handle, VPCCMD_W_FAN, state); + if (err) + return err; + return count; } -static DEVICE_ATTR(fan_mode, 0644, show_ideapad_fan, store_ideapad_fan); +static DEVICE_ATTR_RW(fan_mode); static ssize_t touchpad_show(struct device *dev, struct device_attribute *attr, @@ -441,6 +473,7 @@ static ssize_t touchpad_show(struct device *dev, err = read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &result); if (err) return err; + return sysfs_emit(buf, "%lu\n", result); } @@ -450,23 +483,24 @@ static ssize_t touchpad_store(struct device *dev, { struct ideapad_private *priv = dev_get_drvdata(dev); bool state; - int ret; + int err; - ret = kstrtobool(buf, &state); - if (ret) - return ret; + err = kstrtobool(buf, &state); + if (err) + return err; + + err = write_ec_cmd(priv->adev->handle, VPCCMD_W_TOUCHPAD, state); + if (err) + return err; - ret = write_ec_cmd(priv->adev->handle, VPCCMD_W_TOUCHPAD, state); - if (ret) - return ret; return count; } static DEVICE_ATTR_RW(touchpad); static ssize_t conservation_mode_show(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct ideapad_private *priv = dev_get_drvdata(dev); unsigned long result; @@ -475,25 +509,27 @@ static ssize_t conservation_mode_show(struct device *dev, err = eval_gbmd(priv->adev->handle, &result); if (err) return err; + return sysfs_emit(buf, "%u\n", test_bit(GBMD_CONSERVATION_STATE_BIT, &result)); } static ssize_t conservation_mode_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { struct ideapad_private *priv = dev_get_drvdata(dev); bool state; - int ret; + int err; - ret = kstrtobool(buf, &state); - if (ret) - return ret; + err = kstrtobool(buf, &state); + if (err) + return err; - ret = eval_smbc(priv->adev->handle, + err = eval_smbc(priv->adev->handle, state ? SMBC_CONSERVATION_ON : SMBC_CONSERVATION_OFF); - if (ret) - return ret; + if (err) + return err; + return count; } @@ -505,10 +541,11 @@ static ssize_t fn_lock_show(struct device *dev, { struct ideapad_private *priv = dev_get_drvdata(dev); unsigned long hals; - int fail = eval_hals(priv->adev->handle, &hals); + int err; - if (fail) - return fail; + err = eval_hals(priv->adev->handle, &hals); + if (err) + return err; return sysfs_emit(buf, "%u\n", test_bit(HALS_FNLOCK_STATE_BIT, &hals)); } @@ -519,22 +556,22 @@ static ssize_t fn_lock_store(struct device *dev, { struct ideapad_private *priv = dev_get_drvdata(dev); bool state; - int ret; + int err; - ret = kstrtobool(buf, &state); - if (ret) - return ret; + err = kstrtobool(buf, &state); + if (err) + return err; - ret = eval_sals(priv->adev->handle, + err = eval_sals(priv->adev->handle, state ? SALS_FNLOCK_ON : SALS_FNLOCK_OFF); - if (ret) - return ret; + if (err) + return err; + return count; } static DEVICE_ATTR_RW(fn_lock); - static struct attribute *ideapad_attributes[] = { &dev_attr_camera_power.attr, &dev_attr_fan_mode.attr, @@ -618,16 +655,16 @@ static void ideapad_sync_rfk_state(struct ideapad_private *priv) static int ideapad_register_rfkill(struct ideapad_private *priv, int dev) { - int ret; - unsigned long sw_blocked; + unsigned long rf_enabled; + int err; - if (no_bt_rfkill && - (ideapad_rfk_data[dev].type == RFKILL_TYPE_BLUETOOTH)) { + if (no_bt_rfkill && ideapad_rfk_data[dev].type == RFKILL_TYPE_BLUETOOTH) { /* Force to enable bluetooth when no_bt_rfkill=1 */ write_ec_cmd(priv->adev->handle, ideapad_rfk_data[dev].opcode, 1); return 0; } + priv->rfk_priv[dev].dev = dev; priv->rfk_priv[dev].priv = priv; @@ -639,19 +676,19 @@ static int ideapad_register_rfkill(struct ideapad_private *priv, int dev) if (!priv->rfk[dev]) return -ENOMEM; - if (read_ec_data(priv->adev->handle, ideapad_rfk_data[dev].opcode-1, - &sw_blocked)) { - rfkill_init_sw_state(priv->rfk[dev], 0); - } else { - sw_blocked = !sw_blocked; - rfkill_init_sw_state(priv->rfk[dev], sw_blocked); - } + err = read_ec_data(priv->adev->handle, ideapad_rfk_data[dev].opcode - 1, + &rf_enabled); + if (err) + rf_enabled = 1; + + rfkill_init_sw_state(priv->rfk[dev], !rf_enabled); - ret = rfkill_register(priv->rfk[dev]); - if (ret) { + err = rfkill_register(priv->rfk[dev]); + if (err) { rfkill_destroy(priv->rfk[dev]); - return ret; + return err; } + return 0; } @@ -670,7 +707,7 @@ static void ideapad_unregister_rfkill(struct ideapad_private *priv, int dev) static int ideapad_sysfs_init(struct ideapad_private *priv) { return sysfs_create_group(&priv->platform_device->dev.kobj, - &ideapad_attribute_group); + &ideapad_attribute_group); } static void ideapad_sysfs_exit(struct ideapad_private *priv) @@ -696,13 +733,13 @@ static const struct key_entry ideapad_keymap[] = { { KE_KEY, 67, { KEY_TOUCHPAD_ON } }, { KE_KEY, 128, { KEY_ESC } }, - { KE_END, 0 }, + { KE_END }, }; static int ideapad_input_init(struct ideapad_private *priv) { struct input_dev *inputdev; - int error; + int err; inputdev = input_allocate_device(); if (!inputdev) @@ -713,15 +750,15 @@ static int ideapad_input_init(struct ideapad_private *priv) inputdev->id.bustype = BUS_HOST; inputdev->dev.parent = &priv->platform_device->dev; - error = sparse_keymap_setup(inputdev, ideapad_keymap, NULL); - if (error) { + err = sparse_keymap_setup(inputdev, ideapad_keymap, NULL); + if (err) { dev_err(&priv->platform_device->dev, "Unable to setup input device keymap\n"); goto err_free_dev; } - error = input_register_device(inputdev); - if (error) { + err = input_register_device(inputdev); + if (err) { dev_err(&priv->platform_device->dev, "Unable to register input device\n"); goto err_free_dev; @@ -732,7 +769,7 @@ static int ideapad_input_init(struct ideapad_private *priv) err_free_dev: input_free_device(inputdev); - return error; + return err; } static void ideapad_input_exit(struct ideapad_private *priv) @@ -753,6 +790,7 @@ static void ideapad_input_novokey(struct ideapad_private *priv) if (read_ec_data(priv->adev->handle, VPCCMD_R_NOVO, &long_pressed)) return; + if (long_pressed) ideapad_input_report(priv, 17); else @@ -815,6 +853,7 @@ static int ideapad_backlight_update_status(struct backlight_device *blightdev) blightdev->props.brightness); if (err) return err; + err = write_ec_cmd(priv->adev->handle, VPCCMD_W_BL_POWER, blightdev->props.power != FB_BLANK_POWERDOWN); if (err) @@ -875,13 +914,15 @@ static void ideapad_backlight_exit(struct ideapad_private *priv) static void ideapad_backlight_notify_power(struct ideapad_private *priv) { - unsigned long power; struct backlight_device *blightdev = priv->blightdev; + unsigned long power; if (!blightdev) return; + if (read_ec_data(priv->adev->handle, VPCCMD_R_BL_POWER, &power)) return; + blightdev->props.power = power ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; } @@ -890,12 +931,10 @@ static void ideapad_backlight_notify_brightness(struct ideapad_private *priv) unsigned long now; /* if we control brightness via acpi video driver */ - if (priv->blightdev == NULL) { + if (!priv->blightdev) read_ec_data(priv->adev->handle, VPCCMD_R_BL, &now); - return; - } - - backlight_force_update(priv->blightdev, BACKLIGHT_UPDATE_HOTKEY); + else + backlight_force_update(priv->blightdev, BACKLIGHT_UPDATE_HOTKEY); } /* @@ -910,13 +949,15 @@ static void ideapad_sync_touchpad_state(struct ideapad_private *priv) /* Without reading from EC touchpad LED doesn't switch state */ if (!read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &value)) { - /* Some IdeaPads don't really turn off touchpad - they only + unsigned char param; + /* + * Some IdeaPads don't really turn off touchpad - they only * switch the LED state. We (de)activate KBC AUX port to turn * touchpad off and on. We send KEY_TOUCHPAD_OFF and - * KEY_TOUCHPAD_ON to not to get out of sync with LED */ - unsigned char param; - i8042_command(¶m, value ? I8042_CMD_AUX_ENABLE : - I8042_CMD_AUX_DISABLE); + * KEY_TOUCHPAD_ON to not to get out of sync with LED + */ + i8042_command(¶m, + value ? I8042_CMD_AUX_ENABLE : I8042_CMD_AUX_DISABLE); ideapad_input_report(priv, value ? 67 : 66); } } @@ -960,7 +1001,8 @@ static void ideapad_acpi_notify(acpi_handle handle, u32 event, void *data) ideapad_check_special_buttons(priv); break; case 1: - /* Some IdeaPads report event 1 every ~20 + /* + * Some IdeaPads report event 1 every ~20 * seconds while on battery power; some * report this when changing to/from tablet * mode. Squelch this event. @@ -1033,14 +1075,14 @@ static void ideapad_check_features(struct ideapad_private *priv) static int ideapad_acpi_add(struct platform_device *pdev) { - int ret, i; - unsigned long cfg; struct ideapad_private *priv; struct acpi_device *adev; acpi_status acpi_err; + unsigned long cfg; + int err, i; - ret = acpi_bus_get_device(ACPI_HANDLE(&pdev->dev), &adev); - if (ret) + err = acpi_bus_get_device(ACPI_HANDLE(&pdev->dev), &adev); + if (err) return -ENODEV; if (eval_int(adev->handle, "_CFG", &cfg)) @@ -1057,14 +1099,14 @@ static int ideapad_acpi_add(struct platform_device *pdev) ideapad_check_features(priv); - ret = ideapad_sysfs_init(priv); - if (ret) - return ret; + err = ideapad_sysfs_init(priv); + if (err) + return err; ideapad_debugfs_init(priv); - ret = ideapad_input_init(priv); - if (ret) + err = ideapad_input_init(priv); + if (err) goto input_failed; /* @@ -1086,14 +1128,16 @@ static int ideapad_acpi_add(struct platform_device *pdev) ideapad_sync_touchpad_state(priv); if (acpi_video_get_backlight_type() == acpi_backlight_vendor) { - ret = ideapad_backlight_init(priv); - if (ret && ret != -ENODEV) + err = ideapad_backlight_init(priv); + if (err && err != -ENODEV) goto backlight_failed; } + acpi_err = acpi_install_notify_handler(adev->handle, - ACPI_DEVICE_NOTIFY, ideapad_acpi_notify, priv); + ACPI_DEVICE_NOTIFY, + ideapad_acpi_notify, priv); if (ACPI_FAILURE(acpi_err)) { - ret = -EIO; + err = -EIO; goto notification_failed; } @@ -1106,28 +1150,36 @@ static int ideapad_acpi_add(struct platform_device *pdev) break; } } + if (ACPI_FAILURE(acpi_err) && acpi_err != AE_NOT_EXIST) { - ret = -EIO; + err = -EIO; goto notification_failed_wmi; } #endif return 0; + #if IS_ENABLED(CONFIG_ACPI_WMI) notification_failed_wmi: acpi_remove_notify_handler(priv->adev->handle, - ACPI_DEVICE_NOTIFY, ideapad_acpi_notify); + ACPI_DEVICE_NOTIFY, + ideapad_acpi_notify); #endif + notification_failed: ideapad_backlight_exit(priv); + backlight_failed: for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++) ideapad_unregister_rfkill(priv, i); + ideapad_input_exit(priv); + input_failed: ideapad_debugfs_exit(priv); ideapad_sysfs_exit(priv); - return ret; + + return err; } static int ideapad_acpi_remove(struct platform_device *pdev) @@ -1139,11 +1191,15 @@ static int ideapad_acpi_remove(struct platform_device *pdev) if (priv->fnesc_guid) wmi_remove_notify_handler(priv->fnesc_guid); #endif + acpi_remove_notify_handler(priv->adev->handle, - ACPI_DEVICE_NOTIFY, ideapad_acpi_notify); + ACPI_DEVICE_NOTIFY, + ideapad_acpi_notify); ideapad_backlight_exit(priv); + for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++) ideapad_unregister_rfkill(priv, i); + ideapad_input_exit(priv); ideapad_debugfs_exit(priv); ideapad_sysfs_exit(priv); @@ -1158,18 +1214,20 @@ static int ideapad_acpi_resume(struct device *device) if (!device) return -EINVAL; + priv = dev_get_drvdata(device); ideapad_sync_rfk_state(priv); ideapad_sync_touchpad_state(priv); + return 0; } #endif static SIMPLE_DEV_PM_OPS(ideapad_pm, NULL, ideapad_acpi_resume); static const struct acpi_device_id ideapad_device_ids[] = { - { "VPC2004", 0}, - { "", 0}, + {"VPC2004", 0}, + {"", 0}, }; MODULE_DEVICE_TABLE(acpi, ideapad_device_ids); From patchwork Wed Jan 13 18:22:33 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: 12017535 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.8 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 9DDFFC433E6 for ; Wed, 13 Jan 2021 18:23:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 620292343F for ; Wed, 13 Jan 2021 18:23:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728251AbhAMSXW (ORCPT ); Wed, 13 Jan 2021 13:23:22 -0500 Received: from mail1.protonmail.ch ([185.70.40.18]:24843 "EHLO mail1.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727560AbhAMSXV (ORCPT ); Wed, 13 Jan 2021 13:23:21 -0500 Date: Wed, 13 Jan 2021 18:22:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1610562158; bh=m2dtrtSEIyVTEepko5QtvVRW293YasTBDW1c07v5S54=; h=Date:To:From:Reply-To:Subject:From; b=irDfrr1on7zspPJCYgbwoB3PvQAbAU9UFd93aZGszGLoxOb8nRrME+ejSYAUcWN6d 8CbL+6l0FwIztbelquIT/79+0qdLodRULwQqmyvnqj2HJZ9AXAxEd9jyvyTLlBlKRJ sSd5EWSGmNwEynby4WkbjS1YW/F65OznnjLi/85E= To: platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Gross , Ike Panhc From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v2 20/24] platform/x86: ideapad-laptop: send notification about touchpad state change to sysfs Message-ID: <20210113182016.166049-21-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Consumers can determine if the value of an attribute changed much more easily if changes are broadcast using sysfs_notify(), so utilize it. Signed-off-by: Barnabás Pőcze Reviewed-by: Hans de Goede diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 0e50969bd194..e1ab5c2e982f 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -959,6 +959,7 @@ static void ideapad_sync_touchpad_state(struct ideapad_private *priv) i8042_command(¶m, value ? I8042_CMD_AUX_ENABLE : I8042_CMD_AUX_DISABLE); ideapad_input_report(priv, value ? 67 : 66); + sysfs_notify(&priv->platform_device->dev.kobj, NULL, "touchpad"); } } From patchwork Wed Jan 13 18:22:37 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: 12017537 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.8 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 1D20DC433E9 for ; Wed, 13 Jan 2021 18:23:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C6D192343F for ; Wed, 13 Jan 2021 18:23:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727560AbhAMSXY (ORCPT ); Wed, 13 Jan 2021 13:23:24 -0500 Received: from mail2.protonmail.ch ([185.70.40.22]:53177 "EHLO mail2.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728016AbhAMSXY (ORCPT ); Wed, 13 Jan 2021 13:23:24 -0500 Date: Wed, 13 Jan 2021 18:22:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1610562160; bh=DY43qlnV4V/jkod+VKvUB82WxK9UbINZIGvTYTvlDM8=; h=Date:To:From:Reply-To:Subject:From; b=ED7heM9r4X855TDd72dbpuaMWI922fqXYbaQBfHIAxVxJX5gICkO1ffEk/GAUshfe 7x7261nQUJBCADszrBN0stR9etRnvJp//6QPvUwDseEkfFjqr7u+M2I/KzRowINEBV /OUuyevhi0xdi2Wv7Va9KVywDMnBjlDNb5PinrXg= To: platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Gross , Ike Panhc From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v2 21/24] platform/x86: ideapad-laptop: add keyboard backlight control support Message-ID: <20210113182016.166049-22-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org On certain models it is possible to control/query the keyboard backlight via the SALS/HALS ACPI methods. Add support for that, and register an LED class device to expose this functionality. Tested on: Lenovo YOGA 520-14IKB 80X8 Signed-off-by: Barnabás Pőcze diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index 91e6176cdfbd..6192bf42a87d 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -624,6 +624,8 @@ config IDEAPAD_LAPTOP depends on BACKLIGHT_CLASS_DEVICE depends on ACPI_VIDEO || ACPI_VIDEO = n depends on ACPI_WMI || ACPI_WMI = n + select NEW_LEDS + select LEDS_CLASS select INPUT_SPARSEKMAP help This is a driver for Lenovo IdeaPad netbooks contains drivers for diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index e1ab5c2e982f..7a0dbafe5dfc 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -30,6 +31,8 @@ #include +#include + #define IDEAPAD_RFKILL_DEV_NUM (3) #if IS_ENABLED(CONFIG_ACPI_WMI) @@ -57,12 +60,16 @@ enum { }; enum { + HALS_KBD_BL_SUPPORT_BIT = 4, + HALS_KBD_BL_STATE_BIT = 5, HALS_FNLOCK_SUPPORT_BIT = 9, HALS_FNLOCK_STATE_BIT = 10, HALS_HOTKEYS_PRIMARY_BIT = 11, }; enum { + SALS_KBD_BL_ON = 0x8, + SALS_KBD_BL_OFF = 0x9, SALS_FNLOCK_ON = 0xe, SALS_FNLOCK_OFF = 0xf, }; @@ -114,8 +121,14 @@ struct ideapad_private { fan_mode : 1, touchpad_ctrl_via_ec : 1, conservation_mode : 1, - fn_lock : 1; + fn_lock : 1, + kbd_bl : 1; } features; + struct { + bool initialized; + struct led_classdev led; + unsigned int last_brightness; + } kbd_bl; }; static bool no_bt_rfkill; @@ -937,6 +950,105 @@ static void ideapad_backlight_notify_brightness(struct ideapad_private *priv) backlight_force_update(priv->blightdev, BACKLIGHT_UPDATE_HOTKEY); } +/* + * keyboard backlight + */ +static int ideapad_kbd_bl_brightness_get(struct ideapad_private *priv) +{ + unsigned long hals; + int err; + + err = eval_hals(priv->adev->handle, &hals); + if (err) + return err; + + return test_bit(HALS_KBD_BL_STATE_BIT, &hals); +} + +static enum led_brightness ideapad_kbd_bl_led_cdev_brightness_get(struct led_classdev *led_cdev) +{ + struct ideapad_private *priv = container_of(led_cdev, struct ideapad_private, kbd_bl.led); + + return ideapad_kbd_bl_brightness_get(priv); +} + +static int ideapad_kbd_bl_brightness_set(struct ideapad_private *priv, unsigned int brightness) +{ + int err; + + err = eval_sals(priv->adev->handle, + brightness ? SALS_KBD_BL_ON : SALS_KBD_BL_OFF); + if (err) + return err; + + priv->kbd_bl.last_brightness = brightness; + + return 0; +} + +static int ideapad_kbd_bl_led_cdev_brightness_set(struct led_classdev *led_cdev, + enum led_brightness brightness) +{ + struct ideapad_private *priv = container_of(led_cdev, struct ideapad_private, kbd_bl.led); + + return ideapad_kbd_bl_brightness_set(priv, brightness); +} + +static void ideapad_kbd_bl_notify(struct ideapad_private *priv) +{ + int brightness; + + if (!priv->kbd_bl.initialized) + return; + + brightness = ideapad_kbd_bl_brightness_get(priv); + if (brightness < 0) + return; + + if (brightness == priv->kbd_bl.last_brightness) + return; + + priv->kbd_bl.last_brightness = brightness; + + led_classdev_notify_brightness_hw_changed(&priv->kbd_bl.led, brightness); +} + +static int ideapad_kbd_bl_init(struct ideapad_private *priv) +{ + int err; + + if (!priv->features.kbd_bl) + return -ENODEV; + + err = ideapad_kbd_bl_brightness_get(priv); + if (err < 0) + return err; + + priv->kbd_bl.last_brightness = err; + + priv->kbd_bl.led.name = "platform::" LED_FUNCTION_KBD_BACKLIGHT; + priv->kbd_bl.led.max_brightness = 1; + priv->kbd_bl.led.brightness_get = ideapad_kbd_bl_led_cdev_brightness_get; + priv->kbd_bl.led.brightness_set_blocking = ideapad_kbd_bl_led_cdev_brightness_set; + priv->kbd_bl.led.flags = LED_BRIGHT_HW_CHANGED; + + err = led_classdev_register(&priv->platform_device->dev, &priv->kbd_bl.led); + if (err) + return err; + + priv->kbd_bl.initialized = true; + + return 0; +} + +static void ideapad_kbd_bl_exit(struct ideapad_private *priv) +{ + if (!priv->kbd_bl.initialized) + return; + + led_classdev_unregister(&priv->kbd_bl.led); +} + /* * module init/exit */ @@ -1006,8 +1118,9 @@ static void ideapad_acpi_notify(acpi_handle handle, u32 event, void *data) * Some IdeaPads report event 1 every ~20 * seconds while on battery power; some * report this when changing to/from tablet - * mode. Squelch this event. + * mode. */ + ideapad_kbd_bl_notify(priv); break; default: dev_warn(&priv->platform_device->dev, @@ -1068,9 +1181,13 @@ static void ideapad_check_features(struct ideapad_private *priv) priv->features.conservation_mode = true; if (acpi_has_method(handle, "HALS") && acpi_has_method(handle, "SALS")) { - if (!eval_hals(handle, &val)) + if (!eval_hals(handle, &val)) { if (test_bit(HALS_FNLOCK_SUPPORT_BIT, &val)) priv->features.fn_lock = true; + + if (test_bit(HALS_KBD_BL_SUPPORT_BIT, &val)) + priv->features.kbd_bl = true; + } } } @@ -1110,6 +1227,11 @@ static int ideapad_acpi_add(struct platform_device *pdev) if (err) goto input_failed; + err = ideapad_kbd_bl_init(priv); + if (err && err != -ENODEV) + dev_warn(&pdev->dev, + "Could not register keyboard backlight led: %d\n", err); + /* * On some models without a hw-switch (the yoga 2 13 at least) * VPCCMD_W_RF must be explicitly set to 1 for the wifi to work. @@ -1174,6 +1296,7 @@ static int ideapad_acpi_add(struct platform_device *pdev) for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++) ideapad_unregister_rfkill(priv, i); + ideapad_kbd_bl_exit(priv); ideapad_input_exit(priv); input_failed: @@ -1201,6 +1324,7 @@ static int ideapad_acpi_remove(struct platform_device *pdev) for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++) ideapad_unregister_rfkill(priv, i); + ideapad_kbd_bl_exit(priv); ideapad_input_exit(priv); ideapad_debugfs_exit(priv); ideapad_sysfs_exit(priv); From patchwork Wed Jan 13 18:22:42 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: 12017539 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.8 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 D0D9EC433DB for ; Wed, 13 Jan 2021 18:24:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8142C23436 for ; Wed, 13 Jan 2021 18:24:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727998AbhAMSXe (ORCPT ); Wed, 13 Jan 2021 13:23:34 -0500 Received: from mail1.protonmail.ch ([185.70.40.18]:55621 "EHLO mail1.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727984AbhAMSXd (ORCPT ); Wed, 13 Jan 2021 13:23:33 -0500 Date: Wed, 13 Jan 2021 18:22:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1610562169; bh=+sS6pRrnr3xd5yOrE9QR7DNWIvpqoMvbatCJYNRsMbk=; h=Date:To:From:Reply-To:Subject:From; b=PCyLym9gFVEC2HRUSDfLBFTc91Jy/S/PfTtUhXPrg4Ey4TCycSlcwdiUem/aQafsK 0lDgzdAuKyl2aEJlQXDr3XH1rTvzAeLzebsMpEgkVLFscPiyphczQ7SP1Lm5FIuzV9 AbobGo/SPN+lgISWsNcuOfrXgB9ZpAmQEMs9dHC4= To: platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Gross , Ike Panhc From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v2 22/24] platform/x86: ideapad-laptop: add "always on USB charging" control support Message-ID: <20210113182016.166049-23-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Certain models have a so-called "always on USB charging" feature, which enables USB charging even when the computer is turned off or suspended, and which may be controlled/queried using the SALS/HALS ACPI methods. Expose this functionality via a new device attribute (usb_charging). Tested on: Lenovo YOGA 520-14IKB 80X8 Signed-off-by: Barnabás Pőcze Reviewed-by: Hans de Goede diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 7a0dbafe5dfc..da1c89b2e086 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -60,18 +60,22 @@ enum { }; enum { - HALS_KBD_BL_SUPPORT_BIT = 4, - HALS_KBD_BL_STATE_BIT = 5, - HALS_FNLOCK_SUPPORT_BIT = 9, - HALS_FNLOCK_STATE_BIT = 10, - HALS_HOTKEYS_PRIMARY_BIT = 11, + HALS_KBD_BL_SUPPORT_BIT = 4, + HALS_KBD_BL_STATE_BIT = 5, + HALS_USB_CHARGING_SUPPORT_BIT = 6, + HALS_USB_CHARGING_STATE_BIT = 7, + HALS_FNLOCK_SUPPORT_BIT = 9, + HALS_FNLOCK_STATE_BIT = 10, + HALS_HOTKEYS_PRIMARY_BIT = 11, }; enum { - SALS_KBD_BL_ON = 0x8, - SALS_KBD_BL_OFF = 0x9, - SALS_FNLOCK_ON = 0xe, - SALS_FNLOCK_OFF = 0xf, + SALS_KBD_BL_ON = 0x8, + SALS_KBD_BL_OFF = 0x9, + SALS_USB_CHARGING_ON = 0xa, + SALS_USB_CHARGING_OFF = 0xb, + SALS_FNLOCK_ON = 0xe, + SALS_FNLOCK_OFF = 0xf, }; enum { @@ -122,7 +126,8 @@ struct ideapad_private { touchpad_ctrl_via_ec : 1, conservation_mode : 1, fn_lock : 1, - kbd_bl : 1; + kbd_bl : 1, + usb_charging : 1; } features; struct { bool initialized; @@ -585,12 +590,50 @@ static ssize_t fn_lock_store(struct device *dev, static DEVICE_ATTR_RW(fn_lock); +static ssize_t usb_charging_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct ideapad_private *priv = dev_get_drvdata(dev); + unsigned long hals; + int err; + + err = eval_hals(priv->adev->handle, &hals); + if (err) + return err; + + return sysfs_emit(buf, "%u\n", test_bit(HALS_USB_CHARGING_STATE_BIT, &hals)); +} + +static ssize_t usb_charging_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct ideapad_private *priv = dev_get_drvdata(dev); + bool state; + int err; + + err = kstrtobool(buf, &state); + if (err) + return err; + + err = eval_sals(priv->adev->handle, + state ? SALS_USB_CHARGING_ON : SALS_USB_CHARGING_OFF); + if (err) + return err; + + return count; +} + +static DEVICE_ATTR_RW(usb_charging); + static struct attribute *ideapad_attributes[] = { &dev_attr_camera_power.attr, &dev_attr_fan_mode.attr, &dev_attr_touchpad.attr, &dev_attr_conservation_mode.attr, &dev_attr_fn_lock.attr, + &dev_attr_usb_charging.attr, NULL }; @@ -613,6 +656,8 @@ static umode_t ideapad_is_visible(struct kobject *kobj, supported = priv->features.conservation_mode; else if (attr == &dev_attr_fn_lock.attr) supported = priv->features.fn_lock; + else if (attr == &dev_attr_usb_charging.attr) + supported = priv->features.usb_charging; return supported ? attr->mode : 0; } @@ -1187,6 +1232,9 @@ static void ideapad_check_features(struct ideapad_private *priv) if (test_bit(HALS_KBD_BL_SUPPORT_BIT, &val)) priv->features.kbd_bl = true; + + if (test_bit(HALS_USB_CHARGING_SUPPORT_BIT, &val)) + priv->features.usb_charging = true; } } } From patchwork Wed Jan 13 18:22:54 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: 12017545 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.8 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 1E517C433E6 for ; Wed, 13 Jan 2021 18:24:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D0FB32343F for ; Wed, 13 Jan 2021 18:24:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728252AbhAMSXk (ORCPT ); Wed, 13 Jan 2021 13:23:40 -0500 Received: from mail1.protonmail.ch ([185.70.40.18]:54928 "EHLO mail1.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727984AbhAMSXk (ORCPT ); Wed, 13 Jan 2021 13:23:40 -0500 Date: Wed, 13 Jan 2021 18:22:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1610562177; bh=iqAwI1IuE13sRI/q34P1JwdMO/H3mkdvkrVBPMh6n3k=; h=Date:To:From:Reply-To:Subject:From; b=ZNJXQHYKAW6K45YLe5SeFs8nVIOAztmfAML2rrV3ZoBP5tdsNmcO3A6vJI8IZYFfW mZepqzc7h3se1I4k8d6dS1qoNBVXC60ooDdXBMjMA70HAc4xKfc+yT6jrYm1gUhGlK XtWGIydH9eAyok00sVkSCMlQWg7Bh2Ip1w1cxA2Q= To: platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Gross , Ike Panhc From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v2 23/24] Documentation/ABI: sysfs-platform-ideapad-laptop: update device attribute paths Message-ID: <20210113182016.166049-24-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org The documentation referred to non-existent device attributes under a non-existent platform device. Update it with the current location of the attributes. Signed-off-by: Barnabás Pőcze Reviewed-by: Hans de Goede diff --git a/Documentation/ABI/testing/sysfs-platform-ideapad-laptop b/Documentation/ABI/testing/sysfs-platform-ideapad-laptop index fd2ac02bc5bd..e024678947c8 100644 --- a/Documentation/ABI/testing/sysfs-platform-ideapad-laptop +++ b/Documentation/ABI/testing/sysfs-platform-ideapad-laptop @@ -1,11 +1,11 @@ -What: /sys/devices/platform/ideapad/camera_power +What: /sys/bus/platform/devices/VPC2004:*/camera_power Date: Dec 2010 KernelVersion: 2.6.37 Contact: "Ike Panhc " Description: Control the power of camera module. 1 means on, 0 means off. -What: /sys/devices/platform/ideapad/fan_mode +What: /sys/bus/platform/devices/VPC2004:*/fan_mode Date: June 2012 KernelVersion: 3.6 Contact: "Maxim Mikityanskiy " @@ -18,7 +18,7 @@ Description: * 2 -> Dust Cleaning * 4 -> Efficient Thermal Dissipation Mode -What: /sys/devices/platform/ideapad/touchpad +What: /sys/bus/platform/devices/VPC2004:*/touchpad Date: May 2017 KernelVersion: 4.13 Contact: "Ritesh Raj Sarraf " @@ -27,7 +27,7 @@ Description: * 1 -> Switched On * 0 -> Switched Off -What: /sys/bus/pci/devices///VPC2004:00/fn_lock +What: /sys/bus/platform/devices/VPC2004:*/fn_lock Date: May 2018 KernelVersion: 4.18 Contact: "Oleg Keri " From patchwork Wed Jan 13 18:23:06 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: 12017543 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.8 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 35AB7C433E9 for ; Wed, 13 Jan 2021 18:24:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F3DD123436 for ; Wed, 13 Jan 2021 18:24:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728253AbhAMSXy (ORCPT ); Wed, 13 Jan 2021 13:23:54 -0500 Received: from mail-40131.protonmail.ch ([185.70.40.131]:29928 "EHLO mail-40131.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727984AbhAMSXx (ORCPT ); Wed, 13 Jan 2021 13:23:53 -0500 Date: Wed, 13 Jan 2021 18:23:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1610562190; bh=PdMLaGx/19IPG/ufbfDkapilXL2o2nuqoyL7SZZxTww=; h=Date:To:From:Reply-To:Subject:From; b=nMoxrPWbNATd87MdK7VdX4cSNg++FNF3d4C97wYJcFAZSfWjstAjIiEwboqlRfEE1 j98nF8Ei5Qu+2QnScrqyeLIn6EeJ7HIp4uQdobRo2i8foyFuLIQ9ouxZyUW2JE1wVL 3ltSTTub/sZaRkGKA4qq7uV8GcMs7o/iQya2zvxI= To: platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Gross , Ike Panhc From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v2 24/24] Documentation/ABI: sysfs-platform-ideapad-laptop: conservation_mode and usb_charging Message-ID: <20210113182016.166049-25-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Document the conservation_mode and usb_charging attributes provided by the ideapad-laptop module. Signed-off-by: Barnabás Pőcze diff --git a/Documentation/ABI/testing/sysfs-platform-ideapad-laptop b/Documentation/ABI/testing/sysfs-platform-ideapad-laptop index e024678947c8..c8b64c39eb18 100644 --- a/Documentation/ABI/testing/sysfs-platform-ideapad-laptop +++ b/Documentation/ABI/testing/sysfs-platform-ideapad-laptop @@ -27,6 +27,15 @@ Description: * 1 -> Switched On * 0 -> Switched Off +What: /sys/bus/platform/devices/VPC2004:*/conservation_mode +Date: Aug 2017 +KernelVersion: 4.14 +Contact: platform-driver-x86@vger.kernel.org +Description: + Controls whether the conservation mode is enabled or not. + This feature limits the maximum battery charge percentage to + around 50-60% in order to prolong the lifetime of the battery. + What: /sys/bus/platform/devices/VPC2004:*/fn_lock Date: May 2018 KernelVersion: 4.18 @@ -41,3 +50,12 @@ Description: # echo "0" > \ /sys/bus/pci/devices/0000:00:1f.0/PNP0C09:00/VPC2004:00/fn_lock + +What: /sys/bus/platform/devices/VPC2004:*/usb_charging +Date: Dec 2020 +KernelVersion: 5.12 +Contact: platform-driver-x86@vger.kernel.org +Description: + Controls whether the "always on USB charging" feature is + enabled or not. This features enables charging USB devices + even if the computer is not turned on.