From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Linux ACPI <linux-acpi@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Linux PM <linux-pm@vger.kernel.org>, Armin Wolf <w_armin@gmx.de>,
Hans de Goede <hansg@kernel.org>
Subject: [PATCH v1 3/3] ACPI: video: Convert the driver to a platform one
Date: Wed, 10 Dec 2025 15:51:32 +0100 [thread overview]
Message-ID: <3920674.kQq0lBPeGt@rafael.j.wysocki> (raw)
In-Reply-To: <8617910.T7Z3S40VBb@rafael.j.wysocki>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
While binding drivers directly to struct acpi_device objects allows
basic functionality to be provided, at least in the majority of cases,
there are some problems with it, related to general consistency, sysfs
layout, power management operation ordering, and code cleanliness.
Overall, it is better to bind drivers to platform devices than to their
ACPI companions, so convert the ACPI video 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.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/acpi_video.c | 47 ++++++++++++++++++++++------------------------
1 file changed, 23 insertions(+), 24 deletions(-)
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -21,6 +21,7 @@
#include <linux/sort.h>
#include <linux/pci.h>
#include <linux/pci_ids.h>
+#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/dmi.h>
#include <linux/suspend.h>
@@ -76,8 +77,8 @@ static int register_count;
static DEFINE_MUTEX(register_count_mutex);
static DEFINE_MUTEX(video_list_lock);
static LIST_HEAD(video_bus_head);
-static int acpi_video_bus_add(struct acpi_device *device);
-static void acpi_video_bus_remove(struct acpi_device *device);
+static int acpi_video_bus_probe(struct platform_device *pdev);
+static void acpi_video_bus_remove(struct platform_device *pdev);
static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data);
/*
@@ -98,14 +99,13 @@ static const struct acpi_device_id video
};
MODULE_DEVICE_TABLE(acpi, video_device_ids);
-static struct acpi_driver acpi_video_bus = {
- .name = "video",
- .class = ACPI_VIDEO_CLASS,
- .ids = video_device_ids,
- .ops = {
- .add = acpi_video_bus_add,
- .remove = acpi_video_bus_remove,
- },
+static struct platform_driver acpi_video_bus = {
+ .probe = acpi_video_bus_probe,
+ .remove = acpi_video_bus_remove,
+ .driver = {
+ .name = "acpi-video",
+ .acpi_match_table = video_device_ids,
+ },
};
struct acpi_video_bus_flags {
@@ -1888,7 +1888,8 @@ static void acpi_video_dev_add_notify_ha
device->flags.notify = 1;
}
-static int acpi_video_bus_add_notify_handler(struct acpi_video_bus *video)
+static int acpi_video_bus_add_notify_handler(struct acpi_video_bus *video,
+ struct platform_device *pdev)
{
struct input_dev *input;
struct acpi_video_device *dev;
@@ -1911,7 +1912,7 @@ static int acpi_video_bus_add_notify_han
input->phys = video->phys;
input->id.bustype = BUS_HOST;
input->id.product = 0x06;
- input->dev.parent = &video->device->dev;
+ input->dev.parent = &pdev->dev;
input->evbit[0] = BIT(EV_KEY);
set_bit(KEY_SWITCHVIDEOMODE, input->keybit);
set_bit(KEY_VIDEO_NEXT, input->keybit);
@@ -1983,8 +1984,9 @@ static int acpi_video_bus_put_devices(st
static int instance;
-static int acpi_video_bus_add(struct acpi_device *device)
+static int acpi_video_bus_probe(struct platform_device *pdev)
{
+ struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
struct acpi_video_bus *video;
bool auto_detect;
int error;
@@ -2021,6 +2023,8 @@ static int acpi_video_bus_add(struct acp
instance++;
}
+ platform_set_drvdata(pdev, video);
+
video->device = device;
strscpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME);
strscpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
@@ -2068,7 +2072,7 @@ static int acpi_video_bus_add(struct acp
!auto_detect)
acpi_video_bus_register_backlight(video);
- error = acpi_video_bus_add_notify_handler(video);
+ error = acpi_video_bus_add_notify_handler(video, pdev);
if (error)
goto err_del;
@@ -2096,15 +2100,10 @@ err_free_video:
return error;
}
-static void acpi_video_bus_remove(struct acpi_device *device)
+static void acpi_video_bus_remove(struct platform_device *pdev)
{
- struct acpi_video_bus *video = NULL;
-
-
- if (!device || !acpi_driver_data(device))
- return;
-
- video = acpi_driver_data(device);
+ struct acpi_video_bus *video = platform_get_drvdata(pdev);
+ struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY,
acpi_video_bus_notify);
@@ -2167,7 +2166,7 @@ int acpi_video_register(void)
dmi_check_system(video_dmi_table);
- ret = acpi_bus_register_driver(&acpi_video_bus);
+ ret = platform_driver_register(&acpi_video_bus);
if (ret)
goto leave;
@@ -2187,7 +2186,7 @@ void acpi_video_unregister(void)
{
mutex_lock(®ister_count_mutex);
if (register_count) {
- acpi_bus_unregister_driver(&acpi_video_bus);
+ platform_driver_unregister(&acpi_video_bus);
register_count = 0;
may_report_brightness_keys = false;
}
prev parent reply other threads:[~2025-12-10 14:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-10 14:47 [PATCH v1 0/3] ACPI: video: Convert ACPI video driver to a platform one Rafael J. Wysocki
2025-12-10 14:48 ` [PATCH v1 1/3] ACPI: scan: Register platform devices for backlight device objects Rafael J. Wysocki
2025-12-10 14:50 ` [PATCH v1 2/3] ACPI: video: Adjust event notification routine Rafael J. Wysocki
2025-12-10 14:51 ` 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=3920674.kQq0lBPeGt@rafael.j.wysocki \
--to=rafael@kernel.org \
--cc=hansg@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=w_armin@gmx.de \
/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