Skip to content

Commit 3660e64

Browse files
committed
Merge branch 'acpi-bus'
Merge ACPI bus type driver updates for 6.7-rc1: - Add context argument to acpi_dev_install_notify_handler() (Rafael Wysocki). - Clarify ACPI bus concepts in the ACPI device enumeration documentation (Rafael Wysocki). * acpi-bus: ACPI: bus: Add context argument to acpi_dev_install_notify_handler() ACPI: docs: enumeration: Clarify ACPI bus concepts
2 parents e8c3c7f + 470508f commit 3660e64

File tree

9 files changed

+52
-9
lines changed

9 files changed

+52
-9
lines changed

Documentation/firmware-guide/acpi/enumeration.rst

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,49 @@ If the driver needs to perform more complex initialization like getting and
6464
configuring GPIOs it can get its ACPI handle and extract this information
6565
from ACPI tables.
6666

67+
ACPI device objects
68+
===================
69+
70+
Generally speaking, there are two categories of devices in a system in which
71+
ACPI is used as an interface between the platform firmware and the OS: Devices
72+
that can be discovered and enumerated natively, through a protocol defined for
73+
the specific bus that they are on (for example, configuration space in PCI),
74+
without the platform firmware assistance, and devices that need to be described
75+
by the platform firmware so that they can be discovered. Still, for any device
76+
known to the platform firmware, regardless of which category it falls into,
77+
there can be a corresponding ACPI device object in the ACPI Namespace in which
78+
case the Linux kernel will create a struct acpi_device object based on it for
79+
that device.
80+
81+
Those struct acpi_device objects are never used for binding drivers to natively
82+
discoverable devices, because they are represented by other types of device
83+
objects (for example, struct pci_dev for PCI devices) that are bound to by
84+
device drivers (the corresponding struct acpi_device object is then used as
85+
an additional source of information on the configuration of the given device).
86+
Moreover, the core ACPI device enumeration code creates struct platform_device
87+
objects for the majority of devices that are discovered and enumerated with the
88+
help of the platform firmware and those platform device objects can be bound to
89+
by platform drivers in direct analogy with the natively enumerable devices
90+
case. Therefore it is logically inconsistent and so generally invalid to bind
91+
drivers to struct acpi_device objects, including drivers for devices that are
92+
discovered with the help of the platform firmware.
93+
94+
Historically, ACPI drivers that bound directly to struct acpi_device objects
95+
were implemented for some devices enumerated with the help of the platform
96+
firmware, but this is not recommended for any new drivers. As explained above,
97+
platform device objects are created for those devices as a rule (with a few
98+
exceptions that are not relevant here) and so platform drivers should be used
99+
for handling them, even though the corresponding ACPI device objects are the
100+
only source of device configuration information in that case.
101+
102+
For every device having a corresponding struct acpi_device object, the pointer
103+
to it is returned by the ACPI_COMPANION() macro, so it is always possible to
104+
get to the device configuration information stored in the ACPI device object
105+
this way. Accordingly, struct acpi_device can be regarded as a part of the
106+
interface between the kernel and the ACPI Namespace, whereas device objects of
107+
other types (for example, struct pci_dev or struct platform_device) are used
108+
for interacting with the rest of the system.
109+
67110
DMA support
68111
===========
69112

drivers/acpi/ac.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ static int acpi_ac_add(struct acpi_device *device)
257257
register_acpi_notifier(&ac->battery_nb);
258258

259259
result = acpi_dev_install_notify_handler(device, ACPI_ALL_NOTIFY,
260-
acpi_ac_notify);
260+
acpi_ac_notify, device);
261261
if (result)
262262
goto err_unregister;
263263

drivers/acpi/acpi_video.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2062,7 +2062,7 @@ static int acpi_video_bus_add(struct acpi_device *device)
20622062
goto err_del;
20632063

20642064
error = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY,
2065-
acpi_video_bus_notify);
2065+
acpi_video_bus_notify, device);
20662066
if (error)
20672067
goto err_remove;
20682068

drivers/acpi/battery.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ static int acpi_battery_add(struct acpi_device *device)
12141214
device_init_wakeup(&device->dev, 1);
12151215

12161216
result = acpi_dev_install_notify_handler(device, ACPI_ALL_NOTIFY,
1217-
acpi_battery_notify);
1217+
acpi_battery_notify, device);
12181218
if (result)
12191219
goto fail_pm;
12201220

drivers/acpi/bus.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,12 +556,12 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device,
556556

557557
int acpi_dev_install_notify_handler(struct acpi_device *adev,
558558
u32 handler_type,
559-
acpi_notify_handler handler)
559+
acpi_notify_handler handler, void *context)
560560
{
561561
acpi_status status;
562562

563563
status = acpi_install_notify_handler(adev->handle, handler_type,
564-
handler, adev);
564+
handler, context);
565565
if (ACPI_FAILURE(status))
566566
return -ENODEV;
567567

drivers/acpi/hed.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static int acpi_hed_add(struct acpi_device *device)
5757
hed_handle = device->handle;
5858

5959
err = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY,
60-
acpi_hed_notify);
60+
acpi_hed_notify, device);
6161
if (err)
6262
hed_handle = NULL;
6363

drivers/acpi/nfit/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3340,7 +3340,7 @@ static int acpi_nfit_add(struct acpi_device *adev)
33403340
int rc = 0;
33413341

33423342
rc = acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY,
3343-
acpi_nfit_notify);
3343+
acpi_nfit_notify, adev);
33443344
if (rc)
33453345
return rc;
33463346

drivers/acpi/thermal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ static int acpi_thermal_add(struct acpi_device *device)
970970
acpi_device_bid(device), deci_kelvin_to_celsius(tz->temperature));
971971

972972
result = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY,
973-
acpi_thermal_notify);
973+
acpi_thermal_notify, device);
974974
if (result)
975975
goto flush_wq;
976976

include/acpi/acpi_bus.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ int acpi_bus_attach_private_data(acpi_handle, void *);
520520
void acpi_bus_detach_private_data(acpi_handle);
521521
int acpi_dev_install_notify_handler(struct acpi_device *adev,
522522
u32 handler_type,
523-
acpi_notify_handler handler);
523+
acpi_notify_handler handler, void *context);
524524
void acpi_dev_remove_notify_handler(struct acpi_device *adev,
525525
u32 handler_type,
526526
acpi_notify_handler handler);

0 commit comments

Comments
 (0)