diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-03-06 17:41:58 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-03-06 17:41:58 -0500 |
commit | d7553a86b5cd18d46ad3eabebadedcb45eda3ab1 (patch) | |
tree | c58abdcb5a82d4498a856b4e53607857b35926a6 | |
parent | 6dbe51c251a327e012439c4772097a13df43c5b8 (diff) | |
parent | 924144818cf0edc5d9d70d3a44e7cbbf4544796c (diff) |
Merge branch 'acpi-fixes' into fixes
* acpi-fixes:
ACPI / glue: Drop .find_bridge() callback from struct acpi_bus_type
ACPI / glue: Add .match() callback to struct acpi_bus_type
ACPI / porocessor: Beautify code, pr->id is u32 which is never < 0
ACPI / processor: Remove redundant NULL check before kfree
ACPI / Sleep: Avoid interleaved message on errors
-rw-r--r-- | drivers/acpi/glue.c | 55 | ||||
-rw-r--r-- | drivers/acpi/processor_core.c | 3 | ||||
-rw-r--r-- | drivers/acpi/processor_driver.c | 2 | ||||
-rw-r--r-- | drivers/acpi/sleep.c | 16 | ||||
-rw-r--r-- | drivers/ata/libata-acpi.c | 7 | ||||
-rw-r--r-- | drivers/pci/pci-acpi.c | 8 | ||||
-rw-r--r-- | drivers/pnp/pnpacpi/core.c | 8 | ||||
-rw-r--r-- | drivers/scsi/scsi_lib.c | 7 | ||||
-rw-r--r-- | drivers/usb/core/usb-acpi.c | 9 | ||||
-rw-r--r-- | include/acpi/acpi_bus.h | 6 |
10 files changed, 52 insertions, 69 deletions
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index ef6f155469b5..40a84cc6740c 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c | |||
@@ -36,12 +36,11 @@ int register_acpi_bus_type(struct acpi_bus_type *type) | |||
36 | { | 36 | { |
37 | if (acpi_disabled) | 37 | if (acpi_disabled) |
38 | return -ENODEV; | 38 | return -ENODEV; |
39 | if (type && type->bus && type->find_device) { | 39 | if (type && type->match && type->find_device) { |
40 | down_write(&bus_type_sem); | 40 | down_write(&bus_type_sem); |
41 | list_add_tail(&type->list, &bus_type_list); | 41 | list_add_tail(&type->list, &bus_type_list); |
42 | up_write(&bus_type_sem); | 42 | up_write(&bus_type_sem); |
43 | printk(KERN_INFO PREFIX "bus type %s registered\n", | 43 | printk(KERN_INFO PREFIX "bus type %s registered\n", type->name); |
44 | type->bus->name); | ||
45 | return 0; | 44 | return 0; |
46 | } | 45 | } |
47 | return -ENODEV; | 46 | return -ENODEV; |
@@ -56,24 +55,21 @@ int unregister_acpi_bus_type(struct acpi_bus_type *type) | |||
56 | down_write(&bus_type_sem); | 55 | down_write(&bus_type_sem); |
57 | list_del_init(&type->list); | 56 | list_del_init(&type->list); |
58 | up_write(&bus_type_sem); | 57 | up_write(&bus_type_sem); |
59 | printk(KERN_INFO PREFIX "ACPI bus type %s unregistered\n", | 58 | printk(KERN_INFO PREFIX "bus type %s unregistered\n", |
60 | type->bus->name); | 59 | type->name); |
61 | return 0; | 60 | return 0; |
62 | } | 61 | } |
63 | return -ENODEV; | 62 | return -ENODEV; |
64 | } | 63 | } |
65 | EXPORT_SYMBOL_GPL(unregister_acpi_bus_type); | 64 | EXPORT_SYMBOL_GPL(unregister_acpi_bus_type); |
66 | 65 | ||
67 | static struct acpi_bus_type *acpi_get_bus_type(struct bus_type *type) | 66 | static struct acpi_bus_type *acpi_get_bus_type(struct device *dev) |
68 | { | 67 | { |
69 | struct acpi_bus_type *tmp, *ret = NULL; | 68 | struct acpi_bus_type *tmp, *ret = NULL; |
70 | 69 | ||
71 | if (!type) | ||
72 | return NULL; | ||
73 | |||
74 | down_read(&bus_type_sem); | 70 | down_read(&bus_type_sem); |
75 | list_for_each_entry(tmp, &bus_type_list, list) { | 71 | list_for_each_entry(tmp, &bus_type_list, list) { |
76 | if (tmp->bus == type) { | 72 | if (tmp->match(dev)) { |
77 | ret = tmp; | 73 | ret = tmp; |
78 | break; | 74 | break; |
79 | } | 75 | } |
@@ -82,22 +78,6 @@ static struct acpi_bus_type *acpi_get_bus_type(struct bus_type *type) | |||
82 | return ret; | 78 | return ret; |
83 | } | 79 | } |
84 | 80 | ||
85 | static int acpi_find_bridge_device(struct device *dev, acpi_handle * handle) | ||
86 | { | ||
87 | struct acpi_bus_type *tmp; | ||
88 | int ret = -ENODEV; | ||
89 | |||
90 | down_read(&bus_type_sem); | ||
91 | list_for_each_entry(tmp, &bus_type_list, list) { | ||
92 | if (tmp->find_bridge && !tmp->find_bridge(dev, handle)) { | ||
93 | ret = 0; | ||
94 | break; | ||
95 | } | ||
96 | } | ||
97 | up_read(&bus_type_sem); | ||
98 | return ret; | ||
99 | } | ||
100 | |||
101 | static acpi_status do_acpi_find_child(acpi_handle handle, u32 lvl_not_used, | 81 | static acpi_status do_acpi_find_child(acpi_handle handle, u32 lvl_not_used, |
102 | void *addr_p, void **ret_p) | 82 | void *addr_p, void **ret_p) |
103 | { | 83 | { |
@@ -261,29 +241,12 @@ err: | |||
261 | 241 | ||
262 | static int acpi_platform_notify(struct device *dev) | 242 | static int acpi_platform_notify(struct device *dev) |
263 | { | 243 | { |
264 | struct acpi_bus_type *type; | 244 | struct acpi_bus_type *type = acpi_get_bus_type(dev); |
265 | acpi_handle handle; | 245 | acpi_handle handle; |
266 | int ret; | 246 | int ret; |
267 | 247 | ||
268 | ret = acpi_bind_one(dev, NULL); | 248 | ret = acpi_bind_one(dev, NULL); |
269 | if (ret && (!dev->bus || !dev->parent)) { | 249 | if (ret && type) { |
270 | /* bridge devices genernally haven't bus or parent */ | ||
271 | ret = acpi_find_bridge_device(dev, &handle); | ||
272 | if (!ret) { | ||
273 | ret = acpi_bind_one(dev, handle); | ||
274 | if (ret) | ||
275 | goto out; | ||
276 | } | ||
277 | } | ||
278 | |||
279 | type = acpi_get_bus_type(dev->bus); | ||
280 | if (ret) { | ||
281 | if (!type || !type->find_device) { | ||
282 | DBG("No ACPI bus support for %s\n", dev_name(dev)); | ||
283 | ret = -EINVAL; | ||
284 | goto out; | ||
285 | } | ||
286 | |||
287 | ret = type->find_device(dev, &handle); | 250 | ret = type->find_device(dev, &handle); |
288 | if (ret) { | 251 | if (ret) { |
289 | DBG("Unable to get handle for %s\n", dev_name(dev)); | 252 | DBG("Unable to get handle for %s\n", dev_name(dev)); |
@@ -316,7 +279,7 @@ static int acpi_platform_notify_remove(struct device *dev) | |||
316 | { | 279 | { |
317 | struct acpi_bus_type *type; | 280 | struct acpi_bus_type *type; |
318 | 281 | ||
319 | type = acpi_get_bus_type(dev->bus); | 282 | type = acpi_get_bus_type(dev); |
320 | if (type && type->cleanup) | 283 | if (type && type->cleanup) |
321 | type->cleanup(dev); | 284 | type->cleanup(dev); |
322 | 285 | ||
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index eff722278ff5..164d49569aeb 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c | |||
@@ -158,8 +158,7 @@ static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id) | |||
158 | } | 158 | } |
159 | 159 | ||
160 | exit: | 160 | exit: |
161 | if (buffer.pointer) | 161 | kfree(buffer.pointer); |
162 | kfree(buffer.pointer); | ||
163 | return apic_id; | 162 | return apic_id; |
164 | } | 163 | } |
165 | 164 | ||
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c index df34bd04ae62..bec717ffd25f 100644 --- a/drivers/acpi/processor_driver.c +++ b/drivers/acpi/processor_driver.c | |||
@@ -559,7 +559,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device) | |||
559 | return 0; | 559 | return 0; |
560 | #endif | 560 | #endif |
561 | 561 | ||
562 | BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0)); | 562 | BUG_ON(pr->id >= nr_cpu_ids); |
563 | 563 | ||
564 | /* | 564 | /* |
565 | * Buggy BIOS check | 565 | * Buggy BIOS check |
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index 6d3a06a629a1..24213033fbae 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c | |||
@@ -599,7 +599,6 @@ static void acpi_sleep_suspend_setup(void) | |||
599 | status = acpi_get_sleep_type_data(i, &type_a, &type_b); | 599 | status = acpi_get_sleep_type_data(i, &type_a, &type_b); |
600 | if (ACPI_SUCCESS(status)) { | 600 | if (ACPI_SUCCESS(status)) { |
601 | sleep_states[i] = 1; | 601 | sleep_states[i] = 1; |
602 | pr_cont(" S%d", i); | ||
603 | } | 602 | } |
604 | } | 603 | } |
605 | 604 | ||
@@ -742,7 +741,6 @@ static void acpi_sleep_hibernate_setup(void) | |||
742 | hibernation_set_ops(old_suspend_ordering ? | 741 | hibernation_set_ops(old_suspend_ordering ? |
743 | &acpi_hibernation_ops_old : &acpi_hibernation_ops); | 742 | &acpi_hibernation_ops_old : &acpi_hibernation_ops); |
744 | sleep_states[ACPI_STATE_S4] = 1; | 743 | sleep_states[ACPI_STATE_S4] = 1; |
745 | pr_cont(KERN_CONT " S4"); | ||
746 | if (nosigcheck) | 744 | if (nosigcheck) |
747 | return; | 745 | return; |
748 | 746 | ||
@@ -788,6 +786,9 @@ int __init acpi_sleep_init(void) | |||
788 | { | 786 | { |
789 | acpi_status status; | 787 | acpi_status status; |
790 | u8 type_a, type_b; | 788 | u8 type_a, type_b; |
789 | char supported[ACPI_S_STATE_COUNT * 3 + 1]; | ||
790 | char *pos = supported; | ||
791 | int i; | ||
791 | 792 | ||
792 | if (acpi_disabled) | 793 | if (acpi_disabled) |
793 | return 0; | 794 | return 0; |
@@ -795,7 +796,6 @@ int __init acpi_sleep_init(void) | |||
795 | acpi_sleep_dmi_check(); | 796 | acpi_sleep_dmi_check(); |
796 | 797 | ||
797 | sleep_states[ACPI_STATE_S0] = 1; | 798 | sleep_states[ACPI_STATE_S0] = 1; |
798 | pr_info(PREFIX "(supports S0"); | ||
799 | 799 | ||
800 | acpi_sleep_suspend_setup(); | 800 | acpi_sleep_suspend_setup(); |
801 | acpi_sleep_hibernate_setup(); | 801 | acpi_sleep_hibernate_setup(); |
@@ -803,11 +803,17 @@ int __init acpi_sleep_init(void) | |||
803 | status = acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b); | 803 | status = acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b); |
804 | if (ACPI_SUCCESS(status)) { | 804 | if (ACPI_SUCCESS(status)) { |
805 | sleep_states[ACPI_STATE_S5] = 1; | 805 | sleep_states[ACPI_STATE_S5] = 1; |
806 | pr_cont(" S5"); | ||
807 | pm_power_off_prepare = acpi_power_off_prepare; | 806 | pm_power_off_prepare = acpi_power_off_prepare; |
808 | pm_power_off = acpi_power_off; | 807 | pm_power_off = acpi_power_off; |
809 | } | 808 | } |
810 | pr_cont(")\n"); | 809 | |
810 | supported[0] = 0; | ||
811 | for (i = 0; i < ACPI_S_STATE_COUNT; i++) { | ||
812 | if (sleep_states[i]) | ||
813 | pos += sprintf(pos, " S%d", i); | ||
814 | } | ||
815 | pr_info(PREFIX "(supports%s)\n", supported); | ||
816 | |||
811 | /* | 817 | /* |
812 | * Register the tts_notifier to reboot notifier list so that the _TTS | 818 | * Register the tts_notifier to reboot notifier list so that the _TTS |
813 | * object can also be evaluated when the system enters S5. | 819 | * object can also be evaluated when the system enters S5. |
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index 0ea1018280bd..beea3115577e 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c | |||
@@ -1144,13 +1144,8 @@ static int ata_acpi_find_device(struct device *dev, acpi_handle *handle) | |||
1144 | return -ENODEV; | 1144 | return -ENODEV; |
1145 | } | 1145 | } |
1146 | 1146 | ||
1147 | static int ata_acpi_find_dummy(struct device *dev, acpi_handle *handle) | ||
1148 | { | ||
1149 | return -ENODEV; | ||
1150 | } | ||
1151 | |||
1152 | static struct acpi_bus_type ata_acpi_bus = { | 1147 | static struct acpi_bus_type ata_acpi_bus = { |
1153 | .find_bridge = ata_acpi_find_dummy, | 1148 | .name = "ATA", |
1154 | .find_device = ata_acpi_find_device, | 1149 | .find_device = ata_acpi_find_device, |
1155 | }; | 1150 | }; |
1156 | 1151 | ||
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index 39c937f9b426..dee5dddaa292 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c | |||
@@ -331,8 +331,14 @@ static void pci_acpi_cleanup(struct device *dev) | |||
331 | } | 331 | } |
332 | } | 332 | } |
333 | 333 | ||
334 | static bool pci_acpi_bus_match(struct device *dev) | ||
335 | { | ||
336 | return dev->bus == &pci_bus_type; | ||
337 | } | ||
338 | |||
334 | static struct acpi_bus_type acpi_pci_bus = { | 339 | static struct acpi_bus_type acpi_pci_bus = { |
335 | .bus = &pci_bus_type, | 340 | .name = "PCI", |
341 | .match = pci_acpi_bus_match, | ||
336 | .find_device = acpi_pci_find_device, | 342 | .find_device = acpi_pci_find_device, |
337 | .setup = pci_acpi_setup, | 343 | .setup = pci_acpi_setup, |
338 | .cleanup = pci_acpi_cleanup, | 344 | .cleanup = pci_acpi_cleanup, |
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c index 8813fc03aa09..55cd459a3908 100644 --- a/drivers/pnp/pnpacpi/core.c +++ b/drivers/pnp/pnpacpi/core.c | |||
@@ -353,8 +353,14 @@ static int __init acpi_pnp_find_device(struct device *dev, acpi_handle * handle) | |||
353 | /* complete initialization of a PNPACPI device includes having | 353 | /* complete initialization of a PNPACPI device includes having |
354 | * pnpdev->dev.archdata.acpi_handle point to its ACPI sibling. | 354 | * pnpdev->dev.archdata.acpi_handle point to its ACPI sibling. |
355 | */ | 355 | */ |
356 | static bool acpi_pnp_bus_match(struct device *dev) | ||
357 | { | ||
358 | return dev->bus == &pnp_bus_type; | ||
359 | } | ||
360 | |||
356 | static struct acpi_bus_type __initdata acpi_pnp_bus = { | 361 | static struct acpi_bus_type __initdata acpi_pnp_bus = { |
357 | .bus = &pnp_bus_type, | 362 | .name = "PNP", |
363 | .match = acpi_pnp_bus_match, | ||
358 | .find_device = acpi_pnp_find_device, | 364 | .find_device = acpi_pnp_find_device, |
359 | }; | 365 | }; |
360 | 366 | ||
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 765398c063c7..c31187d79343 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -71,9 +71,14 @@ struct kmem_cache *scsi_sdb_cache; | |||
71 | #ifdef CONFIG_ACPI | 71 | #ifdef CONFIG_ACPI |
72 | #include <acpi/acpi_bus.h> | 72 | #include <acpi/acpi_bus.h> |
73 | 73 | ||
74 | static bool acpi_scsi_bus_match(struct device *dev) | ||
75 | { | ||
76 | return dev->bus == &scsi_bus_type; | ||
77 | } | ||
78 | |||
74 | int scsi_register_acpi_bus_type(struct acpi_bus_type *bus) | 79 | int scsi_register_acpi_bus_type(struct acpi_bus_type *bus) |
75 | { | 80 | { |
76 | bus->bus = &scsi_bus_type; | 81 | bus->match = acpi_scsi_bus_match; |
77 | return register_acpi_bus_type(bus); | 82 | return register_acpi_bus_type(bus); |
78 | } | 83 | } |
79 | EXPORT_SYMBOL_GPL(scsi_register_acpi_bus_type); | 84 | EXPORT_SYMBOL_GPL(scsi_register_acpi_bus_type); |
diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c index cef4252bb31a..b6f4bad3f756 100644 --- a/drivers/usb/core/usb-acpi.c +++ b/drivers/usb/core/usb-acpi.c | |||
@@ -210,9 +210,14 @@ static int usb_acpi_find_device(struct device *dev, acpi_handle *handle) | |||
210 | return 0; | 210 | return 0; |
211 | } | 211 | } |
212 | 212 | ||
213 | static bool usb_acpi_bus_match(struct device *dev) | ||
214 | { | ||
215 | return is_usb_device(dev) || is_usb_port(dev); | ||
216 | } | ||
217 | |||
213 | static struct acpi_bus_type usb_acpi_bus = { | 218 | static struct acpi_bus_type usb_acpi_bus = { |
214 | .bus = &usb_bus_type, | 219 | .name = "USB", |
215 | .find_bridge = usb_acpi_find_device, | 220 | .match = usb_acpi_bus_match, |
216 | .find_device = usb_acpi_find_device, | 221 | .find_device = usb_acpi_find_device, |
217 | }; | 222 | }; |
218 | 223 | ||
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index e65278f560c4..22ba56e834e2 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h | |||
@@ -437,11 +437,9 @@ void acpi_remove_dir(struct acpi_device *); | |||
437 | */ | 437 | */ |
438 | struct acpi_bus_type { | 438 | struct acpi_bus_type { |
439 | struct list_head list; | 439 | struct list_head list; |
440 | struct bus_type *bus; | 440 | const char *name; |
441 | /* For general devices under the bus */ | 441 | bool (*match)(struct device *dev); |
442 | int (*find_device) (struct device *, acpi_handle *); | 442 | int (*find_device) (struct device *, acpi_handle *); |
443 | /* For bridges, such as PCI root bridge, IDE controller */ | ||
444 | int (*find_bridge) (struct device *, acpi_handle *); | ||
445 | void (*setup)(struct device *); | 443 | void (*setup)(struct device *); |
446 | void (*cleanup)(struct device *); | 444 | void (*cleanup)(struct device *); |
447 | }; | 445 | }; |