From patchwork Wed Apr 14 15:10:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12203113 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=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 6AFCDC433B4 for ; Wed, 14 Apr 2021 15:11:31 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2AC7560E08 for ; Wed, 14 Apr 2021 15:11:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2AC7560E08 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7D4D96E93D; Wed, 14 Apr 2021 15:11:30 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4A1B66E93E for ; Wed, 14 Apr 2021 15:11:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618413088; 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=fiLdO0zpXOfs4JKbchOx+vi/e6P7q0nbbAmu0kiz5fXuBHPoKHZBBJtJW2RLWbA54tPQ+f h1VMhvYCgaK3PQOL3HukzZfDZuOkmv7h3layiY9ddlpqEhIqbG5PjiOpT5f5jounCnoZtv TyAi7e/o7I9+zd7P83rVPmJl6Lwg68o= 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 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 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marco Trevisan , Pekka Paalanen , Sebastien Bacher , intel-gfx , dri-devel@lists.freedesktop.org, platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Pearson , Mario Limonciello Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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; }