aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/utils.c
Commit message (Collapse)AuthorAgeFilesLines
* ACPI: bus: change the prototype for acpi_get_physical_device_locationRicardo Ribalda2024-12-191-4/+3
| | | | | | | | | | | | | | | It generally is not OK to use acpi_status and/or AE_ error codes without CONFIG_ACPI and they really only should be used in drivers/acpi/ (and not everywhere in there for that matter). So acpi_get_physical_device_location() needs to be redefined to return something different from acpi_status (preferably bool) in order to be used in !CONFIG_ACPI code. Suggested-by: Rafael J. Wysocki <[email protected]> Signed-off-by: Ricardo Ribalda <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Rafael J. Wysocki <[email protected]>
* ACPI: utils: Add rev/func to message when acpi_evaluate_dsm() failsDavid Wang2024-08-291-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When acpi_evaluate_dsm() fails, the warning message lacks the rev and func information which is available and helpful. For example, iwlwifi would make _DSM queries for lari config, and when it fails, all warning messages are all the same: ACPI: \: failed to evaluate _DSM bf0212f2-788f-c64d-a5b3-1f738e285ade (0x1001) ACPI: \: failed to evaluate _DSM bf0212f2-788f-c64d-a5b3-1f738e285ade (0x1001) ACPI: \: failed to evaluate _DSM bf0212f2-788f-c64d-a5b3-1f738e285ade (0x1001) ACPI: \: failed to evaluate _DSM bf0212f2-788f-c64d-a5b3-1f738e285ade (0x1001) ACPI: \: failed to evaluate _DSM bf0212f2-788f-c64d-a5b3-1f738e285ade (0x1001) ACPI: \: failed to evaluate _DSM bf0212f2-788f-c64d-a5b3-1f738e285ade (0x1001) ACPI: \: failed to evaluate _DSM bf0212f2-788f-c64d-a5b3-1f738e285ade (0x1001) ACPI: \: failed to evaluate _DSM bf0212f2-788f-c64d-a5b3-1f738e285ade (0x1001) With this change, the warnings would be more informative: ACPI: \: failed to evaluate _DSM bf0212f2-788f-c64d-a5b3-1f738e285ade rev:0 func:1 (0x1001) ACPI: \: failed to evaluate _DSM bf0212f2-788f-c64d-a5b3-1f738e285ade rev:0 func:6 (0x1001) ACPI: \: failed to evaluate _DSM bf0212f2-788f-c64d-a5b3-1f738e285ade rev:0 func:7 (0x1001) ACPI: \: failed to evaluate _DSM bf0212f2-788f-c64d-a5b3-1f738e285ade rev:0 func:8 (0x1001) ACPI: \: failed to evaluate _DSM bf0212f2-788f-c64d-a5b3-1f738e285ade rev:0 func:3 (0x1001) ACPI: \: failed to evaluate _DSM bf0212f2-788f-c64d-a5b3-1f738e285ade rev:0 func:9 (0x1001) ACPI: \: failed to evaluate _DSM bf0212f2-788f-c64d-a5b3-1f738e285ade rev:0 func:10 (0x1001) ACPI: \: failed to evaluate _DSM bf0212f2-788f-c64d-a5b3-1f738e285ade rev:0 func:12 (0x1001) Signed-off-by: David Wang <[email protected]> Link: https://patch.msgid.link/[email protected] [ rjw: Subject and changelog edits ] Signed-off-by: Rafael J. Wysocki <[email protected]>
* ACPI: utils: introduce acpi_get_local_u64_address()Pierre-Louis Bossart2024-06-101-3/+13
| | | | | | | | | | | | | | | | | | | The ACPI _ADR is a 64-bit value. We changed the definitions in commit ca6f998cf9a2 ("ACPI: bus: change _ADR representation to 64 bits") but some helpers still assume the value is a 32-bit value. This patch adds a new helper to extract the full 64-bits. The existing 32-bit helper is kept for backwards-compatibility and cases where the _ADR is known to fit in a 32-bit value. Signed-off-by: Pierre-Louis Bossart <[email protected]> Reviewed-by: Péter Ujfalusi <[email protected]> Reviewed-by: Bard Liao <[email protected]> Acked-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Takashi Iwai <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
* ACPI: utils: Make acpi_handle_path() not staticSakari Ailus2024-02-151-1/+1
| | | | | | | | | acpi_handle_path() will soon be required for node name comparison elsewhere in ACPI framework. Remove the static keyword and add the prototype to include/linux/acpi.h. Signed-off-by: Sakari Ailus <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
* ACPI: utils: Introduce helper for _DEP list lookupRafael J. Wysocki2023-12-191-0/+34
| | | | | | | | | | | | | | The ACPI LPSS driver and the Surface platform driver code use almost the same code pattern for checking if one ACPI device is present in the list returned by _DEP for another ACPI device. To reduce the resulting code duplication, introduce a helper for that called acpi_device_dep() and invoke it from both places. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Mika Westerberg <[email protected]>
* ACPI: utils: Refine acpi_handle_list_equal() slightlyRafael J. Wysocki2023-12-151-1/+1
| | | | | | | | | | | | It is somewhat better to use the size of the first array element for computing the size of the entire array than to rely on the array element data type definition knowledge and the former is also consistent with the array allocation in acpi_evaluate_reference(), so modify the code accordingly. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <[email protected]>
* ACPI: utils: Return bool from acpi_evaluate_reference()Rafael J. Wysocki2023-12-151-20/+12
| | | | | | | | | | | | | | | | There are only 4 users of acpi_evaluate_reference() and none of them actually cares about the reason why it fails. All of them are only interested in whether or not it is successful, so it can return a bool value indicating that. Modify acpi_evaluate_reference() as per the observation above and update its callers accordingly so as to get rid of useless code and local variables. The observable behavior of the kernel is not expected to change after this modification of the code. Signed-off-by: Rafael J. Wysocki <[email protected]>
* ACPI: utils: Rearrange in acpi_evaluate_reference()Rafael J. Wysocki2023-12-151-34/+24
| | | | | | | | | | | | | | | | | | | | | | | The code in acpi_evaluate_reference() can be improved in some ways without changing its observable behavior. Among other things: * None of the local variables in that function except for buffer needs to be initialized. * The element local variable is only used in the for () loop block, so it can be defined there. * Multiple checks can be combined. * Code duplication related to error handling can be eliminated. * Redundant inner parens can be dropped. Modify the function as per the above. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <[email protected]>
* Merge back earlier acpi-utils material for v6.8.Rafael J. Wysocki2023-12-081-48/+0
|\
| * ACPI: bus: update acpi_dev_hid_uid_match() to support multiple typesRaag Jadav2023-12-061-29/+0
| | | | | | | | | | | | | | | | | | Now that we have _UID matching support for both integer and string types, we can support them into acpi_dev_hid_uid_match() helper as well. Signed-off-by: Raag Jadav <[email protected]> Reviewed-by: Mika Westerberg <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
| * ACPI: bus: update acpi_dev_uid_match() to support multiple typesRaag Jadav2023-12-061-19/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | According to the ACPI specification, a _UID object can evaluate to either a numeric value or a string. Update acpi_dev_uid_match() to support _UID matching for both integer and string types. Suggested-by: Mika Westerberg <[email protected]> Signed-off-by: Raag Jadav <[email protected]> [ rjw: Rename auxiliary macros, relocate kerneldoc comment ] Signed-off-by: Rafael J. Wysocki <[email protected]>
* | ACPI: utils: Fix error path in acpi_evaluate_reference()Rafael J. Wysocki2023-12-071-1/+1
|/ | | | | | | | | | | | | | | | | If a pointer to an uninitialized struct acpi_handle_list is passed to acpi_evaluate_reference() and it decides to bail out early, either because acpi_evaluate_object() fails, or because it produces invalid data, the handles pointer from the struct acpi_handle_list will be passed to kfree() and if it is not NULL, the kernel will crash on an attempt to free unallocated memory. Address this by moving the "end" label in acpi_evaluate_reference() to the end of the function, which is sufficient, because no cleanup is needed in that case. Fixes: 2e57d10a6591 ("ACPI: utils: Dynamically determine acpi_handle_list size") Signed-off-by: Rafael J. Wysocki <[email protected]> Tested-by: Woody Suwalski <[email protected]>
*-. Merge branches 'acpi-ec', 'acpi-sysfs', 'acpi-misc' and 'acpi-uid'Rafael J. Wysocki2023-10-261-6/+28
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Merge ACPI EC driver updates, ACPI sysfs interface updates, misc updates related to ACPI and changes related to ACPI _UID handling for 6.7-rc1: - Add EC GPE detection quirk for HP 250 G7 Notebook PC (Jonathan Denose). - Fix and clean up create_pnp_modalias() and create_of_modalias() (Christophe JAILLET). - Modify 2 pieces of code to use acpi_evaluate_dsm_typed() (Andy Shevchenko). - Define acpi_dev_uid_match() for matching _UID and use it in several places (Raag Jadav). - Use acpi_device_uid() for fetching _UID in 2 places (Raag Jadav). * acpi-ec: ACPI: EC: Add quirk for HP 250 G7 Notebook PC * acpi-sysfs: ACPI: sysfs: Clean up create_pnp_modalias() and create_of_modalias() ACPI: sysfs: Fix create_pnp_modalias() and create_of_modalias() * acpi-misc: ACPI: x86: s2idle: Switch to use acpi_evaluate_dsm_typed() ACPI: PCI: Switch to use acpi_evaluate_dsm_typed() * acpi-uid: perf: arm_cspmu: use acpi_dev_hid_uid_match() for matching _HID and _UID ACPI: x86: use acpi_dev_uid_match() for matching _UID ACPI: utils: use acpi_dev_uid_match() for matching _UID pinctrl: intel: use acpi_dev_uid_match() for matching _UID ACPI: utils: Introduce acpi_dev_uid_match() for matching _UID perf: qcom: use acpi_device_uid() for fetching _UID ACPI: sysfs: use acpi_device_uid() for fetching _UID
| | * ACPI: utils: use acpi_dev_uid_match() for matching _UIDRaag Jadav2023-10-241-2/+1
| | | | | | | | | | | | | | | | | | | | | Convert manual _UID references to use the standard ACPI helper. Signed-off-by: Raag Jadav <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
| | * ACPI: utils: Introduce acpi_dev_uid_match() for matching _UIDRaag Jadav2023-10-241-4/+27
| |/ | | | | | | | | | | | | | | | | Introduce acpi_dev_uid_match() helper that matches the device with supplied _UID string. Signed-off-by: Raag Jadav <[email protected]> Reviewed-by: Mika Westerberg <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
* | ACPI: utils: Remove redundant braces around individual statementJonathan Bergh2023-10-031-2/+1
| | | | | | | | | | | | | | | | | | Remove braces that are not required for a one-line statement which follows a control statement. Signed-off-by: Jonathan Bergh <[email protected]> [ rjw: Subject and changelog edits ] Signed-off-by: Rafael J. Wysocki <[email protected]>
* | ACPI: utils: Fix up white space in a few placesJonathan Bergh2023-10-031-2/+2
| | | | | | | | | | | | | | | | | | | | Fix up the following formatting issues flagged by checkpatch: * Remove indentation before goto label * Remove whitespace ahead of a comma in parameter list Signed-off-by: Jonathan Bergh <[email protected]> [ rjw: Subject and changelog edits ] Signed-off-by: Rafael J. Wysocki <[email protected]>
* | ACPI: utils: Dynamically determine acpi_handle_list sizeRafael J. Wysocki2023-09-291-2/+59
|/ | | | | | | | | | | | | | | | | | | | Address a long-standing "TBD" comment in the ACPI headers regarding the number of handles in struct acpi_handle_list. The number 10, which along with the comment dates back to 2.4.23, seems like it may have been arbitrarily chosen and isn't sufficient in all cases [1]. Finally change the code to dynamically determine the size of the handles table in struct acpi_handle_list and allocate it accordingly. Update the users of to struct acpi_handle_list to take the additional dynamic allocation into account. Link: https://lore.kernel.org/linux-acpi/[email protected] # [1] Co-developed-by: Vicki Pfau <[email protected]> Signed-off-by: Vicki Pfau <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
* Merge branch 'acpi-uid'Rafael J. Wysocki2022-10-031-0/+24
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Merge ACPI _UID handling unification changes for 6.1-rc1: - Introduce acpi_dev_uid_to_integer() to convert a _UID string into an integer value (Andy Shevchenko). - Use acpi_dev_uid_to_integer() in several places to unify _UID handling (Andy Shevchenko). * acpi-uid: efi/dev-path-parser: Refactor _UID handling to use acpi_dev_uid_to_integer() spi: pxa2xx: Refactor _UID handling to use acpi_dev_uid_to_integer() perf: qcom_l2_pmu: Refactor _UID handling to use acpi_dev_uid_to_integer() i2c: mlxbf: Refactor _UID handling to use acpi_dev_uid_to_integer() i2c: amd-mp2-plat: Refactor _UID handling to use acpi_dev_uid_to_integer() ACPI: x86: Refactor _UID handling to use acpi_dev_uid_to_integer() ACPI: LPSS: Refactor _UID handling to use acpi_dev_uid_to_integer() ACPI: utils: Add acpi_dev_uid_to_integer() helper to get _UID as integer
| * ACPI: utils: Add acpi_dev_uid_to_integer() helper to get _UID as integerAndy Shevchenko2022-09-191-0/+24
| | | | | | | | | | | | | | | | | | Some users interpret _UID only as integer and for them it's easier to have an integer representation of _UID. Add respective helper for that. Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
* | ACPI: move from strlcpy() with unused retval to strscpy()Wolfram Sang2022-08-231-3/+3
|/ | | | | | | | | | Follow the advice of the below link and prefer 'strscpy' in this subsystem. Conversion is 1:1 because the return value is not used. Generated by a coccinelle script. Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/ Signed-off-by: Wolfram Sang <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
* ACPI: utils: Add api to read _SUB from ACPIStefan Binding2022-07-151-0/+38
| | | | | | | | | Add a wrapper function to read the _SUB string from ACPI. Signed-off-by: Stefan Binding <[email protected]> Acked-by: Rafael J. Wysocki <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
* ACPI: utils: include UUID in _DSM evaluation warningMichael Niewöhner2022-05-191-1/+1
| | | | | | | | | | | | The _DSM evaluation warning in its current form is not very helpful, as it lacks any specific information: ACPI: \: failed to evaluate _DSM (0x1001) Thus, include the UUID of the missing _DSM: ACPI: \: failed to evaluate _DSM bf0212f2-... (0x1001) Signed-off-by: Michael Niewöhner <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
* ACPI: utils: Fix reference counting in for_each_acpi_dev_match()Andy Shevchenko2021-07-191-4/+3
| | | | | | | | | | | | | | Currently it's possible to iterate over the dangling pointer in case the device suddenly disappears. This may happen becase callers put it at the end of a loop. Instead, let's move that call inside acpi_dev_get_next_match_dev(). Fixes: 803abec64ef9 ("media: ipu3-cio2: Add cio2-bridge to ipu3-cio2 driver") Fixes: bf263f64e804 ("media: ACPI / bus: Add acpi_dev_get_next_match_dev() and helper macro") Fixes: edbd1bc4951e ("efi/dev-path-parser: Switch to use for_each_acpi_dev_match()") Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Daniel Scally <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
* ACPI: utils: Introduce acpi_get_local_address()Calvin Johnson2021-06-111-0/+14
| | | | | | | | | | | Introduce a wrapper around the _ADR evaluation. Signed-off-by: Calvin Johnson <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Ioana Ciornei <[email protected]> Acked-by: Rafael J. Wysocki <[email protected]> Acked-by: Grant Likely <[email protected]> Signed-off-by: David S. Miller <[email protected]>
*---. Merge branches 'acpi-cppc', 'acpi-video' and 'acpi-utils'Rafael J. Wysocki2021-04-261-4/+19
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * acpi-cppc: ACPI: CPPC: Replace cppc_attr with kobj_attribute ACPI: CPPC: Add emtpy stubs of functions for CONFIG_ACPI_CPPC_LIB unset * acpi-video: ACPI: video: use native backlight for GA401/GA502/GA503 ACPI: video: Check LCD flag on ACPI-reduced-hardware devices ACPI: utils: Add acpi_reduced_hardware() helper * acpi-utils: ACPI: utils: Capitalize abbreviations in the comments ACPI: utils: Document for_each_acpi_dev_match() macro
| | | * ACPI: utils: Capitalize abbreviations in the commentsAndy Shevchenko2021-04-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The DSDT and ACPI should be capitalized. Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
| | | * ACPI: utils: Document for_each_acpi_dev_match() macroAndy Shevchenko2021-04-131-2/+6
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The macro requires to call acpi_dev_put() on each iteration. Due to this it doesn't tolerate sudden disappearence of the devices. Document all these nuances to prevent users blindly call it without understanding the possible issues. While at it, add the note to the acpi_dev_get_next_match_dev() and advertise acpi_dev_put() instead of put_device() in the whole family of the helper functions. Fixes: bf263f64e804 ("media: ACPI / bus: Add acpi_dev_get_next_match_dev() and helper macro") Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
| | * ACPI: utils: Add acpi_reduced_hardware() helperHans de Goede2021-04-081-0/+11
| |/ | | | | | | | | | | | | | | Add a getter for the acpi_gbl_reduced_hardware variable so that modules can check if they are running on an ACPI reduced-hw platform or not. Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
* / ACPI: utils: Introduce acpi_evaluation_failure_warn()Rafael J. Wysocki2021-03-081-0/+14
|/ | | | | | | | | | | Quite a few users of ACPI objects want to log a warning message if the evaluation fails which is a repeating pattern, so introduce a helper function for that purpose and convert some code where it is open-coded to using it. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <[email protected]>
* Merge tag 'media/v5.12-1' of ↵Linus Torvalds2021-02-211-4/+26
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media Pull media updates from Mauro Carvalho Chehab: - some core fixes in VB2 mem2mem support - some improvements and cleanups in V4L2 async kAPI - newer controls in V4L2 API for H-264 and HEVC codecs - allegro-dvt driver was promoted from staging - new i2c sendor drivers: imx334, ov5648, ov8865 - new automobile camera module: rdacm21 - ipu3 cio2 driver started gained support for some ACPI BIOSes - new ATSC frontend: MaxLinear mxl692 VSB tuner/demod - the SMIA/CCS driver gained more support for CSS standard - several driver fixes, updates and improvements * tag 'media/v5.12-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (362 commits) media: v4l: async: Fix kerneldoc documentation for async functions media: i2c: max9271: Add MODULE_* macros media: i2c: Kconfig: Make MAX9271 a module media: imx334: 'ret' is uninitialized, should have been PTR_ERR() media: i2c: Add imx334 camera sensor driver media: dt-bindings: media: Add bindings for imx334 media: ov8856: Configure sensor for GRBG Bayer for all modes media: i2c: imx219: Implement V4L2_CID_LINK_FREQ control media: ov5675: fix vflip/hflip control media: ipu3-cio2: Build bridge only if ACPI is enabled media: Remove the legacy v4l2-clk API media: ov6650: Use the generic clock framework media: mt9m111: Use the generic clock framework media: ov9640: Use the generic clock framework media: pxa_camera: Drop the v4l2-clk clock register media: mach-pxa: Register the camera sensor fixed-rate clock media: i2c: imx258: get clock from device properties and enable it via runtime PM media: i2c: imx258: simplify getting state container media: i2c: imx258: add support for binding via device tree media: dt-bindings: media: imx258: add bindings for IMX258 sensor ...
| * media: ACPI / bus: Add acpi_dev_get_next_match_dev() and helper macroDaniel Scally2021-01-261-4/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To ensure we handle situations in which multiple sensors of the same model (and therefore _HID) are present in a system, we need to be able to iterate over devices matching a known _HID but unknown _UID and _HRV - add acpi_dev_get_next_match_dev() to accommodate that possibility and change acpi_dev_get_first_match_dev() to simply call the new function with a NULL starting point. Add an iterator macro for convenience. Reviewed-by: Andy Shevchenko <[email protected]> Suggested-by: Andy Shevchenko <[email protected]> Signed-off-by: Daniel Scally <[email protected]> Acked-by: Rafael J. Wysocki <[email protected]> Signed-off-by: Sakari Ailus <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
* | ACPI: utils: Clean up printing messagesRafael J. Wysocki2021-02-041-38/+18
|/ | | | | | | | | | | | | Replace all of the ACPI_DEBUG_PRINT() instances in utils.c with pr_debug() and acpi_handle_debug(), drop the _COMPONENT and ACPI_MODULE_NAME() definitions that are not used any more and replace direct printk() invocations with pr_debug() calls (the log level in there is way excessive). Also add a special pr_fmt() definition, but this only affects the pr_debug() messages mentioned above. Signed-off-by: Rafael J. Wysocki <[email protected]>
* ACPI: utils: remove unreachable breaksTom Rix2020-10-221-4/+0
| | | | | | | | | A break following a return statement is pointless, so drop all of the breaks following return statements from this file. Signed-off-by: Tom Rix <[email protected]> [ rjw: Subject and changelog edits ] Signed-off-by: Rafael J. Wysocki <[email protected]>
* ACPI: utils: Add acpi_evaluate_reg() helperHans de Goede2020-05-091-0/+25
| | | | | | | | | | | | | | With a recent fix to the pinctrl-cherryview driver we now have 2 drivers open-coding the parameter building / passing for calling _REG on an ACPI handle. Add a helper for this, so that these 2 drivers can be converted to this helper. Suggested-by: Andy Shevchenko <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
* ACPI / utils: Introduce acpi_dev_hid_uid_match() helperAndy Shevchenko2019-10-151-0/+25
| | | | | | | | | | | There are users outside of ACPI realm which reimplementing the comparator function to check if the given device matches to given HID and UID. For better utilization, introduce a helper for everyone to use. Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Mika Westerberg <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
* ACPI / utils: Describe function parameters in kernel-docAndy Shevchenko2019-10-151-0/+7
| | | | | | | | | | | | | | | | | | | Kernel documentation script complains that some of the function parameters are not described: drivers/acpi/utils.c:462: warning: Function parameter or member 'handle' not described in 'acpi_handle_path' drivers/acpi/utils.c:484: warning: Function parameter or member 'level' not described in 'acpi_handle_printk' drivers/acpi/utils.c:484: warning: Function parameter or member 'handle' not described in 'acpi_handle_printk' drivers/acpi/utils.c:484: warning: Function parameter or member 'fmt' not described in 'acpi_handle_printk' drivers/acpi/utils.c:513: warning: Function parameter or member 'descriptor' not described in '__acpi_handle_debug' drivers/acpi/utils.c:513: warning: Function parameter or member 'handle' not described in '__acpi_handle_debug' drivers/acpi/utils.c:513: warning: Function parameter or member 'fmt' not described in '__acpi_handle_debug' Describe function parameters where it's appropriate. Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Mika Westerberg <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
* bus_find_device: Unify the match callback with class_find_deviceSuzuki K Poulose2019-06-241-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is an arbitrary difference between the prototypes of bus_find_device() and class_find_device() preventing their callers from passing the same pair of data and match() arguments to both of them, which is the const qualifier used in the prototype of class_find_device(). If that qualifier is also used in the bus_find_device() prototype, it will be possible to pass the same match() callback function to both bus_find_device() and class_find_device(), which will allow some optimizations to be made in order to avoid code duplication going forward. Also with that, constify the "data" parameter as it is passed as a const to the match function. For this reason, change the prototype of bus_find_device() to match the prototype of class_find_device() and adjust its callers to use the const qualifier in accordance with the new prototype of it. Cc: Alexander Shishkin <[email protected]> Cc: Andrew Lunn <[email protected]> Cc: Andreas Noever <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Bjorn Helgaas <[email protected]> Cc: Corey Minyard <[email protected]> Cc: Christian Borntraeger <[email protected]> Cc: David Kershner <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: David Airlie <[email protected]> Cc: Felipe Balbi <[email protected]> Cc: Frank Rowand <[email protected]> Cc: Grygorii Strashko <[email protected]> Cc: Harald Freudenberger <[email protected]> Cc: Hartmut Knaack <[email protected]> Cc: Heiko Stuebner <[email protected]> Cc: Jason Gunthorpe <[email protected]> Cc: Jonathan Cameron <[email protected]> Cc: "James E.J. Bottomley" <[email protected]> Cc: Len Brown <[email protected]> Cc: Mark Brown <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Michael Jamet <[email protected]> Cc: "Martin K. Petersen" <[email protected]> Cc: Peter Oberparleiter <[email protected]> Cc: Sebastian Ott <[email protected]> Cc: Srinivas Kandagatla <[email protected]> Cc: Yehezkel Bernat <[email protected]> Cc: [email protected] Acked-by: Corey Minyard <[email protected]> Acked-by: David Kershner <[email protected]> Acked-by: Mark Brown <[email protected]> Acked-by: Rafael J. Wysocki <[email protected]> Acked-by: Srinivas Kandagatla <[email protected]> Acked-by: Wolfram Sang <[email protected]> # for the I2C parts Acked-by: Rob Herring <[email protected]> Signed-off-by: Suzuki K Poulose <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
* acpi: utils: Cleanup acpi_dev_match_cbSuzuki K Poulose2019-06-241-6/+1
| | | | | | | | | | | | | | | | | | | | | The prototype of bus_find_device() will be unified with that of class_find_device() subsequently, but for this purpose the callback functions passed to it need to take (const void *) as the second argument. Consequently, they cannot modify the memory pointed to by that argument which currently is not the case for acpi_dev_match_cb(). However, acpi_dev_match_cb() really need not modify the "match" object passed to it, because acpi_dev_get_first_match_dev() which uses it via bus_find_device() can easily convert the result of bus_find_device() into the pointer to return. For this reason, update acpi_dev_match_cb() to avoid the redundant memory updates. Cc: Len Brown <[email protected]> Cc: [email protected] Signed-off-by: Suzuki K Poulose <[email protected]> Reviewed-by: Rafael J. Wysocki <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
* treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157Thomas Gleixner2019-05-301-14/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on 3 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version [author] [kishon] [vijay] [abraham] [i] [kishon]@[ti] [com] this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version [author] [graeme] [gregory] [gg]@[slimlogic] [co] [uk] [author] [kishon] [vijay] [abraham] [i] [kishon]@[ti] [com] [based] [on] [twl6030]_[usb] [c] [author] [hema] [hk] [hemahk]@[ti] [com] this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details extracted by the scancode license scanner the SPDX license identifier GPL-2.0-or-later has been chosen to replace the boilerplate/reference in 1105 file(s). Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Allison Randal <[email protected]> Reviewed-by: Richard Fontana <[email protected]> Reviewed-by: Kate Stewart <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
* ACPI / utils: Remove deprecated function since no user leftAndy Shevchenko2019-04-011-16/+0
| | | | | | | | | There is no more user of acpi_dev_get_first_match_name(), which is deprecated and has no user left, so, remove it for good. Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Mika Westerberg <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
* ACPI / utils: Introduce acpi_dev_get_first_match_dev() helperAndy Shevchenko2019-04-011-2/+22
| | | | | | | | | | | | | | The acpi_dev_get_first_match_name() is missing put_device() call and thus keeping reference counting unbalanced. In order to fix the issue introduce a new helper to convert existing users one-by-one to a better API. Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Reviewed-by: Mika Westerberg <[email protected]> Acked-by: Mark Brown <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
* ACPI / utils: Drop reference in test for device presenceAndy Shevchenko2019-03-191-0/+1
| | | | | | | | | | | | | | When commit 8661423eea1a ("ACPI / utils: Add new acpi_dev_present helper") introduced acpi_dev_present(), it missed the fact that bus_find_device() took a reference on the device found by it and the callers of acpi_dev_present() don't drop that reference. Drop the reference on the device in acpi_dev_present(). Fixes: 8661423eea1a ("ACPI / utils: Add new acpi_dev_present helper") Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
* ACPI: utils: Introduce acpi_dev_get_first_match_name()Andy Shevchenko2018-01-091-7/+34
| | | | | | | | | | | | | | | | | | | | | | Sometimes the user wants to have device name of the match rather than just checking if device present or not. To make life easier for such users introduce acpi_dev_get_first_match_name() helper based on code for acpi_dev_present(). For example, GPIO driver for Intel Merrifield needs to know the device name of pin control to be able to apply GPIO mapping table to the proper device. To be more consistent with the purpose rename struct acpi_dev_present_info -> struct acpi_dev_match_info acpi_dev_present_cb() -> acpi_dev_match_cb() in the utils.c file. Tested-by: Pierre-Louis Bossart <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
* ACPI / utils: Fix memory leak in acpi_evaluate_reference() error pathXiongfeng Wang2017-11-141-0/+1
| | | | | | | | | When package.count is larger than ACPI_MAX_HANDLES, buffer.pointer is not freed before the function returns AE_NO_MEMORY. Fix this possible memory leak by kfree'ing it. Signed-off-by: Xiongfeng Wang <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
* ACPI / blacklist: add acpi_match_platform_list()Toshi Kani2017-08-281-0/+36
| | | | | | | | | | | | | | | | | | ACPI OEM ID / OEM Table ID / Revision can be used to identify a platform based on ACPI firmware info. acpi_blacklisted(), intel_pstate_platform_pwr_mgmt_exists(), and some other funcs, have been using similar check to detect a list of platforms that require special handlings. Move the platform check in acpi_blacklisted() to a new common utility function, acpi_match_platform_list(), so that other drivers do not have to implement their own version. There is no change in functionality. Signed-off-by: Toshi Kani <[email protected]> Reviewed-by: Borislav Petkov <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
* ACPI: Switch to use generic guid_t in acpi_evaluate_dsm()Andy Shevchenko2017-06-071-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | acpi_evaluate_dsm() and friends take a pointer to a raw buffer of 16 bytes. Instead we convert them to use guid_t type. At the same time we convert current users. acpi_str_to_uuid() becomes useless after the conversion and it's safe to get rid of it. Acked-by: Rafael J. Wysocki <[email protected]> Cc: Borislav Petkov <[email protected]> Acked-by: Dan Williams <[email protected]> Cc: Amir Goldstein <[email protected]> Reviewed-by: Jarkko Sakkinen <[email protected]> Reviewed-by: Jani Nikula <[email protected]> Acked-by: Jani Nikula <[email protected]> Cc: Ben Skeggs <[email protected]> Acked-by: Benjamin Tissoires <[email protected]> Acked-by: Joerg Roedel <[email protected]> Acked-by: Adrian Hunter <[email protected]> Cc: Yisen Zhuang <[email protected]> Acked-by: Bjorn Helgaas <[email protected]> Acked-by: Felipe Balbi <[email protected]> Acked-by: Mathias Nyman <[email protected]> Reviewed-by: Heikki Krogerus <[email protected]> Acked-by: Mark Brown <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
* ACPI / utils: Add new acpi_dev_present helperHans de Goede2017-04-191-0/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | acpi_dev_found just iterates over all ACPI-ids and sees if one matches. This means that it will return true for devices which are in the DSDT but disabled (their _STA method returns 0). For some drivers it is useful to be able to check if a certain HID is not only present in the namespace, but also actually present as in acpi_device_is_present() will return true for the device. For example because if a certain device is present then the driver will want to use an extcon or IIO ADC channel provided by that device. This commit adds a new acpi_dev_present helper which drivers can use to this end. Like acpi_dev_found, acpi_dev_present take a HID as argument, but it also has 2 extra optional arguments to only check for an ACPI device with a specific UID and/or HRV value. This makes it more generic and allows it to replace custom code doing similar checks in several places. Arguably acpi_dev_present is what acpi_dev_found should have been, but there are too many users to just change acpi_dev_found without the risk of breaking something. Signed-off-by: Hans de Goede <[email protected]> Reviewed-by: Lukas Wunner <[email protected]> Reviewed-by: Mika Westerberg <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
* nfit: make DIMM DSMs optionalDan Williams2016-07-191-3/+3
| | | | | | | | | | | | | | | | | | | | | | Commit 4995734e973a "acpi, nfit: fix acpi_check_dsm() vs zero functions implemented" attempted to fix a QEMU regression by supporting its usage of a zero-mask as a valid response to a DSM-family probe request. However, this behavior breaks HP platforms that return a zero-mask by default causing the probe to misidentify the DSM-family. Instead, the QEMU regression can be fixed by simply not requiring the DSM family to be identified. This effectively reverts commit 4995734e973a, and removes the DSM requirement from the init path. Cc: "Rafael J. Wysocki" <[email protected]> Cc: Xiao Guangrong <[email protected]> Cc: Linda Knippers <[email protected]> Fixes: 4995734e973a ("acpi, nfit: fix acpi_check_dsm() vs zero functions implemented") Reported-by: Jerry Hoemann <[email protected]> Tested-by: Jerry Hoemann <[email protected]> Signed-off-by: Dan Williams <[email protected]>
* acpi, nfit: fix acpi_check_dsm() vs zero functions implementedDan Williams2016-06-241-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QEMU 2.6 implements nascent support for nvdimm DSMs. Depending on configuration it may only implement the function0 dsm to indicate that no other DSMs are available. Commit 31eca76ba2fc "nfit, libnvdimm: limited/whitelisted dimm command marshaling mechanism" breaks QEMU, but QEMU is spec compliant. Per the spec the way to indicate that no functions are supported is: If Function Index is zero, the return is a buffer containing one bit for each function index, starting with zero. Bit 0 indicates whether there is support for any functions other than function 0 for the specified UUID and Revision ID. If set to zero, no functions are supported (other than function zero) for the specified UUID and Revision ID. Update the nfit driver to determine the family (interface UUID) without requiring the implementation to define any other functions, i.e. short-circuit acpi_check_dsm() to succeed per the spec. The nfit driver appears to be the only user passing funcs==0 to acpi_check_dsm(), so this behavior change of the common routine should be limited to the probing done by the nfit driver. Cc: Len Brown <[email protected]> Cc: Jerry Hoemann <[email protected]> Acked-by: "Rafael J. Wysocki" <[email protected]> Fixes: 31eca76ba2fc ("nfit, libnvdimm: limited/whitelisted dimm command marshaling mechanism") Reported-by: Xiao Guangrong <[email protected]> Tested-by: Xiao Guangrong <[email protected]> Signed-off-by: Dan Williams <[email protected]>