From patchwork Fri May 19 07:44:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBLxJlwaWXFhA==?= X-Patchwork-Id: 9736129 X-Patchwork-Delegate: dvhart@infradead.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 40F166034C for ; Fri, 19 May 2017 07:46:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39C022881B for ; Fri, 19 May 2017 07:46:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D98A288E5; Fri, 19 May 2017 07:46:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABB6A2881B for ; Fri, 19 May 2017 07:46:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752127AbdESHpH (ORCPT ); Fri, 19 May 2017 03:45:07 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35734 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751704AbdESHpF (ORCPT ); Fri, 19 May 2017 03:45:05 -0400 Received: by mail-wm0-f67.google.com with SMTP id v4so16458554wmb.2 for ; Fri, 19 May 2017 00:45:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kempniu.pl; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6JB7ZiHQQrIOuS1ECJeh+lCaZtUsWFQwndZwL8Ak8v8=; b=UkP+gn2bQhokSfrBt6MZw/xbod7QvNiHrVMQoM1KkRQOiRGHZm06MZEqAe/qmUfj5N +pTI0yTciNp6MlANm+bBhJ98fcUhZGakBippQlNQaVgj0io0haphkJ2vO5mwqwtk1Wc6 njwX02Ovshtipx2zUZT218E1e+gNmqMl9CX1w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6JB7ZiHQQrIOuS1ECJeh+lCaZtUsWFQwndZwL8Ak8v8=; b=PS3wlbxWFkKUXJxtaZ8L6aJWE2MYljvoAGmG1J+IzKIe9la7TPH7Rv0cZqk6AAOUZf QCiTz7hxWDhpuATjdK5gcl6qujnqg9v94XZgXNjJxB/Iuqd9xBqmD2CfDJgX5QGZcM2i P3/tun+eQKQfEEb8MpsGYI1Y7Xr6DnJw8Ah949JCclwlVhqHCORnCiZXTwWEK3W4Kbpu u0PBSDn517V9LxJ6j0c3CPUgw3xdchm5BTIAqUalUaawSg/mIsfZDYpjBJhxHtrmkrZV ID+GEiVlsCY7JN8foxE20t7Pftd6t4eLRNoO5BxYtxQYbd+2c5rPtBjm7bswPGm/ApSH 65JQ== X-Gm-Message-State: AODbwcAmmUGmeEYkDD4HYXBpDOgOLjIksnhutTfS/BQnW6lVNi9f7tI0 Um4jt19lNHHXgzAZ X-Received: by 10.25.18.84 with SMTP id h81mr1752299lfi.63.1495179899224; Fri, 19 May 2017 00:44:59 -0700 (PDT) Received: from ozzy.nask.waw.pl ([2001:a10:160:3::3]) by smtp.googlemail.com with ESMTPSA id a1sm811623lfb.15.2017.05.19.00.44.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 May 2017 00:44:58 -0700 (PDT) From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= To: Jonathan Woithe , Darren Hart , Andy Shevchenko Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/8] platform/x86: fujitsu-laptop: track the last instantiated FUJ02E3 ACPI device Date: Fri, 19 May 2017 09:44:45 +0200 Message-Id: <20170519074448.12716-6-kernel@kempniu.pl> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170519074448.12716-1-kernel@kempniu.pl> References: <20170519074448.12716-1-kernel@kempniu.pl> MIME-Version: 1.0 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP fujitsu-laptop registers two ACPI drivers: one for ACPI device FUJ02B1 enabling backlight control and another for ACPI device FUJ02E3 which handles various other stuff (hotkeys, LEDs, etc.) In a perfect world, private data used by each of these drivers would be neatly encapsulated in a structure specific to a given driver instance. Sadly, firmware present on some Fujitsu laptops makes that impossible by exposing backlight power control (which is what the FUJ02B1 ACPI device should take care of) through the FUJ02E3 ACPI device. This means the backlight driver needs a way to access an ACPI device it is not bound to. When the backlight driver is extracted into a separate module, it will not be able to rely on a module-wide variable any more and such access will happen through an API exposed by fujitsu-laptop. For all known firmwares out in the wild, it seems that whenever the FUJ02B1 ACPI device is present, it is always accompanied by a single instance of the FUJ02E3 ACPI device. We could independently grab an ACPI handle to the FUJ02E3 ACPI device from the backlight driver, but that would require using a hardcoded absolute path to that ACPI device, which is subject to change. It is easier to simply store a module-wide pointer to the last (most likely only) FUJ02E3 ACPI device found, make the aforementioned API use it and cover our bases by warning the user if firmware exposes multiple FUJ02E3 ACPI devices. Introducing this pointer in advance allows us to get rid of the acpi_handle field of struct fujitsu_bl and also enables a bit more step-by-step migration to a device-specific implementation of call_fext_func(). Signed-off-by: Michał Kępień --- drivers/platform/x86/fujitsu-laptop.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c index 3916f0ae59f3..21bd60afea75 100644 --- a/drivers/platform/x86/fujitsu-laptop.c +++ b/drivers/platform/x86/fujitsu-laptop.c @@ -155,6 +155,7 @@ struct fujitsu_laptop { }; static struct fujitsu_laptop *fujitsu_laptop; +static struct acpi_device *fext; #ifdef CONFIG_FUJITSU_LAPTOP_DEBUG static u32 dbg_level = 0x03; @@ -788,6 +789,9 @@ static int acpi_fujitsu_laptop_add(struct acpi_device *device) if (!priv) return -ENOMEM; + WARN_ONCE(fext, "More than one FUJ02E3 ACPI device was found. Driver may not work as intended."); + fext = device; + fujitsu_laptop = priv; fujitsu_laptop->acpi_handle = device->handle; sprintf(acpi_device_name(device), "%s",