Skip to content

Commit e921f8c

Browse files
committed
Merge branches 'acpi-bus' and 'acpi-video'
Merge changes related to the ACPI bus type and ACPI backlight driver changes for 6.6-rc1: - Introduce new wrappers for ACPICA notify handler install/remove and convert multiple drivers to using their own Notify() handlers instead of the ACPI bus type .notify() slated for removal (Michal Wilczynski). - Add backlight=native DMI quirk for Apple iMac12,1 and iMac12,2 (Hans de Goede). - Put ACPI video and its child devices explicitly into D0 on boot to avoid platform firmware confusion (Kai-Heng Feng). - Add backlight=native DMI quirk for Lenovo Ideapad Z470 (Jiri Slaby). * acpi-bus: ACPI: thermal: Install Notify() handler directly ACPI: NFIT: Remove unnecessary .remove callback ACPI: NFIT: Install Notify() handler directly ACPI: HED: Install Notify() handler directly ACPI: battery: Install Notify() handler directly ACPI: video: Install Notify() handler directly ACPI: AC: Install Notify() handler directly ACPI: bus: Set driver_data to NULL every time .add() fails ACPI: bus: Introduce wrappers for ACPICA notify handler install/remove * acpi-video: ACPI: video: Add backlight=native DMI quirk for Apple iMac12,1 and iMac12,2 ACPI: video: Put ACPI video and its child devices into D0 on boot ACPI: video: Add backlight=native DMI quirk for Lenovo Ideapad Z470
3 parents 8850ada + 9d67b6a + 8cf04bb commit e921f8c

File tree

9 files changed

+179
-39
lines changed

9 files changed

+179
-39
lines changed

drivers/acpi/ac.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ MODULE_LICENSE("GPL");
3434

3535
static int acpi_ac_add(struct acpi_device *device);
3636
static void acpi_ac_remove(struct acpi_device *device);
37-
static void acpi_ac_notify(struct acpi_device *device, u32 event);
37+
static void acpi_ac_notify(acpi_handle handle, u32 event, void *data);
3838

3939
static const struct acpi_device_id ac_device_ids[] = {
4040
{"ACPI0003", 0},
@@ -54,11 +54,9 @@ static struct acpi_driver acpi_ac_driver = {
5454
.name = "ac",
5555
.class = ACPI_AC_CLASS,
5656
.ids = ac_device_ids,
57-
.flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
5857
.ops = {
5958
.add = acpi_ac_add,
6059
.remove = acpi_ac_remove,
61-
.notify = acpi_ac_notify,
6260
},
6361
.drv.pm = &acpi_ac_pm,
6462
};
@@ -128,8 +126,9 @@ static enum power_supply_property ac_props[] = {
128126
};
129127

130128
/* Driver Model */
131-
static void acpi_ac_notify(struct acpi_device *device, u32 event)
129+
static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
132130
{
131+
struct acpi_device *device = data;
133132
struct acpi_ac *ac = acpi_driver_data(device);
134133

135134
if (!ac)
@@ -235,7 +234,7 @@ static int acpi_ac_add(struct acpi_device *device)
235234

236235
result = acpi_ac_get_state(ac);
237236
if (result)
238-
goto end;
237+
goto err_release_ac;
239238

240239
psy_cfg.drv_data = ac;
241240

@@ -248,17 +247,27 @@ static int acpi_ac_add(struct acpi_device *device)
248247
&ac->charger_desc, &psy_cfg);
249248
if (IS_ERR(ac->charger)) {
250249
result = PTR_ERR(ac->charger);
251-
goto end;
250+
goto err_release_ac;
252251
}
253252

254253
pr_info("%s [%s] (%s)\n", acpi_device_name(device),
255254
acpi_device_bid(device), ac->state ? "on-line" : "off-line");
256255

257256
ac->battery_nb.notifier_call = acpi_ac_battery_notify;
258257
register_acpi_notifier(&ac->battery_nb);
259-
end:
258+
259+
result = acpi_dev_install_notify_handler(device, ACPI_ALL_NOTIFY,
260+
acpi_ac_notify);
260261
if (result)
261-
kfree(ac);
262+
goto err_unregister;
263+
264+
return 0;
265+
266+
err_unregister:
267+
power_supply_unregister(ac->charger);
268+
unregister_acpi_notifier(&ac->battery_nb);
269+
err_release_ac:
270+
kfree(ac);
262271

263272
return result;
264273
}
@@ -297,6 +306,8 @@ static void acpi_ac_remove(struct acpi_device *device)
297306

298307
ac = acpi_driver_data(device);
299308

309+
acpi_dev_remove_notify_handler(device, ACPI_ALL_NOTIFY,
310+
acpi_ac_notify);
300311
power_supply_unregister(ac->charger);
301312
unregister_acpi_notifier(&ac->battery_nb);
302313

drivers/acpi/acpi_video.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static DEFINE_MUTEX(video_list_lock);
7777
static LIST_HEAD(video_bus_head);
7878
static int acpi_video_bus_add(struct acpi_device *device);
7979
static void acpi_video_bus_remove(struct acpi_device *device);
80-
static void acpi_video_bus_notify(struct acpi_device *device, u32 event);
80+
static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data);
8181

8282
/*
8383
* Indices in the _BCL method response: the first two items are special,
@@ -104,7 +104,6 @@ static struct acpi_driver acpi_video_bus = {
104104
.ops = {
105105
.add = acpi_video_bus_add,
106106
.remove = acpi_video_bus_remove,
107-
.notify = acpi_video_bus_notify,
108107
},
109108
};
110109

@@ -1527,8 +1526,9 @@ static int acpi_video_bus_stop_devices(struct acpi_video_bus *video)
15271526
acpi_osi_is_win8() ? 0 : 1);
15281527
}
15291528

1530-
static void acpi_video_bus_notify(struct acpi_device *device, u32 event)
1529+
static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
15311530
{
1531+
struct acpi_device *device = data;
15321532
struct acpi_video_bus *video = acpi_driver_data(device);
15331533
struct input_dev *input;
15341534
int keycode = 0;
@@ -2027,6 +2027,12 @@ static int acpi_video_bus_add(struct acpi_device *device)
20272027
if (error)
20282028
goto err_put_video;
20292029

2030+
/*
2031+
* HP ZBook Fury 16 G10 requires ACPI video's child devices have _PS0
2032+
* evaluated to have functional panel brightness control.
2033+
*/
2034+
acpi_device_fix_up_power_extended(device);
2035+
20302036
pr_info("%s [%s] (multi-head: %s rom: %s post: %s)\n",
20312037
ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device),
20322038
video->flags.multihead ? "yes" : "no",
@@ -2053,8 +2059,19 @@ static int acpi_video_bus_add(struct acpi_device *device)
20532059

20542060
acpi_video_bus_add_notify_handler(video);
20552061

2062+
error = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY,
2063+
acpi_video_bus_notify);
2064+
if (error)
2065+
goto err_remove;
2066+
20562067
return 0;
20572068

2069+
err_remove:
2070+
mutex_lock(&video_list_lock);
2071+
list_del(&video->entry);
2072+
mutex_unlock(&video_list_lock);
2073+
acpi_video_bus_remove_notify_handler(video);
2074+
acpi_video_bus_unregister_backlight(video);
20582075
err_put_video:
20592076
acpi_video_bus_put_devices(video);
20602077
kfree(video->attached_array);
@@ -2075,6 +2092,9 @@ static void acpi_video_bus_remove(struct acpi_device *device)
20752092

20762093
video = acpi_driver_data(device);
20772094

2095+
acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY,
2096+
acpi_video_bus_notify);
2097+
20782098
mutex_lock(&video_list_lock);
20792099
list_del(&video->entry);
20802100
mutex_unlock(&video_list_lock);

drivers/acpi/battery.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,8 +1034,9 @@ static void acpi_battery_refresh(struct acpi_battery *battery)
10341034
}
10351035

10361036
/* Driver Interface */
1037-
static void acpi_battery_notify(struct acpi_device *device, u32 event)
1037+
static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
10381038
{
1039+
struct acpi_device *device = data;
10391040
struct acpi_battery *battery = acpi_driver_data(device);
10401041
struct power_supply *old;
10411042

@@ -1212,13 +1213,22 @@ static int acpi_battery_add(struct acpi_device *device)
12121213

12131214
device_init_wakeup(&device->dev, 1);
12141215

1215-
return result;
1216+
result = acpi_dev_install_notify_handler(device, ACPI_ALL_NOTIFY,
1217+
acpi_battery_notify);
1218+
if (result)
1219+
goto fail_pm;
1220+
1221+
return 0;
12161222

1223+
fail_pm:
1224+
device_init_wakeup(&device->dev, 0);
1225+
unregister_pm_notifier(&battery->pm_nb);
12171226
fail:
12181227
sysfs_remove_battery(battery);
12191228
mutex_destroy(&battery->lock);
12201229
mutex_destroy(&battery->sysfs_lock);
12211230
kfree(battery);
1231+
12221232
return result;
12231233
}
12241234

@@ -1228,10 +1238,16 @@ static void acpi_battery_remove(struct acpi_device *device)
12281238

12291239
if (!device || !acpi_driver_data(device))
12301240
return;
1231-
device_init_wakeup(&device->dev, 0);
1241+
12321242
battery = acpi_driver_data(device);
1243+
1244+
acpi_dev_remove_notify_handler(device, ACPI_ALL_NOTIFY,
1245+
acpi_battery_notify);
1246+
1247+
device_init_wakeup(&device->dev, 0);
12331248
unregister_pm_notifier(&battery->pm_nb);
12341249
sysfs_remove_battery(battery);
1250+
12351251
mutex_destroy(&battery->lock);
12361252
mutex_destroy(&battery->sysfs_lock);
12371253
kfree(battery);
@@ -1264,11 +1280,9 @@ static struct acpi_driver acpi_battery_driver = {
12641280
.name = "battery",
12651281
.class = ACPI_BATTERY_CLASS,
12661282
.ids = battery_device_ids,
1267-
.flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
12681283
.ops = {
12691284
.add = acpi_battery_add,
12701285
.remove = acpi_battery_remove,
1271-
.notify = acpi_battery_notify,
12721286
},
12731287
.drv.pm = &acpi_battery_pm,
12741288
};

drivers/acpi/bus.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,30 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device,
554554
acpi_os_wait_events_complete();
555555
}
556556

557+
int acpi_dev_install_notify_handler(struct acpi_device *adev,
558+
u32 handler_type,
559+
acpi_notify_handler handler)
560+
{
561+
acpi_status status;
562+
563+
status = acpi_install_notify_handler(adev->handle, handler_type,
564+
handler, adev);
565+
if (ACPI_FAILURE(status))
566+
return -ENODEV;
567+
568+
return 0;
569+
}
570+
EXPORT_SYMBOL_GPL(acpi_dev_install_notify_handler);
571+
572+
void acpi_dev_remove_notify_handler(struct acpi_device *adev,
573+
u32 handler_type,
574+
acpi_notify_handler handler)
575+
{
576+
acpi_remove_notify_handler(adev->handle, handler_type, handler);
577+
acpi_os_wait_events_complete();
578+
}
579+
EXPORT_SYMBOL_GPL(acpi_dev_remove_notify_handler);
580+
557581
/* Handle events targeting \_SB device (at present only graceful shutdown) */
558582

559583
#define ACPI_SB_NOTIFY_SHUTDOWN_REQUEST 0x81
@@ -1005,8 +1029,10 @@ static int acpi_device_probe(struct device *dev)
10051029
return -ENOSYS;
10061030

10071031
ret = acpi_drv->ops.add(acpi_dev);
1008-
if (ret)
1032+
if (ret) {
1033+
acpi_dev->driver_data = NULL;
10091034
return ret;
1035+
}
10101036

10111037
pr_debug("Driver [%s] successfully bound to device [%s]\n",
10121038
acpi_drv->name, acpi_dev->pnp.bus_id);

drivers/acpi/hed.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,32 @@ EXPORT_SYMBOL_GPL(unregister_acpi_hed_notifier);
4242
* it is used by HEST Generic Hardware Error Source with notify type
4343
* SCI.
4444
*/
45-
static void acpi_hed_notify(struct acpi_device *device, u32 event)
45+
static void acpi_hed_notify(acpi_handle handle, u32 event, void *data)
4646
{
4747
blocking_notifier_call_chain(&acpi_hed_notify_list, 0, NULL);
4848
}
4949

5050
static int acpi_hed_add(struct acpi_device *device)
5151
{
52+
int err;
53+
5254
/* Only one hardware error device */
5355
if (hed_handle)
5456
return -EINVAL;
5557
hed_handle = device->handle;
56-
return 0;
58+
59+
err = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY,
60+
acpi_hed_notify);
61+
if (err)
62+
hed_handle = NULL;
63+
64+
return err;
5765
}
5866

5967
static void acpi_hed_remove(struct acpi_device *device)
6068
{
69+
acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY,
70+
acpi_hed_notify);
6171
hed_handle = NULL;
6272
}
6373

@@ -68,7 +78,6 @@ static struct acpi_driver acpi_hed_driver = {
6878
.ops = {
6979
.add = acpi_hed_add,
7080
.remove = acpi_hed_remove,
71-
.notify = acpi_hed_notify,
7281
},
7382
};
7483
module_acpi_driver(acpi_hed_driver);

drivers/acpi/nfit/core.c

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3282,6 +3282,23 @@ static void acpi_nfit_put_table(void *table)
32823282
acpi_put_table(table);
32833283
}
32843284

3285+
static void acpi_nfit_notify(acpi_handle handle, u32 event, void *data)
3286+
{
3287+
struct acpi_device *adev = data;
3288+
3289+
device_lock(&adev->dev);
3290+
__acpi_nfit_notify(&adev->dev, handle, event);
3291+
device_unlock(&adev->dev);
3292+
}
3293+
3294+
static void acpi_nfit_remove_notify_handler(void *data)
3295+
{
3296+
struct acpi_device *adev = data;
3297+
3298+
acpi_dev_remove_notify_handler(adev, ACPI_DEVICE_NOTIFY,
3299+
acpi_nfit_notify);
3300+
}
3301+
32853302
void acpi_nfit_shutdown(void *data)
32863303
{
32873304
struct acpi_nfit_desc *acpi_desc = data;
@@ -3368,12 +3385,18 @@ static int acpi_nfit_add(struct acpi_device *adev)
33683385

33693386
if (rc)
33703387
return rc;
3371-
return devm_add_action_or_reset(dev, acpi_nfit_shutdown, acpi_desc);
3372-
}
33733388

3374-
static void acpi_nfit_remove(struct acpi_device *adev)
3375-
{
3376-
/* see acpi_nfit_unregister */
3389+
rc = devm_add_action_or_reset(dev, acpi_nfit_shutdown, acpi_desc);
3390+
if (rc)
3391+
return rc;
3392+
3393+
rc = acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY,
3394+
acpi_nfit_notify);
3395+
if (rc)
3396+
return rc;
3397+
3398+
return devm_add_action_or_reset(dev, acpi_nfit_remove_notify_handler,
3399+
adev);
33773400
}
33783401

33793402
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)
34463469
}
34473470
EXPORT_SYMBOL_GPL(__acpi_nfit_notify);
34483471

3449-
static void acpi_nfit_notify(struct acpi_device *adev, u32 event)
3450-
{
3451-
device_lock(&adev->dev);
3452-
__acpi_nfit_notify(&adev->dev, adev->handle, event);
3453-
device_unlock(&adev->dev);
3454-
}
3455-
34563472
static const struct acpi_device_id acpi_nfit_ids[] = {
34573473
{ "ACPI0012", 0 },
34583474
{ "", 0 },
@@ -3464,8 +3480,6 @@ static struct acpi_driver acpi_nfit_driver = {
34643480
.ids = acpi_nfit_ids,
34653481
.ops = {
34663482
.add = acpi_nfit_add,
3467-
.remove = acpi_nfit_remove,
3468-
.notify = acpi_nfit_notify,
34693483
},
34703484
};
34713485

0 commit comments

Comments
 (0)