]> Git Repo - J-linux.git/commitdiff
ACPI: scan: Introduce typedef:s for struct acpi_hotplug_context members
authorAndy Shevchenko <[email protected]>
Mon, 25 Mar 2024 12:33:03 +0000 (14:33 +0200)
committerRafael J. Wysocki <[email protected]>
Thu, 4 Apr 2024 19:19:02 +0000 (21:19 +0200)
Follow the struct acpi_device_ops approach and introduce typedef:s
for the members. It makes code less verbose and more particular on
what parameters we take or types we use.

Signed-off-by: Andy Shevchenko <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
drivers/acpi/dock.c
drivers/acpi/scan.c
include/acpi/acpi_bus.h

index a7c00ef78086cf17a9ce72eae63b23a2b93e5b55..34affbda295eb772c8939db3acecf881f8cad68e 100644 (file)
@@ -88,43 +88,29 @@ static void dock_hotplug_event(struct dock_dependent_device *dd, u32 event,
                               enum dock_callback_type cb_type)
 {
        struct acpi_device *adev = dd->adev;
+       acpi_hp_fixup fixup = NULL;
+       acpi_hp_uevent uevent = NULL;
+       acpi_hp_notify notify = NULL;
 
        acpi_lock_hp_context();
 
-       if (!adev->hp)
-               goto out;
-
-       if (cb_type == DOCK_CALL_FIXUP) {
-               void (*fixup)(struct acpi_device *);
-
-               fixup = adev->hp->fixup;
-               if (fixup) {
-                       acpi_unlock_hp_context();
-                       fixup(adev);
-                       return;
-               }
-       } else if (cb_type == DOCK_CALL_UEVENT) {
-               void (*uevent)(struct acpi_device *, u32);
-
-               uevent = adev->hp->uevent;
-               if (uevent) {
-                       acpi_unlock_hp_context();
-                       uevent(adev, event);
-                       return;
-               }
-       } else {
-               int (*notify)(struct acpi_device *, u32);
-
-               notify = adev->hp->notify;
-               if (notify) {
-                       acpi_unlock_hp_context();
-                       notify(adev, event);
-                       return;
-               }
+       if (adev->hp) {
+               if (cb_type == DOCK_CALL_FIXUP)
+                       fixup = adev->hp->fixup;
+               else if (cb_type == DOCK_CALL_UEVENT)
+                       uevent = adev->hp->uevent;
+               else
+                       notify = adev->hp->notify;
        }
 
- out:
        acpi_unlock_hp_context();
+
+       if (fixup)
+               fixup(adev);
+       else if (uevent)
+               uevent(adev, event);
+       else if (notify)
+               notify(adev, event);
 }
 
 static struct dock_station *find_dock_station(acpi_handle handle)
index b9a33364e553bd126814765f21cd43ab8ae050d2..f06d92b1183fae0ae80958181ef58b54aa16c7bd 100644 (file)
@@ -73,8 +73,7 @@ void acpi_unlock_hp_context(void)
 
 void acpi_initialize_hp_context(struct acpi_device *adev,
                                struct acpi_hotplug_context *hp,
-                               int (*notify)(struct acpi_device *, u32),
-                               void (*uevent)(struct acpi_device *, u32))
+                               acpi_hp_notify notify, acpi_hp_uevent uevent)
 {
        acpi_lock_hp_context();
        hp->notify = notify;
@@ -428,7 +427,7 @@ void acpi_device_hotplug(struct acpi_device *adev, u32 src)
        } else if (adev->flags.hotplug_notify) {
                error = acpi_generic_hotplug_event(adev, src);
        } else {
-               int (*notify)(struct acpi_device *, u32);
+               acpi_hp_notify notify;
 
                acpi_lock_hp_context();
                notify = adev->hp ? adev->hp->notify : NULL;
index a6ced88a08f35d63dc36d45eb88b7af485cb5090..6f8cc4cc61be14d977226648672ffa1efb66d33a 100644 (file)
@@ -144,11 +144,15 @@ struct acpi_scan_handler {
  * --------------------
  */
 
+typedef int (*acpi_hp_notify) (struct acpi_device *, u32);
+typedef void (*acpi_hp_uevent) (struct acpi_device *, u32);
+typedef void (*acpi_hp_fixup) (struct acpi_device *);
+
 struct acpi_hotplug_context {
        struct acpi_device *self;
-       int (*notify)(struct acpi_device *, u32);
-       void (*uevent)(struct acpi_device *, u32);
-       void (*fixup)(struct acpi_device *);
+       acpi_hp_notify notify;
+       acpi_hp_uevent uevent;
+       acpi_hp_fixup fixup;
 };
 
 /*
@@ -583,8 +587,7 @@ static inline void acpi_set_hp_context(struct acpi_device *adev,
 
 void acpi_initialize_hp_context(struct acpi_device *adev,
                                struct acpi_hotplug_context *hp,
-                               int (*notify)(struct acpi_device *, u32),
-                               void (*uevent)(struct acpi_device *, u32));
+                               acpi_hp_notify notify, acpi_hp_uevent uevent);
 
 /* acpi_device.dev.bus == &acpi_bus_type */
 extern const struct bus_type acpi_bus_type;
This page took 0.087931 seconds and 4 git commands to generate.