Commit d7553a86 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

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
parents 6dbe51c2 92414481
...@@ -36,12 +36,11 @@ int register_acpi_bus_type(struct acpi_bus_type *type) ...@@ -36,12 +36,11 @@ int register_acpi_bus_type(struct acpi_bus_type *type)
{ {
if (acpi_disabled) if (acpi_disabled)
return -ENODEV; return -ENODEV;
if (type && type->bus && type->find_device) { if (type && type->match && type->find_device) {
down_write(&bus_type_sem); down_write(&bus_type_sem);
list_add_tail(&type->list, &bus_type_list); list_add_tail(&type->list, &bus_type_list);
up_write(&bus_type_sem); up_write(&bus_type_sem);
printk(KERN_INFO PREFIX "bus type %s registered\n", printk(KERN_INFO PREFIX "bus type %s registered\n", type->name);
type->bus->name);
return 0; return 0;
} }
return -ENODEV; return -ENODEV;
...@@ -56,24 +55,21 @@ int unregister_acpi_bus_type(struct acpi_bus_type *type) ...@@ -56,24 +55,21 @@ int unregister_acpi_bus_type(struct acpi_bus_type *type)
down_write(&bus_type_sem); down_write(&bus_type_sem);
list_del_init(&type->list); list_del_init(&type->list);
up_write(&bus_type_sem); up_write(&bus_type_sem);
printk(KERN_INFO PREFIX "ACPI bus type %s unregistered\n", printk(KERN_INFO PREFIX "bus type %s unregistered\n",
type->bus->name); type->name);
return 0; return 0;
} }
return -ENODEV; return -ENODEV;
} }
EXPORT_SYMBOL_GPL(unregister_acpi_bus_type); EXPORT_SYMBOL_GPL(unregister_acpi_bus_type);
static struct acpi_bus_type *acpi_get_bus_type(struct bus_type *type) static struct acpi_bus_type *acpi_get_bus_type(struct device *dev)
{ {
struct acpi_bus_type *tmp, *ret = NULL; struct acpi_bus_type *tmp, *ret = NULL;
if (!type)
return NULL;
down_read(&bus_type_sem); down_read(&bus_type_sem);
list_for_each_entry(tmp, &bus_type_list, list) { list_for_each_entry(tmp, &bus_type_list, list) {
if (tmp->bus == type) { if (tmp->match(dev)) {
ret = tmp; ret = tmp;
break; break;
} }
...@@ -82,22 +78,6 @@ static struct acpi_bus_type *acpi_get_bus_type(struct bus_type *type) ...@@ -82,22 +78,6 @@ static struct acpi_bus_type *acpi_get_bus_type(struct bus_type *type)
return ret; return ret;
} }
static int acpi_find_bridge_device(struct device *dev, acpi_handle * handle)
{
struct acpi_bus_type *tmp;
int ret = -ENODEV;
down_read(&bus_type_sem);
list_for_each_entry(tmp, &bus_type_list, list) {
if (tmp->find_bridge && !tmp->find_bridge(dev, handle)) {
ret = 0;
break;
}
}
up_read(&bus_type_sem);
return ret;
}
static acpi_status do_acpi_find_child(acpi_handle handle, u32 lvl_not_used, static acpi_status do_acpi_find_child(acpi_handle handle, u32 lvl_not_used,
void *addr_p, void **ret_p) void *addr_p, void **ret_p)
{ {
...@@ -261,29 +241,12 @@ static int acpi_unbind_one(struct device *dev) ...@@ -261,29 +241,12 @@ static int acpi_unbind_one(struct device *dev)
static int acpi_platform_notify(struct device *dev) static int acpi_platform_notify(struct device *dev)
{ {
struct acpi_bus_type *type; struct acpi_bus_type *type = acpi_get_bus_type(dev);
acpi_handle handle; acpi_handle handle;
int ret; int ret;
ret = acpi_bind_one(dev, NULL); ret = acpi_bind_one(dev, NULL);
if (ret && (!dev->bus || !dev->parent)) { if (ret && type) {
/* bridge devices genernally haven't bus or parent */
ret = acpi_find_bridge_device(dev, &handle);
if (!ret) {
ret = acpi_bind_one(dev, handle);
if (ret)
goto out;
}
}
type = acpi_get_bus_type(dev->bus);
if (ret) {
if (!type || !type->find_device) {
DBG("No ACPI bus support for %s\n", dev_name(dev));
ret = -EINVAL;
goto out;
}
ret = type->find_device(dev, &handle); ret = type->find_device(dev, &handle);
if (ret) { if (ret) {
DBG("Unable to get handle for %s\n", dev_name(dev)); 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,7 +279,7 @@ static int acpi_platform_notify_remove(struct device *dev)
{ {
struct acpi_bus_type *type; struct acpi_bus_type *type;
type = acpi_get_bus_type(dev->bus); type = acpi_get_bus_type(dev);
if (type && type->cleanup) if (type && type->cleanup)
type->cleanup(dev); type->cleanup(dev);
......
...@@ -158,8 +158,7 @@ static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id) ...@@ -158,8 +158,7 @@ static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
} }
exit: exit:
if (buffer.pointer) kfree(buffer.pointer);
kfree(buffer.pointer);
return apic_id; return apic_id;
} }
......
...@@ -559,7 +559,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device) ...@@ -559,7 +559,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
return 0; return 0;
#endif #endif
BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0)); BUG_ON(pr->id >= nr_cpu_ids);
/* /*
* Buggy BIOS check * Buggy BIOS check
......
...@@ -599,7 +599,6 @@ static void acpi_sleep_suspend_setup(void) ...@@ -599,7 +599,6 @@ static void acpi_sleep_suspend_setup(void)
status = acpi_get_sleep_type_data(i, &type_a, &type_b); status = acpi_get_sleep_type_data(i, &type_a, &type_b);
if (ACPI_SUCCESS(status)) { if (ACPI_SUCCESS(status)) {
sleep_states[i] = 1; sleep_states[i] = 1;
pr_cont(" S%d", i);
} }
} }
...@@ -742,7 +741,6 @@ static void acpi_sleep_hibernate_setup(void) ...@@ -742,7 +741,6 @@ static void acpi_sleep_hibernate_setup(void)
hibernation_set_ops(old_suspend_ordering ? hibernation_set_ops(old_suspend_ordering ?
&acpi_hibernation_ops_old : &acpi_hibernation_ops); &acpi_hibernation_ops_old : &acpi_hibernation_ops);
sleep_states[ACPI_STATE_S4] = 1; sleep_states[ACPI_STATE_S4] = 1;
pr_cont(KERN_CONT " S4");
if (nosigcheck) if (nosigcheck)
return; return;
...@@ -788,6 +786,9 @@ int __init acpi_sleep_init(void) ...@@ -788,6 +786,9 @@ int __init acpi_sleep_init(void)
{ {
acpi_status status; acpi_status status;
u8 type_a, type_b; u8 type_a, type_b;
char supported[ACPI_S_STATE_COUNT * 3 + 1];
char *pos = supported;
int i;
if (acpi_disabled) if (acpi_disabled)
return 0; return 0;
...@@ -795,7 +796,6 @@ int __init acpi_sleep_init(void) ...@@ -795,7 +796,6 @@ int __init acpi_sleep_init(void)
acpi_sleep_dmi_check(); acpi_sleep_dmi_check();
sleep_states[ACPI_STATE_S0] = 1; sleep_states[ACPI_STATE_S0] = 1;
pr_info(PREFIX "(supports S0");
acpi_sleep_suspend_setup(); acpi_sleep_suspend_setup();
acpi_sleep_hibernate_setup(); acpi_sleep_hibernate_setup();
...@@ -803,11 +803,17 @@ int __init acpi_sleep_init(void) ...@@ -803,11 +803,17 @@ int __init acpi_sleep_init(void)
status = acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b); status = acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b);
if (ACPI_SUCCESS(status)) { if (ACPI_SUCCESS(status)) {
sleep_states[ACPI_STATE_S5] = 1; sleep_states[ACPI_STATE_S5] = 1;
pr_cont(" S5");
pm_power_off_prepare = acpi_power_off_prepare; pm_power_off_prepare = acpi_power_off_prepare;
pm_power_off = acpi_power_off; pm_power_off = acpi_power_off;
} }
pr_cont(")\n");
supported[0] = 0;
for (i = 0; i < ACPI_S_STATE_COUNT; i++) {
if (sleep_states[i])
pos += sprintf(pos, " S%d", i);
}
pr_info(PREFIX "(supports%s)\n", supported);
/* /*
* Register the tts_notifier to reboot notifier list so that the _TTS * Register the tts_notifier to reboot notifier list so that the _TTS
* object can also be evaluated when the system enters S5. * object can also be evaluated when the system enters S5.
......
...@@ -1144,13 +1144,8 @@ static int ata_acpi_find_device(struct device *dev, acpi_handle *handle) ...@@ -1144,13 +1144,8 @@ static int ata_acpi_find_device(struct device *dev, acpi_handle *handle)
return -ENODEV; return -ENODEV;
} }
static int ata_acpi_find_dummy(struct device *dev, acpi_handle *handle)
{
return -ENODEV;
}
static struct acpi_bus_type ata_acpi_bus = { static struct acpi_bus_type ata_acpi_bus = {
.find_bridge = ata_acpi_find_dummy, .name = "ATA",
.find_device = ata_acpi_find_device, .find_device = ata_acpi_find_device,
}; };
......
...@@ -331,8 +331,14 @@ static void pci_acpi_cleanup(struct device *dev) ...@@ -331,8 +331,14 @@ static void pci_acpi_cleanup(struct device *dev)
} }
} }
static bool pci_acpi_bus_match(struct device *dev)
{
return dev->bus == &pci_bus_type;
}
static struct acpi_bus_type acpi_pci_bus = { static struct acpi_bus_type acpi_pci_bus = {
.bus = &pci_bus_type, .name = "PCI",
.match = pci_acpi_bus_match,
.find_device = acpi_pci_find_device, .find_device = acpi_pci_find_device,
.setup = pci_acpi_setup, .setup = pci_acpi_setup,
.cleanup = pci_acpi_cleanup, .cleanup = pci_acpi_cleanup,
......
...@@ -353,8 +353,14 @@ static int __init acpi_pnp_find_device(struct device *dev, acpi_handle * handle) ...@@ -353,8 +353,14 @@ static int __init acpi_pnp_find_device(struct device *dev, acpi_handle * handle)
/* complete initialization of a PNPACPI device includes having /* complete initialization of a PNPACPI device includes having
* pnpdev->dev.archdata.acpi_handle point to its ACPI sibling. * pnpdev->dev.archdata.acpi_handle point to its ACPI sibling.
*/ */
static bool acpi_pnp_bus_match(struct device *dev)
{
return dev->bus == &pnp_bus_type;
}
static struct acpi_bus_type __initdata acpi_pnp_bus = { static struct acpi_bus_type __initdata acpi_pnp_bus = {
.bus = &pnp_bus_type, .name = "PNP",
.match = acpi_pnp_bus_match,
.find_device = acpi_pnp_find_device, .find_device = acpi_pnp_find_device,
}; };
......
...@@ -71,9 +71,14 @@ struct kmem_cache *scsi_sdb_cache; ...@@ -71,9 +71,14 @@ struct kmem_cache *scsi_sdb_cache;
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
#include <acpi/acpi_bus.h> #include <acpi/acpi_bus.h>
static bool acpi_scsi_bus_match(struct device *dev)
{
return dev->bus == &scsi_bus_type;
}
int scsi_register_acpi_bus_type(struct acpi_bus_type *bus) int scsi_register_acpi_bus_type(struct acpi_bus_type *bus)
{ {
bus->bus = &scsi_bus_type; bus->match = acpi_scsi_bus_match;
return register_acpi_bus_type(bus); return register_acpi_bus_type(bus);
} }
EXPORT_SYMBOL_GPL(scsi_register_acpi_bus_type); EXPORT_SYMBOL_GPL(scsi_register_acpi_bus_type);
......
...@@ -210,9 +210,14 @@ static int usb_acpi_find_device(struct device *dev, acpi_handle *handle) ...@@ -210,9 +210,14 @@ static int usb_acpi_find_device(struct device *dev, acpi_handle *handle)
return 0; return 0;
} }
static bool usb_acpi_bus_match(struct device *dev)
{
return is_usb_device(dev) || is_usb_port(dev);
}
static struct acpi_bus_type usb_acpi_bus = { static struct acpi_bus_type usb_acpi_bus = {
.bus = &usb_bus_type, .name = "USB",
.find_bridge = usb_acpi_find_device, .match = usb_acpi_bus_match,
.find_device = usb_acpi_find_device, .find_device = usb_acpi_find_device,
}; };
......
...@@ -437,11 +437,9 @@ void acpi_remove_dir(struct acpi_device *); ...@@ -437,11 +437,9 @@ void acpi_remove_dir(struct acpi_device *);
*/ */
struct acpi_bus_type { struct acpi_bus_type {
struct list_head list; struct list_head list;
struct bus_type *bus; const char *name;
/* For general devices under the bus */ bool (*match)(struct device *dev);
int (*find_device) (struct device *, acpi_handle *); int (*find_device) (struct device *, acpi_handle *);
/* For bridges, such as PCI root bridge, IDE controller */
int (*find_bridge) (struct device *, acpi_handle *);
void (*setup)(struct device *); void (*setup)(struct device *);
void (*cleanup)(struct device *); void (*cleanup)(struct device *);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment