Skip to content

Commit

Permalink
Merge tag 'acpi-6.13-rc1' of git://git.kernel.org/pub/scm/linux/kerne…
Browse files Browse the repository at this point in the history
…l/git/rafael/linux-pm

Pull ACPI updates from Rafael Wysocki:
 "These include a couple of fixes, a new ACPI backlight quirk for Apple
  MacbookPro11,2 and Air7,2 and a bunch of cleanups:

   - Fix _CPC register setting issue for registers located in memory in
     the ACPI CPPC library code (Lifeng Zheng)

   - 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)

   - Rearrange the processor_perflib code in the ACPI processor driver
     to avoid compiling x86-specific code on other architectures (Arnd
     Bergmann)

   - Add adev NULL check to acpi_quirk_skip_serdev_enumeration() and
     make UART skip quirks work on PCI UARTs without an UID (Hans de
     Goede)

   - Force native backlight handling Apple MacbookPro11,2 and Air7,2 in
     the ACPI video driver (Jonathan Denose)

   - Switch several ACPI platform drivers back to using struct
     platform_driver::remove() (Uwe Kleine-König)

   - Replace strcpy() with strscpy() in multiple places in the ACPI
     subsystem (Muhammad Qasim Abdul Majeed, Abdul Rahim)"

* tag 'acpi-6.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (24 commits)
  ACPI: video: force native for Apple MacbookPro11,2 and Air7,2
  ACPI: CPPC: Fix _CPC register setting issue
  ACPI: Switch back to struct platform_driver::remove()
  ACPI: x86: Add adev NULL check to acpi_quirk_skip_serdev_enumeration()
  ACPI: x86: Make UART skip quirks work on PCI UARTs without an UID
  ACPI: allow building without CONFIG_HAS_IOPORT
  ACPI: processor_perflib: extend X86 dependency
  ACPI: scan: Use strscpy() instead of strcpy()
  ACPI: SBSHC: Use strscpy() instead of strcpy()
  ACPI: SBS: Use strscpy() instead of strcpy()
  ACPI: power: Use strscpy() instead of strcpy()
  ACPI: pci_root: Use strscpy() instead of strcpy()
  ACPI: pci_link: Use strscpy() instead of strcpy()
  ACPI: event: Use strscpy() instead of strcpy()
  ACPI: EC: Use strscpy() instead of strcpy()
  ACPI: APD: Use strscpy() instead of strcpy()
  ACPI: thermal: Use strscpy() instead of strcpy()
  ACPI: battery: Check for error code from devm_mutex_init() call
  ACPI: EC: make EC support compile-time conditional
  ACPI: pfr_telemetry: remove redundant error check on ret
  ...
  • Loading branch information
Linus Torvalds committed Nov 19, 2024
2 parents cd7fa3e + d47a60e commit 4e9ad03
Show file tree
Hide file tree
Showing 38 changed files with 189 additions and 101 deletions.
11 changes: 10 additions & 1 deletion drivers/acpi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,17 @@ config ACPI_REV_OVERRIDE_POSSIBLE
makes it possible to force the kernel to return "5" as the supported
ACPI revision via the "acpi_rev_override" command line switch.

config ACPI_EC
bool "Embedded Controller"
depends on HAS_IOPORT
default X86
help
This driver handles communication with the microcontroller
on many x86 laptops and other machines.

config ACPI_EC_DEBUGFS
tristate "EC read/write access through /sys/kernel/debug/ec"
depends on ACPI_EC
help
Say N to disable Embedded Controller /sys/kernel/debug interface

Expand Down Expand Up @@ -433,7 +442,7 @@ config ACPI_HOTPLUG_IOAPIC

config ACPI_SBS
tristate "Smart Battery System"
depends on X86
depends on X86 && ACPI_EC
select POWER_SUPPLY
help
This driver supports the Smart Battery System, another
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ acpi-y += resource.o
acpi-y += acpi_processor.o
acpi-y += processor_core.o
acpi-$(CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC) += processor_pdc.o
acpi-y += ec.o
acpi-$(CONFIG_ACPI_EC) += ec.o
acpi-$(CONFIG_ACPI_DOCK) += dock.o
acpi-$(CONFIG_PCI) += pci_root.o pci_link.o pci_irq.o
obj-$(CONFIG_ACPI_MCFG) += pci_mcfg.o
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/ac.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ static void acpi_ac_remove(struct platform_device *pdev)

static struct platform_driver acpi_ac_driver = {
.probe = acpi_ac_probe,
.remove_new = acpi_ac_remove,
.remove = acpi_ac_remove,
.driver = {
.name = "ac",
.acpi_match_table = ac_device_ids,
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/acpi_apd.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static int fch_misc_setup(struct apd_private_data *pdata)
if (!clk_data->name)
return -ENOMEM;

strcpy(clk_data->name, obj->string.pointer);
strscpy(clk_data->name, obj->string.pointer, obj->string.length);
} else {
/* Set default name to mclk if entry missing in firmware */
clk_data->name = "mclk";
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/acpi_pad.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ MODULE_DEVICE_TABLE(acpi, pad_device_ids);

static struct platform_driver acpi_pad_driver = {
.probe = acpi_pad_probe,
.remove_new = acpi_pad_remove,
.remove = acpi_pad_remove,
.driver = {
.dev_groups = acpi_pad_groups,
.name = "processor_aggregator",
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/acpi_tad.c
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ static struct platform_driver acpi_tad_driver = {
.acpi_match_table = acpi_tad_ids,
},
.probe = acpi_tad_probe,
.remove_new = acpi_tad_remove,
.remove = acpi_tad_remove,
};
MODULE_DEVICE_TABLE(acpi, acpi_tad_ids);

Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/apei/einj-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ static struct platform_device *einj_dev;
* triggering a section mismatch warning.
*/
static struct platform_driver einj_driver __refdata = {
.remove_new = __exit_p(einj_remove),
.remove = __exit_p(einj_remove),
.driver = {
.name = "acpi-einj",
},
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/apei/ghes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1605,7 +1605,7 @@ static struct platform_driver ghes_platform_driver = {
.name = "GHES",
},
.probe = ghes_probe,
.remove_new = ghes_remove,
.remove = ghes_remove,
};

void __init acpi_ghes_init(void)
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/arm64/agdi.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static struct platform_driver agdi_driver = {
.name = "agdi",
},
.probe = agdi_probe,
.remove_new = agdi_remove,
.remove = agdi_remove,
};

void __init acpi_agdi_init(void)
Expand Down
31 changes: 14 additions & 17 deletions drivers/acpi/battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -1218,15 +1218,21 @@ static int acpi_battery_add(struct acpi_device *device)
if (device->dep_unmet)
return -EPROBE_DEFER;

battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL);
battery = devm_kzalloc(&device->dev, sizeof(*battery), GFP_KERNEL);
if (!battery)
return -ENOMEM;
battery->device = device;
strscpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
strscpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
device->driver_data = battery;
mutex_init(&battery->lock);
mutex_init(&battery->sysfs_lock);
result = devm_mutex_init(&device->dev, &battery->lock);
if (result)
return result;

result = devm_mutex_init(&device->dev, &battery->sysfs_lock);
if (result)
return result;

if (acpi_has_method(battery->device->handle, "_BIX"))
set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags);

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

battery->pm_nb.notifier_call = battery_notify;
register_pm_notifier(&battery->pm_nb);
result = register_pm_notifier(&battery->pm_nb);
if (result)
goto fail;

device_init_wakeup(&device->dev, 1);

Expand All @@ -1254,9 +1262,6 @@ static int acpi_battery_add(struct acpi_device *device)
unregister_pm_notifier(&battery->pm_nb);
fail:
sysfs_remove_battery(battery);
mutex_destroy(&battery->lock);
mutex_destroy(&battery->sysfs_lock);
kfree(battery);

return result;
}
Expand All @@ -1276,13 +1281,8 @@ static void acpi_battery_remove(struct acpi_device *device)
device_init_wakeup(&device->dev, 0);
unregister_pm_notifier(&battery->pm_nb);
sysfs_remove_battery(battery);

mutex_destroy(&battery->lock);
mutex_destroy(&battery->sysfs_lock);
kfree(battery);
}

#ifdef CONFIG_PM_SLEEP
/* this is needed to learn about changes made in suspended state */
static int acpi_battery_resume(struct device *dev)
{
Expand All @@ -1299,11 +1299,8 @@ static int acpi_battery_resume(struct device *dev)
acpi_battery_update(battery, true);
return 0;
}
#else
#define acpi_battery_resume NULL
#endif

static SIMPLE_DEV_PM_OPS(acpi_battery_pm, NULL, acpi_battery_resume);
static DEFINE_SIMPLE_DEV_PM_OPS(acpi_battery_pm, NULL, acpi_battery_resume);

static struct acpi_driver acpi_battery_driver = {
.name = "battery",
Expand All @@ -1313,7 +1310,7 @@ static struct acpi_driver acpi_battery_driver = {
.add = acpi_battery_add,
.remove = acpi_battery_remove,
},
.drv.pm = &acpi_battery_pm,
.drv.pm = pm_sleep_ptr(&acpi_battery_pm),
.drv.probe_type = PROBE_PREFER_ASYNCHRONOUS,
};

Expand Down
7 changes: 4 additions & 3 deletions drivers/acpi/cppc_acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,8 @@ static int cpc_read(int cpu, struct cpc_register_resource *reg_res, u64 *val)
*val = 0;
size = GET_BIT_WIDTH(reg);

if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
if (IS_ENABLED(CONFIG_HAS_IOPORT) &&
reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
u32 val_u32;
acpi_status status;

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

size = GET_BIT_WIDTH(reg);

if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
if (IS_ENABLED(CONFIG_HAS_IOPORT) &&
reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
acpi_status status;

status = acpi_os_write_port((acpi_io_address)reg->address,
Expand Down Expand Up @@ -1140,7 +1142,6 @@ static int cpc_write(int cpu, struct cpc_register_resource *reg_res, u64 val)
return -EFAULT;
}
val = MASK_VAL_WRITE(reg, prev_val, val);
val |= prev_val;
}

switch (size) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/dptf/dptf_pch_fivr.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ MODULE_DEVICE_TABLE(acpi, pch_fivr_device_ids);

static struct platform_driver pch_fivr_driver = {
.probe = pch_fivr_add,
.remove_new = pch_fivr_remove,
.remove = pch_fivr_remove,
.driver = {
.name = "dptf_pch_fivr",
.acpi_match_table = pch_fivr_device_ids,
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/dptf/dptf_power.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ MODULE_DEVICE_TABLE(acpi, int3407_device_ids);

static struct platform_driver dptf_power_driver = {
.probe = dptf_power_add,
.remove_new = dptf_power_remove,
.remove = dptf_power_remove,
.driver = {
.name = "dptf_power",
.acpi_match_table = int3407_device_ids,
Expand Down
4 changes: 2 additions & 2 deletions drivers/acpi/ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1677,8 +1677,8 @@ static int acpi_ec_add(struct acpi_device *device)
struct acpi_ec *ec;
int ret;

strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_EC_CLASS);
strscpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
strscpy(acpi_device_class(device), ACPI_EC_CLASS);

if (boot_ec && (boot_ec->handle == device->handle ||
!strcmp(acpi_device_hid(device), ACPI_ECDT_HID))) {
Expand Down
4 changes: 2 additions & 2 deletions drivers/acpi/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ int acpi_notifier_call_chain(struct acpi_device *dev, u32 type, u32 data)
{
struct acpi_bus_event event;

strcpy(event.device_class, dev->pnp.device_class);
strcpy(event.bus_id, dev->pnp.bus_id);
strscpy(event.device_class, dev->pnp.device_class);
strscpy(event.bus_id, dev->pnp.bus_id);
event.type = type;
event.data = data;
return (blocking_notifier_call_chain(&acpi_chain_head, 0, (void *)&event)
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/evged.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ static const struct acpi_device_id ged_acpi_ids[] = {

static struct platform_driver ged_driver = {
.probe = ged_probe,
.remove_new = ged_remove,
.remove = ged_remove,
.shutdown = ged_shutdown,
.driver = {
.name = MODULE_NAME,
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/fan_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ static const struct dev_pm_ops acpi_fan_pm = {

static struct platform_driver acpi_fan_driver = {
.probe = acpi_fan_probe,
.remove_new = acpi_fan_remove,
.remove = acpi_fan_remove,
.driver = {
.name = "acpi-fan",
.acpi_match_table = fan_device_ids,
Expand Down
25 changes: 25 additions & 0 deletions drivers/acpi/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ extern struct acpi_ec *first_ec;
/* External interfaces use first EC only, so remember */
typedef int (*acpi_ec_query_func) (void *data);

#ifdef CONFIG_ACPI_EC

void acpi_ec_init(void);
void acpi_ec_ecdt_probe(void);
void acpi_ec_dsdt_probe(void);
Expand All @@ -231,6 +233,29 @@ void acpi_ec_flush_work(void);
bool acpi_ec_dispatch_gpe(void);
#endif

#else

static inline void acpi_ec_init(void) {}
static inline void acpi_ec_ecdt_probe(void) {}
static inline void acpi_ec_dsdt_probe(void) {}
static inline void acpi_ec_block_transactions(void) {}
static inline void acpi_ec_unblock_transactions(void) {}
static inline int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
acpi_handle handle, acpi_ec_query_func func,
void *data)
{
return -ENXIO;
}
static inline void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit) {}
static inline void acpi_ec_register_opregions(struct acpi_device *adev) {}

static inline void acpi_ec_flush_work(void) {}
static inline bool acpi_ec_dispatch_gpe(void)
{
return false;
}

#endif

/*--------------------------------------------------------------------------
Suspend/Resume
Expand Down
12 changes: 12 additions & 0 deletions drivers/acpi/osl.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,15 @@ acpi_status acpi_os_read_port(acpi_io_address port, u32 *value, u32 width)
{
u32 dummy;

if (!IS_ENABLED(CONFIG_HAS_IOPORT)) {
/*
* set all-1 result as if reading from non-existing
* I/O port
*/
*value = GENMASK(width, 0);
return AE_NOT_IMPLEMENTED;
}

if (value)
*value = 0;
else
Expand All @@ -665,6 +674,9 @@ EXPORT_SYMBOL(acpi_os_read_port);

acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width)
{
if (!IS_ENABLED(CONFIG_HAS_IOPORT))
return AE_NOT_IMPLEMENTED;

if (width <= 8) {
outb(value, port);
} else if (width <= 16) {
Expand Down
4 changes: 2 additions & 2 deletions drivers/acpi/pci_link.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,8 @@ static int acpi_pci_link_add(struct acpi_device *device,
return -ENOMEM;

link->device = device;
strcpy(acpi_device_name(device), ACPI_PCI_LINK_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_PCI_LINK_CLASS);
strscpy(acpi_device_name(device), ACPI_PCI_LINK_DEVICE_NAME);
strscpy(acpi_device_class(device), ACPI_PCI_LINK_CLASS);
device->driver_data = link;

mutex_lock(&acpi_link_lock);
Expand Down
4 changes: 2 additions & 2 deletions drivers/acpi/pci_root.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,8 @@ static int acpi_pci_root_add(struct acpi_device *device,

root->device = device;
root->segment = segment & 0xFFFF;
strcpy(acpi_device_name(device), ACPI_PCI_ROOT_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS);
strscpy(acpi_device_name(device), ACPI_PCI_ROOT_DEVICE_NAME);
strscpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS);
device->driver_data = root;

if (hotadd && dmar_device_add(handle)) {
Expand Down
5 changes: 1 addition & 4 deletions drivers/acpi/pfr_telemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,6 @@ static long pfrt_log_ioctl(struct file *file, unsigned int cmd, unsigned long ar

case PFRT_LOG_IOC_GET_INFO:
info.log_level = get_pfrt_log_level(pfrt_log_dev);
if (ret < 0)
return ret;

info.log_type = pfrt_log_dev->info.log_type;
info.log_revid = pfrt_log_dev->info.log_revid;
if (copy_to_user(p, &info, sizeof(info)))
Expand Down Expand Up @@ -425,7 +422,7 @@ static struct platform_driver acpi_pfrt_log_driver = {
.acpi_match_table = acpi_pfrt_log_ids,
},
.probe = acpi_pfrt_log_probe,
.remove_new = acpi_pfrt_log_remove,
.remove = acpi_pfrt_log_remove,
};
module_platform_driver(acpi_pfrt_log_driver);

Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/pfr_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ static struct platform_driver acpi_pfru_driver = {
.acpi_match_table = acpi_pfru_ids,
},
.probe = acpi_pfru_probe,
.remove_new = acpi_pfru_remove,
.remove = acpi_pfru_remove,
};
module_platform_driver(acpi_pfru_driver);

Expand Down
4 changes: 2 additions & 2 deletions drivers/acpi/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -950,8 +950,8 @@ struct acpi_device *acpi_add_power_resource(acpi_handle handle)
mutex_init(&resource->resource_lock);
INIT_LIST_HEAD(&resource->list_node);
INIT_LIST_HEAD(&resource->dependents);
strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_POWER_CLASS);
strscpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME);
strscpy(acpi_device_class(device), ACPI_POWER_CLASS);
device->power.state = ACPI_STATE_UNKNOWN;
device->flags.match_driver = true;

Expand Down
Loading

0 comments on commit 4e9ad03

Please sign in to comment.