ACPI: Introduce acpi_set_device_status()
Introduce a static inline function for setting the status field of struct acpi_device on the basis of a supplied u32 number, acpi_set_device_status(), and use it instead of the horrible horrible STRUCT_TO_INT() macro wherever applicable. Having done that, drop STRUCT_TO_INT() (and pretend that it has never existed). Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
This commit is contained in:
parent
f4b734c35e
commit
25db115b0b
@ -52,9 +52,6 @@ struct acpi_device *acpi_root;
|
|||||||
struct proc_dir_entry *acpi_root_dir;
|
struct proc_dir_entry *acpi_root_dir;
|
||||||
EXPORT_SYMBOL(acpi_root_dir);
|
EXPORT_SYMBOL(acpi_root_dir);
|
||||||
|
|
||||||
#define STRUCT_TO_INT(s) (*((int*)&s))
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef CONFIG_X86
|
#ifdef CONFIG_X86
|
||||||
static int set_copy_dsdt(const struct dmi_system_id *id)
|
static int set_copy_dsdt(const struct dmi_system_id *id)
|
||||||
{
|
{
|
||||||
@ -115,18 +112,16 @@ int acpi_bus_get_status(struct acpi_device *device)
|
|||||||
if (ACPI_FAILURE(status))
|
if (ACPI_FAILURE(status))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
STRUCT_TO_INT(device->status) = (int) sta;
|
acpi_set_device_status(device, sta);
|
||||||
|
|
||||||
if (device->status.functional && !device->status.present) {
|
if (device->status.functional && !device->status.present) {
|
||||||
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: "
|
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: "
|
||||||
"functional but not present;\n",
|
"functional but not present;\n",
|
||||||
device->pnp.bus_id,
|
device->pnp.bus_id, (u32)sta));
|
||||||
(u32) STRUCT_TO_INT(device->status)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n",
|
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n",
|
||||||
device->pnp.bus_id,
|
device->pnp.bus_id, (u32)sta));
|
||||||
(u32) STRUCT_TO_INT(device->status)));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(acpi_bus_get_status);
|
EXPORT_SYMBOL(acpi_bus_get_status);
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#define _COMPONENT ACPI_BUS_COMPONENT
|
#define _COMPONENT ACPI_BUS_COMPONENT
|
||||||
ACPI_MODULE_NAME("scan");
|
ACPI_MODULE_NAME("scan");
|
||||||
#define STRUCT_TO_INT(s) (*((int*)&s))
|
|
||||||
extern struct acpi_device *acpi_root;
|
extern struct acpi_device *acpi_root;
|
||||||
|
|
||||||
#define ACPI_BUS_CLASS "system_bus"
|
#define ACPI_BUS_CLASS "system_bus"
|
||||||
@ -1683,7 +1682,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
|
|||||||
device->device_type = type;
|
device->device_type = type;
|
||||||
device->handle = handle;
|
device->handle = handle;
|
||||||
device->parent = acpi_bus_get_parent(handle);
|
device->parent = acpi_bus_get_parent(handle);
|
||||||
STRUCT_TO_INT(device->status) = sta;
|
acpi_set_device_status(device, sta);
|
||||||
acpi_device_get_busid(device);
|
acpi_device_get_busid(device);
|
||||||
acpi_set_pnp_ids(handle, &device->pnp, type);
|
acpi_set_pnp_ids(handle, &device->pnp, type);
|
||||||
acpi_bus_get_flags(device);
|
acpi_bus_get_flags(device);
|
||||||
@ -1927,7 +1926,7 @@ static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used,
|
|||||||
if (acpi_bus_get_device(handle, &device))
|
if (acpi_bus_get_device(handle, &device))
|
||||||
return AE_CTRL_DEPTH;
|
return AE_CTRL_DEPTH;
|
||||||
|
|
||||||
STRUCT_TO_INT(device->status) = sta;
|
acpi_set_device_status(device, sta);
|
||||||
/* Skip devices that are not present. */
|
/* Skip devices that are not present. */
|
||||||
if (!acpi_device_is_present(device))
|
if (!acpi_device_is_present(device))
|
||||||
goto err;
|
goto err;
|
||||||
|
@ -320,6 +320,11 @@ static inline void *acpi_driver_data(struct acpi_device *d)
|
|||||||
#define to_acpi_device(d) container_of(d, struct acpi_device, dev)
|
#define to_acpi_device(d) container_of(d, struct acpi_device, dev)
|
||||||
#define to_acpi_driver(d) container_of(d, struct acpi_driver, drv)
|
#define to_acpi_driver(d) container_of(d, struct acpi_driver, drv)
|
||||||
|
|
||||||
|
static inline void acpi_set_device_status(struct acpi_device *adev, u32 sta)
|
||||||
|
{
|
||||||
|
*((u32 *)&adev->status) = sta;
|
||||||
|
}
|
||||||
|
|
||||||
/* acpi_device.dev.bus == &acpi_bus_type */
|
/* acpi_device.dev.bus == &acpi_bus_type */
|
||||||
extern struct bus_type acpi_bus_type;
|
extern struct bus_type acpi_bus_type;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user