From mboxrd@z Thu Jan 1 00:00:00 1970 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=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 42C40C433ED for ; Wed, 14 Apr 2021 15:11:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1F12161132 for ; Wed, 14 Apr 2021 15:11:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348918AbhDNPLt (ORCPT ); Wed, 14 Apr 2021 11:11:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43807 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348646AbhDNPLs (ORCPT ); Wed, 14 Apr 2021 11:11:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618413086; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IWj3DnOXodLriM5MBUvwzzfku67ab3+bGwLOp0tAVFk=; b=HdVn7jtXfnJaBlSoBZdVAACUk3diWolPiE6Q+GsJ4Mc4KUCw2KYqxEXun1/svU4efs+iiL +mM4ZVJrGREVl3Z2VigFmCFzPbAFW5zZN8cpv0DZofU8vxrsTcM5mOpezyYR2PMpHNztYw +/BTSIQ3Bh/+FPgKKkJRC6jnIQZFd+M= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-193-UkreENd0NmGAO2RFElak0Q-1; Wed, 14 Apr 2021 11:11:24 -0400 X-MC-Unique: UkreENd0NmGAO2RFElak0Q-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E17C5A6861; Wed, 14 Apr 2021 15:11:21 +0000 (UTC) Received: from x1.localdomain (ovpn-112-168.ams2.redhat.com [10.36.112.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A8F25D6A8; Wed, 14 Apr 2021 15:11:18 +0000 (UTC) From: Hans de Goede To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Daniel Vetter , David Airlie , Rajat Jain , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Mark Gross , Andy Shevchenko Cc: Hans de Goede , Pekka Paalanen , Mario Limonciello , Sebastien Bacher , Marco Trevisan , intel-gfx , dri-devel@lists.freedesktop.org, Mark Pearson , platform-driver-x86@vger.kernel.org Subject: [PATCH resend 7/9] platform/x86: thinkpad_acpi: Get privacy-screen / lcdshadow ACPI handles only once Date: Wed, 14 Apr 2021 17:10:47 +0200 Message-Id: <20210414151049.95828-8-hdegoede@redhat.com> In-Reply-To: <20210414151049.95828-1-hdegoede@redhat.com> References: <20210414151049.95828-1-hdegoede@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Get the privacy-screen / lcdshadow ACPI handles once and cache them, instead of retrieving them every time we need them. Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 683c175cc28a..fe919700b8ae 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -9759,19 +9759,15 @@ static struct ibm_struct battery_driver_data = { * LCD Shadow subdriver, for the Lenovo PrivacyGuard feature */ +static acpi_handle lcdshadow_get_handle; +static acpi_handle lcdshadow_set_handle; static int lcdshadow_state; static int lcdshadow_on_off(bool state) { - acpi_handle set_shadow_handle; int output; - if (ACPI_FAILURE(acpi_get_handle(hkey_handle, "SSSS", &set_shadow_handle))) { - pr_warn("Thinkpad ACPI has no %s interface.\n", "SSSS"); - return -EIO; - } - - if (!acpi_evalf(set_shadow_handle, &output, NULL, "dd", (int)state)) + if (!acpi_evalf(lcdshadow_set_handle, &output, NULL, "dd", (int)state)) return -EIO; lcdshadow_state = state; @@ -9789,15 +9785,17 @@ static int lcdshadow_set(bool on) static int tpacpi_lcdshadow_init(struct ibm_init_struct *iibm) { - acpi_handle get_shadow_handle; + acpi_status status1, status2; int output; - if (ACPI_FAILURE(acpi_get_handle(hkey_handle, "GSSS", &get_shadow_handle))) { + status1 = acpi_get_handle(hkey_handle, "GSSS", &lcdshadow_get_handle); + status2 = acpi_get_handle(hkey_handle, "SSSS", &lcdshadow_set_handle); + if (ACPI_FAILURE(status1) || ACPI_FAILURE(status2)) { lcdshadow_state = -ENODEV; return 0; } - if (!acpi_evalf(get_shadow_handle, &output, NULL, "dd", 0)) { + if (!acpi_evalf(lcdshadow_get_handle, &output, NULL, "dd", 0)) { lcdshadow_state = -EIO; return -EIO; } -- 2.31.1