Skip to content

Commit f5c519f

Browse files
andy-shevrafaeljw
authored andcommitted
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>
1 parent 602401e commit f5c519f

3 files changed

Lines changed: 27 additions & 39 deletions

File tree

drivers/acpi/dock.c

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -88,43 +88,29 @@ static void dock_hotplug_event(struct dock_dependent_device *dd, u32 event,
8888
enum dock_callback_type cb_type)
8989
{
9090
struct acpi_device *adev = dd->adev;
91+
acpi_hp_fixup fixup = NULL;
92+
acpi_hp_uevent uevent = NULL;
93+
acpi_hp_notify notify = NULL;
9194

9295
acpi_lock_hp_context();
9396

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;
124104
}
125105

126-
out:
127106
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);
128114
}
129115

130116
static struct dock_station *find_dock_station(acpi_handle handle)

drivers/acpi/scan.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ void acpi_unlock_hp_context(void)
7373

7474
void acpi_initialize_hp_context(struct acpi_device *adev,
7575
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)
7877
{
7978
acpi_lock_hp_context();
8079
hp->notify = notify;
@@ -428,7 +427,7 @@ void acpi_device_hotplug(struct acpi_device *adev, u32 src)
428427
} else if (adev->flags.hotplug_notify) {
429428
error = acpi_generic_hotplug_event(adev, src);
430429
} else {
431-
int (*notify)(struct acpi_device *, u32);
430+
acpi_hp_notify notify;
432431

433432
acpi_lock_hp_context();
434433
notify = adev->hp ? adev->hp->notify : NULL;

include/acpi/acpi_bus.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,15 @@ struct acpi_scan_handler {
144144
* --------------------
145145
*/
146146

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+
147151
struct acpi_hotplug_context {
148152
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;
152156
};
153157

154158
/*
@@ -583,8 +587,7 @@ static inline void acpi_set_hp_context(struct acpi_device *adev,
583587

584588
void acpi_initialize_hp_context(struct acpi_device *adev,
585589
struct acpi_hotplug_context *hp,
586-
int (*notify)(struct acpi_device *, u32),
587-
void (*uevent)(struct acpi_device *, u32));
590+
acpi_hp_notify notify, acpi_hp_uevent uevent);
588591

589592
/* acpi_device.dev.bus == &acpi_bus_type */
590593
extern const struct bus_type acpi_bus_type;

0 commit comments

Comments
 (0)