summaryrefslogtreecommitdiff
path: root/drivers/of/unittest.c
AgeCommit message (Collapse)Author
2024-05-20Merge tag 'i2c-for-6.10-rc1' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux Pull i2c updates from Wolfram Sang: "i2c core removes an argument from the i2c_mux_add_adapter() call to further deprecate class based I2C device instantiation. All users are converted, too. Other that that, Andi collected a number if I2C host driver patches. Those merges have their own description" * tag 'i2c-for-6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (72 commits) power: supply: sbs-manager: Remove class argument from i2c_mux_add_adapter() i2c: mux: Remove class argument from i2c_mux_add_adapter() i2c: synquacer: Fix an error handling path in synquacer_i2c_probe() i2c: acpi: Unbind mux adapters before delete i2c: designware: Replace MODULE_ALIAS() with MODULE_DEVICE_TABLE() i2c: pxa: use 'time_left' variable with wait_event_timeout() i2c: s3c2410: use 'time_left' variable with wait_event_timeout() i2c: rk3x: use 'time_left' variable with wait_event_timeout() i2c: qcom-geni: use 'time_left' variable with wait_for_completion_timeout() i2c: jz4780: use 'time_left' variable with wait_for_completion_timeout() i2c: synquacer: use 'time_left' variable with wait_for_completion_timeout() i2c: stm32f7: use 'time_left' variable with wait_for_completion_timeout() i2c: stm32f4: use 'time_left' variable with wait_for_completion_timeout() i2c: st: use 'time_left' variable with wait_for_completion_timeout() i2c: omap: use 'time_left' variable with wait_for_completion_timeout() i2c: imx-lpi2c: use 'time_left' variable with wait_for_completion_timeout() i2c: hix5hd2: use 'time_left' variable with wait_for_completion_timeout() i2c: exynos5: use 'time_left' variable with wait_for_completion_timeout() i2c: digicolor: use 'time_left' variable with wait_for_completion_timeout() i2c: amd-mp2-plat: use 'time_left' variable with wait_for_completion_timeout() ...
2024-05-13i2c: mux: Remove class argument from i2c_mux_add_adapter()Heiner Kallweit
99a741aa7a2d ("i2c: mux: gpio: remove support for class-based device instantiation") removed the last call to i2c_mux_add_adapter() with a non-null class argument. Therefore the class argument can be removed. Note: Class-based device instantiation is a legacy mechanism which shouldn't be used in new code, so we can rule out that this argument may be needed again in the future. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Acked-by: Peter Rosin <peda@axentia.se> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Acked-by: Rob Herring (Arm) <robh@kernel.org> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
2024-04-15of: Add a helper to free property structRob Herring
Freeing a property struct is 3 kfree()'s which is duplicated in multiple spots. Add a helper, __of_prop_free(), and replace all the open coded cases in the DT code. Reviewed-by: Saravana Kannan <saravanak@google.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Link: https://lore.kernel.org/r/20240409-dt-cleanup-free-v2-1-5b419a4af38d@kernel.org Signed-off-by: Rob Herring <robh@kernel.org>
2024-03-15Merge tag 'devicetree-for-6.9' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux Pull devicetree updates from Rob Herring: "DT core: - Add cleanup.h based auto release of struct device_node pointers via __free marking and new for_each_child_of_node_scoped() iterator to use it. - Always create a base skeleton DT when CONFIG_OF is enabled. This supports several usecases of adding DT data on non-DT booted systems. - Move around some /reserved-memory code in preparation for further improvements - Add a stub for_each_property_of_node() for !OF - Adjust the printk levels on some messages - Fix __be32 sparse warning - Drop RESERVEDMEM_OF_DECLARE usage from Freescale qbman driver (currently orphaned) - Add Saravana Kannan and drop Frank Rowand as DT maintainers DT bindings: - Convert Mediatek timer, Mediatek sysirq, fsl,imx6ul-tsc, fsl,imx6ul-pinctrl, Atmel AIC, Atmel HLCDC, FPGA region, and xlnx,sd-fec to DT schemas - Add existing, but undocumented fsl,imx-anatop binding - Add bunch of undocumented vendor prefixes used in compatible strings - Drop obsolete brcm,bcm2835-pm-wdt binding - Drop obsolete i2c.txt which as been replaced with schema in dtschema - Add DPS310 device and sort trivial-devices.yaml - Enable undocumented compatible checks on DT binding examples - More QCom maintainer fixes/updates - Updates to writing-schema.rst and DT submitting-patches.rst to cover some frequent review comments - Clean-up SPDX tags to use 'OR' rather than 'or'" * tag 'devicetree-for-6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: (56 commits) dt-bindings: soc: imx: fsl,imx-anatop: add imx6q regulators of: unittest: Use for_each_child_of_node_scoped() of: Introduce for_each_*_child_of_node_scoped() to automate of_node_put() handling of: Add cleanup.h based auto release via __free(device_node) markings of: Move all FDT reserved-memory handling into of_reserved_mem.c of: Add KUnit test to confirm DTB is loaded of: unittest: treat missing of_root as error instead of fixing up x86/of: Unconditionally call unflatten_and_copy_device_tree() um: Unconditionally call unflatten_device_tree() of: Create of_root if no dtb provided by firmware of: Always unflatten in unflatten_and_copy_device_tree() dt-bindings: timer: mediatek: Convert to json-schema dt-bindings: interrupt-controller: fsl,intmux: Include power-domains support soc: fsl: qbman: Remove RESERVEDMEM_OF_DECLARE usage dt-bindings: fsl-imx-sdma: fix HDMI audio index dt-bindings: soc: imx: fsl,imx-iomuxc-gpr: add imx6 dt-bindings: soc: imx: fsl,imx-anatop: add binding dt-bindings: input: touchscreen: fsl,imx6ul-tsc convert to YAML dt-bindings: pinctrl: fsl,imx6ul-pinctrl: convert to YAML of: make for_each_property_of_node() available to to !OF ...
2024-03-13of: unittest: Use for_each_child_of_node_scoped()Jonathan Cameron
A simple example of the utility of this autocleanup approach to handling of_node_put(). In this particular case some of the nodes needed for the test are not available and the _available_ version would cause them to be skipped resulting in a test failure. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20240225142714.286440-4-jic23@kernel.org Signed-off-by: Rob Herring <robh@kernel.org>
2024-03-08of: unittest: treat missing of_root as error instead of fixing upFrank Rowand
unflatten_device_tree() now ensures that the 'of_root' node is populated with the root of a default empty devicetree. Remove the unittest code that created 'of_root' if it was missing. Verify that 'of_root' is valid before attempting to attach the testcase-data subtree. Remove the unittest code that unflattens the unittest overlay base if architecture is UML because that is always done now. Signed-off-by: Frank Rowand <frowand.list@gmail.com> Link: https://lore.kernel.org/r/20230317053415.2254616-3-frowand.list@gmail.com Cc: Rob Herring <robh+dt@kernel.org> Signed-off-by: Stephen Boyd <sboyd@kernel.org> Link: https://lore.kernel.org/r/20240217010557.2381548-7-sboyd@kernel.org Signed-off-by: Rob Herring <robh@kernel.org>
2024-03-08um: Unconditionally call unflatten_device_tree()Stephen Boyd
Call this function unconditionally so that we can populate an empty DTB on platforms that don't boot with a command line provided DTB. There's no harm in calling unflatten_device_tree() unconditionally. If there isn't a valid initial_boot_params dtb then unflatten_device_tree() returns early. Cc: Rob Herring <robh+dt@kernel.org> Cc: Frank Rowand <frowand.list@gmail.com> Cc: Richard Weinberger <richard@nod.at> Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com> Cc: Johannes Berg <johannes@sipsolutions.net> Cc: linux-um@lists.infradead.org Signed-off-by: Stephen Boyd <sboyd@kernel.org> Link: https://lore.kernel.org/r/20240217010557.2381548-4-sboyd@kernel.org Signed-off-by: Rob Herring <robh@kernel.org>
2024-01-31of: unittest: Fix compile in the non-dynamic caseChristian A. Ehrhardt
If CONFIG_OF_KOBJ is not set, a device_node does not contain a kobj and attempts to access the embedded kobj via kref_read break the compile. Replace affected kref_read calls with a macro that reads the refcount if it exists and returns 1 if there is no embedded kobj. Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202401291740.VP219WIz-lkp@intel.com/ Fixes: 4dde83569832 ("of: Fix double free in of_parse_phandle_with_args_map") Signed-off-by: Christian A. Ehrhardt <lk@c--e.de> Link: https://lore.kernel.org/r/20240129192556.403271-1-lk@c--e.de Signed-off-by: Rob Herring <robh@kernel.org>
2024-01-11of: unittest: Fix of_count_phandle_with_args() expected value messageGeert Uytterhoeven
The expected result value for the call to of_count_phandle_with_args() was updated from 7 to 8, but the accompanying error message was forgotten. Fixes: 4dde83569832f937 ("of: Fix double free in of_parse_phandle_with_args_map") Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/r/20240111085025.2073894-1-geert+renesas@glider.be Signed-off-by: Rob Herring <robh@kernel.org>
2024-01-09of: Fix double free in of_parse_phandle_with_args_mapChristian A. Ehrhardt
In of_parse_phandle_with_args_map() the inner loop that iterates through the map entries calls of_node_put(new) to free the reference acquired by the previous iteration of the inner loop. This assumes that the value of "new" is NULL on the first iteration of the inner loop. Make sure that this is true in all iterations of the outer loop by setting "new" to NULL after its value is assigned to "cur". Extend the unittest to detect the double free and add an additional test case that actually triggers this path. Fixes: bd6f2fd5a1 ("of: Support parsing phandle argument lists through a nexus node") Cc: Stephen Boyd <stephen.boyd@linaro.org> Signed-off-by: "Christian A. Ehrhardt" <lk@c--e.de> Link: https://lore.kernel.org/r/20231229105411.1603434-1-lk@c--e.de Signed-off-by: Rob Herring <robh@kernel.org>
2023-10-27of: unittest: Add tests for address translationsHerve Codina
Add tests to exercise address translations based on ranges properties. Tests added cover "default" (2cell) address translations, "default flags" (3cell) address translations and PCI address translations. They also cover PCI BAR translations introduced in commit 407d1a51921e ("PCI: Create device tree node for bridge"). Signed-off-by: Herve Codina <herve.codina@bootlin.com> Link: https://lore.kernel.org/r/20231017110221.189299-4-herve.codina@bootlin.com Signed-off-by: Rob Herring <robh@kernel.org>
2023-08-28of: unittest: Fix of_unittest_pci_node() kconfig dependenciesRob Herring
of_unittest_pci_node test depends on both CONFIG_PCI_DYNAMIC_OF_NODES and CONFIG_OF_OVERLAY. Move the test into the existing CONFIG_OF_OVERLAY ifdef and rework the CONFIG_PCI_DYNAMIC_OF_NODES dependency to use IS_ENABLED() instead. This reduces the combinations to build. Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202308241954.oRNfVqmB-lkp@intel.com/ Fixes: 26409dd04589 ("of: unittest: Add pci_dt_testdrv pci driver") Cc: Lizhi Hou <lizhi.hou@amd.com> Acked-by: Randy Dunlap <rdunlap@infradead.org> Tested-by: Randy Dunlap <rdunlap@infradead.org> Link: https://lore.kernel.org/r/20230824221743.1581707-1-robh@kernel.org Signed-off-by: Rob Herring <robh@kernel.org>
2023-08-23of: overlay: unittest: Add test for unresolved symbolGeert Uytterhoeven
Add a test to exercise the error paths when trying to apply an overlay with an unresolved symbol and cleaning up the resulting partial state. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/r/580394587976975770c84411896fce9fbbcf25fa.1690533838.git.geert+renesas@glider.be Signed-off-by: Rob Herring <robh@kernel.org>
2023-08-23of: unittest: Add separators to of_unittest_overlay_high_level()Geert Uytterhoeven
It is hard to see the start and end of each individual test in of_unittest_overlay_high_level(). Add visual cues in the form of separator comments, like was done in of_unittest_overlay_notify(). Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/r/84530100a54a1fac932008057746015e65bc4d9a.1690533838.git.geert+renesas@glider.be Signed-off-by: Rob Herring <robh@kernel.org>
2023-08-23of: unittest: Cleanup partially-applied overlaysGeert Uytterhoeven
When of_overlay_fdt_apply() fails, the changeset may be partially applied, and the caller is still expected to call of_overlay_remove() to clean up this partial state. However, overlay_17 is the only test that takes care of cleaning up after an (expected) failure. Instead of adding cleanup code to each individual test, extend overlay_info with the optional expected return value of of_overlay_remove(), and handle cleanup in the overlay_data_apply() helper. While at it, simplify the end marker in the overlay_info table. Update the expected error output for errors during the newly cleanup. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/r/594a6a8934e5569bf96d317a6a3c0a9129a2ae20.1690533838.git.geert+renesas@glider.be [robh: update and fix EXPECT messages] Signed-off-by: Rob Herring <robh@kernel.org>
2023-08-23of: unittest: Merge of_unittest_apply{,_revert}_overlay_check()Geert Uytterhoeven
of_unittest_apply_overlay_check() and the first part of of_unittest_apply_revert_overlay_check() are identical. Reduce code duplication by replacing them by two wrappers around a common helper. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/r/4bafe338655beab6b244047e737c0c2aa60b613d.1690533838.git.geert+renesas@glider.be Signed-off-by: Rob Herring <robh@kernel.org>
2023-08-23of: unittest: Improve messages and comments in apply/revert checksGeert Uytterhoeven
Miscellaneous improvements for the apply and apply/revert checks, making them more similar: - Fix inverted comment for before state check, - Add more comments to improve symmetry, - Fix grammar s/must be to set to/must be in/, - Avoid saying "create" in messages, as the actual operation depends on the value of the before/after parameters. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/r/326ecfe0889c53d2cfff31b3bf950d0b70be225f.1690533838.git.geert+renesas@glider.be Signed-off-by: Rob Herring <robh@kernel.org>
2023-08-23of: unittest: Restore indentation in overlay_bad_add_dup_prop testGeert Uytterhoeven
When updating the expected error messages for the overlay_bad_add_dup_prop test, indentation of the EXPECT_END() statements was accidentally changed. Fixes: 29acfb65598f9167 ("of: unittest: kmemleak in duplicate property update") Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/r/c9bd81b74b0a1ab394ac7ff8819e6fb032fe8ded.1690533838.git.geert+renesas@glider.be Signed-off-by: Rob Herring <robh@kernel.org>
2023-08-23of: unittest: Fix overlay type in apply/revert checkGeert Uytterhoeven
The removal check in of_unittest_apply_revert_overlay_check() always uses the platform device overlay type, while it should use the actual overlay type, as passed as a parameter to the function. This has no impact on any current test, as all tests calling of_unittest_apply_revert_overlay_check() use the platform device overlay type. Fixes: d5e75500ca401d31 ("of: unitest: Add I2C overlay unit tests.") Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/r/ba0234c41ba808f10112094f88792beeb6dbaedf.1690533838.git.geert+renesas@glider.be Signed-off-by: Rob Herring <robh@kernel.org>
2023-08-23of: unittest: Check tree matches original after reverting a changesetRob Herring
Enhance the changeset unittest to ensure after a revert, the tree matches the original tree before the changeset was applied. Specifically, check an added node is removed, a removed property is added back, and an updated property has its original value. Signed-off-by: Rob Herring <robh@kernel.org>
2023-08-23of: unittest: Run overlay apply/revert sequence three timesGeert Uytterhoeven
Run the test for the overlay apply/revert sequence three times, to test if there are unbalanced of_node_put() calls causing reference counts to become negative. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/r/a9fb4eb560c58d11a7f167bc78a137b46e76cf15.1692699743.git.geert+renesas@glider.be Signed-off-by: Rob Herring <robh@kernel.org>
2023-08-22of: unittest: Add pci_dt_testdrv pci driverLizhi Hou
pci_dt_testdrv is bound to QEMU PCI Test Device. It reads overlay_pci_node fdt fragment and apply it to Test Device. Then it calls of_platform_default_populate() to populate the platform devices. Tested-by: Herve Codina <herve.codina@bootlin.com> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com> Link: https://lore.kernel.org/r/1692120000-46900-6-git-send-email-lizhi.hou@amd.com Signed-off-by: Rob Herring <robh@kernel.org>
2023-08-22of: overlay: Extend of_overlay_fdt_apply() to specify the target nodeLizhi Hou
Currently, in an overlay fdt fragment, it needs to specify the exact location in base DT. In another word, when the fdt fragment is generated, the base DT location for the fragment is already known. There is new use case that the base DT location is unknown when fdt fragment is generated. For example, the add-on device provide a fdt overlay with its firmware to describe its downstream devices. Because it is add-on device which can be plugged to different systems, its firmware will not be able to know the overlay location in base DT. Instead, the device driver will load the overlay fdt and apply it to base DT at runtime. In this case, of_overlay_fdt_apply() needs to be extended to specify the target node for device driver to apply overlay fdt. int overlay_fdt_apply(..., struct device_node *base); Signed-off-by: Lizhi Hou <lizhi.hou@amd.com> Link: https://lore.kernel.org/r/1692120000-46900-5-git-send-email-lizhi.hou@amd.com Signed-off-by: Rob Herring <robh@kernel.org>
2023-08-22of: dynamic: Add interfaces for creating device node dynamicallyLizhi Hou
of_changeset_create_node() creates device node dynamically and attaches the newly created node to a changeset. Expand of_changeset APIs to handle specific types of properties. of_changeset_add_prop_string() of_changeset_add_prop_string_array() of_changeset_add_prop_u32_array() Signed-off-by: Clément Léger <clement.leger@bootlin.com> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com> Link: https://lore.kernel.org/r/1692120000-46900-2-git-send-email-lizhi.hou@amd.com Signed-off-by: Rob Herring <robh@kernel.org>
2023-08-21Merge branch 'dt/linus' into dt/nextRob Herring
Pick up changeset fixes for further rework.
2023-08-21of: unittest: Fix EXPECT for parse_phandle_with_args_map() testRob Herring
Commit 12e17243d8a1 ("of: base: improve error msg in of_phandle_iterator_next()") added printing of the phandle value on error, but failed to update the unittest. Fixes: 12e17243d8a1 ("of: base: improve error msg in of_phandle_iterator_next()") Cc: stable@vger.kernel.org Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/r/20230801-dt-changeset-fixes-v3-1-5f0410e007dd@kernel.org Signed-off-by: Rob Herring <robh@kernel.org>
2023-08-10of: unittest: Remove redundant of_match_ptr()Ruan Jinjie
The driver depends on CONFIG_OF, it is not necessary to use of_match_ptr() here. Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com> Link: https://lore.kernel.org/r/20230808094043.2732158-1-ruanjinjie@huawei.com Signed-off-by: Rob Herring <robh@kernel.org>
2023-07-27of: unittest: fix null pointer dereferencing in of_unittest_find_node_by_name()Ruan Jinjie
when kmalloc() fail to allocate memory in kasprintf(), name or full_name will be NULL, strcmp() will cause null pointer dereference. Fixes: 0d638a07d3a1 ("of: Convert to using %pOF instead of full_name") Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com> Link: https://lore.kernel.org/r/20230727080246.519539-1-ruanjinjie@huawei.com Signed-off-by: Rob Herring <robh@kernel.org>
2023-06-29Merge tag 'devicetree-for-6.5' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux Pull devicetree updates from Rob Herring: "Bindings: - Add some missing type definitions to properties - Drop unneeded quotes and use absolute paths in bindings - Remove redundant "binding" or "schema" in binding titles - Add bindings for Ralink SoCs interrupt controller, QCA2066 Bluetooth, infineon,irps5401, new NXP i.MX GPT variants, shineworld lh133k MIPI SPI panel, Socionext Synquacer platforms, RK3588 PCIe, ST M95640 EEPROM, and FSL DCP crypto variants, and Arm Cortex-R52 DT core: - Improve the reserved-memory range allocation to maximize contiguous space - Use device_set_node() helper in place of open coding" * tag 'devicetree-for-6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: (40 commits) dt-bindings: interrupt-controller: add Ralink SoCs interrupt controller dt-bindings: PCI: dwc: rockchip: Update for RK3588 dt-bindings: auxdisplay: holtek: Add missing type for "linux,no-autorepeat" dt-bindings: input: mediatek,pmic-keys: Fix typo in "linux,keycodes" property name dt-bindings: pwm: drop unneeded quotes dt-bindings: crypto: drop unneeded quotes dt-bindings: arm: socionext: add Synquacer platforms dt-bindings: connector: usb: allow a single HS port dt-bindings: bus: ti-sysc: fix typo of: reserved_mem: Use stable allocation order of: reserved_mem: Try to keep range allocations contiguous dt-bindings: arm: drop unneeded quotes and use absolute /schemas path dt-bindings: firmware: arm,scmi: drop unneeded quotes and use absolute /schemas path dt-bindings: dvfs: drop unneeded quotes dt-bindings: gpu: drop unneeded quotes dt-bindings: i3c: silvaco,i3c-master: drop unneeded quotes dt-bindings: rockchip: grf: drop unneeded quotes dt-bindings: spmi: mtk,spmi-mtk-pmif: drop unneeded quotes dt-bindings: Remove last usage of "binding" or "schema" in titles dt-bindings: display: panel: mipi-dbi-spi: add spi-3wire property ...
2023-06-23of: unittest: drop assertions for GPIO hog messagesBartosz Golaszewski
These have now been demoted to debug and are normally hidden. Drop the assertions entirely. Suggested-by: Rob Herring <robh@kernel.org> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Rob Herring <robh@kernel.org>
2023-06-12of: unittest: Switch i2c driver back to use .probe()Uwe Kleine-König
After commit b8a1a4cd5a98 ("i2c: Provide a temporary .probe_new() call-back type"), all drivers being converted to .probe_new() and then 03c835f498b5 ("i2c: Switch .probe() to not take an id parameter") convert back to (the new) .probe() to be able to eventually drop .probe_new() from struct i2c_driver. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20230525204812.733642-1-u.kleine-koenig@pengutronix.de Signed-off-by: Rob Herring <robh@kernel.org>
2023-06-07gpiolib: demote the hogging log messages to debugBartosz Golaszewski
Drivers should be silent when they work correctly. There's no reason to emit info messages when GPIO lines are hogged. Demote the message to debug. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Suggested-by: Kent Gibson <warthog618@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2023-04-27Merge tag 'devicetree-for-6.4-2' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux Pull more devicetree updates from Rob Herring: - First part of DT header detangling dropping cpu.h from of_device.h and replacing some includes with forward declarations. A handful of drivers needed some adjustment to their includes as a result. - Refactor of_device.h to be used by bus drivers rather than various device drivers. This moves non-bus related functions out of of_device.h. The end goal is for of_platform.h and of_device.h to stop including each other. - Refactor open coded parsing of "ranges" in some bus drivers to use DT address parsing functions - Add some new address parsing functions of_property_read_reg(), of_range_count(), and of_range_to_resource() in preparation to convert more open coded parsing of DT addresses to use them. - Treewide clean-ups to use of_property_read_bool() and of_property_present() as appropriate. The ones here are the ones that didn't get picked up elsewhere. * tag 'devicetree-for-6.4-2' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: (34 commits) bus: tegra-gmi: Replace of_platform.h with explicit includes hte: Use of_property_present() for testing DT property presence w1: w1-gpio: Use of_property_read_bool() for boolean properties virt: fsl: Use of_property_present() for testing DT property presence soc: fsl: Use of_property_present() for testing DT property presence sbus: display7seg: Use of_property_read_bool() for boolean properties sparc: Use of_property_read_bool() for boolean properties sparc: Use of_property_present() for testing DT property presence bus: mvebu-mbus: Remove open coded "ranges" parsing of/address: Add of_property_read_reg() helper of/address: Add of_range_count() helper of/address: Add support for 3 address cell bus of/address: Add of_range_to_resource() helper of: unittest: Add bus address range parsing tests of: Drop cpu.h include from of_device.h OPP: Adjust includes to remove of_device.h irqchip: loongson-eiointc: Add explicit include for cpuhotplug.h cpuidle: Adjust includes to remove of_device.h cpufreq: sun50i: Add explicit include for cpu.h cpufreq: Adjust includes to remove of_device.h ...
2023-04-13of/address: Add of_property_read_reg() helperRob Herring
Add a helper, of_property_read_reg(), to read "reg" entries untranslated address and size. This function is intended mainly for cases with an untranslatable "reg" address (i.e. not MMIO). There's also a few translatable cases such as address cells containing a bus chip-select number. Link: https://lore.kernel.org/r/20230328-dt-address-helpers-v1-5-e2456c3e77ab@kernel.org Signed-off-by: Rob Herring <robh@kernel.org>
2023-04-13of/address: Add of_range_count() helperRob Herring
Some users need a count of the number of ranges entries before iterating over the entries. Typically this is for allocating some data structure based on the size. Add a helper, of_range_count(), to get the count. The helper must be called with an struct of_range_parser initialized by of_range_parser_init(). Link: https://lore.kernel.org/r/20230328-dt-address-helpers-v1-4-e2456c3e77ab@kernel.org Signed-off-by: Rob Herring <robh@kernel.org>
2023-04-13of/address: Add support for 3 address cell busRob Herring
There's a few custom bus bindings (e.g. fsl,qoriq-mc) which use a 3 cell format with custom flags in the high cell. We can match these buses as a fallback if we didn't match on PCI bus which is the only standard bus binding with 3 address cells. Link: https://lore.kernel.org/r/20230328-dt-address-helpers-v1-3-e2456c3e77ab@kernel.org Signed-off-by: Rob Herring <robh@kernel.org>
2023-04-13of/address: Add of_range_to_resource() helperRob Herring
A few users need to convert a specific "ranges" entry into a struct resource. Add a helper to similar to of_address_to_resource(). The existing of_pci_range_to_resource() helper isn't really PCI specific, so it can be used with the CONFIG_PCI check dropped. Link: https://lore.kernel.org/r/20230328-dt-address-helpers-v1-2-e2456c3e77ab@kernel.org Signed-off-by: Rob Herring <robh@kernel.org>
2023-04-13of: unittest: Add bus address range parsing testsRob Herring
While there are tests for "dma-ranges" helpers, "ranges" is missing any tests. It's the same underlying code, but for completeness add a test for "ranges" parsing iterators. This is in preparation to add some additional "ranges" helpers. Link: https://lore.kernel.org/r/20230328-dt-address-helpers-v1-1-e2456c3e77ab@kernel.org Signed-off-by: Rob Herring <robh@kernel.org>
2023-03-20of: unittest: Convert to platform remove callback returning voidUwe Kleine-König
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is (mostly) ignored and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void. Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20230319100620.295849-4-u.kleine-koenig@pengutronix.de Signed-off-by: Rob Herring <robh@kernel.org>
2023-03-20of: unittest: Drop if blocks with always false conditionUwe Kleine-König
unittest_gpio_remove() is only called after unittest_gpio_probe() completed successfully. In this case driver data was set to a non-NULL value and so platform_get_drvdata() never returns NULL. Also note that the compiler might optimize away this check anyhow as devptr was already dereferenced for the dev_dbg call above. Drop this if block. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20230319100620.295849-3-u.kleine-koenig@pengutronix.de Signed-off-by: Rob Herring <robh@kernel.org>
2023-03-20of: unittest: Drop call to platform_set_drvdata(..., NULL)Uwe Kleine-König
The driver core already unsets driver data after .remove() completes. So there is no reason to do this explicitly in the driver itself. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20230319100620.295849-2-u.kleine-koenig@pengutronix.de Signed-off-by: Rob Herring <robh@kernel.org>
2023-02-20of: unittest: add node lifecycle testsFrank Rowand
Add tests to exercise the actions that occur when the reference count of devicetree nodes decrement to zero and beyond. Decrementing to zero triggers freeing memory allocated for the node. This commit will expose a pr_err() issue in of_node_release(), resulting in some kernal warnings and stack traces. When scripts/dtc/of_unittest_expect processes the console messages, it will also report related problems for EXPECT messages due to the pr_err() issue: ** missing EXPECT begin : 5 Signed-off-by: Frank Rowand <frowand.list@gmail.com> Link: https://lore.kernel.org/r/20230213185702.395776-5-frowand.list@gmail.com [robh: Fix !CONFIG_OF_DYNAMIC build] Signed-off-by: Rob Herring <robh@kernel.org>
2022-12-06of: unittest: Convert to i2c's .probe_new()Uwe Kleine-König
In struct i2c_driver, field new_probe replaces the soon to be deprecated field probe. Update unittest for this change. The probe function doesn't make use of the i2c_device_id * parameter so it can be trivially converted. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Frank Rowand <frowand.list@gmail.com> Link: https://lore.kernel.org/r/20221118224540.619276-510-uwe@kleine-koenig.org [robh: Add Frank's commit msg addition] Signed-off-by: Rob Herring <robh@kernel.org>
2022-10-26of: overlay: rename overlay source files from .dts to .dtsoFrank Rowand
In drivers/of/unittest-data/: - Rename .dts overlay source files to use .dtso suffix. Modify driver/of/unitest.c to use .dtbo.o based symbols instead of .dtb.o Signed-off-by: Frank Rowand <frank.rowand@sony.com> Signed-off-by: Andrew Davis <afd@ti.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Frank Rowand <frowand.list@gmail.com> Tested-by: Frank Rowand <frowand.list@gmail.com> Link: https://lore.kernel.org/r/20221024173434.32518-4-afd@ti.com Signed-off-by: Rob Herring <robh@kernel.org>
2022-10-10Merge tag 'devicetree-for-6.1' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux Pull devicetree updates from Rob Herring: "DT core: - Fix node refcounting in of_find_last_cache_level() - Constify device_node in of_device_compatible_match() - Fix 'dma-ranges' handling in bus controller nodes - Fix handling of initrd start > end - Improve error reporting in of_irq_init() - Taint kernel on DT unittest running - Use strscpy instead of strlcpy - Add a build target, dt_compatible_check, to check for compatible strings used in kernel sources against compatible strings in DT schemas. - Handle DT_SCHEMA_FILES changes when rebuilding DT bindings: - LED bindings for MT6370 PMIC - Convert Mediatek mtk-gce mailbox, MIPS CPU interrupt controller, mt7621 I2C, virtio,pci-iommu, nxp,tda998x, QCom fastrpc, qcom,pdc, and arm,versatile-sysreg to DT schema format - Add nvmem cells to u-boot,env schema - Add more LED_COLOR_ID definitions - Require 'opp-table' uses to be a node - Various schema fixes to match QEMU 'virt' DT usage - Tree wide dropping of redundant 'Device Tree Binding' in schema titles - More (unevaluated|additional)Properties fixes in schema child nodes - Drop various redundant minItems equal to maxItems" * tag 'devicetree-for-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: (62 commits) of: base: Shift refcount decrement in of_find_last_cache_level() dt-bindings: leds: Add MediaTek MT6370 flashlight dt-bindings: leds: mt6370: Add MediaTek MT6370 current sink type LED indicator dt-bindings: mailbox: Convert mtk-gce to DT schema of: base: make of_device_compatible_match() accept const device node of: Fix "dma-ranges" handling for bus controllers of: fdt: Remove unused struct fdt_scan_status dt-bindings: display: st,stm32-dsi: Handle data-lanes in DSI port node dt-bindings: timer: Add power-domains for TI timer-dm on K3 dt: Add a check for undocumented compatible strings in kernel kbuild: take into account DT_SCHEMA_FILES changes while checking dtbs dt-bindings: interrupt-controller: migrate MIPS CPU interrupt controller text bindings to YAML dt-bindings: i2c: migrate mt7621 text bindings to YAML dt-bindings: power: gpcv2: correct patternProperties dt-bindings: virtio: Convert virtio,pci-iommu to DT schema dt-bindings: timer: arm,arch_timer: Allow dual compatible string dt-bindings: arm: cpus: Add kryo240 compatible dt-bindings: display: bridge: nxp,tda998x: Convert to json-schema dt-bindings: nvmem: u-boot,env: add basic NVMEM cells dt-bindings: remoteproc: qcom,adsp: enforce smd-edge schema ...
2022-08-25of: unittest: taint the kernel when of unittest runsFrank Rowand
Make OF unittest trigger the new TAINT_TEST taint when OF unittest runs. Due to OF unittest not being intended to run on production systems, and potentially causing problems (or security issues like leaking kernel addresses), the kernel's state should not be considered safe for production use after OF unittest runs. Signed-off-by: Frank Rowand <frank.rowand@sony.com> Link: https://lore.kernel.org/r/20220823200152.3465751-1-frowand.list@gmail.com Signed-off-by: Rob Herring <robh@kernel.org>
2022-08-22of: move from strlcpy with unused retval to strscpyWolfram Sang
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 <wsa+renesas@sang-engineering.com> Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20220818210054.7157-1-wsa+renesas@sang-engineering.com
2022-08-16i2c: Make remove callback return voidUwe Kleine-König
The value returned by an i2c driver's remove function is mostly ignored. (Only an error message is printed if the value is non-zero that the error is ignored.) So change the prototype of the remove function to return no value. This way driver authors are not tempted to assume that passing an error to the upper layer is a good idea. All drivers are adapted accordingly. There is no intended change of behaviour, all callbacks were prepared to return 0 before. Reviewed-by: Peter Senna Tschudin <peter.senna@gmail.com> Reviewed-by: Jeremy Kerr <jk@codeconstruct.com.au> Reviewed-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Reviewed-by: Crt Mori <cmo@melexis.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Marek Behún <kabel@kernel.org> # for leds-turris-omnia Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Petr Machata <petrm@nvidia.com> # for mlxsw Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com> # for surface3_power Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> # for bmc150-accel-i2c + kxcjk-1013 Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> # for media/* + staging/media/* Acked-by: Miguel Ojeda <ojeda@kernel.org> # for auxdisplay/ht16k33 + auxdisplay/lcd2s Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com> # for versaclock5 Reviewed-by: Ajay Gupta <ajayg@nvidia.com> # for ucsi_ccg Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> # for iio Acked-by: Peter Rosin <peda@axentia.se> # for i2c-mux-*, max9860 Acked-by: Adrien Grassein <adrien.grassein@gmail.com> # for lontium-lt8912b Reviewed-by: Jean Delvare <jdelvare@suse.de> # for hwmon, i2c-core and i2c/muxes Acked-by: Corey Minyard <cminyard@mvista.com> # for IPMI Reviewed-by: Vladimir Oltean <olteanv@gmail.com> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com> # for drivers/power Acked-by: Krzysztof Hałasa <khalasa@piap.pl> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-07-11of: unittest: make unittest_gpio_remove() consistent with unittest_gpio_probe()Andy Shevchenko
On the ->remove() stage the callback uses physical device node instead of one from GPIO chip and the variable name which is different to one used in unittest_gpio_probe(). Make these consistent with unittest_gpio_probe(). Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20220708214539.7254-2-andriy.shevchenko@linux.intel.com
2022-07-11of: unittest: Switch to use fwnode instead of of_nodeAndy Shevchenko
The OF node in the GPIO library is deprecated and soon will be removed. GPIO library now accepts fwnode as a firmware node, so switch the module to use it instead. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Bartosz Golaszewski <brgl@bgdev.pl> Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20220708214539.7254-1-andriy.shevchenko@linux.intel.com