Skip to content

Commit 1c58e3a

Browse files
committed
Merge branches 'acpi-battery', 'acpi-ec', 'acpi-pfr' and 'acpi-osl'
Merge updates of the ACPI battery and EC drivers, an ACPI Platform Firmware Runtime (PFR) telemetry driver update and an ACPI OS support layer change for 6.13-rc1: - Use DEFINE_SIMPLE_DEV_PM_OPS in the ACPI battery driver, make it use devm_ for initializing mutexes and allocating driver data, and make it check the register_pm_notifier() return value (Thomas Weißschuh, Andy Shevchenko). - Make the ACPI EC driver support compile-time conditional and allow ACPI to be built without CONFIG_HAS_IOPORT (Arnd Bergmann). - Remove a redundant error check from the pfr_telemetry driver (Colin Ian King). * acpi-battery: ACPI: battery: Check for error code from devm_mutex_init() call ACPI: battery: use DEFINE_SIMPLE_DEV_PM_OPS ACPI: battery: initialize mutexes through devm_ APIs ACPI: battery: allocate driver data through devm_ APIs ACPI: battery: check result of register_pm_notifier() * acpi-ec: ACPI: EC: make EC support compile-time conditional * acpi-pfr: ACPI: pfr_telemetry: remove redundant error check on ret * acpi-osl: ACPI: allow building without CONFIG_HAS_IOPORT
5 parents 2388b26 + 815daed + a6021aa + f8dc439 + 4435a12 commit 1c58e3a

File tree

15 files changed

+91
-46
lines changed

15 files changed

+91
-46
lines changed

drivers/acpi/Kconfig

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,17 @@ config ACPI_REV_OVERRIDE_POSSIBLE
132132
makes it possible to force the kernel to return "5" as the supported
133133
ACPI revision via the "acpi_rev_override" command line switch.
134134

135+
config ACPI_EC
136+
bool "Embedded Controller"
137+
depends on HAS_IOPORT
138+
default X86
139+
help
140+
This driver handles communication with the microcontroller
141+
on many x86 laptops and other machines.
142+
135143
config ACPI_EC_DEBUGFS
136144
tristate "EC read/write access through /sys/kernel/debug/ec"
145+
depends on ACPI_EC
137146
help
138147
Say N to disable Embedded Controller /sys/kernel/debug interface
139148

@@ -433,7 +442,7 @@ config ACPI_HOTPLUG_IOAPIC
433442

434443
config ACPI_SBS
435444
tristate "Smart Battery System"
436-
depends on X86
445+
depends on X86 && ACPI_EC
437446
select POWER_SUPPLY
438447
help
439448
This driver supports the Smart Battery System, another

drivers/acpi/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ acpi-y += resource.o
4141
acpi-y += acpi_processor.o
4242
acpi-y += processor_core.o
4343
acpi-$(CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC) += processor_pdc.o
44-
acpi-y += ec.o
44+
acpi-$(CONFIG_ACPI_EC) += ec.o
4545
acpi-$(CONFIG_ACPI_DOCK) += dock.o
4646
acpi-$(CONFIG_PCI) += pci_root.o pci_link.o pci_irq.o
4747
obj-$(CONFIG_ACPI_MCFG) += pci_mcfg.o

drivers/acpi/battery.c

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,15 +1218,21 @@ static int acpi_battery_add(struct acpi_device *device)
12181218
if (device->dep_unmet)
12191219
return -EPROBE_DEFER;
12201220

1221-
battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL);
1221+
battery = devm_kzalloc(&device->dev, sizeof(*battery), GFP_KERNEL);
12221222
if (!battery)
12231223
return -ENOMEM;
12241224
battery->device = device;
12251225
strscpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
12261226
strscpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
12271227
device->driver_data = battery;
1228-
mutex_init(&battery->lock);
1229-
mutex_init(&battery->sysfs_lock);
1228+
result = devm_mutex_init(&device->dev, &battery->lock);
1229+
if (result)
1230+
return result;
1231+
1232+
result = devm_mutex_init(&device->dev, &battery->sysfs_lock);
1233+
if (result)
1234+
return result;
1235+
12301236
if (acpi_has_method(battery->device->handle, "_BIX"))
12311237
set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags);
12321238

@@ -1238,7 +1244,9 @@ static int acpi_battery_add(struct acpi_device *device)
12381244
device->status.battery_present ? "present" : "absent");
12391245

12401246
battery->pm_nb.notifier_call = battery_notify;
1241-
register_pm_notifier(&battery->pm_nb);
1247+
result = register_pm_notifier(&battery->pm_nb);
1248+
if (result)
1249+
goto fail;
12421250

12431251
device_init_wakeup(&device->dev, 1);
12441252

@@ -1254,9 +1262,6 @@ static int acpi_battery_add(struct acpi_device *device)
12541262
unregister_pm_notifier(&battery->pm_nb);
12551263
fail:
12561264
sysfs_remove_battery(battery);
1257-
mutex_destroy(&battery->lock);
1258-
mutex_destroy(&battery->sysfs_lock);
1259-
kfree(battery);
12601265

12611266
return result;
12621267
}
@@ -1276,13 +1281,8 @@ static void acpi_battery_remove(struct acpi_device *device)
12761281
device_init_wakeup(&device->dev, 0);
12771282
unregister_pm_notifier(&battery->pm_nb);
12781283
sysfs_remove_battery(battery);
1279-
1280-
mutex_destroy(&battery->lock);
1281-
mutex_destroy(&battery->sysfs_lock);
1282-
kfree(battery);
12831284
}
12841285

1285-
#ifdef CONFIG_PM_SLEEP
12861286
/* this is needed to learn about changes made in suspended state */
12871287
static int acpi_battery_resume(struct device *dev)
12881288
{
@@ -1299,11 +1299,8 @@ static int acpi_battery_resume(struct device *dev)
12991299
acpi_battery_update(battery, true);
13001300
return 0;
13011301
}
1302-
#else
1303-
#define acpi_battery_resume NULL
1304-
#endif
13051302

1306-
static SIMPLE_DEV_PM_OPS(acpi_battery_pm, NULL, acpi_battery_resume);
1303+
static DEFINE_SIMPLE_DEV_PM_OPS(acpi_battery_pm, NULL, acpi_battery_resume);
13071304

13081305
static struct acpi_driver acpi_battery_driver = {
13091306
.name = "battery",
@@ -1313,7 +1310,7 @@ static struct acpi_driver acpi_battery_driver = {
13131310
.add = acpi_battery_add,
13141311
.remove = acpi_battery_remove,
13151312
},
1316-
.drv.pm = &acpi_battery_pm,
1313+
.drv.pm = pm_sleep_ptr(&acpi_battery_pm),
13171314
.drv.probe_type = PROBE_PREFER_ASYNCHRONOUS,
13181315
};
13191316

drivers/acpi/cppc_acpi.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,8 @@ static int cpc_read(int cpu, struct cpc_register_resource *reg_res, u64 *val)
10111011
*val = 0;
10121012
size = GET_BIT_WIDTH(reg);
10131013

1014-
if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
1014+
if (IS_ENABLED(CONFIG_HAS_IOPORT) &&
1015+
reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
10151016
u32 val_u32;
10161017
acpi_status status;
10171018

@@ -1085,7 +1086,8 @@ static int cpc_write(int cpu, struct cpc_register_resource *reg_res, u64 val)
10851086

10861087
size = GET_BIT_WIDTH(reg);
10871088

1088-
if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
1089+
if (IS_ENABLED(CONFIG_HAS_IOPORT) &&
1090+
reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
10891091
acpi_status status;
10901092

10911093
status = acpi_os_write_port((acpi_io_address)reg->address,

drivers/acpi/internal.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ extern struct acpi_ec *first_ec;
215215
/* External interfaces use first EC only, so remember */
216216
typedef int (*acpi_ec_query_func) (void *data);
217217

218+
#ifdef CONFIG_ACPI_EC
219+
218220
void acpi_ec_init(void);
219221
void acpi_ec_ecdt_probe(void);
220222
void acpi_ec_dsdt_probe(void);
@@ -231,6 +233,29 @@ void acpi_ec_flush_work(void);
231233
bool acpi_ec_dispatch_gpe(void);
232234
#endif
233235

236+
#else
237+
238+
static inline void acpi_ec_init(void) {}
239+
static inline void acpi_ec_ecdt_probe(void) {}
240+
static inline void acpi_ec_dsdt_probe(void) {}
241+
static inline void acpi_ec_block_transactions(void) {}
242+
static inline void acpi_ec_unblock_transactions(void) {}
243+
static inline int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
244+
acpi_handle handle, acpi_ec_query_func func,
245+
void *data)
246+
{
247+
return -ENXIO;
248+
}
249+
static inline void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit) {}
250+
static inline void acpi_ec_register_opregions(struct acpi_device *adev) {}
251+
252+
static inline void acpi_ec_flush_work(void) {}
253+
static inline bool acpi_ec_dispatch_gpe(void)
254+
{
255+
return false;
256+
}
257+
258+
#endif
234259

235260
/*--------------------------------------------------------------------------
236261
Suspend/Resume

drivers/acpi/osl.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,15 @@ acpi_status acpi_os_read_port(acpi_io_address port, u32 *value, u32 width)
642642
{
643643
u32 dummy;
644644

645+
if (!IS_ENABLED(CONFIG_HAS_IOPORT)) {
646+
/*
647+
* set all-1 result as if reading from non-existing
648+
* I/O port
649+
*/
650+
*value = GENMASK(width, 0);
651+
return AE_NOT_IMPLEMENTED;
652+
}
653+
645654
if (value)
646655
*value = 0;
647656
else
@@ -665,6 +674,9 @@ EXPORT_SYMBOL(acpi_os_read_port);
665674

666675
acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width)
667676
{
677+
if (!IS_ENABLED(CONFIG_HAS_IOPORT))
678+
return AE_NOT_IMPLEMENTED;
679+
668680
if (width <= 8) {
669681
outb(value, port);
670682
} else if (width <= 16) {

drivers/acpi/pfr_telemetry.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,6 @@ static long pfrt_log_ioctl(struct file *file, unsigned int cmd, unsigned long ar
272272

273273
case PFRT_LOG_IOC_GET_INFO:
274274
info.log_level = get_pfrt_log_level(pfrt_log_dev);
275-
if (ret < 0)
276-
return ret;
277-
278275
info.log_type = pfrt_log_dev->info.log_type;
279276
info.log_revid = pfrt_log_dev->info.log_revid;
280277
if (copy_to_user(p, &info, sizeof(info)))

drivers/acpi/sbshc.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/module.h>
1515
#include <linux/interrupt.h>
1616
#include "sbshc.h"
17+
#include "internal.h"
1718

1819
#define ACPI_SMB_HC_CLASS "smbus_host_ctl"
1920
#define ACPI_SMB_HC_DEVICE_NAME "ACPI SMBus HC"
@@ -236,12 +237,6 @@ static int smbus_alarm(void *context)
236237
return 0;
237238
}
238239

239-
typedef int (*acpi_ec_query_func) (void *data);
240-
241-
extern int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
242-
acpi_handle handle, acpi_ec_query_func func,
243-
void *data);
244-
245240
static int acpi_smbus_hc_add(struct acpi_device *device)
246241
{
247242
int status;
@@ -278,8 +273,6 @@ static int acpi_smbus_hc_add(struct acpi_device *device)
278273
return 0;
279274
}
280275

281-
extern void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit);
282-
283276
static void acpi_smbus_hc_remove(struct acpi_device *device)
284277
{
285278
struct acpi_smb_hc *hc;

drivers/char/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ config APPLICOM
238238
config SONYPI
239239
tristate "Sony Vaio Programmable I/O Control Device support"
240240
depends on X86_32 && PCI && INPUT
241+
depends on ACPI_EC || !ACPI
241242
help
242243
This driver enables access to the Sony Programmable I/O Control
243244
Device which can be found in many (all ?) Sony Vaio laptops.

drivers/hwmon/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1752,7 +1752,7 @@ source "drivers/hwmon/occ/Kconfig"
17521752

17531753
config SENSORS_OXP
17541754
tristate "OneXPlayer EC fan control"
1755-
depends on ACPI
1755+
depends on ACPI_EC
17561756
depends on X86
17571757
help
17581758
If you say yes here you get support for fan readings and control over
@@ -2592,6 +2592,7 @@ config SENSORS_ASUS_WMI
25922592
config SENSORS_ASUS_EC
25932593
tristate "ASUS EC Sensors"
25942594
depends on X86
2595+
depends on ACPI_EC
25952596
help
25962597
If you say yes here you get support for the ACPI embedded controller
25972598
hardware monitoring interface found in ASUS motherboards. The driver

0 commit comments

Comments
 (0)