diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-11-22 15:56:06 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-11-22 15:56:06 -0500 |
commit | 25db115b0bf72acfdf8a339fa8e37d8b895214d6 (patch) | |
tree | 57e73fb5457a5ecb591a8f750583274006afe763 | |
parent | f4b734c35e98c343cd99824153de09e48867b97e (diff) |
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>
-rw-r--r-- | drivers/acpi/bus.c | 11 | ||||
-rw-r--r-- | drivers/acpi/scan.c | 5 | ||||
-rw-r--r-- | include/acpi/acpi_bus.h | 5 |
3 files changed, 10 insertions, 11 deletions
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 8b09a75f6579..f509019ee2c7 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c | |||
@@ -52,9 +52,6 @@ struct acpi_device *acpi_root; | |||
52 | struct proc_dir_entry *acpi_root_dir; | 52 | struct proc_dir_entry *acpi_root_dir; |
53 | EXPORT_SYMBOL(acpi_root_dir); | 53 | EXPORT_SYMBOL(acpi_root_dir); |
54 | 54 | ||
55 | #define STRUCT_TO_INT(s) (*((int*)&s)) | ||
56 | |||
57 | |||
58 | #ifdef CONFIG_X86 | 55 | #ifdef CONFIG_X86 |
59 | static int set_copy_dsdt(const struct dmi_system_id *id) | 56 | static int set_copy_dsdt(const struct dmi_system_id *id) |
60 | { | 57 | { |
@@ -115,18 +112,16 @@ int acpi_bus_get_status(struct acpi_device *device) | |||
115 | if (ACPI_FAILURE(status)) | 112 | if (ACPI_FAILURE(status)) |
116 | return -ENODEV; | 113 | return -ENODEV; |
117 | 114 | ||
118 | STRUCT_TO_INT(device->status) = (int) sta; | 115 | acpi_set_device_status(device, sta); |
119 | 116 | ||
120 | if (device->status.functional && !device->status.present) { | 117 | if (device->status.functional && !device->status.present) { |
121 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: " | 118 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: " |
122 | "functional but not present;\n", | 119 | "functional but not present;\n", |
123 | device->pnp.bus_id, | 120 | device->pnp.bus_id, (u32)sta)); |
124 | (u32) STRUCT_TO_INT(device->status))); | ||
125 | } | 121 | } |
126 | 122 | ||
127 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n", | 123 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n", |
128 | device->pnp.bus_id, | 124 | device->pnp.bus_id, (u32)sta)); |
129 | (u32) STRUCT_TO_INT(device->status))); | ||
130 | return 0; | 125 | return 0; |
131 | } | 126 | } |
132 | EXPORT_SYMBOL(acpi_bus_get_status); | 127 | EXPORT_SYMBOL(acpi_bus_get_status); |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 06db2c036085..cf773c918102 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -20,7 +20,6 @@ | |||
20 | 20 | ||
21 | #define _COMPONENT ACPI_BUS_COMPONENT | 21 | #define _COMPONENT ACPI_BUS_COMPONENT |
22 | ACPI_MODULE_NAME("scan"); | 22 | ACPI_MODULE_NAME("scan"); |
23 | #define STRUCT_TO_INT(s) (*((int*)&s)) | ||
24 | extern struct acpi_device *acpi_root; | 23 | extern struct acpi_device *acpi_root; |
25 | 24 | ||
26 | #define ACPI_BUS_CLASS "system_bus" | 25 | #define ACPI_BUS_CLASS "system_bus" |
@@ -1683,7 +1682,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, | |||
1683 | device->device_type = type; | 1682 | device->device_type = type; |
1684 | device->handle = handle; | 1683 | device->handle = handle; |
1685 | device->parent = acpi_bus_get_parent(handle); | 1684 | device->parent = acpi_bus_get_parent(handle); |
1686 | STRUCT_TO_INT(device->status) = sta; | 1685 | acpi_set_device_status(device, sta); |
1687 | acpi_device_get_busid(device); | 1686 | acpi_device_get_busid(device); |
1688 | acpi_set_pnp_ids(handle, &device->pnp, type); | 1687 | acpi_set_pnp_ids(handle, &device->pnp, type); |
1689 | acpi_bus_get_flags(device); | 1688 | acpi_bus_get_flags(device); |
@@ -1927,7 +1926,7 @@ static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used, | |||
1927 | if (acpi_bus_get_device(handle, &device)) | 1926 | if (acpi_bus_get_device(handle, &device)) |
1928 | return AE_CTRL_DEPTH; | 1927 | return AE_CTRL_DEPTH; |
1929 | 1928 | ||
1930 | STRUCT_TO_INT(device->status) = sta; | 1929 | acpi_set_device_status(device, sta); |
1931 | /* Skip devices that are not present. */ | 1930 | /* Skip devices that are not present. */ |
1932 | if (!acpi_device_is_present(device)) | 1931 | if (!acpi_device_is_present(device)) |
1933 | goto err; | 1932 | goto err; |
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 3e4150b6d71a..95831e7b70be 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h | |||
@@ -320,6 +320,11 @@ static inline void *acpi_driver_data(struct acpi_device *d) | |||
320 | #define to_acpi_device(d) container_of(d, struct acpi_device, dev) | 320 | #define to_acpi_device(d) container_of(d, struct acpi_device, dev) |
321 | #define to_acpi_driver(d) container_of(d, struct acpi_driver, drv) | 321 | #define to_acpi_driver(d) container_of(d, struct acpi_driver, drv) |
322 | 322 | ||
323 | static inline void acpi_set_device_status(struct acpi_device *adev, u32 sta) | ||
324 | { | ||
325 | *((u32 *)&adev->status) = sta; | ||
326 | } | ||
327 | |||
323 | /* acpi_device.dev.bus == &acpi_bus_type */ | 328 | /* acpi_device.dev.bus == &acpi_bus_type */ |
324 | extern struct bus_type acpi_bus_type; | 329 | extern struct bus_type acpi_bus_type; |
325 | 330 | ||