The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=a12d069ef37fd60538b6f46372b194e6cf117250
commit a12d069ef37fd60538b6f46372b194e6cf117250 Author: Olivier Certner <[email protected]> AuthorDate: 2026-06-03 20:30:22 +0000 Commit: Olivier Certner <[email protected]> CommitDate: 2026-06-22 21:40:08 +0000 acpi: Constify thanks to AcpiGetHandle() taking a constant pathname Make the ACPI interface's functions evaluate_object() and get_property() take a constant pathname (by substituting ACPI_STRING with 'const char *'). This allows to remove some __DECONST(). No functional change (intended). Reviewed by: obiwac Event: Halifax Hackathon 202606 Sponsored by: The FreeBSD Foundation Pull Request: https://github.com/OlCe2/freebsd-src/pull/8 --- sys/dev/acpica/acpi.c | 24 +++++++++--------------- sys/dev/acpica/acpi_if.m | 8 ++++---- sys/dev/acpica/acpivar.h | 6 +++--- 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index 7103eea16053..48d868b6ac00 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -1946,7 +1946,7 @@ acpi_device_id_probe(device_t bus, device_t dev, char **ids, char **match) } static ACPI_STATUS -acpi_device_eval_obj(device_t bus, device_t dev, ACPI_STRING pathname, +acpi_device_eval_obj(device_t bus, device_t dev, const char *pathname, ACPI_OBJECT_LIST *parameters, ACPI_BUFFER *ret) { ACPI_HANDLE h; @@ -1955,11 +1955,12 @@ acpi_device_eval_obj(device_t bus, device_t dev, ACPI_STRING pathname, h = ACPI_ROOT_OBJECT; else if ((h = acpi_get_handle(dev)) == NULL) return (AE_BAD_PARAMETER); - return (AcpiEvaluateObject(h, pathname, parameters, ret)); + return (AcpiEvaluateObject(h, __DECONST(char *, pathname), parameters, + ret)); } static ACPI_STATUS -acpi_device_get_prop(device_t bus, device_t dev, ACPI_STRING propname, +acpi_device_get_prop(device_t bus, device_t dev, const char *propname, const ACPI_OBJECT **value) { const ACPI_OBJECT *pkg, *name, *val; @@ -2068,8 +2069,7 @@ acpi_bus_get_prop(device_t bus, device_t child, const char *propname, ACPI_STATUS status; const ACPI_OBJECT *obj; - status = acpi_device_get_prop(bus, child, __DECONST(char *, propname), - &obj); + status = acpi_device_get_prop(bus, child, propname, &obj); if (ACPI_FAILURE(status)) return (-1); @@ -2114,8 +2114,7 @@ acpi_bus_get_prop(device_t bus, device_t child, const char *propname, case ACPI_TYPE_PACKAGE: if (propvalue != NULL && size >= sizeof(ACPI_OBJECT *)) { - *((ACPI_OBJECT **) propvalue) = - __DECONST(ACPI_OBJECT *, obj); + *((const ACPI_OBJECT **) propvalue) = obj; } return (sizeof(ACPI_OBJECT *)); @@ -2844,7 +2843,7 @@ acpi_MatchHid(ACPI_HANDLE h, const char *hid) * or one if its parents. */ ACPI_STATUS -acpi_GetHandleInScope(ACPI_HANDLE parent, char *path, ACPI_HANDLE *result) +acpi_GetHandleInScope(ACPI_HANDLE parent, const char *path, ACPI_HANDLE *result) { ACPI_HANDLE r; ACPI_STATUS status; @@ -2866,8 +2865,7 @@ acpi_GetHandleInScope(ACPI_HANDLE parent, char *path, ACPI_HANDLE *result) } ACPI_STATUS -acpi_GetProperty(device_t dev, ACPI_STRING propname, - const ACPI_OBJECT **value) +acpi_GetProperty(device_t dev, const char *propname, const ACPI_OBJECT **value) { device_t bus = device_get_parent(dev); @@ -4328,14 +4326,10 @@ acpi_lookup(void *arg, const char *name, device_t *dev) * starts with '\'. We could restrict this to \_SB and friends, * but see acpi_probe_children() for notes on why we scan the entire * namespace for devices. - * - * XXX: The pathname argument to AcpiGetHandle() should be fixed to - * be const. */ if (name[0] != '\\') return; - if (ACPI_FAILURE(AcpiGetHandle(ACPI_ROOT_OBJECT, __DECONST(char *, name), - &handle))) + if (ACPI_FAILURE(AcpiGetHandle(ACPI_ROOT_OBJECT, name, &handle))) return; *dev = acpi_get_device(handle); } diff --git a/sys/dev/acpica/acpi_if.m b/sys/dev/acpica/acpi_if.m index 6b7a770f8812..b9960995a052 100644 --- a/sys/dev/acpica/acpi_if.m +++ b/sys/dev/acpica/acpi_if.m @@ -102,7 +102,7 @@ METHOD int id_probe { # device_t dev: evaluate the object relative to this device's handle. # Specify NULL to begin the search at the ACPI root. # -# ACPI_STRING pathname: absolute or relative path to this object +# const char *pathname: absolute or relative path to this object # # ACPI_OBJECT_LIST *parameters: array of arguments to pass to the object. # Specify NULL if there are none. @@ -115,7 +115,7 @@ METHOD int id_probe { METHOD ACPI_STATUS evaluate_object { device_t bus; device_t dev; - ACPI_STRING pathname; + const char *pathname; ACPI_OBJECT_LIST *parameters; ACPI_BUFFER *ret; }; @@ -127,7 +127,7 @@ METHOD ACPI_STATUS evaluate_object { # # device_t dev: find property for this device's handle. # -# const ACPI_STRING propname: name of the property +# const char *propname: name of the property # # const ACPI_OBJECT **value: property value output # Specify NULL if ignored @@ -137,7 +137,7 @@ METHOD ACPI_STATUS evaluate_object { METHOD ACPI_STATUS get_property { device_t bus; device_t dev; - ACPI_STRING propname; + const char *propname; const ACPI_OBJECT **value; }; diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h index 01e7ddcd74cd..5d1415a8f543 100644 --- a/sys/dev/acpica/acpivar.h +++ b/sys/dev/acpica/acpivar.h @@ -365,9 +365,9 @@ typedef void acpi_subtable_handler(ACPI_SUBTABLE_HEADER *, void *); BOOLEAN acpi_DeviceIsPresent(device_t dev); BOOLEAN acpi_BatteryIsPresent(device_t dev); -ACPI_STATUS acpi_GetHandleInScope(ACPI_HANDLE parent, char *path, +ACPI_STATUS acpi_GetHandleInScope(ACPI_HANDLE parent, const char *path, ACPI_HANDLE *result); -ACPI_STATUS acpi_GetProperty(device_t dev, ACPI_STRING propname, +ACPI_STATUS acpi_GetProperty(device_t dev, const char *propname, const ACPI_OBJECT **value); ACPI_BUFFER *acpi_AllocBuffer(int size); ACPI_STATUS acpi_ConvertBufferToInteger(ACPI_BUFFER *bufp, @@ -416,7 +416,7 @@ int acpi_MatchHid(ACPI_HANDLE h, const char *hid); #define ACPI_MATCHHID_CID 2 static __inline bool -acpi_HasProperty(device_t dev, ACPI_STRING propname) +acpi_HasProperty(device_t dev, const char *propname) { return ACPI_SUCCESS(acpi_GetProperty(dev, propname, NULL));
