Commit 1996e9d7 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

Merge 'acpi-bus' material for v6.6 to satisfy dependencies.

parents eca3f0a8 9d67b6ac
...@@ -34,7 +34,7 @@ MODULE_LICENSE("GPL"); ...@@ -34,7 +34,7 @@ MODULE_LICENSE("GPL");
static int acpi_ac_add(struct acpi_device *device); static int acpi_ac_add(struct acpi_device *device);
static void acpi_ac_remove(struct acpi_device *device); static void acpi_ac_remove(struct acpi_device *device);
static void acpi_ac_notify(struct acpi_device *device, u32 event); static void acpi_ac_notify(acpi_handle handle, u32 event, void *data);
static const struct acpi_device_id ac_device_ids[] = { static const struct acpi_device_id ac_device_ids[] = {
{"ACPI0003", 0}, {"ACPI0003", 0},
...@@ -54,11 +54,9 @@ static struct acpi_driver acpi_ac_driver = { ...@@ -54,11 +54,9 @@ static struct acpi_driver acpi_ac_driver = {
.name = "ac", .name = "ac",
.class = ACPI_AC_CLASS, .class = ACPI_AC_CLASS,
.ids = ac_device_ids, .ids = ac_device_ids,
.flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
.ops = { .ops = {
.add = acpi_ac_add, .add = acpi_ac_add,
.remove = acpi_ac_remove, .remove = acpi_ac_remove,
.notify = acpi_ac_notify,
}, },
.drv.pm = &acpi_ac_pm, .drv.pm = &acpi_ac_pm,
}; };
...@@ -128,8 +126,9 @@ static enum power_supply_property ac_props[] = { ...@@ -128,8 +126,9 @@ static enum power_supply_property ac_props[] = {
}; };
/* Driver Model */ /* Driver Model */
static void acpi_ac_notify(struct acpi_device *device, u32 event) static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
{ {
struct acpi_device *device = data;
struct acpi_ac *ac = acpi_driver_data(device); struct acpi_ac *ac = acpi_driver_data(device);
if (!ac) if (!ac)
...@@ -235,7 +234,7 @@ static int acpi_ac_add(struct acpi_device *device) ...@@ -235,7 +234,7 @@ static int acpi_ac_add(struct acpi_device *device)
result = acpi_ac_get_state(ac); result = acpi_ac_get_state(ac);
if (result) if (result)
goto end; goto err_release_ac;
psy_cfg.drv_data = ac; psy_cfg.drv_data = ac;
...@@ -248,7 +247,7 @@ static int acpi_ac_add(struct acpi_device *device) ...@@ -248,7 +247,7 @@ static int acpi_ac_add(struct acpi_device *device)
&ac->charger_desc, &psy_cfg); &ac->charger_desc, &psy_cfg);
if (IS_ERR(ac->charger)) { if (IS_ERR(ac->charger)) {
result = PTR_ERR(ac->charger); result = PTR_ERR(ac->charger);
goto end; goto err_release_ac;
} }
pr_info("%s [%s] (%s)\n", acpi_device_name(device), pr_info("%s [%s] (%s)\n", acpi_device_name(device),
...@@ -256,9 +255,19 @@ static int acpi_ac_add(struct acpi_device *device) ...@@ -256,9 +255,19 @@ static int acpi_ac_add(struct acpi_device *device)
ac->battery_nb.notifier_call = acpi_ac_battery_notify; ac->battery_nb.notifier_call = acpi_ac_battery_notify;
register_acpi_notifier(&ac->battery_nb); register_acpi_notifier(&ac->battery_nb);
end:
result = acpi_dev_install_notify_handler(device, ACPI_ALL_NOTIFY,
acpi_ac_notify);
if (result) if (result)
kfree(ac); goto err_unregister;
return 0;
err_unregister:
power_supply_unregister(ac->charger);
unregister_acpi_notifier(&ac->battery_nb);
err_release_ac:
kfree(ac);
return result; return result;
} }
...@@ -297,6 +306,8 @@ static void acpi_ac_remove(struct acpi_device *device) ...@@ -297,6 +306,8 @@ static void acpi_ac_remove(struct acpi_device *device)
ac = acpi_driver_data(device); ac = acpi_driver_data(device);
acpi_dev_remove_notify_handler(device, ACPI_ALL_NOTIFY,
acpi_ac_notify);
power_supply_unregister(ac->charger); power_supply_unregister(ac->charger);
unregister_acpi_notifier(&ac->battery_nb); unregister_acpi_notifier(&ac->battery_nb);
......
...@@ -77,7 +77,7 @@ static DEFINE_MUTEX(video_list_lock); ...@@ -77,7 +77,7 @@ static DEFINE_MUTEX(video_list_lock);
static LIST_HEAD(video_bus_head); static LIST_HEAD(video_bus_head);
static int acpi_video_bus_add(struct acpi_device *device); static int acpi_video_bus_add(struct acpi_device *device);
static void acpi_video_bus_remove(struct acpi_device *device); static void acpi_video_bus_remove(struct acpi_device *device);
static void acpi_video_bus_notify(struct acpi_device *device, u32 event); static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data);
/* /*
* Indices in the _BCL method response: the first two items are special, * Indices in the _BCL method response: the first two items are special,
...@@ -104,7 +104,6 @@ static struct acpi_driver acpi_video_bus = { ...@@ -104,7 +104,6 @@ static struct acpi_driver acpi_video_bus = {
.ops = { .ops = {
.add = acpi_video_bus_add, .add = acpi_video_bus_add,
.remove = acpi_video_bus_remove, .remove = acpi_video_bus_remove,
.notify = acpi_video_bus_notify,
}, },
}; };
...@@ -1527,8 +1526,9 @@ static int acpi_video_bus_stop_devices(struct acpi_video_bus *video) ...@@ -1527,8 +1526,9 @@ static int acpi_video_bus_stop_devices(struct acpi_video_bus *video)
acpi_osi_is_win8() ? 0 : 1); acpi_osi_is_win8() ? 0 : 1);
} }
static void acpi_video_bus_notify(struct acpi_device *device, u32 event) static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
{ {
struct acpi_device *device = data;
struct acpi_video_bus *video = acpi_driver_data(device); struct acpi_video_bus *video = acpi_driver_data(device);
struct input_dev *input; struct input_dev *input;
int keycode = 0; int keycode = 0;
...@@ -2053,8 +2053,19 @@ static int acpi_video_bus_add(struct acpi_device *device) ...@@ -2053,8 +2053,19 @@ static int acpi_video_bus_add(struct acpi_device *device)
acpi_video_bus_add_notify_handler(video); acpi_video_bus_add_notify_handler(video);
error = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY,
acpi_video_bus_notify);
if (error)
goto err_remove;
return 0; return 0;
err_remove:
mutex_lock(&video_list_lock);
list_del(&video->entry);
mutex_unlock(&video_list_lock);
acpi_video_bus_remove_notify_handler(video);
acpi_video_bus_unregister_backlight(video);
err_put_video: err_put_video:
acpi_video_bus_put_devices(video); acpi_video_bus_put_devices(video);
kfree(video->attached_array); kfree(video->attached_array);
...@@ -2075,6 +2086,9 @@ static void acpi_video_bus_remove(struct acpi_device *device) ...@@ -2075,6 +2086,9 @@ static void acpi_video_bus_remove(struct acpi_device *device)
video = acpi_driver_data(device); video = acpi_driver_data(device);
acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY,
acpi_video_bus_notify);
mutex_lock(&video_list_lock); mutex_lock(&video_list_lock);
list_del(&video->entry); list_del(&video->entry);
mutex_unlock(&video_list_lock); mutex_unlock(&video_list_lock);
......
...@@ -1034,8 +1034,9 @@ static void acpi_battery_refresh(struct acpi_battery *battery) ...@@ -1034,8 +1034,9 @@ static void acpi_battery_refresh(struct acpi_battery *battery)
} }
/* Driver Interface */ /* Driver Interface */
static void acpi_battery_notify(struct acpi_device *device, u32 event) static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
{ {
struct acpi_device *device = data;
struct acpi_battery *battery = acpi_driver_data(device); struct acpi_battery *battery = acpi_driver_data(device);
struct power_supply *old; struct power_supply *old;
...@@ -1212,13 +1213,22 @@ static int acpi_battery_add(struct acpi_device *device) ...@@ -1212,13 +1213,22 @@ static int acpi_battery_add(struct acpi_device *device)
device_init_wakeup(&device->dev, 1); device_init_wakeup(&device->dev, 1);
return result; result = acpi_dev_install_notify_handler(device, ACPI_ALL_NOTIFY,
acpi_battery_notify);
if (result)
goto fail_pm;
return 0;
fail_pm:
device_init_wakeup(&device->dev, 0);
unregister_pm_notifier(&battery->pm_nb);
fail: fail:
sysfs_remove_battery(battery); sysfs_remove_battery(battery);
mutex_destroy(&battery->lock); mutex_destroy(&battery->lock);
mutex_destroy(&battery->sysfs_lock); mutex_destroy(&battery->sysfs_lock);
kfree(battery); kfree(battery);
return result; return result;
} }
...@@ -1228,10 +1238,16 @@ static void acpi_battery_remove(struct acpi_device *device) ...@@ -1228,10 +1238,16 @@ static void acpi_battery_remove(struct acpi_device *device)
if (!device || !acpi_driver_data(device)) if (!device || !acpi_driver_data(device))
return; return;
device_init_wakeup(&device->dev, 0);
battery = acpi_driver_data(device); battery = acpi_driver_data(device);
acpi_dev_remove_notify_handler(device, ACPI_ALL_NOTIFY,
acpi_battery_notify);
device_init_wakeup(&device->dev, 0);
unregister_pm_notifier(&battery->pm_nb); unregister_pm_notifier(&battery->pm_nb);
sysfs_remove_battery(battery); sysfs_remove_battery(battery);
mutex_destroy(&battery->lock); mutex_destroy(&battery->lock);
mutex_destroy(&battery->sysfs_lock); mutex_destroy(&battery->sysfs_lock);
kfree(battery); kfree(battery);
...@@ -1264,11 +1280,9 @@ static struct acpi_driver acpi_battery_driver = { ...@@ -1264,11 +1280,9 @@ static struct acpi_driver acpi_battery_driver = {
.name = "battery", .name = "battery",
.class = ACPI_BATTERY_CLASS, .class = ACPI_BATTERY_CLASS,
.ids = battery_device_ids, .ids = battery_device_ids,
.flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
.ops = { .ops = {
.add = acpi_battery_add, .add = acpi_battery_add,
.remove = acpi_battery_remove, .remove = acpi_battery_remove,
.notify = acpi_battery_notify,
}, },
.drv.pm = &acpi_battery_pm, .drv.pm = &acpi_battery_pm,
}; };
......
...@@ -554,6 +554,30 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device, ...@@ -554,6 +554,30 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device,
acpi_os_wait_events_complete(); acpi_os_wait_events_complete();
} }
int acpi_dev_install_notify_handler(struct acpi_device *adev,
u32 handler_type,
acpi_notify_handler handler)
{
acpi_status status;
status = acpi_install_notify_handler(adev->handle, handler_type,
handler, adev);
if (ACPI_FAILURE(status))
return -ENODEV;
return 0;
}
EXPORT_SYMBOL_GPL(acpi_dev_install_notify_handler);
void acpi_dev_remove_notify_handler(struct acpi_device *adev,
u32 handler_type,
acpi_notify_handler handler)
{
acpi_remove_notify_handler(adev->handle, handler_type, handler);
acpi_os_wait_events_complete();
}
EXPORT_SYMBOL_GPL(acpi_dev_remove_notify_handler);
/* Handle events targeting \_SB device (at present only graceful shutdown) */ /* Handle events targeting \_SB device (at present only graceful shutdown) */
#define ACPI_SB_NOTIFY_SHUTDOWN_REQUEST 0x81 #define ACPI_SB_NOTIFY_SHUTDOWN_REQUEST 0x81
...@@ -1005,8 +1029,10 @@ static int acpi_device_probe(struct device *dev) ...@@ -1005,8 +1029,10 @@ static int acpi_device_probe(struct device *dev)
return -ENOSYS; return -ENOSYS;
ret = acpi_drv->ops.add(acpi_dev); ret = acpi_drv->ops.add(acpi_dev);
if (ret) if (ret) {
acpi_dev->driver_data = NULL;
return ret; return ret;
}
pr_debug("Driver [%s] successfully bound to device [%s]\n", pr_debug("Driver [%s] successfully bound to device [%s]\n",
acpi_drv->name, acpi_dev->pnp.bus_id); acpi_drv->name, acpi_dev->pnp.bus_id);
......
...@@ -42,22 +42,32 @@ EXPORT_SYMBOL_GPL(unregister_acpi_hed_notifier); ...@@ -42,22 +42,32 @@ EXPORT_SYMBOL_GPL(unregister_acpi_hed_notifier);
* it is used by HEST Generic Hardware Error Source with notify type * it is used by HEST Generic Hardware Error Source with notify type
* SCI. * SCI.
*/ */
static void acpi_hed_notify(struct acpi_device *device, u32 event) static void acpi_hed_notify(acpi_handle handle, u32 event, void *data)
{ {
blocking_notifier_call_chain(&acpi_hed_notify_list, 0, NULL); blocking_notifier_call_chain(&acpi_hed_notify_list, 0, NULL);
} }
static int acpi_hed_add(struct acpi_device *device) static int acpi_hed_add(struct acpi_device *device)
{ {
int err;
/* Only one hardware error device */ /* Only one hardware error device */
if (hed_handle) if (hed_handle)
return -EINVAL; return -EINVAL;
hed_handle = device->handle; hed_handle = device->handle;
return 0;
err = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY,
acpi_hed_notify);
if (err)
hed_handle = NULL;
return err;
} }
static void acpi_hed_remove(struct acpi_device *device) static void acpi_hed_remove(struct acpi_device *device)
{ {
acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY,
acpi_hed_notify);
hed_handle = NULL; hed_handle = NULL;
} }
...@@ -68,7 +78,6 @@ static struct acpi_driver acpi_hed_driver = { ...@@ -68,7 +78,6 @@ static struct acpi_driver acpi_hed_driver = {
.ops = { .ops = {
.add = acpi_hed_add, .add = acpi_hed_add,
.remove = acpi_hed_remove, .remove = acpi_hed_remove,
.notify = acpi_hed_notify,
}, },
}; };
module_acpi_driver(acpi_hed_driver); module_acpi_driver(acpi_hed_driver);
......
...@@ -3282,6 +3282,23 @@ static void acpi_nfit_put_table(void *table) ...@@ -3282,6 +3282,23 @@ static void acpi_nfit_put_table(void *table)
acpi_put_table(table); acpi_put_table(table);
} }
static void acpi_nfit_notify(acpi_handle handle, u32 event, void *data)
{
struct acpi_device *adev = data;
device_lock(&adev->dev);
__acpi_nfit_notify(&adev->dev, handle, event);
device_unlock(&adev->dev);
}
static void acpi_nfit_remove_notify_handler(void *data)
{
struct acpi_device *adev = data;
acpi_dev_remove_notify_handler(adev, ACPI_DEVICE_NOTIFY,
acpi_nfit_notify);
}
void acpi_nfit_shutdown(void *data) void acpi_nfit_shutdown(void *data)
{ {
struct acpi_nfit_desc *acpi_desc = data; struct acpi_nfit_desc *acpi_desc = data;
...@@ -3368,12 +3385,18 @@ static int acpi_nfit_add(struct acpi_device *adev) ...@@ -3368,12 +3385,18 @@ static int acpi_nfit_add(struct acpi_device *adev)
if (rc) if (rc)
return rc; return rc;
return devm_add_action_or_reset(dev, acpi_nfit_shutdown, acpi_desc);
}
static void acpi_nfit_remove(struct acpi_device *adev) rc = devm_add_action_or_reset(dev, acpi_nfit_shutdown, acpi_desc);
{ if (rc)
/* see acpi_nfit_unregister */ return rc;
rc = acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY,
acpi_nfit_notify);
if (rc)
return rc;
return devm_add_action_or_reset(dev, acpi_nfit_remove_notify_handler,
adev);
} }
static void acpi_nfit_update_notify(struct device *dev, acpi_handle handle) static void acpi_nfit_update_notify(struct device *dev, acpi_handle handle)
...@@ -3446,13 +3469,6 @@ void __acpi_nfit_notify(struct device *dev, acpi_handle handle, u32 event) ...@@ -3446,13 +3469,6 @@ void __acpi_nfit_notify(struct device *dev, acpi_handle handle, u32 event)
} }
EXPORT_SYMBOL_GPL(__acpi_nfit_notify); EXPORT_SYMBOL_GPL(__acpi_nfit_notify);
static void acpi_nfit_notify(struct acpi_device *adev, u32 event)
{
device_lock(&adev->dev);
__acpi_nfit_notify(&adev->dev, adev->handle, event);
device_unlock(&adev->dev);
}
static const struct acpi_device_id acpi_nfit_ids[] = { static const struct acpi_device_id acpi_nfit_ids[] = {
{ "ACPI0012", 0 }, { "ACPI0012", 0 },
{ "", 0 }, { "", 0 },
...@@ -3464,8 +3480,6 @@ static struct acpi_driver acpi_nfit_driver = { ...@@ -3464,8 +3480,6 @@ static struct acpi_driver acpi_nfit_driver = {
.ids = acpi_nfit_ids, .ids = acpi_nfit_ids,
.ops = { .ops = {
.add = acpi_nfit_add, .add = acpi_nfit_add,
.remove = acpi_nfit_remove,
.notify = acpi_nfit_notify,
}, },
}; };
......
...@@ -809,8 +809,9 @@ static void acpi_queue_thermal_check(struct acpi_thermal *tz) ...@@ -809,8 +809,9 @@ static void acpi_queue_thermal_check(struct acpi_thermal *tz)
queue_work(acpi_thermal_pm_queue, &tz->thermal_check_work); queue_work(acpi_thermal_pm_queue, &tz->thermal_check_work);
} }
static void acpi_thermal_notify(struct acpi_device *device, u32 event) static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data)
{ {
struct acpi_device *device = data;
struct acpi_thermal *tz = acpi_driver_data(device); struct acpi_thermal *tz = acpi_driver_data(device);
if (!tz) if (!tz)
...@@ -981,11 +982,20 @@ static int acpi_thermal_add(struct acpi_device *device) ...@@ -981,11 +982,20 @@ static int acpi_thermal_add(struct acpi_device *device)
pr_info("%s [%s] (%ld C)\n", acpi_device_name(device), pr_info("%s [%s] (%ld C)\n", acpi_device_name(device),
acpi_device_bid(device), deci_kelvin_to_celsius(tz->temperature)); acpi_device_bid(device), deci_kelvin_to_celsius(tz->temperature));
goto end;
result = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY,
acpi_thermal_notify);
if (result)
goto flush_wq;
return 0;
flush_wq:
flush_workqueue(acpi_thermal_pm_queue);
acpi_thermal_unregister_thermal_zone(tz);
free_memory: free_memory:
kfree(tz); kfree(tz);
end:
return result; return result;
} }
...@@ -996,10 +1006,14 @@ static void acpi_thermal_remove(struct acpi_device *device) ...@@ -996,10 +1006,14 @@ static void acpi_thermal_remove(struct acpi_device *device)
if (!device || !acpi_driver_data(device)) if (!device || !acpi_driver_data(device))
return; return;
flush_workqueue(acpi_thermal_pm_queue);
tz = acpi_driver_data(device); tz = acpi_driver_data(device);
acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY,
acpi_thermal_notify);
flush_workqueue(acpi_thermal_pm_queue);
acpi_thermal_unregister_thermal_zone(tz); acpi_thermal_unregister_thermal_zone(tz);
kfree(tz); kfree(tz);
} }
...@@ -1056,7 +1070,6 @@ static struct acpi_driver acpi_thermal_driver = { ...@@ -1056,7 +1070,6 @@ static struct acpi_driver acpi_thermal_driver = {
.ops = { .ops = {
.add = acpi_thermal_add, .add = acpi_thermal_add,
.remove = acpi_thermal_remove, .remove = acpi_thermal_remove,
.notify = acpi_thermal_notify,
}, },
.drv.pm = &acpi_thermal_pm, .drv.pm = &acpi_thermal_pm,
}; };
......
...@@ -515,6 +515,12 @@ void acpi_bus_private_data_handler(acpi_handle, void *); ...@@ -515,6 +515,12 @@ void acpi_bus_private_data_handler(acpi_handle, void *);
int acpi_bus_get_private_data(acpi_handle, void **); int acpi_bus_get_private_data(acpi_handle, void **);
int acpi_bus_attach_private_data(acpi_handle, void *); int acpi_bus_attach_private_data(acpi_handle, void *);
void acpi_bus_detach_private_data(acpi_handle); void acpi_bus_detach_private_data(acpi_handle);
int acpi_dev_install_notify_handler(struct acpi_device *adev,
u32 handler_type,
acpi_notify_handler handler);
void acpi_dev_remove_notify_handler(struct acpi_device *adev,
u32 handler_type,
acpi_notify_handler handler);
extern int acpi_notifier_call_chain(struct acpi_device *, u32, u32); extern int acpi_notifier_call_chain(struct acpi_device *, u32, u32);
extern int register_acpi_notifier(struct notifier_block *); extern int register_acpi_notifier(struct notifier_block *);
extern int unregister_acpi_notifier(struct notifier_block *); extern int unregister_acpi_notifier(struct notifier_block *);
......
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