From: "Michał Kępień" <kernel@kempniu.pl>
To: Jonathan Woithe <jwoithe@just42.net>,
Darren Hart <dvhart@infradead.org>,
Andy Shevchenko <andy@infradead.org>
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 [thread overview]
Message-ID: <20170314102631.8203-5-kernel@kempniu.pl> (raw)
In-Reply-To: <20170314102631.8203-1-kernel@kempniu.pl>
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ń <kernel@kempniu.pl>
---
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);
--
2.12.0
next prev parent reply other threads:[~2017-03-14 10:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-14 10:26 [PATCH 0/5] fujitsu-laptop: platform device code cleanup Michał Kępień
2017-03-14 10:26 ` [PATCH 1/5] platform/x86: fujitsu-laptop: remove backlight-related attributes from the platform device Michał Kępień
2017-03-14 10:26 ` [PATCH 2/5] platform/x86: fujitsu-laptop: simplify platform device attribute definitions Michał Kępień
2017-03-14 10:26 ` [PATCH 3/5] platform/x86: fujitsu-laptop: add and remove platform device in separate functions Michał Kępień
2017-03-14 10:26 ` Michał Kępień [this message]
2017-03-14 10:26 ` [PATCH 5/5] platform/x86: fujitsu-laptop: remove pf_device field from struct fujitsu_bl Michał Kępień
2017-03-15 0:19 ` [PATCH 0/5] fujitsu-laptop: platform device code cleanup Jonathan Woithe
2017-03-15 23:39 ` Darren Hart
2017-03-18 11:40 ` Jonathan Woithe
2017-03-22 16:01 ` Darren Hart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170314102631.8203-5-kernel@kempniu.pl \
--to=kernel@kempniu.pl \
--cc=andy@infradead.org \
--cc=dvhart@infradead.org \
--cc=jwoithe@just42.net \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox