* [PATCH v1 1/7] platform/x86: toshiba_acpi: Reorder code to avoid forward declaration
2026-03-24 19:57 [PATCH v1 0/7] platform/x86: toshiba: Bind to platform devices instead of ACPI ones Rafael J. Wysocki
@ 2026-03-24 19:58 ` Rafael J. Wysocki
2026-03-24 19:58 ` [PATCH v1 2/7] platform/x86: toshiba_acpi: Register ACPI notify handler directly Rafael J. Wysocki
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Rafael J. Wysocki @ 2026-03-24 19:58 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: LKML, Linux ACPI, Hans de Goede, platform-driver-x86,
Azael Avalos
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Move the definition of toshiba_acpi_notify() before the definitions of
the functions that will refer to it after subsequent updates to avoid
having to add a forward declarations of it.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/platform/x86/toshiba_acpi.c | 120 ++++++++++++++--------------
1 file changed, 60 insertions(+), 60 deletions(-)
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 18fb558115aa..fbd7b6b6b826 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -3193,6 +3193,66 @@ static void print_supported_features(struct toshiba_acpi_dev *dev)
pr_cont("\n");
}
+static void toshiba_acpi_notify(struct acpi_device *acpi_dev, u32 event)
+{
+ struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev);
+
+ switch (event) {
+ case 0x80: /* Hotkeys and some system events */
+ /*
+ * Machines with this WMI GUID aren't supported due to bugs in
+ * their AML.
+ *
+ * Return silently to avoid triggering a netlink event.
+ */
+ if (wmi_has_guid(TOSHIBA_WMI_EVENT_GUID))
+ return;
+ toshiba_acpi_process_hotkeys(dev);
+ break;
+ case 0x81: /* Dock events */
+ case 0x82:
+ case 0x83:
+ pr_info("Dock event received %x\n", event);
+ break;
+ case 0x88: /* Thermal events */
+ pr_info("Thermal event received\n");
+ break;
+ case 0x8f: /* LID closed */
+ case 0x90: /* LID is closed and Dock has been ejected */
+ break;
+ case 0x8c: /* SATA power events */
+ case 0x8b:
+ pr_info("SATA power event received %x\n", event);
+ break;
+ case 0x92: /* Keyboard backlight mode changed */
+ dev->kbd_event_generated = true;
+ /* Update sysfs entries */
+ if (sysfs_update_group(&acpi_dev->dev.kobj,
+ &toshiba_attr_group))
+ pr_err("Unable to update sysfs entries\n");
+ /* Notify LED subsystem about keyboard backlight change */
+ if (dev->kbd_type == 2 && dev->kbd_mode != SCI_KBD_MODE_AUTO)
+ led_classdev_notify_brightness_hw_changed(&dev->kbd_led,
+ (dev->kbd_mode == SCI_KBD_MODE_ON) ?
+ LED_FULL : LED_OFF);
+ break;
+ case 0x8e: /* Power button pressed */
+ break;
+ case 0x85: /* Unknown */
+ case 0x8d: /* Unknown */
+ case 0x94: /* Unknown */
+ case 0x95: /* Unknown */
+ default:
+ pr_info("Unknown event received %x\n", event);
+ break;
+ }
+
+ acpi_bus_generate_netlink_event(acpi_dev->pnp.device_class,
+ dev_name(&acpi_dev->dev),
+ event, (event == 0x80) ?
+ dev->last_key_event : 0);
+}
+
static void toshiba_acpi_remove(struct acpi_device *acpi_dev)
{
struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev);
@@ -3495,66 +3555,6 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
return ret;
}
-static void toshiba_acpi_notify(struct acpi_device *acpi_dev, u32 event)
-{
- struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev);
-
- switch (event) {
- case 0x80: /* Hotkeys and some system events */
- /*
- * Machines with this WMI GUID aren't supported due to bugs in
- * their AML.
- *
- * Return silently to avoid triggering a netlink event.
- */
- if (wmi_has_guid(TOSHIBA_WMI_EVENT_GUID))
- return;
- toshiba_acpi_process_hotkeys(dev);
- break;
- case 0x81: /* Dock events */
- case 0x82:
- case 0x83:
- pr_info("Dock event received %x\n", event);
- break;
- case 0x88: /* Thermal events */
- pr_info("Thermal event received\n");
- break;
- case 0x8f: /* LID closed */
- case 0x90: /* LID is closed and Dock has been ejected */
- break;
- case 0x8c: /* SATA power events */
- case 0x8b:
- pr_info("SATA power event received %x\n", event);
- break;
- case 0x92: /* Keyboard backlight mode changed */
- dev->kbd_event_generated = true;
- /* Update sysfs entries */
- if (sysfs_update_group(&acpi_dev->dev.kobj,
- &toshiba_attr_group))
- pr_err("Unable to update sysfs entries\n");
- /* Notify LED subsystem about keyboard backlight change */
- if (dev->kbd_type == 2 && dev->kbd_mode != SCI_KBD_MODE_AUTO)
- led_classdev_notify_brightness_hw_changed(&dev->kbd_led,
- (dev->kbd_mode == SCI_KBD_MODE_ON) ?
- LED_FULL : LED_OFF);
- break;
- case 0x8e: /* Power button pressed */
- break;
- case 0x85: /* Unknown */
- case 0x8d: /* Unknown */
- case 0x94: /* Unknown */
- case 0x95: /* Unknown */
- default:
- pr_info("Unknown event received %x\n", event);
- break;
- }
-
- acpi_bus_generate_netlink_event(acpi_dev->pnp.device_class,
- dev_name(&acpi_dev->dev),
- event, (event == 0x80) ?
- dev->last_key_event : 0);
-}
-
#ifdef CONFIG_PM_SLEEP
static int toshiba_acpi_suspend(struct device *device)
{
--
2.51.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v1 2/7] platform/x86: toshiba_acpi: Register ACPI notify handler directly
2026-03-24 19:57 [PATCH v1 0/7] platform/x86: toshiba: Bind to platform devices instead of ACPI ones Rafael J. Wysocki
2026-03-24 19:58 ` [PATCH v1 1/7] platform/x86: toshiba_acpi: Reorder code to avoid forward declaration Rafael J. Wysocki
@ 2026-03-24 19:58 ` Rafael J. Wysocki
2026-03-24 20:00 ` [PATCH v1 3/7] platform/x86: toshiba_acpi: Convert ACPI driver to a platform one Rafael J. Wysocki
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Rafael J. Wysocki @ 2026-03-24 19:58 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: LKML, Linux ACPI, Hans de Goede, platform-driver-x86,
Azael Avalos
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
To facilitate subsequent conversion of the driver to a platform one,
make it install an ACPI notify handler directly instead of using
a .notify() callback in struct acpi_driver.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/platform/x86/toshiba_acpi.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index fbd7b6b6b826..b839f62ec9cc 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -223,6 +223,7 @@ struct toshiba_acpi_dev {
unsigned int cooling_method_supported:1;
unsigned int battery_charge_mode_supported:1;
unsigned int sysfs_created:1;
+ unsigned int notify_handler_installed:1;
unsigned int special_functions;
bool kbd_event_generated;
@@ -3193,9 +3194,10 @@ static void print_supported_features(struct toshiba_acpi_dev *dev)
pr_cont("\n");
}
-static void toshiba_acpi_notify(struct acpi_device *acpi_dev, u32 event)
+static void toshiba_acpi_notify(acpi_handle handle, u32 event, void *data)
{
- struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev);
+ struct toshiba_acpi_dev *dev = data;
+ struct acpi_device *acpi_dev = dev->acpi_dev;
switch (event) {
case 0x80: /* Hotkeys and some system events */
@@ -3261,6 +3263,10 @@ static void toshiba_acpi_remove(struct acpi_device *acpi_dev)
remove_toshiba_proc_entries(dev);
+ if (dev->notify_handler_installed)
+ acpi_dev_remove_notify_handler(acpi_dev, ACPI_DEVICE_NOTIFY,
+ toshiba_acpi_notify);
+
#if IS_ENABLED(CONFIG_HWMON)
if (dev->hwmon_device)
hwmon_device_unregister(dev->hwmon_device);
@@ -3537,6 +3543,13 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
}
dev->sysfs_created = !ret;
+ ret = acpi_dev_install_notify_handler(acpi_dev, ACPI_DEVICE_NOTIFY,
+ toshiba_acpi_notify, dev);
+ if (ret)
+ goto error;
+
+ dev->notify_handler_installed = 1;
+
create_toshiba_proc_entries(dev);
toshiba_acpi = dev;
@@ -3602,7 +3615,6 @@ static struct acpi_driver toshiba_acpi_driver = {
.ops = {
.add = toshiba_acpi_add,
.remove = toshiba_acpi_remove,
- .notify = toshiba_acpi_notify,
},
.drv.pm = &toshiba_acpi_pm,
};
--
2.51.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v1 3/7] platform/x86: toshiba_acpi: Convert ACPI driver to a platform one
2026-03-24 19:57 [PATCH v1 0/7] platform/x86: toshiba: Bind to platform devices instead of ACPI ones Rafael J. Wysocki
2026-03-24 19:58 ` [PATCH v1 1/7] platform/x86: toshiba_acpi: Reorder code to avoid forward declaration Rafael J. Wysocki
2026-03-24 19:58 ` [PATCH v1 2/7] platform/x86: toshiba_acpi: Register ACPI notify handler directly Rafael J. Wysocki
@ 2026-03-24 20:00 ` Rafael J. Wysocki
2026-03-24 20:00 ` [PATCH v1 4/7] platform/x86: toshiba_bluetooth: Register ACPI notify handler directly Rafael J. Wysocki
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Rafael J. Wysocki @ 2026-03-24 20:00 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: LKML, Linux ACPI, Hans de Goede, platform-driver-x86,
Azael Avalos
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
In all cases in which a struct acpi_driver is used for binding a driver
to an ACPI device object, a corresponding platform device is created by
the ACPI core and that device is regarded as a proper representation of
underlying hardware. Accordingly, a struct platform_driver should be
used by driver code to bind to that device. There are multiple reasons
why drivers should not bind directly to ACPI device objects [1].
Overall, it is better to bind drivers to platform devices than to their
ACPI companions, so convert the Toshiba Laptop ACPI Extras driver from
an ACPI driver to a platform one.
After this change, all of the subordinate hwmon, IIO, and LED class
devices will be registered under the platform device used for driver
binding instead of its ACPI companion.
While this is not expected to alter functionality, it changes sysfs
layout and so it will be visible to user space.
However, the sysfs attributes in toshiba_attr_group will still be there
in the sysfs directory of the ACPI companion of the platform device used
for driver binding to maintain backwards compatibility with possibly
existing user space utilities depending on the presence of those
attributes.
Link: https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/ [1]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/platform/x86/toshiba_acpi.c | 50 ++++++++++++++++-------------
1 file changed, 27 insertions(+), 23 deletions(-)
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index b839f62ec9cc..35d899c01740 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -44,6 +44,7 @@
#include <linux/rfkill.h>
#include <linux/hwmon.h>
#include <linux/iio/iio.h>
+#include <linux/platform_device.h>
#include <linux/toshiba.h>
#include <acpi/battery.h>
#include <acpi/video.h>
@@ -3255,16 +3256,17 @@ static void toshiba_acpi_notify(acpi_handle handle, u32 event, void *data)
dev->last_key_event : 0);
}
-static void toshiba_acpi_remove(struct acpi_device *acpi_dev)
+static void toshiba_acpi_remove(struct platform_device *pdev)
{
- struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev);
+ struct toshiba_acpi_dev *dev = platform_get_drvdata(pdev);
misc_deregister(&dev->miscdev);
remove_toshiba_proc_entries(dev);
if (dev->notify_handler_installed)
- acpi_dev_remove_notify_handler(acpi_dev, ACPI_DEVICE_NOTIFY,
+ acpi_dev_remove_notify_handler(ACPI_COMPANION(&pdev->dev),
+ ACPI_DEVICE_NOTIFY,
toshiba_acpi_notify);
#if IS_ENABLED(CONFIG_HWMON)
@@ -3306,6 +3308,8 @@ static void toshiba_acpi_remove(struct acpi_device *acpi_dev)
if (toshiba_acpi)
toshiba_acpi = NULL;
+ dev_set_drvdata(&dev->acpi_dev->dev, NULL);
+
kfree(dev);
}
@@ -3368,8 +3372,9 @@ static const struct dmi_system_id toshiba_dmi_quirks[] __initconst = {
{ }
};
-static int toshiba_acpi_add(struct acpi_device *acpi_dev)
+static int toshiba_acpi_probe(struct platform_device *pdev)
{
+ struct acpi_device *acpi_dev = ACPI_COMPANION(&pdev->dev);
struct toshiba_acpi_dev *dev;
const char *hci_method;
u32 dummy;
@@ -3403,7 +3408,7 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
return ret;
}
- acpi_dev->driver_data = dev;
+ platform_set_drvdata(pdev, dev);
dev_set_drvdata(&acpi_dev->dev, dev);
/* Query the BIOS for supported features */
@@ -3434,7 +3439,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;
- led_classdev_register(&acpi_dev->dev, &dev->led_dev);
+ led_classdev_register(&pdev->dev, &dev->led_dev);
}
toshiba_eco_mode_available(dev);
@@ -3443,7 +3448,7 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
dev->eco_led.max_brightness = 1;
dev->eco_led.brightness_set = toshiba_eco_mode_set_status;
dev->eco_led.brightness_get = toshiba_eco_mode_get_status;
- led_classdev_register(&dev->acpi_dev->dev, &dev->eco_led);
+ led_classdev_register(&pdev->dev, &dev->eco_led);
}
toshiba_kbd_illum_available(dev);
@@ -3459,7 +3464,7 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
dev->kbd_led.max_brightness = 1;
dev->kbd_led.brightness_set = toshiba_kbd_backlight_set;
dev->kbd_led.brightness_get = toshiba_kbd_backlight_get;
- led_classdev_register(&dev->acpi_dev->dev, &dev->kbd_led);
+ led_classdev_register(&pdev->dev, &dev->kbd_led);
}
ret = toshiba_touchpad_get(dev, &dummy);
@@ -3467,7 +3472,7 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
toshiba_accelerometer_available(dev);
if (dev->accelerometer_supported) {
- dev->indio_dev = iio_device_alloc(&acpi_dev->dev, sizeof(*dev));
+ dev->indio_dev = iio_device_alloc(&pdev->dev, sizeof(*dev));
if (!dev->indio_dev) {
pr_err("Unable to allocate iio device\n");
goto iio_error;
@@ -3516,7 +3521,7 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
#if IS_ENABLED(CONFIG_HWMON)
if (dev->fan_rpm_supported) {
dev->hwmon_device = hwmon_device_register_with_info(
- &dev->acpi_dev->dev, "toshiba_acpi_sensors", NULL,
+ &pdev->dev, "toshiba_acpi_sensors", NULL,
&toshiba_acpi_hwmon_chip_info, NULL);
if (IS_ERR(dev->hwmon_device)) {
dev->hwmon_device = NULL;
@@ -3564,14 +3569,14 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
return 0;
error:
- toshiba_acpi_remove(acpi_dev);
+ toshiba_acpi_remove(pdev);
return ret;
}
#ifdef CONFIG_PM_SLEEP
static int toshiba_acpi_suspend(struct device *device)
{
- struct toshiba_acpi_dev *dev = acpi_driver_data(to_acpi_device(device));
+ struct toshiba_acpi_dev *dev = dev_get_drvdata(device);
if (dev->hotkey_dev) {
u32 result;
@@ -3586,7 +3591,7 @@ static int toshiba_acpi_suspend(struct device *device)
static int toshiba_acpi_resume(struct device *device)
{
- struct toshiba_acpi_dev *dev = acpi_driver_data(to_acpi_device(device));
+ struct toshiba_acpi_dev *dev = dev_get_drvdata(device);
if (dev->hotkey_dev) {
if (toshiba_acpi_enable_hotkeys(dev))
@@ -3608,15 +3613,14 @@ static int toshiba_acpi_resume(struct device *device)
static SIMPLE_DEV_PM_OPS(toshiba_acpi_pm,
toshiba_acpi_suspend, toshiba_acpi_resume);
-static struct acpi_driver toshiba_acpi_driver = {
- .name = "Toshiba ACPI driver",
- .ids = toshiba_device_ids,
- .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
- .ops = {
- .add = toshiba_acpi_add,
- .remove = toshiba_acpi_remove,
+static struct platform_driver toshiba_acpi_driver = {
+ .probe = toshiba_acpi_probe,
+ .remove = toshiba_acpi_remove,
+ .driver = {
+ .name = "Toshiba ACPI driver",
+ .acpi_match_table = toshiba_device_ids,
+ .pm = &toshiba_acpi_pm,
},
- .drv.pm = &toshiba_acpi_pm,
};
static void __init toshiba_dmi_init(void)
@@ -3646,7 +3650,7 @@ static int __init toshiba_acpi_init(void)
return -ENODEV;
}
- ret = acpi_bus_register_driver(&toshiba_acpi_driver);
+ ret = platform_driver_register(&toshiba_acpi_driver);
if (ret) {
pr_err("Failed to register ACPI driver: %d\n", ret);
remove_proc_entry(PROC_TOSHIBA, acpi_root_dir);
@@ -3657,7 +3661,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(&toshiba_acpi_driver);
if (toshiba_proc_dir)
remove_proc_entry(PROC_TOSHIBA, acpi_root_dir);
}
--
2.51.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v1 4/7] platform/x86: toshiba_bluetooth: Register ACPI notify handler directly
2026-03-24 19:57 [PATCH v1 0/7] platform/x86: toshiba: Bind to platform devices instead of ACPI ones Rafael J. Wysocki
` (2 preceding siblings ...)
2026-03-24 20:00 ` [PATCH v1 3/7] platform/x86: toshiba_acpi: Convert ACPI driver to a platform one Rafael J. Wysocki
@ 2026-03-24 20:00 ` Rafael J. Wysocki
2026-03-24 20:01 ` [PATCH v1 5/7] platform/x86: toshiba_bluetooth: Convert ACPI driver to a platform one Rafael J. Wysocki
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Rafael J. Wysocki @ 2026-03-24 20:00 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: LKML, Linux ACPI, Hans de Goede, platform-driver-x86,
Azael Avalos
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
To facilitate subsequent conversion of the driver to a platform one,
make it install an ACPI notify handler directly instead of using
a .notify() callback in struct acpi_driver.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/platform/x86/toshiba_bluetooth.c | 32 ++++++++++++++++++------
1 file changed, 24 insertions(+), 8 deletions(-)
diff --git a/drivers/platform/x86/toshiba_bluetooth.c b/drivers/platform/x86/toshiba_bluetooth.c
index e587beef05b9..3824c2beaf11 100644
--- a/drivers/platform/x86/toshiba_bluetooth.c
+++ b/drivers/platform/x86/toshiba_bluetooth.c
@@ -37,7 +37,7 @@ struct toshiba_bluetooth_dev {
static int toshiba_bt_rfkill_add(struct acpi_device *device);
static void toshiba_bt_rfkill_remove(struct acpi_device *device);
-static void toshiba_bt_rfkill_notify(struct acpi_device *device, u32 event);
+static void toshiba_bt_rfkill_notify(acpi_handle handle, u32 event, void *data);
static const struct acpi_device_id bt_device_ids[] = {
{ "TOS6205", 0},
@@ -57,7 +57,6 @@ static struct acpi_driver toshiba_bt_rfkill_driver = {
.ops = {
.add = toshiba_bt_rfkill_add,
.remove = toshiba_bt_rfkill_remove,
- .notify = toshiba_bt_rfkill_notify,
},
.drv.pm = &toshiba_bt_pm,
};
@@ -203,9 +202,9 @@ static const struct rfkill_ops rfk_ops = {
};
/* ACPI driver functions */
-static void toshiba_bt_rfkill_notify(struct acpi_device *device, u32 event)
+static void toshiba_bt_rfkill_notify(acpi_handle handle, u32 event, void *data)
{
- struct toshiba_bluetooth_dev *bt_dev = acpi_driver_data(device);
+ struct toshiba_bluetooth_dev *bt_dev = data;
if (toshiba_bluetooth_sync_status(bt_dev))
return;
@@ -262,8 +261,8 @@ static int toshiba_bt_rfkill_add(struct acpi_device *device)
bt_dev);
if (!bt_dev->rfk) {
pr_err("Unable to allocate rfkill device\n");
- kfree(bt_dev);
- return -ENOMEM;
+ result = -ENOMEM;
+ goto err_free_bt_dev;
}
rfkill_set_hw_state(bt_dev->rfk, !bt_dev->killswitch);
@@ -271,10 +270,24 @@ static int toshiba_bt_rfkill_add(struct acpi_device *device)
result = rfkill_register(bt_dev->rfk);
if (result) {
pr_err("Unable to register rfkill device\n");
- rfkill_destroy(bt_dev->rfk);
- kfree(bt_dev);
+ goto err_rfkill_destroy;
}
+ result = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY,
+ toshiba_bt_rfkill_notify, bt_dev);
+ if (result) {
+ pr_err("Unable to register ACPI notify handler\n");
+ goto err_rfkill_unregister;
+ }
+
+ return 0;
+
+err_rfkill_unregister:
+ rfkill_unregister(bt_dev->rfk);
+err_rfkill_destroy:
+ rfkill_destroy(bt_dev->rfk);
+err_free_bt_dev:
+ kfree(bt_dev);
return result;
}
@@ -283,6 +296,9 @@ static void toshiba_bt_rfkill_remove(struct acpi_device *device)
struct toshiba_bluetooth_dev *bt_dev = acpi_driver_data(device);
/* clean up */
+ acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY,
+ toshiba_bt_rfkill_notify);
+
if (bt_dev->rfk) {
rfkill_unregister(bt_dev->rfk);
rfkill_destroy(bt_dev->rfk);
--
2.51.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v1 5/7] platform/x86: toshiba_bluetooth: Convert ACPI driver to a platform one
2026-03-24 19:57 [PATCH v1 0/7] platform/x86: toshiba: Bind to platform devices instead of ACPI ones Rafael J. Wysocki
` (3 preceding siblings ...)
2026-03-24 20:00 ` [PATCH v1 4/7] platform/x86: toshiba_bluetooth: Register ACPI notify handler directly Rafael J. Wysocki
@ 2026-03-24 20:01 ` Rafael J. Wysocki
2026-03-24 20:02 ` [PATCH v1 6/7] platform/x86: toshiba_haps: Register ACPI notify handler directly Rafael J. Wysocki
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Rafael J. Wysocki @ 2026-03-24 20:01 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: LKML, Linux ACPI, Hans de Goede, platform-driver-x86,
Azael Avalos
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
In all cases in which a struct acpi_driver is used for binding a driver
to an ACPI device object, a corresponding platform device is created by
the ACPI core and that device is regarded as a proper representation of
underlying hardware. Accordingly, a struct platform_driver should be
used by driver code to bind to that device. There are multiple reasons
why drivers should not bind directly to ACPI device objects [1].
Overall, it is better to bind drivers to platform devices than to their
ACPI companions, so convert the Toshiba Bluetooth Enable driver from an
ACPI driver to a platform one.
While this is not expected to alter functionality, it changes sysfs
layout and so it will be visible to user space.
Link: https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/ [1]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/platform/x86/toshiba_bluetooth.c | 42 ++++++++++++------------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/drivers/platform/x86/toshiba_bluetooth.c b/drivers/platform/x86/toshiba_bluetooth.c
index 3824c2beaf11..e50d4fc1e603 100644
--- a/drivers/platform/x86/toshiba_bluetooth.c
+++ b/drivers/platform/x86/toshiba_bluetooth.c
@@ -17,6 +17,7 @@
#include <linux/types.h>
#include <linux/acpi.h>
#include <linux/rfkill.h>
+#include <linux/platform_device.h>
#define BT_KILLSWITCH_MASK 0x01
#define BT_PLUGGED_MASK 0x40
@@ -35,8 +36,8 @@ struct toshiba_bluetooth_dev {
bool powered;
};
-static int toshiba_bt_rfkill_add(struct acpi_device *device);
-static void toshiba_bt_rfkill_remove(struct acpi_device *device);
+static int toshiba_bt_rfkill_probe(struct platform_device *pdev);
+static void toshiba_bt_rfkill_remove(struct platform_device *pdev);
static void toshiba_bt_rfkill_notify(acpi_handle handle, u32 event, void *data);
static const struct acpi_device_id bt_device_ids[] = {
@@ -50,15 +51,14 @@ static int toshiba_bt_resume(struct device *dev);
#endif
static SIMPLE_DEV_PM_OPS(toshiba_bt_pm, NULL, toshiba_bt_resume);
-static struct acpi_driver toshiba_bt_rfkill_driver = {
- .name = "Toshiba BT",
- .class = "Toshiba",
- .ids = bt_device_ids,
- .ops = {
- .add = toshiba_bt_rfkill_add,
- .remove = toshiba_bt_rfkill_remove,
- },
- .drv.pm = &toshiba_bt_pm,
+static struct platform_driver toshiba_bt_rfkill_driver = {
+ .probe = toshiba_bt_rfkill_probe,
+ .remove = toshiba_bt_rfkill_remove,
+ .driver = {
+ .name = "Toshiba BT",
+ .acpi_match_table = bt_device_ids,
+ .pm = &toshiba_bt_pm,
+ },
};
static int toshiba_bluetooth_present(acpi_handle handle)
@@ -215,11 +215,9 @@ static void toshiba_bt_rfkill_notify(acpi_handle handle, u32 event, void *data)
#ifdef CONFIG_PM_SLEEP
static int toshiba_bt_resume(struct device *dev)
{
- struct toshiba_bluetooth_dev *bt_dev;
+ struct toshiba_bluetooth_dev *bt_dev = dev_get_drvdata(dev);
int ret;
- bt_dev = acpi_driver_data(to_acpi_device(dev));
-
ret = toshiba_bluetooth_sync_status(bt_dev);
if (ret)
return ret;
@@ -230,8 +228,9 @@ static int toshiba_bt_resume(struct device *dev)
}
#endif
-static int toshiba_bt_rfkill_add(struct acpi_device *device)
+static int toshiba_bt_rfkill_probe(struct platform_device *pdev)
{
+ struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
struct toshiba_bluetooth_dev *bt_dev;
int result;
@@ -245,8 +244,8 @@ static int toshiba_bt_rfkill_add(struct acpi_device *device)
if (!bt_dev)
return -ENOMEM;
bt_dev->acpi_dev = device;
- device->driver_data = bt_dev;
- dev_set_drvdata(&device->dev, bt_dev);
+
+ platform_set_drvdata(pdev, bt_dev);
result = toshiba_bluetooth_sync_status(bt_dev);
if (result) {
@@ -255,7 +254,7 @@ static int toshiba_bt_rfkill_add(struct acpi_device *device)
}
bt_dev->rfk = rfkill_alloc("Toshiba Bluetooth",
- &device->dev,
+ &pdev->dev,
RFKILL_TYPE_BLUETOOTH,
&rfk_ops,
bt_dev);
@@ -291,9 +290,10 @@ static int toshiba_bt_rfkill_add(struct acpi_device *device)
return result;
}
-static void toshiba_bt_rfkill_remove(struct acpi_device *device)
+static void toshiba_bt_rfkill_remove(struct platform_device *pdev)
{
- struct toshiba_bluetooth_dev *bt_dev = acpi_driver_data(device);
+ struct toshiba_bluetooth_dev *bt_dev = platform_get_drvdata(pdev);
+ struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
/* clean up */
acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY,
@@ -309,4 +309,4 @@ static void toshiba_bt_rfkill_remove(struct acpi_device *device)
toshiba_bluetooth_disable(device->handle);
}
-module_acpi_driver(toshiba_bt_rfkill_driver);
+module_platform_driver(toshiba_bt_rfkill_driver);
--
2.51.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v1 6/7] platform/x86: toshiba_haps: Register ACPI notify handler directly
2026-03-24 19:57 [PATCH v1 0/7] platform/x86: toshiba: Bind to platform devices instead of ACPI ones Rafael J. Wysocki
` (4 preceding siblings ...)
2026-03-24 20:01 ` [PATCH v1 5/7] platform/x86: toshiba_bluetooth: Convert ACPI driver to a platform one Rafael J. Wysocki
@ 2026-03-24 20:02 ` Rafael J. Wysocki
2026-03-24 20:03 ` [PATCH v1 7/7] platform/x86: toshiba_haps: Convert ACPI driver to a platform one Rafael J. Wysocki
2026-03-31 16:41 ` [PATCH v1 0/7] platform/x86: toshiba: Bind to platform devices instead of ACPI ones Ilpo Järvinen
7 siblings, 0 replies; 9+ messages in thread
From: Rafael J. Wysocki @ 2026-03-24 20:02 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: LKML, Linux ACPI, Hans de Goede, platform-driver-x86,
Azael Avalos
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
To facilitate subsequent conversion of the driver to a platform one,
make it install an ACPI notify handler directly instead of using
a .notify() callback in struct acpi_driver.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/platform/x86/toshiba_haps.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/x86/toshiba_haps.c b/drivers/platform/x86/toshiba_haps.c
index e9324bf16aea..6eac306cf92a 100644
--- a/drivers/platform/x86/toshiba_haps.c
+++ b/drivers/platform/x86/toshiba_haps.c
@@ -129,8 +129,10 @@ static const struct attribute_group haps_attr_group = {
/*
* ACPI stuff
*/
-static void toshiba_haps_notify(struct acpi_device *device, u32 event)
+static void toshiba_haps_notify(acpi_handle handle, u32 event, void *data)
{
+ struct acpi_device *device = data;
+
pr_debug("Received event: 0x%x\n", event);
acpi_bus_generate_netlink_event(device->pnp.device_class,
@@ -140,6 +142,9 @@ static void toshiba_haps_notify(struct acpi_device *device, u32 event)
static void toshiba_haps_remove(struct acpi_device *device)
{
+ acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY,
+ toshiba_haps_notify);
+
sysfs_remove_group(&device->dev.kobj, &haps_attr_group);
if (toshiba_haps)
@@ -201,9 +206,18 @@ static int toshiba_haps_add(struct acpi_device *acpi_dev)
if (ret)
return ret;
+ ret = acpi_dev_install_notify_handler(acpi_dev, ACPI_DEVICE_NOTIFY,
+ toshiba_haps_notify, acpi_dev);
+ if (ret)
+ goto err;
+
toshiba_haps = haps;
return 0;
+
+err:
+ sysfs_remove_group(&acpi_dev->dev.kobj, &haps_attr_group);
+ return ret;
}
#ifdef CONFIG_PM_SLEEP
@@ -256,7 +270,6 @@ static struct acpi_driver toshiba_haps_driver = {
.ops = {
.add = toshiba_haps_add,
.remove = toshiba_haps_remove,
- .notify = toshiba_haps_notify,
},
.drv.pm = &toshiba_haps_pm,
};
--
2.51.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v1 7/7] platform/x86: toshiba_haps: Convert ACPI driver to a platform one
2026-03-24 19:57 [PATCH v1 0/7] platform/x86: toshiba: Bind to platform devices instead of ACPI ones Rafael J. Wysocki
` (5 preceding siblings ...)
2026-03-24 20:02 ` [PATCH v1 6/7] platform/x86: toshiba_haps: Register ACPI notify handler directly Rafael J. Wysocki
@ 2026-03-24 20:03 ` Rafael J. Wysocki
2026-03-31 16:41 ` [PATCH v1 0/7] platform/x86: toshiba: Bind to platform devices instead of ACPI ones Ilpo Järvinen
7 siblings, 0 replies; 9+ messages in thread
From: Rafael J. Wysocki @ 2026-03-24 20:03 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: LKML, Linux ACPI, Hans de Goede, platform-driver-x86,
Azael Avalos
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
In all cases in which a struct acpi_driver is used for binding a driver
to an ACPI device object, a corresponding platform device is created by
the ACPI core and that device is regarded as a proper representation of
underlying hardware. Accordingly, a struct platform_driver should be
used by driver code to bind to that device. There are multiple reasons
why drivers should not bind directly to ACPI device objects [1].
Overall, it is better to bind drivers to platform devices than to their
ACPI companions, so convert the Toshiba HDD Active Protection Sensor
driver from an ACPI driver to a platform one.
While this is not expected to alter functionality, it changes sysfs
layout and so it will be visible to user space.
Note that the sysfs attributes in haps_attr_group will still be there
in the sysfs directory of the ACPI companion of the platform device
used for driver binding in case there are tools in user space expecting
them to be present there.
Link: https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/ [1]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/platform/x86/toshiba_haps.c | 40 +++++++++++++++--------------
1 file changed, 21 insertions(+), 19 deletions(-)
diff --git a/drivers/platform/x86/toshiba_haps.c b/drivers/platform/x86/toshiba_haps.c
index 6eac306cf92a..1486252b5983 100644
--- a/drivers/platform/x86/toshiba_haps.c
+++ b/drivers/platform/x86/toshiba_haps.c
@@ -12,6 +12,7 @@
#include <linux/init.h>
#include <linux/types.h>
#include <linux/acpi.h>
+#include <linux/platform_device.h>
MODULE_AUTHOR("Azael Avalos <coproscefalo@gmail.com>");
MODULE_DESCRIPTION("Toshiba HDD Active Protection Sensor");
@@ -140,8 +141,10 @@ static void toshiba_haps_notify(acpi_handle handle, u32 event, void *data)
event, 0);
}
-static void toshiba_haps_remove(struct acpi_device *device)
+static void toshiba_haps_remove(struct platform_device *pdev)
{
+ struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
+
acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY,
toshiba_haps_notify);
@@ -149,6 +152,8 @@ static void toshiba_haps_remove(struct acpi_device *device)
if (toshiba_haps)
toshiba_haps = NULL;
+
+ dev_set_drvdata(&device->dev, NULL);
}
/* Helper function */
@@ -175,8 +180,9 @@ static int toshiba_haps_available(acpi_handle handle)
return 1;
}
-static int toshiba_haps_add(struct acpi_device *acpi_dev)
+static int toshiba_haps_probe(struct platform_device *pdev)
{
+ struct acpi_device *acpi_dev = ACPI_COMPANION(&pdev->dev);
struct toshiba_haps_dev *haps;
int ret;
@@ -188,14 +194,15 @@ static int toshiba_haps_add(struct acpi_device *acpi_dev)
pr_info("Toshiba HDD Active Protection Sensor device\n");
- haps = devm_kzalloc(&acpi_dev->dev, sizeof(*haps), GFP_KERNEL);
+ haps = devm_kzalloc(&pdev->dev, sizeof(*haps), GFP_KERNEL);
if (!haps)
return -ENOMEM;
haps->acpi_dev = acpi_dev;
haps->protection_level = 2;
- acpi_dev->driver_data = haps;
+
dev_set_drvdata(&acpi_dev->dev, haps);
+ platform_set_drvdata(pdev, haps);
/* Set the protection level, currently at level 2 (Medium) */
ret = toshiba_haps_protection_level(acpi_dev->handle, 2);
@@ -223,11 +230,9 @@ static int toshiba_haps_add(struct acpi_device *acpi_dev)
#ifdef CONFIG_PM_SLEEP
static int toshiba_haps_suspend(struct device *device)
{
- struct toshiba_haps_dev *haps;
+ struct toshiba_haps_dev *haps = dev_get_drvdata(device);
int ret;
- haps = acpi_driver_data(to_acpi_device(device));
-
/* Deactivate the protection on suspend */
ret = toshiba_haps_protection_level(haps->acpi_dev->handle, 0);
@@ -236,11 +241,9 @@ static int toshiba_haps_suspend(struct device *device)
static int toshiba_haps_resume(struct device *device)
{
- struct toshiba_haps_dev *haps;
+ struct toshiba_haps_dev *haps = dev_get_drvdata(device);
int ret;
- haps = acpi_driver_data(to_acpi_device(device));
-
/* Set the stored protection level */
ret = toshiba_haps_protection_level(haps->acpi_dev->handle,
haps->protection_level);
@@ -263,15 +266,14 @@ static const struct acpi_device_id haps_device_ids[] = {
};
MODULE_DEVICE_TABLE(acpi, haps_device_ids);
-static struct acpi_driver toshiba_haps_driver = {
- .name = "Toshiba HAPS",
- .ids = haps_device_ids,
- .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
- .ops = {
- .add = toshiba_haps_add,
- .remove = toshiba_haps_remove,
+static struct platform_driver toshiba_haps_driver = {
+ .probe = toshiba_haps_probe,
+ .remove = toshiba_haps_remove,
+ .driver = {
+ .name = "Toshiba HAPS",
+ .acpi_match_table = haps_device_ids,
+ .pm = &toshiba_haps_pm,
},
- .drv.pm = &toshiba_haps_pm,
};
-module_acpi_driver(toshiba_haps_driver);
+module_platform_driver(toshiba_haps_driver);
--
2.51.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH v1 0/7] platform/x86: toshiba: Bind to platform devices instead of ACPI ones
2026-03-24 19:57 [PATCH v1 0/7] platform/x86: toshiba: Bind to platform devices instead of ACPI ones Rafael J. Wysocki
` (6 preceding siblings ...)
2026-03-24 20:03 ` [PATCH v1 7/7] platform/x86: toshiba_haps: Convert ACPI driver to a platform one Rafael J. Wysocki
@ 2026-03-31 16:41 ` Ilpo Järvinen
7 siblings, 0 replies; 9+ messages in thread
From: Ilpo Järvinen @ 2026-03-31 16:41 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: LKML, Linux ACPI, Hans de Goede, platform-driver-x86,
Azael Avalos
On Tue, 24 Mar 2026 20:57:18 +0100, Rafael J. Wysocki wrote:
> This series is part of a larger effort to switch over all drivers using
> the struct acpi_driver interface to the more common struct platform_driver
> interface and eliminate the former. The background is explained in
> Documentation/driver-api/acpi/acpi-drivers.rst and in the changelog of
> the patch that introduced the above document:
>
> https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/
>
> [...]
Thank you for your contribution, it has been applied to my local
review-ilpo-next branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-next branch only once I've pushed my
local branch there, which might take a while.
The list of commits applied:
[1/7] platform/x86: toshiba_acpi: Reorder code to avoid forward declaration
commit: 99aef5d711c6e463ceff34d0657eca4b4558996a
[2/7] platform/x86: toshiba_acpi: Register ACPI notify handler directly
commit: b0bcf48c74cc7f72d1b6effc7cecdae871b1785e
[3/7] platform/x86: toshiba_acpi: Convert ACPI driver to a platform one
commit: 246d6cefe525f3fc760017e717bd77a3e751a260
[4/7] platform/x86: toshiba_bluetooth: Register ACPI notify handler directly
commit: 4315abf338301090eec70c68117afa854fddb264
[5/7] platform/x86: toshiba_bluetooth: Convert ACPI driver to a platform one
commit: 553b2ac59fbb434330287fde0cabc64bc6f11ceb
[6/7] platform/x86: toshiba_haps: Register ACPI notify handler directly
commit: 32156fd2fbb8fc2d049ad459336cd71b2556f75a
[7/7] platform/x86: toshiba_haps: Convert ACPI driver to a platform one
commit: 3a96c7915d93231e128df74901fe8fcb960b0ecb
--
i.
^ permalink raw reply [flat|nested] 9+ messages in thread