Skip to content

Commit 829b75d

Browse files
committed
Merge back earlier ACPI device enumeration changes for 6.10.
2 parents d730192 + f5c519f commit 829b75d

3 files changed

Lines changed: 49 additions & 55 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: 14 additions & 14 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;
@@ -1298,10 +1297,10 @@ const char *acpi_device_hid(struct acpi_device *device)
12981297
{
12991298
struct acpi_hardware_id *hid;
13001299

1301-
if (list_empty(&device->pnp.ids))
1300+
hid = list_first_entry_or_null(&device->pnp.ids, struct acpi_hardware_id, list);
1301+
if (!hid)
13021302
return dummy_hid;
13031303

1304-
hid = list_first_entry(&device->pnp.ids, struct acpi_hardware_id, list);
13051304
return hid->id;
13061305
}
13071306
EXPORT_SYMBOL(acpi_device_hid);
@@ -1581,12 +1580,13 @@ int acpi_iommu_fwspec_init(struct device *dev, u32 id,
15811580
struct fwnode_handle *fwnode,
15821581
const struct iommu_ops *ops)
15831582
{
1584-
int ret = iommu_fwspec_init(dev, fwnode, ops);
1583+
int ret;
15851584

1586-
if (!ret)
1587-
ret = iommu_fwspec_add_ids(dev, &id, 1);
1585+
ret = iommu_fwspec_init(dev, fwnode, ops);
1586+
if (ret)
1587+
return ret;
15881588

1589-
return ret;
1589+
return iommu_fwspec_add_ids(dev, &id, 1);
15901590
}
15911591

15921592
static inline const struct iommu_ops *acpi_iommu_fwspec_ops(struct device *dev)
@@ -1625,12 +1625,11 @@ static int acpi_iommu_configure_id(struct device *dev, const u32 *id_in)
16251625
if (!err && dev->bus)
16261626
err = iommu_probe_device(dev);
16271627

1628-
/* Ignore all other errors apart from EPROBE_DEFER */
1629-
if (err == -EPROBE_DEFER) {
1628+
if (err == -EPROBE_DEFER)
16301629
return err;
1631-
} else if (err) {
1630+
if (err) {
16321631
dev_dbg(dev, "Adding to IOMMU failed: %d\n", err);
1633-
return -ENODEV;
1632+
return err;
16341633
}
16351634
if (!acpi_iommu_fwspec_ops(dev))
16361635
return -ENODEV;
@@ -1671,13 +1670,14 @@ int acpi_dma_configure_id(struct device *dev, enum dev_dma_attr attr,
16711670

16721671
acpi_arch_dma_setup(dev);
16731672

1673+
/* Ignore all other errors apart from EPROBE_DEFER */
16741674
ret = acpi_iommu_configure_id(dev, input_id);
16751675
if (ret == -EPROBE_DEFER)
16761676
return -EPROBE_DEFER;
16771677

16781678
/*
16791679
* Historically this routine doesn't fail driver probing due to errors
1680-
* in acpi_iommu_configure_id()
1680+
* in acpi_iommu_configure_id().
16811681
*/
16821682

16831683
arch_setup_dma_ops(dev, 0, U64_MAX, attr == DEV_DMA_COHERENT);

include/acpi/acpi_bus.h

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@
99
#ifndef __ACPI_BUS_H__
1010
#define __ACPI_BUS_H__
1111

12+
#include <linux/completion.h>
13+
#include <linux/container_of.h>
1214
#include <linux/device.h>
15+
#include <linux/kobject.h>
16+
#include <linux/mutex.h>
1317
#include <linux/property.h>
18+
#include <linux/types.h>
1419

1520
struct acpi_handle_list {
1621
u32 count;
@@ -124,8 +129,8 @@ static inline struct acpi_hotplug_profile *to_acpi_hotplug_profile(
124129
}
125130

126131
struct acpi_scan_handler {
127-
const struct acpi_device_id *ids;
128132
struct list_head list_node;
133+
const struct acpi_device_id *ids;
129134
bool (*match)(const char *idstr, const struct acpi_device_id **matchid);
130135
int (*attach)(struct acpi_device *dev, const struct acpi_device_id *id);
131136
void (*detach)(struct acpi_device *dev);
@@ -139,11 +144,15 @@ struct acpi_scan_handler {
139144
* --------------------
140145
*/
141146

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+
142151
struct acpi_hotplug_context {
143152
struct acpi_device *self;
144-
int (*notify)(struct acpi_device *, u32);
145-
void (*uevent)(struct acpi_device *, u32);
146-
void (*fixup)(struct acpi_device *);
153+
acpi_hp_notify notify;
154+
acpi_hp_uevent uevent;
155+
acpi_hp_fixup fixup;
147156
};
148157

149158
/*
@@ -269,14 +278,14 @@ struct acpi_device_power_flags {
269278
};
270279

271280
struct acpi_device_power_state {
281+
struct list_head resources; /* Power resources referenced */
272282
struct {
273283
u8 valid:1;
274284
u8 explicit_set:1; /* _PSx present? */
275285
u8 reserved:6;
276286
} flags;
277287
int power; /* % Power (compared to D0) */
278288
int latency; /* Dx->D0 time (microseconds) */
279-
struct list_head resources; /* Power resources referenced */
280289
};
281290

282291
struct acpi_device_power {
@@ -342,16 +351,16 @@ struct acpi_device_wakeup {
342351
};
343352

344353
struct acpi_device_physical_node {
345-
unsigned int node_id;
346354
struct list_head node;
347355
struct device *dev;
356+
unsigned int node_id;
348357
bool put_online:1;
349358
};
350359

351360
struct acpi_device_properties {
361+
struct list_head list;
352362
const guid_t *guid;
353363
union acpi_object *properties;
354-
struct list_head list;
355364
void **bufs;
356365
};
357366

@@ -488,12 +497,12 @@ struct acpi_device {
488497

489498
/* Non-device subnode */
490499
struct acpi_data_node {
500+
struct list_head sibling;
491501
const char *name;
492502
acpi_handle handle;
493503
struct fwnode_handle fwnode;
494504
struct fwnode_handle *parent;
495505
struct acpi_device_data data;
496-
struct list_head sibling;
497506
struct kobject kobj;
498507
struct completion kobj_done;
499508
};
@@ -578,8 +587,7 @@ static inline void acpi_set_hp_context(struct acpi_device *adev,
578587

579588
void acpi_initialize_hp_context(struct acpi_device *adev,
580589
struct acpi_hotplug_context *hp,
581-
int (*notify)(struct acpi_device *, u32),
582-
void (*uevent)(struct acpi_device *, u32));
590+
acpi_hp_notify notify, acpi_hp_uevent uevent);
583591

584592
/* acpi_device.dev.bus == &acpi_bus_type */
585593
extern const struct bus_type acpi_bus_type;

0 commit comments

Comments
 (0)