Skip to content

Commit

Permalink
Merge branch 'acpi-dev'
Browse files Browse the repository at this point in the history
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()
  • Loading branch information
Rafael J. Wysocki committed Sep 30, 2022
2 parents 63f534b + 2a5a191 commit 80487a3
Show file tree
Hide file tree
Showing 25 changed files with 294 additions and 126 deletions.
5 changes: 3 additions & 2 deletions drivers/acpi/acpi_amba.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ static void amba_register_dummy_clk(void)
static int amba_handler_attach(struct acpi_device *adev,
const struct acpi_device_id *id)
{
struct acpi_device *parent = acpi_dev_parent(adev);
struct amba_device *dev;
struct resource_entry *rentry;
struct list_head resource_list;
Expand Down Expand Up @@ -97,8 +98,8 @@ static int amba_handler_attach(struct acpi_device *adev,
* attached to it, that physical device should be the parent of
* the amba device we are about to create.
*/
if (adev->parent)
dev->dev.parent = acpi_get_first_physical_node(adev->parent);
if (parent)
dev->dev.parent = acpi_get_first_physical_node(parent);

ACPI_COMPANION_SET(&dev->dev, adev);

Expand Down
6 changes: 3 additions & 3 deletions drivers/acpi/acpi_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static void acpi_platform_fill_resource(struct acpi_device *adev,
* If the device has parent we need to take its resources into
* account as well because this device might consume part of those.
*/
parent = acpi_get_first_physical_node(adev->parent);
parent = acpi_get_first_physical_node(acpi_dev_parent(adev));
if (parent && dev_is_pci(parent))
dest->parent = pci_find_resource(to_pci_dev(parent), dest);
}
Expand All @@ -97,6 +97,7 @@ static void acpi_platform_fill_resource(struct acpi_device *adev,
struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
const struct property_entry *properties)
{
struct acpi_device *parent = acpi_dev_parent(adev);
struct platform_device *pdev = NULL;
struct platform_device_info pdevinfo;
struct resource_entry *rentry;
Expand Down Expand Up @@ -137,8 +138,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
* attached to it, that physical device should be the parent of the
* platform device we are about to create.
*/
pdevinfo.parent = adev->parent ?
acpi_get_first_physical_node(adev->parent) : NULL;
pdevinfo.parent = parent ? acpi_get_first_physical_node(parent) : NULL;
pdevinfo.name = dev_name(&adev->dev);
pdevinfo.id = -1;
pdevinfo.res = resources;
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/acpi_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -2030,7 +2030,7 @@ static int acpi_video_bus_add(struct acpi_device *device)
acpi_status status;

status = acpi_walk_namespace(ACPI_TYPE_DEVICE,
device->parent->handle, 1,
acpi_dev_parent(device)->handle, 1,
acpi_video_bus_match, NULL,
device, NULL);
if (status == AE_ALREADY_EXISTS) {
Expand Down
6 changes: 3 additions & 3 deletions drivers/acpi/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
break;
}

adev = acpi_bus_get_acpi_device(handle);
adev = acpi_get_acpi_dev(handle);
if (!adev)
goto err;

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

if (!hotplug_event) {
acpi_bus_put_acpi_device(adev);
acpi_put_acpi_dev(adev);
return;
}

if (ACPI_SUCCESS(acpi_hotplug_schedule(adev, type)))
return;

acpi_bus_put_acpi_device(adev);
acpi_put_acpi_dev(adev);

err:
acpi_evaluate_ost(handle, type, ost_code, NULL);
Expand Down
36 changes: 21 additions & 15 deletions drivers/acpi/device_pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,17 @@ static int acpi_dev_pm_explicit_get(struct acpi_device *device, int *state)
int acpi_device_get_power(struct acpi_device *device, int *state)
{
int result = ACPI_STATE_UNKNOWN;
struct acpi_device *parent;
int error;

if (!device || !state)
return -EINVAL;

parent = acpi_dev_parent(device);

if (!device->flags.power_manageable) {
/* TBD: Non-recursive algorithm for walking up hierarchy. */
*state = device->parent ?
device->parent->power.state : ACPI_STATE_D0;
*state = parent ? parent->power.state : ACPI_STATE_D0;
goto out;
}

Expand Down Expand Up @@ -122,10 +124,10 @@ int acpi_device_get_power(struct acpi_device *device, int *state)
* point, the fact that the device is in D0 implies that the parent has
* to be in D0 too, except if ignore_parent is set.
*/
if (!device->power.flags.ignore_parent && device->parent
&& device->parent->power.state == ACPI_STATE_UNKNOWN
&& result == ACPI_STATE_D0)
device->parent->power.state = ACPI_STATE_D0;
if (!device->power.flags.ignore_parent && parent &&
parent->power.state == ACPI_STATE_UNKNOWN &&
result == ACPI_STATE_D0)
parent->power.state = ACPI_STATE_D0;

*state = result;

Expand Down Expand Up @@ -191,13 +193,17 @@ int acpi_device_set_power(struct acpi_device *device, int state)
return -ENODEV;
}

if (!device->power.flags.ignore_parent && device->parent &&
state < device->parent->power.state) {
acpi_handle_debug(device->handle,
"Cannot transition to %s for parent in %s\n",
acpi_power_state_string(state),
acpi_power_state_string(device->parent->power.state));
return -ENODEV;
if (!device->power.flags.ignore_parent) {
struct acpi_device *parent;

parent = acpi_dev_parent(device);
if (parent && state < parent->power.state) {
acpi_handle_debug(device->handle,
"Cannot transition to %s for parent in %s\n",
acpi_power_state_string(state),
acpi_power_state_string(parent->power.state));
return -ENODEV;
}
}

/*
Expand Down Expand Up @@ -497,7 +503,7 @@ static void acpi_pm_notify_handler(acpi_handle handle, u32 val, void *not_used)

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

adev = acpi_bus_get_acpi_device(handle);
adev = acpi_get_acpi_dev(handle);
if (!adev)
return;

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

mutex_unlock(&acpi_pm_notifier_lock);

acpi_bus_put_acpi_device(adev);
acpi_put_acpi_dev(adev);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions drivers/acpi/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ struct acpi_device_bus_id {
struct list_head node;
};

int acpi_device_add(struct acpi_device *device,
void (*release)(struct device *));
void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
int type);
int type, void (*release)(struct device *));
int acpi_tie_acpi_dev(struct acpi_device *adev);
int acpi_device_add(struct acpi_device *device);
int acpi_device_setup_files(struct acpi_device *dev);
void acpi_device_remove_files(struct acpi_device *dev);
void acpi_device_add_finalize(struct acpi_device *device);
Expand Down
4 changes: 2 additions & 2 deletions drivers/acpi/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ acpi_get_irq_source_fwhandle(const struct acpi_resource_source *source,
if (WARN_ON(ACPI_FAILURE(status)))
return NULL;

device = acpi_bus_get_acpi_device(handle);
device = acpi_get_acpi_dev(handle);
if (WARN_ON(!device))
return NULL;

result = &device->fwnode;
acpi_bus_put_acpi_device(device);
acpi_put_acpi_dev(device);
return result;
}

Expand Down
11 changes: 8 additions & 3 deletions drivers/acpi/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -944,13 +944,15 @@ struct acpi_device *acpi_add_power_resource(acpi_handle handle)
return NULL;

device = &resource->device;
acpi_init_device_object(device, handle, ACPI_BUS_TYPE_POWER);
acpi_init_device_object(device, handle, ACPI_BUS_TYPE_POWER,
acpi_release_power_resource);
mutex_init(&resource->resource_lock);
INIT_LIST_HEAD(&resource->list_node);
INIT_LIST_HEAD(&resource->dependents);
strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_POWER_CLASS);
device->power.state = ACPI_STATE_UNKNOWN;
device->flags.match_driver = true;

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

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

device->flags.match_driver = true;
result = acpi_device_add(device, acpi_release_power_resource);
result = acpi_tie_acpi_dev(device);
if (result)
goto err;

result = acpi_device_add(device);
if (result)
goto err;

Expand Down
13 changes: 8 additions & 5 deletions drivers/acpi/property.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,10 @@ static void acpi_init_of_compatible(struct acpi_device *adev)
ret = acpi_dev_get_property(adev, "compatible",
ACPI_TYPE_STRING, &of_compatible);
if (ret) {
if (adev->parent
&& adev->parent->flags.of_compatible_ok)
struct acpi_device *parent;

parent = acpi_dev_parent(adev);
if (parent && parent->flags.of_compatible_ok)
goto out;

return;
Expand Down Expand Up @@ -1267,10 +1269,11 @@ acpi_node_get_parent(const struct fwnode_handle *fwnode)
return to_acpi_data_node(fwnode)->parent;
}
if (is_acpi_device_node(fwnode)) {
struct device *dev = to_acpi_device_node(fwnode)->dev.parent;
struct acpi_device *parent;

if (dev)
return acpi_fwnode_handle(to_acpi_device(dev));
parent = acpi_dev_parent(to_acpi_device_node(fwnode));
if (parent)
return acpi_fwnode_handle(parent);
}

return NULL;
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/sbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ static int acpi_sbs_add(struct acpi_device *device)

mutex_init(&sbs->lock);

sbs->hc = acpi_driver_data(device->parent);
sbs->hc = acpi_driver_data(acpi_dev_parent(device));
sbs->device = device;
strcpy(acpi_device_name(device), ACPI_SBS_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_SBS_CLASS);
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/sbshc.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ static int acpi_smbus_hc_add(struct acpi_device *device)
mutex_init(&hc->lock);
init_waitqueue_head(&hc->wait);

hc->ec = acpi_driver_data(device->parent);
hc->ec = acpi_driver_data(acpi_dev_parent(device));
hc->offset = (val >> 8) & 0xff;
hc->query_bit = val & 0xff;
device->driver_data = hc;
Expand Down
Loading

0 comments on commit 80487a3

Please sign in to comment.