From: Azael Avalos <coproscefalo@gmail.com>
To: Matthew Garrett <matthew.garrett@nebula.com>,
linux-kernel@vger.kernel.org
Cc: azael.avalos@gmail.com
Subject: [PATCH 3/8] toshiba_acpi: Add platform support
Date: Mon, 4 Nov 2013 20:48:40 -0700 [thread overview]
Message-ID: <1383623325-4004-4-git-send-email-coproscefalo@gmail.com> (raw)
In-Reply-To: <1383623325-4004-1-git-send-email-coproscefalo@gmail.com>
Add platform support and change the backlight
and led devices to register on it instead of the acpi_device.
The use of the platform is to have just one place where to
look for files instead of looking at the current three different
ACPI devices (TOS6200, TOS6208 and TOS1900) and thus making
userspace a bit easier.
Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
---
drivers/platform/x86/toshiba_acpi.c | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index d7ecef3..226e0b5 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -54,6 +54,7 @@
#include <linux/slab.h>
#include <linux/workqueue.h>
#include <linux/i8042.h>
+#include <linux/platform_device.h>
#include <asm/uaccess.h>
@@ -129,6 +130,7 @@ MODULE_LICENSE("GPL");
struct toshiba_acpi_dev {
struct acpi_device *acpi_dev;
+ struct platform_device *pf_dev;
const char *method_hci;
struct rfkill *bt_rfk;
struct input_dev *hotkey_dev;
@@ -1156,7 +1158,7 @@ static int toshiba_acpi_setup_backlight(struct toshiba_acpi_dev *dev)
props.max_brightness++;
dev->backlight_dev = backlight_device_register("toshiba",
- &dev->acpi_dev->dev,
+ &dev->pf_dev->dev,
dev,
&toshiba_backlight_data,
&props);
@@ -1198,6 +1200,9 @@ static int toshiba_acpi_remove(struct acpi_device *acpi_dev)
if (dev->illumination_supported)
led_classdev_unregister(&dev->led_dev);
+ if (dev->pf_dev)
+ platform_device_unregister(dev->pf_dev);
+
if (toshiba_acpi)
toshiba_acpi = NULL;
@@ -1249,6 +1254,15 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
dev->method_hci = hci_method;
acpi_dev->driver_data = dev;
+ dev->pf_dev = platform_device_register_simple("toshiba", -1, NULL, 0);
+ if (IS_ERR(dev->pf_dev)) {
+ ret = PTR_ERR(dev->pf_dev);
+ pr_err("Unable to register platform device\n");
+ kfree(dev);
+ return ret;
+ }
+ platform_set_drvdata(dev->pf_dev, dev);
+
if (toshiba_acpi_setup_keyboard(dev))
pr_info("Unable to activate hotkeys\n");
@@ -1284,7 +1298,7 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
dev->led_dev.max_brightness = 1;
dev->led_dev.brightness_set = toshiba_illumination_set;
dev->led_dev.brightness_get = toshiba_illumination_get;
- if (!led_classdev_register(&acpi_dev->dev, &dev->led_dev))
+ if (!led_classdev_register(&dev->pf_dev->dev, &dev->led_dev))
dev->illumination_supported = 1;
}
@@ -1388,6 +1402,13 @@ static struct acpi_driver toshiba_acpi_driver = {
.drv.pm = &toshiba_acpi_pm,
};
+static struct platform_driver platform_driver = {
+ .driver = {
+ .name = "toshiba",
+ .owner = THIS_MODULE,
+ },
+};
+
static int __init toshiba_acpi_init(void)
{
int ret;
@@ -1406,6 +1427,12 @@ static int __init toshiba_acpi_init(void)
return -ENODEV;
}
+ ret = platform_driver_register(&platform_driver);
+ if (ret < 0) {
+ pr_err("Failed to register platform driver: %d\n", ret);
+ return ret;
+ }
+
ret = acpi_bus_register_driver(&toshiba_acpi_driver);
if (ret) {
pr_err("Failed to register ACPI driver: %d\n", ret);
@@ -1418,6 +1445,7 @@ static int __init toshiba_acpi_init(void)
static void __exit toshiba_acpi_exit(void)
{
acpi_bus_unregister_driver(&toshiba_acpi_driver);
+ platform_driver_unregister(&platform_driver);
if (toshiba_proc_dir)
remove_proc_entry(PROC_TOSHIBA, acpi_root_dir);
}
--
1.8.1.4
next prev parent reply other threads:[~2013-11-05 3:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-05 3:48 [PATCH 0/8] toshiba_acpi: New features added and a fix Azael Avalos
2013-11-05 3:48 ` [PATCH 1/8] toshiba_acpi: Add System Configuration Interface (SCI) Azael Avalos
2013-11-05 3:48 ` [PATCH 2/8] toshiba_acpi: Adapt illumination_* code to use the new SCI Azael Avalos
2013-11-05 3:48 ` Azael Avalos [this message]
2013-11-05 3:48 ` [PATCH 4/8] toshiba_acpi: Add kbd backlight support and sysfs files Azael Avalos
2013-11-05 3:48 ` [PATCH 5/8] toshiba_acpi: Add ECO led support Azael Avalos
2013-11-05 3:48 ` [PATCH 6/8] toshiba_acpi: Add accelerometer support Azael Avalos
2013-11-05 3:48 ` [PATCH 7/8] toshiba_acpi: Add touchpad enable/disable support Azael Avalos
2013-11-05 3:48 ` [PATCH 8/8] toshiba_acpi: Update version and copyright information Azael Avalos
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=1383623325-4004-4-git-send-email-coproscefalo@gmail.com \
--to=coproscefalo@gmail.com \
--cc=azael.avalos@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew.garrett@nebula.com \
/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
all inboxes | Powered by JetHome®