Skip to content

Commit f94a57a

Browse files
committed
Merge branches 'acpi-button', 'acpi-battery', 'acpi-osl', 'acpi-video' and 'acpi-misc'
* acpi-button: ACPI: Add new tiny-power-button driver to directly signal init ACPI: button: move HIDs to acpi/button.h * acpi-battery: ACPI / battery: Cleanup Lenovo Ideapad Miix 320 DMI table entry ACPI / AC: Cleanup DMI quirk table * acpi-osl: ACPI: OSL: Add missing __acquires/__releases annotations * acpi-video: ACPI: video: remove redundant assignments to variable result * acpi-misc: ACPI: list_for_each_safe() -> list_for_each_entry_safe()
6 parents 6d582d7 + a1b93e8 + 8c3f699 + 2288eba + 966f58d + 07761a4 commit f94a57a

File tree

11 files changed

+111
-44
lines changed

11 files changed

+111
-44
lines changed

drivers/acpi/Kconfig

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,30 @@ config ACPI_BUTTON
190190
To compile this driver as a module, choose M here:
191191
the module will be called button.
192192

193+
config ACPI_TINY_POWER_BUTTON
194+
tristate "Tiny Power Button Driver"
195+
depends on !ACPI_BUTTON
196+
help
197+
This driver provides a tiny alternative to the ACPI Button driver.
198+
The tiny power button driver only handles the power button. Rather
199+
than notifying userspace via the input layer or a netlink event, this
200+
driver directly signals the init process to shut down.
201+
202+
This driver is particularly suitable for cloud and VM environments,
203+
which use a simulated power button to initiate a controlled poweroff,
204+
but which may not want to run a separate userspace daemon to process
205+
input events.
206+
207+
config ACPI_TINY_POWER_BUTTON_SIGNAL
208+
int "Tiny Power Button Signal"
209+
depends on ACPI_TINY_POWER_BUTTON
210+
default 38
211+
help
212+
Default signal to send to init in response to the power button.
213+
214+
Likely values here include 38 (SIGRTMIN+4) to power off, or 2
215+
(SIGINT) to simulate Ctrl+Alt+Del.
216+
193217
config ACPI_VIDEO
194218
tristate "Video"
195219
depends on X86 && BACKLIGHT_CLASS_DEVICE

drivers/acpi/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ obj-$(CONFIG_ACPI_IPMI) += acpi_ipmi.o
7171

7272
obj-$(CONFIG_ACPI_AC) += ac.o
7373
obj-$(CONFIG_ACPI_BUTTON) += button.o
74+
obj-$(CONFIG_ACPI_TINY_POWER_BUTTON) += tiny-power-button.o
7475
obj-$(CONFIG_ACPI_FAN) += fan.o
7576
obj-$(CONFIG_ACPI_VIDEO) += video.o
7677
obj-$(CONFIG_ACPI_TAD) += acpi_tad.o

drivers/acpi/ac.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -293,29 +293,30 @@ static int __init ac_do_not_check_pmic_quirk(const struct dmi_system_id *d)
293293
return 0;
294294
}
295295

296+
/* Please keep this list alphabetically sorted */
296297
static const struct dmi_system_id ac_dmi_table[] __initconst = {
297298
{
298-
/* Thinkpad e530 */
299-
.callback = thinkpad_e530_quirk,
300-
.matches = {
301-
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
302-
DMI_MATCH(DMI_PRODUCT_NAME, "32597CG"),
299+
/* ECS EF20EA, AXP288 PMIC but uses separate fuel-gauge */
300+
.callback = ac_do_not_check_pmic_quirk,
301+
.matches = {
302+
DMI_MATCH(DMI_PRODUCT_NAME, "EF20EA"),
303303
},
304304
},
305305
{
306-
/* ECS EF20EA */
306+
/* Lenovo Ideapad Miix 320, AXP288 PMIC, separate fuel-gauge */
307307
.callback = ac_do_not_check_pmic_quirk,
308308
.matches = {
309-
DMI_MATCH(DMI_PRODUCT_NAME, "EF20EA"),
309+
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
310+
DMI_MATCH(DMI_PRODUCT_NAME, "80XF"),
311+
DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo MIIX 320-10ICR"),
310312
},
311313
},
312314
{
313-
/* Lenovo Ideapad Miix 320 */
314-
.callback = ac_do_not_check_pmic_quirk,
315+
/* Lenovo Thinkpad e530, see comment in acpi_ac_notify() */
316+
.callback = thinkpad_e530_quirk,
315317
.matches = {
316-
DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LENOVO"),
317-
DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "80XF"),
318-
DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "Lenovo MIIX 320-10ICR"),
318+
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
319+
DMI_MATCH(DMI_PRODUCT_NAME, "32597CG"),
319320
},
320321
},
321322
{},

drivers/acpi/acpi_video.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ acpi_video_init_brightness(struct acpi_video_device *device)
943943
int i, max_level = 0;
944944
unsigned long long level, level_old;
945945
struct acpi_video_device_brightness *br = NULL;
946-
int result = -EINVAL;
946+
int result;
947947

948948
result = acpi_video_get_levels(device->dev, &br, &max_level);
949949
if (result)

drivers/acpi/battery.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,19 +1365,19 @@ static const struct dmi_system_id bat_dmi_table[] __initconst = {
13651365
},
13661366
},
13671367
{
1368-
/* ECS EF20EA */
1368+
/* ECS EF20EA, AXP288 PMIC but uses separate fuel-gauge */
13691369
.callback = battery_do_not_check_pmic_quirk,
13701370
.matches = {
13711371
DMI_MATCH(DMI_PRODUCT_NAME, "EF20EA"),
13721372
},
13731373
},
13741374
{
1375-
/* Lenovo Ideapad Miix 320 */
1375+
/* Lenovo Ideapad Miix 320, AXP288 PMIC, separate fuel-gauge */
13761376
.callback = battery_do_not_check_pmic_quirk,
13771377
.matches = {
1378-
DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LENOVO"),
1379-
DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "80XF"),
1380-
DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "Lenovo MIIX 320-10ICR"),
1378+
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
1379+
DMI_MATCH(DMI_PRODUCT_NAME, "80XF"),
1380+
DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo MIIX 320-10ICR"),
13811381
},
13821382
},
13831383
{},

drivers/acpi/button.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,14 @@
3030
#define ACPI_BUTTON_NOTIFY_STATUS 0x80
3131

3232
#define ACPI_BUTTON_SUBCLASS_POWER "power"
33-
#define ACPI_BUTTON_HID_POWER "PNP0C0C"
3433
#define ACPI_BUTTON_DEVICE_NAME_POWER "Power Button"
3534
#define ACPI_BUTTON_TYPE_POWER 0x01
3635

3736
#define ACPI_BUTTON_SUBCLASS_SLEEP "sleep"
38-
#define ACPI_BUTTON_HID_SLEEP "PNP0C0E"
3937
#define ACPI_BUTTON_DEVICE_NAME_SLEEP "Sleep Button"
4038
#define ACPI_BUTTON_TYPE_SLEEP 0x03
4139

4240
#define ACPI_BUTTON_SUBCLASS_LID "lid"
43-
#define ACPI_BUTTON_HID_LID "PNP0C0D"
4441
#define ACPI_BUTTON_DEVICE_NAME_LID "Lid Switch"
4542
#define ACPI_BUTTON_TYPE_LID 0x05
4643

drivers/acpi/osl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,6 +1598,7 @@ void acpi_os_delete_lock(acpi_spinlock handle)
15981598
*/
15991599

16001600
acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock lockp)
1601+
__acquires(lockp)
16011602
{
16021603
acpi_cpu_flags flags;
16031604
spin_lock_irqsave(lockp, flags);
@@ -1609,6 +1610,7 @@ acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock lockp)
16091610
*/
16101611

16111612
void acpi_os_release_lock(acpi_spinlock lockp, acpi_cpu_flags flags)
1613+
__releases(lockp)
16121614
{
16131615
spin_unlock_irqrestore(lockp, flags);
16141616
}

drivers/acpi/proc.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@ ACPI_MODULE_NAME("sleep")
2222
static int
2323
acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
2424
{
25-
struct list_head *node, *next;
25+
struct acpi_device *dev, *tmp;
2626

2727
seq_printf(seq, "Device\tS-state\t Status Sysfs node\n");
2828

2929
mutex_lock(&acpi_device_lock);
30-
list_for_each_safe(node, next, &acpi_wakeup_device_list) {
31-
struct acpi_device *dev =
32-
container_of(node, struct acpi_device, wakeup_list);
30+
list_for_each_entry_safe(dev, tmp, &acpi_wakeup_device_list,
31+
wakeup_list) {
3332
struct acpi_device_physical_node *entry;
3433

3534
if (!dev->wakeup.flags.valid)
@@ -96,7 +95,7 @@ acpi_system_write_wakeup_device(struct file *file,
9695
const char __user * buffer,
9796
size_t count, loff_t * ppos)
9897
{
99-
struct list_head *node, *next;
98+
struct acpi_device *dev, *tmp;
10099
char strbuf[5];
101100
char str[5] = "";
102101

@@ -109,9 +108,8 @@ acpi_system_write_wakeup_device(struct file *file,
109108
sscanf(strbuf, "%s", str);
110109

111110
mutex_lock(&acpi_device_lock);
112-
list_for_each_safe(node, next, &acpi_wakeup_device_list) {
113-
struct acpi_device *dev =
114-
container_of(node, struct acpi_device, wakeup_list);
111+
list_for_each_entry_safe(dev, tmp, &acpi_wakeup_device_list,
112+
wakeup_list) {
115113
if (!dev->wakeup.flags.valid)
116114
continue;
117115

drivers/acpi/tiny-power-button.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
#include <linux/module.h>
3+
#include <linux/sched/signal.h>
4+
#include <linux/acpi.h>
5+
#include <acpi/button.h>
6+
7+
ACPI_MODULE_NAME("tiny-power-button");
8+
MODULE_AUTHOR("Josh Triplett");
9+
MODULE_DESCRIPTION("ACPI Tiny Power Button Driver");
10+
MODULE_LICENSE("GPL");
11+
12+
static int power_signal __read_mostly = CONFIG_ACPI_TINY_POWER_BUTTON_SIGNAL;
13+
module_param(power_signal, int, 0644);
14+
MODULE_PARM_DESC(power_signal, "Power button sends this signal to init");
15+
16+
static const struct acpi_device_id tiny_power_button_device_ids[] = {
17+
{ ACPI_BUTTON_HID_POWER, 0 },
18+
{ ACPI_BUTTON_HID_POWERF, 0 },
19+
{ "", 0 },
20+
};
21+
MODULE_DEVICE_TABLE(acpi, tiny_power_button_device_ids);
22+
23+
static int acpi_noop_add_remove(struct acpi_device *device)
24+
{
25+
return 0;
26+
}
27+
28+
static void acpi_tiny_power_button_notify(struct acpi_device *device, u32 event)
29+
{
30+
kill_cad_pid(power_signal, 1);
31+
}
32+
33+
static struct acpi_driver acpi_tiny_power_button_driver = {
34+
.name = "tiny-power-button",
35+
.class = "tiny-power-button",
36+
.ids = tiny_power_button_device_ids,
37+
.ops = {
38+
.add = acpi_noop_add_remove,
39+
.remove = acpi_noop_add_remove,
40+
.notify = acpi_tiny_power_button_notify,
41+
},
42+
};
43+
44+
module_driver(acpi_tiny_power_button_driver,
45+
acpi_bus_register_driver,
46+
acpi_bus_unregister_driver);

drivers/acpi/wakeup.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,10 @@ ACPI_MODULE_NAME("wakeup_devices")
3030
*/
3131
void acpi_enable_wakeup_devices(u8 sleep_state)
3232
{
33-
struct list_head *node, *next;
34-
35-
list_for_each_safe(node, next, &acpi_wakeup_device_list) {
36-
struct acpi_device *dev =
37-
container_of(node, struct acpi_device, wakeup_list);
33+
struct acpi_device *dev, *tmp;
3834

35+
list_for_each_entry_safe(dev, tmp, &acpi_wakeup_device_list,
36+
wakeup_list) {
3937
if (!dev->wakeup.flags.valid
4038
|| sleep_state > (u32) dev->wakeup.sleep_state
4139
|| !(device_may_wakeup(&dev->dev)
@@ -57,12 +55,10 @@ void acpi_enable_wakeup_devices(u8 sleep_state)
5755
*/
5856
void acpi_disable_wakeup_devices(u8 sleep_state)
5957
{
60-
struct list_head *node, *next;
61-
62-
list_for_each_safe(node, next, &acpi_wakeup_device_list) {
63-
struct acpi_device *dev =
64-
container_of(node, struct acpi_device, wakeup_list);
58+
struct acpi_device *dev, *tmp;
6559

60+
list_for_each_entry_safe(dev, tmp, &acpi_wakeup_device_list,
61+
wakeup_list) {
6662
if (!dev->wakeup.flags.valid
6763
|| sleep_state > (u32) dev->wakeup.sleep_state
6864
|| !(device_may_wakeup(&dev->dev)
@@ -79,13 +75,11 @@ void acpi_disable_wakeup_devices(u8 sleep_state)
7975

8076
int __init acpi_wakeup_device_init(void)
8177
{
82-
struct list_head *node, *next;
78+
struct acpi_device *dev, *tmp;
8379

8480
mutex_lock(&acpi_device_lock);
85-
list_for_each_safe(node, next, &acpi_wakeup_device_list) {
86-
struct acpi_device *dev = container_of(node,
87-
struct acpi_device,
88-
wakeup_list);
81+
list_for_each_entry_safe(dev, tmp, &acpi_wakeup_device_list,
82+
wakeup_list) {
8983
if (device_can_wakeup(&dev->dev)) {
9084
/* Button GPEs are supposed to be always enabled. */
9185
acpi_enable_gpe(dev->wakeup.gpe_device,

include/acpi/button.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
#ifndef ACPI_BUTTON_H
33
#define ACPI_BUTTON_H
44

5+
#define ACPI_BUTTON_HID_POWER "PNP0C0C"
6+
#define ACPI_BUTTON_HID_LID "PNP0C0D"
7+
#define ACPI_BUTTON_HID_SLEEP "PNP0C0E"
8+
59
#if IS_ENABLED(CONFIG_ACPI_BUTTON)
610
extern int acpi_lid_open(void);
711
#else

0 commit comments

Comments
 (0)