Skip to content

Commit 80487a3

Browse files
committed
Merge branch 'acpi-dev'
Merge changes regarding the management of ACPI device objects for 6.1-rc1: - Rename ACPI device object reference counting functions (Rafael Wysocki). - Rearrange ACPI device object initialization code (Rafael Wysocki). - Drop parent field from struct acpi_device (Rafael Wysocki). - Extend the the int3472-tps68470 driver to support multiple consumers of a single TPS68470 along with the requisite framework-level support (Daniel Scally). * acpi-dev: platform/x86: int3472: Add board data for Surface Go2 IR camera platform/x86: int3472: Support multiple gpio lookups in board data platform/x86: int3472: Support multiple clock consumers ACPI: bus: Add iterator for dependent devices ACPI: scan: Add acpi_dev_get_next_consumer_dev() ACPI: property: Use acpi_dev_parent() ACPI: Drop redundant acpi_dev_parent() header ACPI: PM: Fix NULL argument handling in acpi_device_get/set_power() ACPI: Drop parent field from struct acpi_device ACPI: scan: Eliminate __acpi_device_add() ACPI: scan: Rearrange initialization of ACPI device objects ACPI: scan: Rename acpi_bus_get_parent() and rearrange it ACPI: Rename acpi_bus_get/put_acpi_device()
2 parents 63f534b + 2a5a191 commit 80487a3

File tree

25 files changed

+294
-126
lines changed

25 files changed

+294
-126
lines changed

drivers/acpi/acpi_amba.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static void amba_register_dummy_clk(void)
4848
static int amba_handler_attach(struct acpi_device *adev,
4949
const struct acpi_device_id *id)
5050
{
51+
struct acpi_device *parent = acpi_dev_parent(adev);
5152
struct amba_device *dev;
5253
struct resource_entry *rentry;
5354
struct list_head resource_list;
@@ -97,8 +98,8 @@ static int amba_handler_attach(struct acpi_device *adev,
9798
* attached to it, that physical device should be the parent of
9899
* the amba device we are about to create.
99100
*/
100-
if (adev->parent)
101-
dev->dev.parent = acpi_get_first_physical_node(adev->parent);
101+
if (parent)
102+
dev->dev.parent = acpi_get_first_physical_node(parent);
102103

103104
ACPI_COMPANION_SET(&dev->dev, adev);
104105

drivers/acpi/acpi_platform.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static void acpi_platform_fill_resource(struct acpi_device *adev,
7878
* If the device has parent we need to take its resources into
7979
* account as well because this device might consume part of those.
8080
*/
81-
parent = acpi_get_first_physical_node(adev->parent);
81+
parent = acpi_get_first_physical_node(acpi_dev_parent(adev));
8282
if (parent && dev_is_pci(parent))
8383
dest->parent = pci_find_resource(to_pci_dev(parent), dest);
8484
}
@@ -97,6 +97,7 @@ static void acpi_platform_fill_resource(struct acpi_device *adev,
9797
struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
9898
const struct property_entry *properties)
9999
{
100+
struct acpi_device *parent = acpi_dev_parent(adev);
100101
struct platform_device *pdev = NULL;
101102
struct platform_device_info pdevinfo;
102103
struct resource_entry *rentry;
@@ -137,8 +138,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
137138
* attached to it, that physical device should be the parent of the
138139
* platform device we are about to create.
139140
*/
140-
pdevinfo.parent = adev->parent ?
141-
acpi_get_first_physical_node(adev->parent) : NULL;
141+
pdevinfo.parent = parent ? acpi_get_first_physical_node(parent) : NULL;
142142
pdevinfo.name = dev_name(&adev->dev);
143143
pdevinfo.id = -1;
144144
pdevinfo.res = resources;

drivers/acpi/acpi_video.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2030,7 +2030,7 @@ static int acpi_video_bus_add(struct acpi_device *device)
20302030
acpi_status status;
20312031

20322032
status = acpi_walk_namespace(ACPI_TYPE_DEVICE,
2033-
device->parent->handle, 1,
2033+
acpi_dev_parent(device)->handle, 1,
20342034
acpi_video_bus_match, NULL,
20352035
device, NULL);
20362036
if (status == AE_ALREADY_EXISTS) {

drivers/acpi/bus.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
511511
break;
512512
}
513513

514-
adev = acpi_bus_get_acpi_device(handle);
514+
adev = acpi_get_acpi_dev(handle);
515515
if (!adev)
516516
goto err;
517517

@@ -524,14 +524,14 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
524524
}
525525

526526
if (!hotplug_event) {
527-
acpi_bus_put_acpi_device(adev);
527+
acpi_put_acpi_dev(adev);
528528
return;
529529
}
530530

531531
if (ACPI_SUCCESS(acpi_hotplug_schedule(adev, type)))
532532
return;
533533

534-
acpi_bus_put_acpi_device(adev);
534+
acpi_put_acpi_dev(adev);
535535

536536
err:
537537
acpi_evaluate_ost(handle, type, ost_code, NULL);

drivers/acpi/device_pm.c

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,17 @@ static int acpi_dev_pm_explicit_get(struct acpi_device *device, int *state)
7575
int acpi_device_get_power(struct acpi_device *device, int *state)
7676
{
7777
int result = ACPI_STATE_UNKNOWN;
78+
struct acpi_device *parent;
7879
int error;
7980

8081
if (!device || !state)
8182
return -EINVAL;
8283

84+
parent = acpi_dev_parent(device);
85+
8386
if (!device->flags.power_manageable) {
8487
/* TBD: Non-recursive algorithm for walking up hierarchy. */
85-
*state = device->parent ?
86-
device->parent->power.state : ACPI_STATE_D0;
88+
*state = parent ? parent->power.state : ACPI_STATE_D0;
8789
goto out;
8890
}
8991

@@ -122,10 +124,10 @@ int acpi_device_get_power(struct acpi_device *device, int *state)
122124
* point, the fact that the device is in D0 implies that the parent has
123125
* to be in D0 too, except if ignore_parent is set.
124126
*/
125-
if (!device->power.flags.ignore_parent && device->parent
126-
&& device->parent->power.state == ACPI_STATE_UNKNOWN
127-
&& result == ACPI_STATE_D0)
128-
device->parent->power.state = ACPI_STATE_D0;
127+
if (!device->power.flags.ignore_parent && parent &&
128+
parent->power.state == ACPI_STATE_UNKNOWN &&
129+
result == ACPI_STATE_D0)
130+
parent->power.state = ACPI_STATE_D0;
129131

130132
*state = result;
131133

@@ -191,13 +193,17 @@ int acpi_device_set_power(struct acpi_device *device, int state)
191193
return -ENODEV;
192194
}
193195

194-
if (!device->power.flags.ignore_parent && device->parent &&
195-
state < device->parent->power.state) {
196-
acpi_handle_debug(device->handle,
197-
"Cannot transition to %s for parent in %s\n",
198-
acpi_power_state_string(state),
199-
acpi_power_state_string(device->parent->power.state));
200-
return -ENODEV;
196+
if (!device->power.flags.ignore_parent) {
197+
struct acpi_device *parent;
198+
199+
parent = acpi_dev_parent(device);
200+
if (parent && state < parent->power.state) {
201+
acpi_handle_debug(device->handle,
202+
"Cannot transition to %s for parent in %s\n",
203+
acpi_power_state_string(state),
204+
acpi_power_state_string(parent->power.state));
205+
return -ENODEV;
206+
}
201207
}
202208

203209
/*
@@ -497,7 +503,7 @@ static void acpi_pm_notify_handler(acpi_handle handle, u32 val, void *not_used)
497503

498504
acpi_handle_debug(handle, "Wake notify\n");
499505

500-
adev = acpi_bus_get_acpi_device(handle);
506+
adev = acpi_get_acpi_dev(handle);
501507
if (!adev)
502508
return;
503509

@@ -515,7 +521,7 @@ static void acpi_pm_notify_handler(acpi_handle handle, u32 val, void *not_used)
515521

516522
mutex_unlock(&acpi_pm_notifier_lock);
517523

518-
acpi_bus_put_acpi_device(adev);
524+
acpi_put_acpi_dev(adev);
519525
}
520526

521527
/**

drivers/acpi/internal.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ struct acpi_device_bus_id {
102102
struct list_head node;
103103
};
104104

105-
int acpi_device_add(struct acpi_device *device,
106-
void (*release)(struct device *));
107105
void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
108-
int type);
106+
int type, void (*release)(struct device *));
107+
int acpi_tie_acpi_dev(struct acpi_device *adev);
108+
int acpi_device_add(struct acpi_device *device);
109109
int acpi_device_setup_files(struct acpi_device *dev);
110110
void acpi_device_remove_files(struct acpi_device *dev);
111111
void acpi_device_add_finalize(struct acpi_device *device);

drivers/acpi/irq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ acpi_get_irq_source_fwhandle(const struct acpi_resource_source *source,
118118
if (WARN_ON(ACPI_FAILURE(status)))
119119
return NULL;
120120

121-
device = acpi_bus_get_acpi_device(handle);
121+
device = acpi_get_acpi_dev(handle);
122122
if (WARN_ON(!device))
123123
return NULL;
124124

125125
result = &device->fwnode;
126-
acpi_bus_put_acpi_device(device);
126+
acpi_put_acpi_dev(device);
127127
return result;
128128
}
129129

drivers/acpi/power.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -944,13 +944,15 @@ struct acpi_device *acpi_add_power_resource(acpi_handle handle)
944944
return NULL;
945945

946946
device = &resource->device;
947-
acpi_init_device_object(device, handle, ACPI_BUS_TYPE_POWER);
947+
acpi_init_device_object(device, handle, ACPI_BUS_TYPE_POWER,
948+
acpi_release_power_resource);
948949
mutex_init(&resource->resource_lock);
949950
INIT_LIST_HEAD(&resource->list_node);
950951
INIT_LIST_HEAD(&resource->dependents);
951952
strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME);
952953
strcpy(acpi_device_class(device), ACPI_POWER_CLASS);
953954
device->power.state = ACPI_STATE_UNKNOWN;
955+
device->flags.match_driver = true;
954956

955957
/* Evaluate the object to get the system level and resource order. */
956958
status = acpi_evaluate_object(handle, NULL, NULL, &buffer);
@@ -967,8 +969,11 @@ struct acpi_device *acpi_add_power_resource(acpi_handle handle)
967969

968970
pr_info("%s [%s]\n", acpi_device_name(device), acpi_device_bid(device));
969971

970-
device->flags.match_driver = true;
971-
result = acpi_device_add(device, acpi_release_power_resource);
972+
result = acpi_tie_acpi_dev(device);
973+
if (result)
974+
goto err;
975+
976+
result = acpi_device_add(device);
972977
if (result)
973978
goto err;
974979

drivers/acpi/property.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,10 @@ static void acpi_init_of_compatible(struct acpi_device *adev)
304304
ret = acpi_dev_get_property(adev, "compatible",
305305
ACPI_TYPE_STRING, &of_compatible);
306306
if (ret) {
307-
if (adev->parent
308-
&& adev->parent->flags.of_compatible_ok)
307+
struct acpi_device *parent;
308+
309+
parent = acpi_dev_parent(adev);
310+
if (parent && parent->flags.of_compatible_ok)
309311
goto out;
310312

311313
return;
@@ -1267,10 +1269,11 @@ acpi_node_get_parent(const struct fwnode_handle *fwnode)
12671269
return to_acpi_data_node(fwnode)->parent;
12681270
}
12691271
if (is_acpi_device_node(fwnode)) {
1270-
struct device *dev = to_acpi_device_node(fwnode)->dev.parent;
1272+
struct acpi_device *parent;
12711273

1272-
if (dev)
1273-
return acpi_fwnode_handle(to_acpi_device(dev));
1274+
parent = acpi_dev_parent(to_acpi_device_node(fwnode));
1275+
if (parent)
1276+
return acpi_fwnode_handle(parent);
12741277
}
12751278

12761279
return NULL;

drivers/acpi/sbs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ static int acpi_sbs_add(struct acpi_device *device)
632632

633633
mutex_init(&sbs->lock);
634634

635-
sbs->hc = acpi_driver_data(device->parent);
635+
sbs->hc = acpi_driver_data(acpi_dev_parent(device));
636636
sbs->device = device;
637637
strcpy(acpi_device_name(device), ACPI_SBS_DEVICE_NAME);
638638
strcpy(acpi_device_class(device), ACPI_SBS_CLASS);

0 commit comments

Comments
 (0)