Skip to content

Commit a56a658

Browse files
committed
Merge back updates of core ACPI drivers for 7.1
2 parents e7648ff + 236ad35 commit a56a658

24 files changed

Lines changed: 106 additions & 180 deletions

drivers/acpi/ac.c

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
#include <linux/acpi.h>
2222
#include <acpi/battery.h>
2323

24-
#define ACPI_AC_CLASS "ac_adapter"
25-
#define ACPI_AC_DEVICE_NAME "AC Adapter"
2624
#define ACPI_AC_FILE_STATE "state"
2725
#define ACPI_AC_NOTIFY_STATUS 0x80
2826
#define ACPI_AC_STATUS_OFFLINE 0x00
@@ -33,22 +31,12 @@ MODULE_AUTHOR("Paul Diefenbaugh");
3331
MODULE_DESCRIPTION("ACPI AC Adapter Driver");
3432
MODULE_LICENSE("GPL");
3533

36-
static int acpi_ac_probe(struct platform_device *pdev);
37-
static void acpi_ac_remove(struct platform_device *pdev);
38-
39-
static void acpi_ac_notify(acpi_handle handle, u32 event, void *data);
40-
4134
static const struct acpi_device_id ac_device_ids[] = {
4235
{"ACPI0003", 0},
4336
{"", 0},
4437
};
4538
MODULE_DEVICE_TABLE(acpi, ac_device_ids);
4639

47-
#ifdef CONFIG_PM_SLEEP
48-
static int acpi_ac_resume(struct device *dev);
49-
#endif
50-
static SIMPLE_DEV_PM_OPS(acpi_ac_pm, NULL, acpi_ac_resume);
51-
5240
static int ac_sleep_before_get_state_ms;
5341
static int ac_only;
5442

@@ -141,10 +129,11 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
141129
msleep(ac_sleep_before_get_state_ms);
142130

143131
acpi_ac_get_state(ac);
144-
acpi_bus_generate_netlink_event(adev->pnp.device_class,
145-
dev_name(&adev->dev), event,
146-
(u32) ac->state);
147-
acpi_notifier_call_chain(adev, event, (u32) ac->state);
132+
acpi_bus_generate_netlink_event(ACPI_AC_CLASS,
133+
dev_name(&adev->dev), event,
134+
ac->state);
135+
acpi_notifier_call_chain(ACPI_AC_CLASS, acpi_device_bid(adev),
136+
event, ac->state);
148137
power_supply_changed(ac->charger);
149138
}
150139
}
@@ -213,8 +202,6 @@ static int acpi_ac_probe(struct platform_device *pdev)
213202
return -ENOMEM;
214203

215204
ac->device = adev;
216-
strscpy(acpi_device_name(adev), ACPI_AC_DEVICE_NAME);
217-
strscpy(acpi_device_class(adev), ACPI_AC_CLASS);
218205

219206
platform_set_drvdata(pdev, ac);
220207

@@ -236,8 +223,8 @@ static int acpi_ac_probe(struct platform_device *pdev)
236223
goto err_release_ac;
237224
}
238225

239-
pr_info("%s [%s] (%s-line)\n", acpi_device_name(adev),
240-
acpi_device_bid(adev), str_on_off(ac->state));
226+
pr_info("AC Adapter [%s] (%s-line)\n", acpi_device_bid(adev),
227+
str_on_off(ac->state));
241228

242229
ac->battery_nb.notifier_call = acpi_ac_battery_notify;
243230
register_acpi_notifier(&ac->battery_nb);
@@ -272,10 +259,10 @@ static int acpi_ac_resume(struct device *dev)
272259

273260
return 0;
274261
}
275-
#else
276-
#define acpi_ac_resume NULL
277262
#endif
278263

264+
static SIMPLE_DEV_PM_OPS(acpi_ac_pm, NULL, acpi_ac_resume);
265+
279266
static void acpi_ac_remove(struct platform_device *pdev)
280267
{
281268
struct acpi_ac *ac = platform_get_drvdata(pdev);

drivers/acpi/acpi_memhotplug.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818

1919
#include "internal.h"
2020

21-
#define ACPI_MEMORY_DEVICE_CLASS "memory"
2221
#define ACPI_MEMORY_DEVICE_HID "PNP0C80"
23-
#define ACPI_MEMORY_DEVICE_NAME "Hotplug Mem Device"
2422

2523
static const struct acpi_device_id memory_device_ids[] = {
2624
{ACPI_MEMORY_DEVICE_HID, 0},
@@ -297,8 +295,6 @@ static int acpi_memory_device_add(struct acpi_device *device,
297295
INIT_LIST_HEAD(&mem_device->res_list);
298296
mem_device->device = device;
299297
mem_device->mgid = -1;
300-
sprintf(acpi_device_name(device), "%s", ACPI_MEMORY_DEVICE_NAME);
301-
sprintf(acpi_device_class(device), "%s", ACPI_MEMORY_DEVICE_CLASS);
302298
device->driver_data = mem_device;
303299

304300
/* Get the range from the _CRS */

drivers/acpi/acpi_pad.c

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
#include <asm/mwait.h>
2424
#include <xen/xen.h>
2525

26-
#define ACPI_PROCESSOR_AGGREGATOR_CLASS "acpi_pad"
27-
#define ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME "Processor Aggregator"
2826
#define ACPI_PROCESSOR_AGGREGATOR_NOTIFY 0x80
2927

3028
#define ACPI_PROCESSOR_AGGREGATOR_STATUS_SUCCESS 0
@@ -407,16 +405,15 @@ static void acpi_pad_handle_notify(acpi_handle handle)
407405
mutex_unlock(&isolated_cpus_lock);
408406
}
409407

410-
static void acpi_pad_notify(acpi_handle handle, u32 event,
411-
void *data)
408+
static void acpi_pad_notify(acpi_handle handle, u32 event, void *data)
412409
{
413410
struct acpi_device *adev = data;
414411

415412
switch (event) {
416413
case ACPI_PROCESSOR_AGGREGATOR_NOTIFY:
417414
acpi_pad_handle_notify(handle);
418-
acpi_bus_generate_netlink_event(adev->pnp.device_class,
419-
dev_name(&adev->dev), event, 0);
415+
acpi_bus_generate_netlink_event("acpi_pad",
416+
dev_name(&adev->dev), event, 0);
420417
break;
421418
default:
422419
pr_warn("Unsupported event [0x%x]\n", event);
@@ -427,30 +424,19 @@ static void acpi_pad_notify(acpi_handle handle, u32 event,
427424
static int acpi_pad_probe(struct platform_device *pdev)
428425
{
429426
struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
430-
acpi_status status;
431427

432-
strscpy(acpi_device_name(adev), ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME);
433-
strscpy(acpi_device_class(adev), ACPI_PROCESSOR_AGGREGATOR_CLASS);
434-
435-
status = acpi_install_notify_handler(adev->handle,
436-
ACPI_DEVICE_NOTIFY, acpi_pad_notify, adev);
437-
438-
if (ACPI_FAILURE(status))
439-
return -ENODEV;
440-
441-
return 0;
428+
return acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY,
429+
acpi_pad_notify, adev);
442430
}
443431

444432
static void acpi_pad_remove(struct platform_device *pdev)
445433
{
446-
struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
447-
448434
mutex_lock(&isolated_cpus_lock);
449435
acpi_pad_idle_cpus(0);
450436
mutex_unlock(&isolated_cpus_lock);
451437

452-
acpi_remove_notify_handler(adev->handle,
453-
ACPI_DEVICE_NOTIFY, acpi_pad_notify);
438+
acpi_dev_remove_notify_handler(ACPI_COMPANION(&pdev->dev),
439+
ACPI_DEVICE_NOTIFY, acpi_pad_notify);
454440
}
455441

456442
static const struct acpi_device_id pad_device_ids[] = {

drivers/acpi/acpi_processor.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,6 @@ static int acpi_processor_add(struct acpi_device *device,
438438
}
439439

440440
pr->handle = device->handle;
441-
strscpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME);
442-
strscpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS);
443441
device->driver_data = pr;
444442

445443
result = acpi_processor_get_info(device);

drivers/acpi/acpi_video.c

Lines changed: 46 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
#include <linux/uaccess.h>
3131
#include <linux/string_choices.h>
3232

33-
#define ACPI_VIDEO_BUS_NAME "Video Bus"
34-
#define ACPI_VIDEO_DEVICE_NAME "Video Device"
35-
3633
#define MAX_NAME_LEN 20
3734

3835
MODULE_AUTHOR("Bruno Ducrot");
@@ -1144,9 +1141,6 @@ static int acpi_video_bus_get_one_device(struct acpi_device *device, void *arg)
11441141
return -ENOMEM;
11451142
}
11461143

1147-
strscpy(acpi_device_name(device), ACPI_VIDEO_DEVICE_NAME);
1148-
strscpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
1149-
11501144
data->device_id = device_id;
11511145
data->video = video;
11521146
data->dev = device;
@@ -1570,7 +1564,8 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
15701564
break;
15711565
}
15721566

1573-
if (acpi_notifier_call_chain(device, event, 0))
1567+
if (acpi_notifier_call_chain(ACPI_VIDEO_CLASS, acpi_device_bid(device),
1568+
event, 0))
15741569
/* Something vetoed the keypress. */
15751570
keycode = 0;
15761571

@@ -1611,7 +1606,8 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
16111606
if (video_device->backlight)
16121607
backlight_force_update(video_device->backlight,
16131608
BACKLIGHT_UPDATE_HOTKEY);
1614-
acpi_notifier_call_chain(device, event, 0);
1609+
acpi_notifier_call_chain(ACPI_VIDEO_CLASS, acpi_device_bid(device),
1610+
event, 0);
16151611
return;
16161612
}
16171613

@@ -1644,7 +1640,8 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
16441640
if (keycode)
16451641
may_report_brightness_keys = true;
16461642

1647-
acpi_notifier_call_chain(device, event, 0);
1643+
acpi_notifier_call_chain(ACPI_VIDEO_CLASS, acpi_device_bid(device),
1644+
event, 0);
16481645

16491646
if (keycode && (report_key_events & REPORT_BRIGHTNESS_KEY_EVENTS)) {
16501647
input_report_key(input, keycode, 1);
@@ -1681,26 +1678,6 @@ static int acpi_video_resume(struct notifier_block *nb,
16811678
return NOTIFY_DONE;
16821679
}
16831680

1684-
static acpi_status
1685-
acpi_video_bus_match(acpi_handle handle, u32 level, void *context,
1686-
void **return_value)
1687-
{
1688-
struct acpi_device *device = context;
1689-
struct acpi_device *sibling;
1690-
1691-
if (handle == device->handle)
1692-
return AE_CTRL_TERMINATE;
1693-
1694-
sibling = acpi_fetch_acpi_dev(handle);
1695-
if (!sibling)
1696-
return AE_OK;
1697-
1698-
if (!strcmp(acpi_device_name(sibling), ACPI_VIDEO_BUS_NAME))
1699-
return AE_ALREADY_EXISTS;
1700-
1701-
return AE_OK;
1702-
}
1703-
17041681
static void acpi_video_dev_register_backlight(struct acpi_video_device *device)
17051682
{
17061683
struct backlight_properties props;
@@ -1902,7 +1879,7 @@ static int acpi_video_bus_add_notify_handler(struct acpi_video_bus *video,
19021879
snprintf(video->phys, sizeof(video->phys),
19031880
"%s/video/input0", acpi_device_hid(video->device));
19041881

1905-
input->name = acpi_device_name(video->device);
1882+
input->name = "Video Bus";
19061883
input->phys = video->phys;
19071884
input->id.bustype = BUS_HOST;
19081885
input->id.product = 0x06;
@@ -1976,53 +1953,69 @@ static int acpi_video_bus_put_devices(struct acpi_video_bus *video)
19761953
return 0;
19771954
}
19781955

1979-
static int instance;
1956+
static int duplicate_dev_check(struct device *sibling, void *data)
1957+
{
1958+
struct acpi_video_bus *video;
1959+
1960+
if (sibling == data || !dev_is_auxiliary(sibling))
1961+
return 0;
1962+
1963+
guard(mutex)(&video_list_lock);
1964+
1965+
list_for_each_entry(video, &video_bus_head, entry) {
1966+
if (video == dev_get_drvdata(sibling))
1967+
return -EEXIST;
1968+
}
1969+
1970+
return 0;
1971+
}
1972+
1973+
static bool acpi_video_bus_dev_is_duplicate(struct device *dev)
1974+
{
1975+
return device_for_each_child(dev->parent, dev, duplicate_dev_check);
1976+
}
19801977

19811978
static int acpi_video_bus_probe(struct auxiliary_device *aux_dev,
19821979
const struct auxiliary_device_id *id_unused)
19831980
{
19841981
struct acpi_device *device = ACPI_COMPANION(&aux_dev->dev);
1982+
static DEFINE_MUTEX(probe_lock);
19851983
struct acpi_video_bus *video;
1984+
static int instance;
19861985
bool auto_detect;
19871986
int error;
1988-
acpi_status status;
19891987

1990-
status = acpi_walk_namespace(ACPI_TYPE_DEVICE,
1991-
acpi_dev_parent(device)->handle, 1,
1992-
acpi_video_bus_match, NULL,
1993-
device, NULL);
1994-
if (status == AE_ALREADY_EXISTS) {
1988+
/* Probe one video bus device at a time in case there are duplicates. */
1989+
guard(mutex)(&probe_lock);
1990+
1991+
if (!allow_duplicates && acpi_video_bus_dev_is_duplicate(&aux_dev->dev)) {
19951992
pr_info(FW_BUG
19961993
"Duplicate ACPI video bus devices for the"
19971994
" same VGA controller, please try module "
19981995
"parameter \"video.allow_duplicates=1\""
19991996
"if the current driver doesn't work.\n");
2000-
if (!allow_duplicates)
2001-
return -ENODEV;
1997+
return -ENODEV;
20021998
}
20031999

20042000
video = kzalloc_obj(struct acpi_video_bus);
20052001
if (!video)
20062002
return -ENOMEM;
20072003

2008-
/* a hack to fix the duplicate name "VID" problem on T61 */
2009-
if (!strcmp(device->pnp.bus_id, "VID")) {
2010-
if (instance)
2011-
device->pnp.bus_id[3] = '0' + instance;
2012-
instance++;
2013-
}
2014-
/* a hack to fix the duplicate name "VGA" problem on Pa 3553 */
2015-
if (!strcmp(device->pnp.bus_id, "VGA")) {
2004+
/*
2005+
* A hack to fix the duplicate name "VID" problem on T61 and the
2006+
* duplicate name "VGA" problem on Pa 3553.
2007+
*/
2008+
if (!strcmp(device->pnp.bus_id, "VID") ||
2009+
!strcmp(device->pnp.bus_id, "VGA")) {
20162010
if (instance)
20172011
device->pnp.bus_id[3] = '0' + instance;
2012+
20182013
instance++;
20192014
}
20202015

20212016
auxiliary_set_drvdata(aux_dev, video);
20222017

20232018
video->device = device;
2024-
strscpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME);
2025-
strscpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
20262019
device->driver_data = video;
20272020

20282021
acpi_video_bus_find_cap(video);
@@ -2043,11 +2036,10 @@ static int acpi_video_bus_probe(struct auxiliary_device *aux_dev,
20432036
*/
20442037
acpi_device_fix_up_power_children(device);
20452038

2046-
pr_info("%s [%s] (multi-head: %s rom: %s post: %s)\n",
2047-
ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device),
2048-
str_yes_no(video->flags.multihead),
2049-
str_yes_no(video->flags.rom),
2050-
str_yes_no(video->flags.post));
2039+
pr_info("Video Device [%s] (multi-head: %s rom: %s post: %s)\n",
2040+
acpi_device_bid(device), str_yes_no(video->flags.multihead),
2041+
str_yes_no(video->flags.rom), str_yes_no(video->flags.post));
2042+
20512043
mutex_lock(&video_list_lock);
20522044
list_add_tail(&video->entry, &video_bus_head);
20532045
mutex_unlock(&video_list_lock);

drivers/acpi/battery.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
#define ACPI_BATTERY_CAPACITY_VALID(capacity) \
3434
((capacity) != 0 && (capacity) != ACPI_BATTERY_VALUE_UNKNOWN)
3535

36-
#define ACPI_BATTERY_DEVICE_NAME "Battery"
37-
3836
/* Battery power unit: 0 means mW, 1 means mA */
3937
#define ACPI_BATTERY_POWER_UNIT_MA 1
4038

@@ -1080,10 +1078,11 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
10801078
if (event == ACPI_BATTERY_NOTIFY_INFO)
10811079
acpi_battery_refresh(battery);
10821080
acpi_battery_update(battery, false);
1083-
acpi_bus_generate_netlink_event(device->pnp.device_class,
1081+
acpi_bus_generate_netlink_event(ACPI_BATTERY_CLASS,
10841082
dev_name(&device->dev), event,
10851083
acpi_battery_present(battery));
1086-
acpi_notifier_call_chain(device, event, acpi_battery_present(battery));
1084+
acpi_notifier_call_chain(ACPI_BATTERY_CLASS, acpi_device_bid(device),
1085+
event, acpi_battery_present(battery));
10871086
/* acpi_battery_update could remove power_supply object */
10881087
if (old && battery->bat)
10891088
power_supply_changed(battery->bat);
@@ -1229,8 +1228,6 @@ static int acpi_battery_probe(struct platform_device *pdev)
12291228
platform_set_drvdata(pdev, battery);
12301229

12311230
battery->device = device;
1232-
strscpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
1233-
strscpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
12341231

12351232
result = devm_mutex_init(&pdev->dev, &battery->update_lock);
12361233
if (result)

0 commit comments

Comments
 (0)