Skip to content

Commit d1ddf94

Browse files
committed
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
4 parents 5e90198 + 02915b4 + c759bc8 + 84524b1 commit d1ddf94

File tree

12 files changed

+58
-58
lines changed

12 files changed

+58
-58
lines changed

drivers/acpi/battery.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ static void battery_hook_unregister_unlocked(struct acpi_battery_hook *hook)
717717
}
718718
list_del_init(&hook->list);
719719

720-
pr_info("extension unregistered: %s\n", hook->name);
720+
pr_info("hook unregistered: %s\n", hook->name);
721721
}
722722

723723
void battery_hook_unregister(struct acpi_battery_hook *hook)
@@ -751,18 +751,18 @@ void battery_hook_register(struct acpi_battery_hook *hook)
751751
if (hook->add_battery(battery->bat, hook)) {
752752
/*
753753
* If a add-battery returns non-zero,
754-
* the registration of the extension has failed,
754+
* the registration of the hook has failed,
755755
* and we will not add it to the list of loaded
756756
* hooks.
757757
*/
758-
pr_err("extension failed to load: %s", hook->name);
758+
pr_err("hook failed to load: %s", hook->name);
759759
battery_hook_unregister_unlocked(hook);
760760
goto end;
761761
}
762762

763763
power_supply_changed(battery->bat);
764764
}
765-
pr_info("new extension: %s\n", hook->name);
765+
pr_info("new hook: %s\n", hook->name);
766766
end:
767767
mutex_unlock(&hook_mutex);
768768
}
@@ -805,10 +805,10 @@ static void battery_hook_add_battery(struct acpi_battery *battery)
805805
list_for_each_entry_safe(hook_node, tmp, &battery_hook_list, list) {
806806
if (hook_node->add_battery(battery->bat, hook_node)) {
807807
/*
808-
* The notification of the extensions has failed, to
809-
* prevent further errors we will unload the extension.
808+
* The notification of the hook has failed, to
809+
* prevent further errors we will unload the hook.
810810
*/
811-
pr_err("error in extension, unloading: %s",
811+
pr_err("error in hook, unloading: %s",
812812
hook_node->name);
813813
battery_hook_unregister_unlocked(hook_node);
814814
}

drivers/acpi/bgrt.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ BGRT_SHOW(type, image_type);
2929
BGRT_SHOW(xoffset, image_offset_x);
3030
BGRT_SHOW(yoffset, image_offset_y);
3131

32-
static BIN_ATTR_SIMPLE_RO(image);
32+
static __ro_after_init BIN_ATTR_SIMPLE_RO(image);
3333

3434
static struct attribute *bgrt_attributes[] = {
3535
&bgrt_attr_version.attr,
@@ -40,14 +40,14 @@ static struct attribute *bgrt_attributes[] = {
4040
NULL,
4141
};
4242

43-
static struct bin_attribute *bgrt_bin_attributes[] = {
43+
static const struct bin_attribute *const bgrt_bin_attributes[] = {
4444
&bin_attr_image,
4545
NULL,
4646
};
4747

4848
static const struct attribute_group bgrt_attribute_group = {
4949
.attrs = bgrt_attributes,
50-
.bin_attrs = bgrt_bin_attributes,
50+
.bin_attrs_new = bgrt_bin_attributes,
5151
};
5252

5353
int __init acpi_parse_bgrt(struct acpi_table_header *table)

drivers/acpi/fan_core.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,19 +371,25 @@ static int acpi_fan_probe(struct platform_device *pdev)
371371
result = sysfs_create_link(&pdev->dev.kobj,
372372
&cdev->device.kobj,
373373
"thermal_cooling");
374-
if (result)
374+
if (result) {
375375
dev_err(&pdev->dev, "Failed to create sysfs link 'thermal_cooling'\n");
376+
goto err_unregister;
377+
}
376378

377379
result = sysfs_create_link(&cdev->device.kobj,
378380
&pdev->dev.kobj,
379381
"device");
380382
if (result) {
381383
dev_err(&pdev->dev, "Failed to create sysfs link 'device'\n");
382-
goto err_end;
384+
goto err_remove_link;
383385
}
384386

385387
return 0;
386388

389+
err_remove_link:
390+
sysfs_remove_link(&pdev->dev.kobj, "thermal_cooling");
391+
err_unregister:
392+
thermal_cooling_device_unregister(cdev);
387393
err_end:
388394
if (fan->acpi4)
389395
acpi_fan_delete_attributes(device);

drivers/acpi/mipi-disco-img.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,7 @@ static void init_crs_csi2_swnodes(struct crs_csi2 *csi2)
624624
if (!fwnode_property_present(adev_fwnode, "rotation")) {
625625
struct acpi_pld_info *pld;
626626

627-
status = acpi_get_physical_device_location(handle, &pld);
628-
if (ACPI_SUCCESS(status)) {
627+
if (acpi_get_physical_device_location(handle, &pld)) {
629628
swnodes->dev_props[NEXT_PROPERTY(prop_index, DEV_ROTATION)] =
630629
PROPERTY_ENTRY_U32("rotation",
631630
pld->rotation * 45U);

drivers/acpi/scan.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -723,10 +723,8 @@ int acpi_tie_acpi_dev(struct acpi_device *adev)
723723
static void acpi_store_pld_crc(struct acpi_device *adev)
724724
{
725725
struct acpi_pld_info *pld;
726-
acpi_status status;
727726

728-
status = acpi_get_physical_device_location(adev->handle, &pld);
729-
if (ACPI_FAILURE(status))
727+
if (!acpi_get_physical_device_location(adev->handle, &pld))
730728
return;
731729

732730
adev->pld_crc = crc32(~0, pld, sizeof(*pld));

drivers/acpi/sysfs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ struct acpi_data_attr {
319319
};
320320

321321
static ssize_t acpi_table_show(struct file *filp, struct kobject *kobj,
322-
struct bin_attribute *bin_attr, char *buf,
322+
const struct bin_attribute *bin_attr, char *buf,
323323
loff_t offset, size_t count)
324324
{
325325
struct acpi_table_attr *table_attr =
@@ -372,7 +372,7 @@ static int acpi_table_attr_init(struct kobject *tables_obj,
372372
}
373373

374374
table_attr->attr.size = table_header->length;
375-
table_attr->attr.read = acpi_table_show;
375+
table_attr->attr.read_new = acpi_table_show;
376376
table_attr->attr.attr.name = table_attr->filename;
377377
table_attr->attr.attr.mode = 0400;
378378

@@ -412,7 +412,7 @@ acpi_status acpi_sysfs_table_handler(u32 event, void *table, void *context)
412412
}
413413

414414
static ssize_t acpi_data_show(struct file *filp, struct kobject *kobj,
415-
struct bin_attribute *bin_attr, char *buf,
415+
const struct bin_attribute *bin_attr, char *buf,
416416
loff_t offset, size_t count)
417417
{
418418
struct acpi_data_attr *data_attr;
@@ -495,7 +495,7 @@ static int acpi_table_data_init(struct acpi_table_header *th)
495495
if (!data_attr)
496496
return -ENOMEM;
497497
sysfs_attr_init(&data_attr->attr.attr);
498-
data_attr->attr.read = acpi_data_show;
498+
data_attr->attr.read_new = acpi_data_show;
499499
data_attr->attr.attr.mode = 0400;
500500
return acpi_data_objs[i].fn(th, data_attr);
501501
}

drivers/acpi/utils.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,17 +494,16 @@ bool acpi_device_dep(acpi_handle target, acpi_handle match)
494494
}
495495
EXPORT_SYMBOL_GPL(acpi_device_dep);
496496

497-
acpi_status
497+
bool
498498
acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld)
499499
{
500500
acpi_status status;
501501
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
502502
union acpi_object *output;
503503

504504
status = acpi_evaluate_object(handle, "_PLD", NULL, &buffer);
505-
506505
if (ACPI_FAILURE(status))
507-
return status;
506+
return false;
508507

509508
output = buffer.pointer;
510509

@@ -523,7 +522,7 @@ acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld
523522

524523
out:
525524
kfree(buffer.pointer);
526-
return status;
525+
return ACPI_SUCCESS(status);
527526
}
528527
EXPORT_SYMBOL(acpi_get_physical_device_location);
529528

drivers/base/physical_location.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@
1313
bool dev_add_physical_location(struct device *dev)
1414
{
1515
struct acpi_pld_info *pld;
16-
acpi_status status;
1716

1817
if (!has_acpi_companion(dev))
1918
return false;
2019

21-
status = acpi_get_physical_device_location(ACPI_HANDLE(dev), &pld);
22-
if (ACPI_FAILURE(status))
20+
if (!acpi_get_physical_device_location(ACPI_HANDLE(dev), &pld))
2321
return false;
2422

2523
dev->physical_location =

drivers/media/pci/intel/ipu-bridge.c

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* Author: Dan Scally <djrscally@gmail.com> */
33

44
#include <linux/acpi.h>
5+
#include <acpi/acpi_bus.h>
56
#include <linux/cleanup.h>
67
#include <linux/device.h>
78
#include <linux/i2c.h>
@@ -107,7 +108,6 @@ static const char * const ipu_vcm_types[] = {
107108
"lc898212axb",
108109
};
109110

110-
#if IS_ENABLED(CONFIG_ACPI)
111111
/*
112112
* Used to figure out IVSC acpi device by ipu_bridge_get_ivsc_acpi_dev()
113113
* instead of device and driver match to probe IVSC device.
@@ -127,24 +127,18 @@ static struct acpi_device *ipu_bridge_get_ivsc_acpi_dev(struct acpi_device *adev
127127
const struct acpi_device_id *acpi_id = &ivsc_acpi_ids[i];
128128
struct acpi_device *consumer, *ivsc_adev;
129129

130-
acpi_handle handle = acpi_device_handle(adev);
130+
acpi_handle handle = acpi_device_handle(ACPI_PTR(adev));
131131
for_each_acpi_dev_match(ivsc_adev, acpi_id->id, NULL, -1)
132132
/* camera sensor depends on IVSC in DSDT if exist */
133133
for_each_acpi_consumer_dev(ivsc_adev, consumer)
134-
if (consumer->handle == handle) {
134+
if (ACPI_PTR(consumer->handle) == handle) {
135135
acpi_dev_put(consumer);
136136
return ivsc_adev;
137137
}
138138
}
139139

140140
return NULL;
141141
}
142-
#else
143-
static struct acpi_device *ipu_bridge_get_ivsc_acpi_dev(struct acpi_device *adev)
144-
{
145-
return NULL;
146-
}
147-
#endif
148142

149143
static int ipu_bridge_match_ivsc_dev(struct device *dev, const void *adev)
150144
{
@@ -259,12 +253,8 @@ static enum v4l2_fwnode_orientation ipu_bridge_parse_orientation(struct acpi_dev
259253
{
260254
enum v4l2_fwnode_orientation orientation;
261255
struct acpi_pld_info *pld = NULL;
262-
acpi_status status = AE_ERROR;
263256

264-
#if IS_ENABLED(CONFIG_ACPI)
265-
status = acpi_get_physical_device_location(adev->handle, &pld);
266-
#endif
267-
if (ACPI_FAILURE(status)) {
257+
if (!acpi_get_physical_device_location(ACPI_PTR(adev->handle), &pld)) {
268258
dev_warn(ADEV_DEV(adev), "_PLD call failed, using default orientation\n");
269259
return V4L2_FWNODE_ORIENTATION_EXTERNAL;
270260
}
@@ -498,9 +488,7 @@ static void ipu_bridge_create_connection_swnodes(struct ipu_bridge *bridge,
498488
if (sensor->csi_dev) {
499489
const char *device_hid = "";
500490

501-
#if IS_ENABLED(CONFIG_ACPI)
502491
device_hid = acpi_device_hid(sensor->ivsc_adev);
503-
#endif
504492

505493
snprintf(sensor->ivsc_name, sizeof(sensor->ivsc_name), "%s-%u",
506494
device_hid, sensor->link);
@@ -671,11 +659,7 @@ static int ipu_bridge_connect_sensor(const struct ipu_sensor_config *cfg,
671659
struct acpi_device *adev = NULL;
672660
int ret;
673661

674-
#if IS_ENABLED(CONFIG_ACPI)
675662
for_each_acpi_dev_match(adev, cfg->hid, NULL, -1) {
676-
#else
677-
while (true) {
678-
#endif
679663
if (!ACPI_PTR(adev->status.enabled))
680664
continue;
681665

@@ -768,15 +752,10 @@ static int ipu_bridge_ivsc_is_ready(void)
768752
unsigned int i;
769753

770754
for (i = 0; i < ARRAY_SIZE(ipu_supported_sensors); i++) {
771-
#if IS_ENABLED(CONFIG_ACPI)
772755
const struct ipu_sensor_config *cfg =
773756
&ipu_supported_sensors[i];
774757

775758
for_each_acpi_dev_match(sensor_adev, cfg->hid, NULL, -1) {
776-
#else
777-
while (true) {
778-
sensor_adev = NULL;
779-
#endif
780759
if (!ACPI_PTR(sensor_adev->status.enabled))
781760
continue;
782761

drivers/usb/core/usb-acpi.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,7 @@ usb_acpi_get_connect_type(struct usb_port *port_dev, acpi_handle *handle)
213213
* no connectable, the port would be not used.
214214
*/
215215

216-
status = acpi_get_physical_device_location(handle, &pld);
217-
if (ACPI_SUCCESS(status) && pld)
216+
if (acpi_get_physical_device_location(handle, &pld) && pld)
218217
port_dev->location = USB_ACPI_LOCATION_VALID |
219218
pld->group_token << 8 | pld->group_position;
220219

0 commit comments

Comments
 (0)