Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ACPI: scan: Introduce typedef:s for struct acpi_hotplug_context members

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 <andriy.shevchenko@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Andy Shevchenko and committed by
Rafael J. Wysocki
f5c519fc 602401e3

+27 -39
+17 -31
drivers/acpi/dock.c
··· 88 88 enum dock_callback_type cb_type) 89 89 { 90 90 struct acpi_device *adev = dd->adev; 91 + acpi_hp_fixup fixup = NULL; 92 + acpi_hp_uevent uevent = NULL; 93 + acpi_hp_notify notify = NULL; 91 94 92 95 acpi_lock_hp_context(); 93 96 94 - if (!adev->hp) 95 - goto out; 96 - 97 - if (cb_type == DOCK_CALL_FIXUP) { 98 - void (*fixup)(struct acpi_device *); 99 - 100 - fixup = adev->hp->fixup; 101 - if (fixup) { 102 - acpi_unlock_hp_context(); 103 - fixup(adev); 104 - return; 105 - } 106 - } else if (cb_type == DOCK_CALL_UEVENT) { 107 - void (*uevent)(struct acpi_device *, u32); 108 - 109 - uevent = adev->hp->uevent; 110 - if (uevent) { 111 - acpi_unlock_hp_context(); 112 - uevent(adev, event); 113 - return; 114 - } 115 - } else { 116 - int (*notify)(struct acpi_device *, u32); 117 - 118 - notify = adev->hp->notify; 119 - if (notify) { 120 - acpi_unlock_hp_context(); 121 - notify(adev, event); 122 - return; 123 - } 97 + if (adev->hp) { 98 + if (cb_type == DOCK_CALL_FIXUP) 99 + fixup = adev->hp->fixup; 100 + else if (cb_type == DOCK_CALL_UEVENT) 101 + uevent = adev->hp->uevent; 102 + else 103 + notify = adev->hp->notify; 124 104 } 125 105 126 - out: 127 106 acpi_unlock_hp_context(); 107 + 108 + if (fixup) 109 + fixup(adev); 110 + else if (uevent) 111 + uevent(adev, event); 112 + else if (notify) 113 + notify(adev, event); 128 114 } 129 115 130 116 static struct dock_station *find_dock_station(acpi_handle handle)
+2 -3
drivers/acpi/scan.c
··· 73 73 74 74 void acpi_initialize_hp_context(struct acpi_device *adev, 75 75 struct acpi_hotplug_context *hp, 76 - int (*notify)(struct acpi_device *, u32), 77 - void (*uevent)(struct acpi_device *, u32)) 76 + acpi_hp_notify notify, acpi_hp_uevent uevent) 78 77 { 79 78 acpi_lock_hp_context(); 80 79 hp->notify = notify; ··· 427 428 } else if (adev->flags.hotplug_notify) { 428 429 error = acpi_generic_hotplug_event(adev, src); 429 430 } else { 430 - int (*notify)(struct acpi_device *, u32); 431 + acpi_hp_notify notify; 431 432 432 433 acpi_lock_hp_context(); 433 434 notify = adev->hp ? adev->hp->notify : NULL;
+8 -5
include/acpi/acpi_bus.h
··· 144 144 * -------------------- 145 145 */ 146 146 147 + typedef int (*acpi_hp_notify) (struct acpi_device *, u32); 148 + typedef void (*acpi_hp_uevent) (struct acpi_device *, u32); 149 + typedef void (*acpi_hp_fixup) (struct acpi_device *); 150 + 147 151 struct acpi_hotplug_context { 148 152 struct acpi_device *self; 149 - int (*notify)(struct acpi_device *, u32); 150 - void (*uevent)(struct acpi_device *, u32); 151 - void (*fixup)(struct acpi_device *); 153 + acpi_hp_notify notify; 154 + acpi_hp_uevent uevent; 155 + acpi_hp_fixup fixup; 152 156 }; 153 157 154 158 /* ··· 587 583 588 584 void acpi_initialize_hp_context(struct acpi_device *adev, 589 585 struct acpi_hotplug_context *hp, 590 - int (*notify)(struct acpi_device *, u32), 591 - void (*uevent)(struct acpi_device *, u32)); 586 + acpi_hp_notify notify, acpi_hp_uevent uevent); 592 587 593 588 /* acpi_device.dev.bus == &acpi_bus_type */ 594 589 extern const struct bus_type acpi_bus_type;