Merge branches 'acpi-battery', 'acpi-fan' and 'acpi-misc'

Merge ACPI battery and fan drivers updates and miscellaneous ACPI
chanages for 6.14:

 - Update messages printed by the ACPI battery driver to always
   refer to driver extensions as "hooks" to avoid confusion with
   similar functionality in the power supply subsystem in the
   future (Thomas Weißschuh).

 - Fix .probe() error path cleanup in the ACPI fan driver to avoid
   memory leaks (Joe Hattori).

 - Constify 'struct bin_attribute' in some places in the ACPI subsystem
   and mark it as __ro_after_init in one place to prevent binary blob
   attributes from being updated (Thomas Weißschuh)

 - Add empty stubs for several ACPI-related symbols so that they can be
   used when CONFIG_ACPI is unset and use them for removing unnecessary
   conditional compilation from the ipu-bridge driver (Ricardo Ribalda).

* acpi-battery:
  ACPI: battery: Rename extensions to hook in messages

* acpi-fan:
  ACPI: fan: cleanup resources in the error path of .probe()

* acpi-misc:
  media: ipu-bridge: Remove unneeded conditional compilations
  ACPI: bus: implement acpi_device_hid when !ACPI
  ACPI: bus: implement for_each_acpi_consumer_dev when !ACPI
  ACPI: header: implement acpi_device_handle when !ACPI
  ACPI: bus: implement acpi_get_physical_device_location when !ACPI
  ACPI: bus: implement for_each_acpi_dev_match when !ACPI
  ACPI: bus: change the prototype for acpi_get_physical_device_location
  ACPI: sysfs: Constify 'struct bin_attribute'
  ACPI: BGRT: Constify 'struct bin_attribute'
  ACPI: BGRT: Mark bin_attribute as __ro_after_init
This commit is contained in:
Rafael J. Wysocki 2025-01-20 17:58:25 +01:00
commit d1ddf94665
12 changed files with 58 additions and 58 deletions

View File

@ -717,7 +717,7 @@ static void battery_hook_unregister_unlocked(struct acpi_battery_hook *hook)
}
list_del_init(&hook->list);
pr_info("extension unregistered: %s\n", hook->name);
pr_info("hook unregistered: %s\n", hook->name);
}
void battery_hook_unregister(struct acpi_battery_hook *hook)
@ -751,18 +751,18 @@ void battery_hook_register(struct acpi_battery_hook *hook)
if (hook->add_battery(battery->bat, hook)) {
/*
* If a add-battery returns non-zero,
* the registration of the extension has failed,
* the registration of the hook has failed,
* and we will not add it to the list of loaded
* hooks.
*/
pr_err("extension failed to load: %s", hook->name);
pr_err("hook failed to load: %s", hook->name);
battery_hook_unregister_unlocked(hook);
goto end;
}
power_supply_changed(battery->bat);
}
pr_info("new extension: %s\n", hook->name);
pr_info("new hook: %s\n", hook->name);
end:
mutex_unlock(&hook_mutex);
}
@ -805,10 +805,10 @@ static void battery_hook_add_battery(struct acpi_battery *battery)
list_for_each_entry_safe(hook_node, tmp, &battery_hook_list, list) {
if (hook_node->add_battery(battery->bat, hook_node)) {
/*
* The notification of the extensions has failed, to
* prevent further errors we will unload the extension.
* The notification of the hook has failed, to
* prevent further errors we will unload the hook.
*/
pr_err("error in extension, unloading: %s",
pr_err("error in hook, unloading: %s",
hook_node->name);
battery_hook_unregister_unlocked(hook_node);
}

View File

@ -29,7 +29,7 @@ BGRT_SHOW(type, image_type);
BGRT_SHOW(xoffset, image_offset_x);
BGRT_SHOW(yoffset, image_offset_y);
static BIN_ATTR_SIMPLE_RO(image);
static __ro_after_init BIN_ATTR_SIMPLE_RO(image);
static struct attribute *bgrt_attributes[] = {
&bgrt_attr_version.attr,
@ -40,14 +40,14 @@ static struct attribute *bgrt_attributes[] = {
NULL,
};
static struct bin_attribute *bgrt_bin_attributes[] = {
static const struct bin_attribute *const bgrt_bin_attributes[] = {
&bin_attr_image,
NULL,
};
static const struct attribute_group bgrt_attribute_group = {
.attrs = bgrt_attributes,
.bin_attrs = bgrt_bin_attributes,
.bin_attrs_new = bgrt_bin_attributes,
};
int __init acpi_parse_bgrt(struct acpi_table_header *table)

View File

@ -371,19 +371,25 @@ static int acpi_fan_probe(struct platform_device *pdev)
result = sysfs_create_link(&pdev->dev.kobj,
&cdev->device.kobj,
"thermal_cooling");
if (result)
if (result) {
dev_err(&pdev->dev, "Failed to create sysfs link 'thermal_cooling'\n");
goto err_unregister;
}
result = sysfs_create_link(&cdev->device.kobj,
&pdev->dev.kobj,
"device");
if (result) {
dev_err(&pdev->dev, "Failed to create sysfs link 'device'\n");
goto err_end;
goto err_remove_link;
}
return 0;
err_remove_link:
sysfs_remove_link(&pdev->dev.kobj, "thermal_cooling");
err_unregister:
thermal_cooling_device_unregister(cdev);
err_end:
if (fan->acpi4)
acpi_fan_delete_attributes(device);

View File

@ -624,8 +624,7 @@ static void init_crs_csi2_swnodes(struct crs_csi2 *csi2)
if (!fwnode_property_present(adev_fwnode, "rotation")) {
struct acpi_pld_info *pld;
status = acpi_get_physical_device_location(handle, &pld);
if (ACPI_SUCCESS(status)) {
if (acpi_get_physical_device_location(handle, &pld)) {
swnodes->dev_props[NEXT_PROPERTY(prop_index, DEV_ROTATION)] =
PROPERTY_ENTRY_U32("rotation",
pld->rotation * 45U);

View File

@ -723,10 +723,8 @@ int acpi_tie_acpi_dev(struct acpi_device *adev)
static void acpi_store_pld_crc(struct acpi_device *adev)
{
struct acpi_pld_info *pld;
acpi_status status;
status = acpi_get_physical_device_location(adev->handle, &pld);
if (ACPI_FAILURE(status))
if (!acpi_get_physical_device_location(adev->handle, &pld))
return;
adev->pld_crc = crc32(~0, pld, sizeof(*pld));

View File

@ -319,7 +319,7 @@ struct acpi_data_attr {
};
static ssize_t acpi_table_show(struct file *filp, struct kobject *kobj,
struct bin_attribute *bin_attr, char *buf,
const struct bin_attribute *bin_attr, char *buf,
loff_t offset, size_t count)
{
struct acpi_table_attr *table_attr =
@ -372,7 +372,7 @@ static int acpi_table_attr_init(struct kobject *tables_obj,
}
table_attr->attr.size = table_header->length;
table_attr->attr.read = acpi_table_show;
table_attr->attr.read_new = acpi_table_show;
table_attr->attr.attr.name = table_attr->filename;
table_attr->attr.attr.mode = 0400;
@ -412,7 +412,7 @@ acpi_status acpi_sysfs_table_handler(u32 event, void *table, void *context)
}
static ssize_t acpi_data_show(struct file *filp, struct kobject *kobj,
struct bin_attribute *bin_attr, char *buf,
const struct bin_attribute *bin_attr, char *buf,
loff_t offset, size_t count)
{
struct acpi_data_attr *data_attr;
@ -495,7 +495,7 @@ static int acpi_table_data_init(struct acpi_table_header *th)
if (!data_attr)
return -ENOMEM;
sysfs_attr_init(&data_attr->attr.attr);
data_attr->attr.read = acpi_data_show;
data_attr->attr.read_new = acpi_data_show;
data_attr->attr.attr.mode = 0400;
return acpi_data_objs[i].fn(th, data_attr);
}

View File

@ -494,7 +494,7 @@ bool acpi_device_dep(acpi_handle target, acpi_handle match)
}
EXPORT_SYMBOL_GPL(acpi_device_dep);
acpi_status
bool
acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld)
{
acpi_status status;
@ -502,9 +502,8 @@ acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld
union acpi_object *output;
status = acpi_evaluate_object(handle, "_PLD", NULL, &buffer);
if (ACPI_FAILURE(status))
return status;
return false;
output = buffer.pointer;
@ -523,7 +522,7 @@ acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld
out:
kfree(buffer.pointer);
return status;
return ACPI_SUCCESS(status);
}
EXPORT_SYMBOL(acpi_get_physical_device_location);

View File

@ -13,13 +13,11 @@
bool dev_add_physical_location(struct device *dev)
{
struct acpi_pld_info *pld;
acpi_status status;
if (!has_acpi_companion(dev))
return false;
status = acpi_get_physical_device_location(ACPI_HANDLE(dev), &pld);
if (ACPI_FAILURE(status))
if (!acpi_get_physical_device_location(ACPI_HANDLE(dev), &pld))
return false;
dev->physical_location =

View File

@ -2,6 +2,7 @@
/* Author: Dan Scally <djrscally@gmail.com> */
#include <linux/acpi.h>
#include <acpi/acpi_bus.h>
#include <linux/cleanup.h>
#include <linux/device.h>
#include <linux/i2c.h>
@ -107,7 +108,6 @@ static const char * const ipu_vcm_types[] = {
"lc898212axb",
};
#if IS_ENABLED(CONFIG_ACPI)
/*
* Used to figure out IVSC acpi device by ipu_bridge_get_ivsc_acpi_dev()
* instead of device and driver match to probe IVSC device.
@ -127,11 +127,11 @@ static struct acpi_device *ipu_bridge_get_ivsc_acpi_dev(struct acpi_device *adev
const struct acpi_device_id *acpi_id = &ivsc_acpi_ids[i];
struct acpi_device *consumer, *ivsc_adev;
acpi_handle handle = acpi_device_handle(adev);
acpi_handle handle = acpi_device_handle(ACPI_PTR(adev));
for_each_acpi_dev_match(ivsc_adev, acpi_id->id, NULL, -1)
/* camera sensor depends on IVSC in DSDT if exist */
for_each_acpi_consumer_dev(ivsc_adev, consumer)
if (consumer->handle == handle) {
if (ACPI_PTR(consumer->handle) == handle) {
acpi_dev_put(consumer);
return ivsc_adev;
}
@ -139,12 +139,6 @@ static struct acpi_device *ipu_bridge_get_ivsc_acpi_dev(struct acpi_device *adev
return NULL;
}
#else
static struct acpi_device *ipu_bridge_get_ivsc_acpi_dev(struct acpi_device *adev)
{
return NULL;
}
#endif
static int ipu_bridge_match_ivsc_dev(struct device *dev, const void *adev)
{
@ -259,12 +253,8 @@ static enum v4l2_fwnode_orientation ipu_bridge_parse_orientation(struct acpi_dev
{
enum v4l2_fwnode_orientation orientation;
struct acpi_pld_info *pld = NULL;
acpi_status status = AE_ERROR;
#if IS_ENABLED(CONFIG_ACPI)
status = acpi_get_physical_device_location(adev->handle, &pld);
#endif
if (ACPI_FAILURE(status)) {
if (!acpi_get_physical_device_location(ACPI_PTR(adev->handle), &pld)) {
dev_warn(ADEV_DEV(adev), "_PLD call failed, using default orientation\n");
return V4L2_FWNODE_ORIENTATION_EXTERNAL;
}
@ -498,9 +488,7 @@ static void ipu_bridge_create_connection_swnodes(struct ipu_bridge *bridge,
if (sensor->csi_dev) {
const char *device_hid = "";
#if IS_ENABLED(CONFIG_ACPI)
device_hid = acpi_device_hid(sensor->ivsc_adev);
#endif
snprintf(sensor->ivsc_name, sizeof(sensor->ivsc_name), "%s-%u",
device_hid, sensor->link);
@ -671,11 +659,7 @@ static int ipu_bridge_connect_sensor(const struct ipu_sensor_config *cfg,
struct acpi_device *adev = NULL;
int ret;
#if IS_ENABLED(CONFIG_ACPI)
for_each_acpi_dev_match(adev, cfg->hid, NULL, -1) {
#else
while (true) {
#endif
if (!ACPI_PTR(adev->status.enabled))
continue;
@ -768,15 +752,10 @@ static int ipu_bridge_ivsc_is_ready(void)
unsigned int i;
for (i = 0; i < ARRAY_SIZE(ipu_supported_sensors); i++) {
#if IS_ENABLED(CONFIG_ACPI)
const struct ipu_sensor_config *cfg =
&ipu_supported_sensors[i];
for_each_acpi_dev_match(sensor_adev, cfg->hid, NULL, -1) {
#else
while (true) {
sensor_adev = NULL;
#endif
if (!ACPI_PTR(sensor_adev->status.enabled))
continue;

View File

@ -213,8 +213,7 @@ usb_acpi_get_connect_type(struct usb_port *port_dev, acpi_handle *handle)
* no connectable, the port would be not used.
*/
status = acpi_get_physical_device_location(handle, &pld);
if (ACPI_SUCCESS(status) && pld)
if (acpi_get_physical_device_location(handle, &pld) && pld)
port_dev->location = USB_ACPI_LOCATION_VALID |
pld->group_token << 8 | pld->group_position;

View File

@ -43,9 +43,6 @@ acpi_status
acpi_evaluate_ost(acpi_handle handle, u32 source_event, u32 status_code,
struct acpi_buffer *status_buf);
acpi_status
acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld);
bool acpi_has_method(acpi_handle handle, char *name);
acpi_status acpi_execute_simple_method(acpi_handle handle, char *method,
u64 arg);
@ -60,6 +57,9 @@ bool acpi_check_dsm(acpi_handle handle, const guid_t *guid, u64 rev, u64 funcs);
union acpi_object *acpi_evaluate_dsm(acpi_handle handle, const guid_t *guid,
u64 rev, u64 func, union acpi_object *argv4);
#ifdef CONFIG_ACPI
bool
acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld);
static inline union acpi_object *
acpi_evaluate_dsm_typed(acpi_handle handle, const guid_t *guid, u64 rev,
u64 func, union acpi_object *argv4,
@ -1003,6 +1003,23 @@ static inline int unregister_acpi_bus_type(void *bus) { return 0; }
static inline int acpi_wait_for_acpi_ipmi(void) { return 0; }
static inline const char *acpi_device_hid(struct acpi_device *device)
{
return "";
}
static inline bool
acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld)
{
return false;
}
#define for_each_acpi_consumer_dev(supplier, consumer) \
for (consumer = NULL; false && (supplier);)
#define for_each_acpi_dev_match(adev, hid, uid, hrv) \
for (adev = NULL; false && (hid) && (uid) && (hrv); )
#endif /* CONFIG_ACPI */
#endif /*__ACPI_BUS_H__*/

View File

@ -854,6 +854,11 @@ static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev)
return NULL;
}
static inline acpi_handle acpi_device_handle(struct acpi_device *adev)
{
return NULL;
}
static inline bool has_acpi_companion(struct device *dev)
{
return false;