From: "Rafael J. Wysocki" <rafael@kernel.org>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
Linux ACPI <linux-acpi@vger.kernel.org>,
Hans de Goede <hansg@kernel.org>,
platform-driver-x86@vger.kernel.org,
Kenneth Chan <kenneth.t.chan@gmail.com>
Subject: [PATCH v1 3/3] platform/x86: panasonic-laptop: Convert ACPI driver to a platform one
Date: Thu, 12 Mar 2026 12:22:20 +0100 [thread overview]
Message-ID: <3760406.R56niFO833@rafael.j.wysocki> (raw)
In-Reply-To: <3616223.QJadu78ljV@rafael.j.wysocki>
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 Panasonic laptop 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.
To maintain backwards compatibility with possibly existing user space,
the sysfs attributes created by the driver under the ACPI device object
used by it are not relocated. Accordingly, the driver will continue to
use the driver_data pointer in struct acpi_device which needs to be
cleared on driver removal.
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/panasonic-laptop.c | 33 ++++++++++++++-----------
1 file changed, 18 insertions(+), 15 deletions(-)
diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c
index 4bd83b987761..632d05adb6f3 100644
--- a/drivers/platform/x86/panasonic-laptop.c
+++ b/drivers/platform/x86/panasonic-laptop.c
@@ -183,8 +183,8 @@ enum SINF_BITS { SINF_NUM_BATTERIES = 0,
};
/* R1 handles SINF_AC_CUR_BRIGHT as SINF_CUR_BRIGHT, doesn't know AC state */
-static int acpi_pcc_hotkey_add(struct acpi_device *device);
-static void acpi_pcc_hotkey_remove(struct acpi_device *device);
+static int acpi_pcc_hotkey_probe(struct platform_device *pdev);
+static void acpi_pcc_hotkey_remove(struct platform_device *pdev);
static void acpi_pcc_hotkey_notify(acpi_handle handle, u32 event, void *data);
static const struct acpi_device_id pcc_device_ids[] = {
@@ -201,15 +201,14 @@ static int acpi_pcc_hotkey_resume(struct device *dev);
#endif
static SIMPLE_DEV_PM_OPS(acpi_pcc_hotkey_pm, NULL, acpi_pcc_hotkey_resume);
-static struct acpi_driver acpi_pcc_driver = {
- .name = ACPI_PCC_DRIVER_NAME,
- .class = ACPI_PCC_CLASS,
- .ids = pcc_device_ids,
- .ops = {
- .add = acpi_pcc_hotkey_add,
- .remove = acpi_pcc_hotkey_remove,
- },
- .drv.pm = &acpi_pcc_hotkey_pm,
+static struct platform_driver acpi_pcc_driver = {
+ .probe = acpi_pcc_hotkey_probe,
+ .remove = acpi_pcc_hotkey_remove,
+ .driver = {
+ .name = ACPI_PCC_DRIVER_NAME,
+ .acpi_match_table = pcc_device_ids,
+ .pm = &acpi_pcc_hotkey_pm,
+ },
};
static const struct key_entry panasonic_keymap[] = {
@@ -967,7 +966,7 @@ static int acpi_pcc_init_input(struct pcc_acpi *pcc)
#ifdef CONFIG_PM_SLEEP
static int acpi_pcc_hotkey_resume(struct device *dev)
{
- struct pcc_acpi *pcc = acpi_driver_data(to_acpi_device(dev));
+ struct pcc_acpi *pcc = acpi_driver_data(ACPI_COMPANION(dev));
if (pcc->num_sifr > SINF_MUTE)
acpi_pcc_write_sset(pcc, SINF_MUTE, pcc->mute);
@@ -983,8 +982,9 @@ static int acpi_pcc_hotkey_resume(struct device *dev)
}
#endif
-static int acpi_pcc_hotkey_add(struct acpi_device *device)
+static int acpi_pcc_hotkey_probe(struct platform_device *pdev)
{
+ struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
struct backlight_properties props;
struct pcc_acpi *pcc;
int num_sifr, result;
@@ -1116,8 +1116,9 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)
return result;
}
-static void acpi_pcc_hotkey_remove(struct acpi_device *device)
+static void acpi_pcc_hotkey_remove(struct platform_device *pdev)
{
+ struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
struct pcc_acpi *pcc = acpi_driver_data(device);
i8042_remove_filter(panasonic_i8042_filter);
@@ -1137,8 +1138,10 @@ static void acpi_pcc_hotkey_remove(struct acpi_device *device)
input_unregister_device(pcc->input_dev);
+ device->driver_data = NULL;
+
kfree(pcc->sinf);
kfree(pcc);
}
-module_acpi_driver(acpi_pcc_driver);
+module_platform_driver(acpi_pcc_driver);
--
2.51.0
prev parent reply other threads:[~2026-03-12 11:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 11:19 [PATCH v1 0/3] platform/x86: panasonic-laptop: Bind to a platform device instead of an ACPI one Rafael J. Wysocki
2026-03-12 11:20 ` [PATCH v1 1/3] platform/x86: panasonic-laptop: Remove redundant checks from 3 functions Rafael J. Wysocki
2026-03-12 11:21 ` [PATCH v1 2/3] platform/x86: panasonic-laptop: Register ACPI notify handler directly Rafael J. Wysocki
2026-03-17 17:35 ` Ilpo Järvinen
2026-03-18 12:53 ` Rafael J. Wysocki
2026-03-12 11:22 ` Rafael J. Wysocki [this message]
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=3760406.R56niFO833@rafael.j.wysocki \
--to=rafael@kernel.org \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=kenneth.t.chan@gmail.com \
--cc=linux-acpi@vger.kernel.org \
--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