From patchwork Tue Mar 14 10:26:30 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: 9622959 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 6431360522 for ; Tue, 14 Mar 2017 10:27:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41DE1283F3 for ; Tue, 14 Mar 2017 10:27:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36C8C2842C; Tue, 14 Mar 2017 10:27:19 +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=ham 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 CE531283F9 for ; Tue, 14 Mar 2017 10:27:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751237AbdCNK1N (ORCPT ); Tue, 14 Mar 2017 06:27:13 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:33626 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751184AbdCNK0o (ORCPT ); Tue, 14 Mar 2017 06:26:44 -0400 Received: by mail-lf0-f68.google.com with SMTP id r36so13781976lfi.0 for ; Tue, 14 Mar 2017 03:26:42 -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=Roex8bNlRZWqMHRUT9dXNs9ajAeWQVZ6kcHihyQO1VE=; b=bbZgBVctaaDUiJaaFT63ihJBAYE2f3Nh3l+88Jz7Yf4GH9QPg2iICk5R23eY6oTtwj WsTqmZj6OWfbBbtR8fsKIvMGTStzYUWHXUKrdpqemVyKaYrMHT6FaCuF6ggkcOOwbx9A rm+LkPYbV9K8Nlu8kUMti9cJ6Qo9X8IR14qNA= 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=Roex8bNlRZWqMHRUT9dXNs9ajAeWQVZ6kcHihyQO1VE=; b=NkVQZ9v28VtWkLGaAhBzBr0ekfJVIyF/AeIrN/cR7kq/0+BN66qSd4Mq1EwBOwkPhc Yflon3NT2VHQQgEeZGOfrPmU8Qx21uBmy7EvVjnsw1i/yKoB5QNgDYfwhP+xgId/4c6k EUbWhFCg6DVIiemOXOqu9zdakXzUBq3lVytdFlb5dG5FFipV5nCj/Ne2iXzH3+2zlZeM ZMGFlYMOwCwDkSSd0OnF60nEZH+/DJQVhxgngWIb/30QdzG0Ht7QqSESz3rSiRTFnf0i AuL9dtPasxpmiE8Rbo/g1+NPQUInO3grkBgIFRLZ0gpf5Ebsr48VyJ7sZw0HmTJmfUx3 mpBg== X-Gm-Message-State: AMke39kOuLvrpKU7ao79U8f43sYpuc1sJBlwFXv7/BQqe4xHMsNm6qS6KiJeyaJMxqRYcw== X-Received: by 10.25.89.135 with SMTP id n129mr8599625lfb.180.1489487201683; Tue, 14 Mar 2017 03:26:41 -0700 (PDT) Received: from ozzy.hq.kempniu.pl ([2001:a10:160:3::3]) by smtp.googlemail.com with ESMTPSA id h62sm4186154lfh.62.2017.03.14.03.26.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Mar 2017 03:26:41 -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 4/5] platform/x86: fujitsu-laptop: only register platform device if FUJ02E3 is present Date: Tue, 14 Mar 2017 11:26:30 +0100 Message-Id: <20170314102631.8203-5-kernel@kempniu.pl> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170314102631.8203-1-kernel@kempniu.pl> References: <20170314102631.8203-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 The platform device registered by fujitsu-laptop is registered unconditionally while sysfs attributes attached to it depend on the FUJ02E3 ACPI device being present. Fix this by moving platform device creation and removal to acpi_fujitsu_laptop_add() and acpi_fujitsu_laptop_remove(), respectively. Signed-off-by: Michał Kępień --- drivers/platform/x86/fujitsu-laptop.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c index 421402a19bb9..a2641cb79df9 100644 --- a/drivers/platform/x86/fujitsu-laptop.c +++ b/drivers/platform/x86/fujitsu-laptop.c @@ -903,6 +903,10 @@ static int acpi_fujitsu_laptop_add(struct acpi_device *device) fujitsu_bl->bl_device->props.power = FB_BLANK_UNBLANK; } + error = fujitsu_laptop_platform_add(); + if (error) + goto err_unregister_input_dev; + #if IS_ENABLED(CONFIG_LEDS_CLASS) if (call_fext_func(FUNC_LEDS, 0x0, 0x0, 0x0) & LOGOLAMP_POWERON) { result = led_classdev_register(&fujitsu_bl->pf_device->dev, @@ -994,6 +998,8 @@ static int acpi_fujitsu_laptop_remove(struct acpi_device *device) led_classdev_unregister(&eco_led); #endif + fujitsu_laptop_platform_remove(); + input_unregister_device(input); kfifo_free(&fujitsu_laptop->fifo); @@ -1180,13 +1186,9 @@ static int __init fujitsu_init(void) /* Register platform stuff */ - ret = fujitsu_laptop_platform_add(); - if (ret) - goto err_unregister_acpi; - ret = platform_driver_register(&fujitsu_pf_driver); if (ret) - goto err_remove_platform_device; + goto err_unregister_acpi; /* Register laptop driver */ @@ -1208,8 +1210,6 @@ static int __init fujitsu_init(void) kfree(fujitsu_laptop); err_unregister_platform_driver: platform_driver_unregister(&fujitsu_pf_driver); -err_remove_platform_device: - fujitsu_laptop_platform_remove(); err_unregister_acpi: acpi_bus_unregister_driver(&acpi_fujitsu_bl_driver); err_free_fujitsu_bl: @@ -1226,8 +1226,6 @@ static void __exit fujitsu_cleanup(void) platform_driver_unregister(&fujitsu_pf_driver); - fujitsu_laptop_platform_remove(); - acpi_bus_unregister_driver(&acpi_fujitsu_bl_driver); kfree(fujitsu_bl);