Merge branch 'acpi-misc' into linux-next

* 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-13 18:11:14 +01:00
commit 977da47ac1
10 changed files with 43 additions and 49 deletions

View File

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

View File

@ -624,8 +624,7 @@ static void init_crs_csi2_swnodes(struct crs_csi2 *csi2)
if (!fwnode_property_present(adev_fwnode, "rotation")) { if (!fwnode_property_present(adev_fwnode, "rotation")) {
struct acpi_pld_info *pld; struct acpi_pld_info *pld;
status = acpi_get_physical_device_location(handle, &pld); if (acpi_get_physical_device_location(handle, &pld)) {
if (ACPI_SUCCESS(status)) {
swnodes->dev_props[NEXT_PROPERTY(prop_index, DEV_ROTATION)] = swnodes->dev_props[NEXT_PROPERTY(prop_index, DEV_ROTATION)] =
PROPERTY_ENTRY_U32("rotation", PROPERTY_ENTRY_U32("rotation",
pld->rotation * 45U); 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) static void acpi_store_pld_crc(struct acpi_device *adev)
{ {
struct acpi_pld_info *pld; struct acpi_pld_info *pld;
acpi_status status;
status = acpi_get_physical_device_location(adev->handle, &pld); if (!acpi_get_physical_device_location(adev->handle, &pld))
if (ACPI_FAILURE(status))
return; return;
adev->pld_crc = crc32(~0, pld, sizeof(*pld)); 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, 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) loff_t offset, size_t count)
{ {
struct acpi_table_attr *table_attr = 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.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.name = table_attr->filename;
table_attr->attr.attr.mode = 0400; 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, 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) loff_t offset, size_t count)
{ {
struct acpi_data_attr *data_attr; struct acpi_data_attr *data_attr;
@ -495,7 +495,7 @@ static int acpi_table_data_init(struct acpi_table_header *th)
if (!data_attr) if (!data_attr)
return -ENOMEM; return -ENOMEM;
sysfs_attr_init(&data_attr->attr.attr); 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; data_attr->attr.attr.mode = 0400;
return acpi_data_objs[i].fn(th, data_attr); 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); EXPORT_SYMBOL_GPL(acpi_device_dep);
acpi_status bool
acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld) acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld)
{ {
acpi_status status; acpi_status status;
@ -502,9 +502,8 @@ acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld
union acpi_object *output; union acpi_object *output;
status = acpi_evaluate_object(handle, "_PLD", NULL, &buffer); status = acpi_evaluate_object(handle, "_PLD", NULL, &buffer);
if (ACPI_FAILURE(status)) if (ACPI_FAILURE(status))
return status; return false;
output = buffer.pointer; output = buffer.pointer;
@ -523,7 +522,7 @@ acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld
out: out:
kfree(buffer.pointer); kfree(buffer.pointer);
return status; return ACPI_SUCCESS(status);
} }
EXPORT_SYMBOL(acpi_get_physical_device_location); EXPORT_SYMBOL(acpi_get_physical_device_location);

View File

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

View File

@ -2,6 +2,7 @@
/* Author: Dan Scally <djrscally@gmail.com> */ /* Author: Dan Scally <djrscally@gmail.com> */
#include <linux/acpi.h> #include <linux/acpi.h>
#include <acpi/acpi_bus.h>
#include <linux/cleanup.h> #include <linux/cleanup.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/i2c.h> #include <linux/i2c.h>
@ -107,7 +108,6 @@ static const char * const ipu_vcm_types[] = {
"lc898212axb", "lc898212axb",
}; };
#if IS_ENABLED(CONFIG_ACPI)
/* /*
* Used to figure out IVSC acpi device by ipu_bridge_get_ivsc_acpi_dev() * Used to figure out IVSC acpi device by ipu_bridge_get_ivsc_acpi_dev()
* instead of device and driver match to probe IVSC device. * 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]; const struct acpi_device_id *acpi_id = &ivsc_acpi_ids[i];
struct acpi_device *consumer, *ivsc_adev; 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) for_each_acpi_dev_match(ivsc_adev, acpi_id->id, NULL, -1)
/* camera sensor depends on IVSC in DSDT if exist */ /* camera sensor depends on IVSC in DSDT if exist */
for_each_acpi_consumer_dev(ivsc_adev, consumer) for_each_acpi_consumer_dev(ivsc_adev, consumer)
if (consumer->handle == handle) { if (ACPI_PTR(consumer->handle) == handle) {
acpi_dev_put(consumer); acpi_dev_put(consumer);
return ivsc_adev; return ivsc_adev;
} }
@ -139,12 +139,6 @@ static struct acpi_device *ipu_bridge_get_ivsc_acpi_dev(struct acpi_device *adev
return NULL; 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) 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; enum v4l2_fwnode_orientation orientation;
struct acpi_pld_info *pld = NULL; struct acpi_pld_info *pld = NULL;
acpi_status status = AE_ERROR;
#if IS_ENABLED(CONFIG_ACPI) if (!acpi_get_physical_device_location(ACPI_PTR(adev->handle), &pld)) {
status = acpi_get_physical_device_location(adev->handle, &pld);
#endif
if (ACPI_FAILURE(status)) {
dev_warn(ADEV_DEV(adev), "_PLD call failed, using default orientation\n"); dev_warn(ADEV_DEV(adev), "_PLD call failed, using default orientation\n");
return V4L2_FWNODE_ORIENTATION_EXTERNAL; return V4L2_FWNODE_ORIENTATION_EXTERNAL;
} }
@ -498,9 +488,7 @@ static void ipu_bridge_create_connection_swnodes(struct ipu_bridge *bridge,
if (sensor->csi_dev) { if (sensor->csi_dev) {
const char *device_hid = ""; const char *device_hid = "";
#if IS_ENABLED(CONFIG_ACPI)
device_hid = acpi_device_hid(sensor->ivsc_adev); device_hid = acpi_device_hid(sensor->ivsc_adev);
#endif
snprintf(sensor->ivsc_name, sizeof(sensor->ivsc_name), "%s-%u", snprintf(sensor->ivsc_name, sizeof(sensor->ivsc_name), "%s-%u",
device_hid, sensor->link); 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; struct acpi_device *adev = NULL;
int ret; int ret;
#if IS_ENABLED(CONFIG_ACPI)
for_each_acpi_dev_match(adev, cfg->hid, NULL, -1) { for_each_acpi_dev_match(adev, cfg->hid, NULL, -1) {
#else
while (true) {
#endif
if (!ACPI_PTR(adev->status.enabled)) if (!ACPI_PTR(adev->status.enabled))
continue; continue;
@ -768,15 +752,10 @@ static int ipu_bridge_ivsc_is_ready(void)
unsigned int i; unsigned int i;
for (i = 0; i < ARRAY_SIZE(ipu_supported_sensors); i++) { for (i = 0; i < ARRAY_SIZE(ipu_supported_sensors); i++) {
#if IS_ENABLED(CONFIG_ACPI)
const struct ipu_sensor_config *cfg = const struct ipu_sensor_config *cfg =
&ipu_supported_sensors[i]; &ipu_supported_sensors[i];
for_each_acpi_dev_match(sensor_adev, cfg->hid, NULL, -1) { 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)) if (!ACPI_PTR(sensor_adev->status.enabled))
continue; 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. * no connectable, the port would be not used.
*/ */
status = acpi_get_physical_device_location(handle, &pld); if (acpi_get_physical_device_location(handle, &pld) && pld)
if (ACPI_SUCCESS(status) && pld)
port_dev->location = USB_ACPI_LOCATION_VALID | port_dev->location = USB_ACPI_LOCATION_VALID |
pld->group_token << 8 | pld->group_position; 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, acpi_evaluate_ost(acpi_handle handle, u32 source_event, u32 status_code,
struct acpi_buffer *status_buf); 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); bool acpi_has_method(acpi_handle handle, char *name);
acpi_status acpi_execute_simple_method(acpi_handle handle, char *method, acpi_status acpi_execute_simple_method(acpi_handle handle, char *method,
u64 arg); 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, union acpi_object *acpi_evaluate_dsm(acpi_handle handle, const guid_t *guid,
u64 rev, u64 func, union acpi_object *argv4); u64 rev, u64 func, union acpi_object *argv4);
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
bool
acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld);
static inline union acpi_object * static inline union acpi_object *
acpi_evaluate_dsm_typed(acpi_handle handle, const guid_t *guid, u64 rev, acpi_evaluate_dsm_typed(acpi_handle handle, const guid_t *guid, u64 rev,
u64 func, union acpi_object *argv4, 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 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 /* CONFIG_ACPI */
#endif /*__ACPI_BUS_H__*/ #endif /*__ACPI_BUS_H__*/

View File

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