summaryrefslogtreecommitdiffstats
path: root/drivers/of/of_path.c
Commit message (Collapse)AuthorAgeFilesLines
* cdev: implement setter/getter for cdev device nodeAhmad Fatoum2024-03-051-2/+2
| | | | | | | | | | | | | A cdev has two device tree node pointers, one directly at struct cdev.device_node and another indirectly via cdev.dev->device_node. We may want to remove cdev::device_node in future, but till then to avoid users having to guess, which device_node is the correct one, add a helper to set and get the device tree node. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-19-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: Print device nodes with %pOFSascha Hauer2023-07-031-7/+7
| | | | | | | We have the %pOF format specifier for printing device nodes. Use it where appropriate. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: export new of_cdev_find helperAhmad Fatoum2023-06-121-19/+40
| | | | | | | | | | | | | __of_find_path goes through the hassle of determining the cdev, only to discard it again and return either zero or an error code. Follow up commits will need to get the cdev corresponding to a path in the DT. So let's make that easier by exporting a suitable helper function. Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230607120714.3083182-16-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: of_path: always call of_partition_ensure_probed before resolvingAhmad Fatoum2023-06-081-0/+10
| | | | | | | | | | | | of_find_path may be called on a partition, whose parent device is not yet probed. state code solves that by calling of_partition_ensure_probed before of_find_path_by_node, but really we should be doing that for all calls to of_find_path. Do so. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20230607120714.3083182-7-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename struct device_d to deviceSascha Hauer2023-01-101-3/+3
| | | | | | | | | | | | | The '_d' suffix was originally introduced in case we want to import Linux struct device as a separate struct into barebox. Over time it became clear that this won't happen, instead barebox struct device_d is basically the same as Linux struct device. Rename the struct name accordingly to make porting Linux code easier. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename device_d::device_node to device_d::of_nodeSascha Hauer2023-01-101-2/+2
| | | | | | | | | | | | | | | | | | | | Linux struct device has the member of_node for the device_node pointer. Rename this in barebox accordingly to minimize the necessary changes when porting Linux code. This was done with the semantic patch: @@ struct device_d E; @@ - E.device_node + E.of_node @@ struct device_d *E; @@ - E->device_node + E->of_node Plus some manual adjustments. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-2-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of_path: Fix typoSascha Hauer2022-02-041-1/+1
| | | | | | | | parition -> partition Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> parition# arch/arm/boards/globalscale-mirabox/binary.0
* drivers: migrate "GPL-2.0" license identifiers to SPDX 2.0Roland Hieber2021-11-221-1/+1
| | | | | | | | | | "GPL-2.0-only" was introduced in SPDX 2.0, and the old identifier "GPL-2.0" is now considered deprecated; see <https://spdx.org/licenses>. Fixes: 28f4a6a4df76f0f1581d (2021-10-30, "drivers: add missing SPDX-License-Identifier") Signed-off-by: Roland Hieber <rhi@pengutronix.de> Link: https://lore.barebox.org/20211117113851.2022669-2-rhi@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: add missing SPDX-License-IdentifierAhmad Fatoum2021-11-011-10/+1
| | | | | | | | | | | | | | | | | | | | This adds the suitable SPDX-License-Identifier to all files in drivers/ that previously lacked one. To aid manual inspection, following heuristics can be used: * No changes outside of comments/whitespace: git show -U0 HEAD | rg -v '^(@@|diff|index)|[-+]([-+]|//|#|[\s/]\*)' * -or-later come in pairs: git show --inter-hunk-context=19 HEAD | \ perl -0777 -F'/^@/gm' -ne 'for (@F) { @m = /later/g; print if @m & 1 }' Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211030175632.2276077-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: remove references to CREDITSUwe Kleine-König2020-04-271-3/+0
| | | | | | | | The CREDITS file was removed from barebox in 2015 by commit 6570288f2d97 ("Remove the CREDITS file"). Remove references to it from several files. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: of_path: fix return in case of EPROBE_DEFERMarco Felsch2019-11-041-1/+1
| | | | | | | | | As said in commit 82eb3dff10 ("of_path: handle no driver for device") this case happens if the driver isn't probed yet. So we should return -EPROBE_DEFER to signal that. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: of: Make use of devpath_to_name()Andrey Smirnov2018-06-251-4/+2
| | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: of_path: find device via partuuidSteffen Trumtrar2017-07-101-1/+16
| | | | | | | | When a node is compatible to a fixed-partitions, support searching the corresponding device via the partuuid, if it specified in the device tree. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
* of: of_find_node_by_devpath: Fix offset in mtd devicesSascha Hauer2017-05-111-1/+4
| | | | | | | When a cdev is a mtd device the partition offset must be used from there, not from the cdev. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: of_path: add of_find_node_by_devpath()Sascha Hauer2017-03-311-0/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | We already have of_find_path_by_node() which finds a device path for a given device node. This is used by the state framework to find its backend path. This path has to be translated back to a device node when Linux is started. The current approach turned out to be too simple: We assumed that the node path is the same in the tree Linux is started with. This is not true in several cases: - partition nodes should have the name "partition@<offset>", but in several trees they have "partition@<num>" - There are two different partition bindings: The legacy binding and the new one with an additional partitions subnode which has a compatible = "fixed-partitions" property. The node path only stays the same when the internal tree uses the same bindings and node names as the tree Linux is started with. To overcome this limitation we create of_find_node_by_devpath() which converts the device path back to a device node. It does so by finding the device node of the hardware device rather than the partition node. It then parses over the partitions in this device node with the known bindings looking for a partition which matches in offset and size to the barebox partition. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of_path: only handle no driver for device if it is on a busIan Abbott2017-01-131-1/+1
| | | | | | | | | | This fixes a regression in __of_find_path() for flash devices created by the cadence-quadspi driver, which do not have 'dev->driver' set. Such devices do not have 'dev->bus' set either, so we can use that to qualify the existing test. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/state'Sascha Hauer2016-11-141-0/+3
|\
| * of_path: handle no driver for deviceSascha Hauer2016-10-201-0/+3
| | | | | | | | | | | | | | | | | | in __of_find_path it can happen that there is a device, but there is no driver for this device because it hasn't been probed yet. Return -ENODEV in this case to let the caller know that it has to try later again. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: of_find_path: Add support for new partition bindingSascha Hauer2016-11-111-1/+6
|/ | | | | | | The partitions now may be in a subnode of the actual device node. Eventually go another step up in the hierarchy if required. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* string: Fix (v)asprintf prototypesSascha Hauer2016-04-151-1/+1
| | | | | | | | | | Our asprintf and vasprintf have different prototypes than the glibc functions. This causes trouble when we want to share barebox code with userspace code. Change the prototypes for (v)asprintf to match the glibc prototypes. Since the current (v)asprintf are convenient to use change the existing functions to b(v)asprintf. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of_path: Drop possible further extensions of device-path propertySascha Hauer2016-01-081-95/+28
| | | | | | | | | | Originally it was intended to further extend the multi string property device-path further with more elements, like for example a filename. It turned out though that this is too complex and instead of further extending the property we should instead create additional properties, so this mechanism is removed with this patch to make the code simpler. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of_path: Fix bug with partitions, simply codeTrent Piepho2016-01-081-18/+29
| | | | | | | | | | | | | | | | | | | | | | In commit 75b682795eafb2385556a9642f09e0af96a1264a using a path that has a partition description broke. Fix this and simpfy the code some. There is no need to loop over each string in the path property: it's defined to have at most one parition description, no extant dts has more than one, and how it would handle more than one didn't make sense anyway. Once not looping, __of_find_path() just needs the partition description text, not both the original node and property name to look it up from. When using a partition description, don't lookup the cdev of the node just to replace it with the partition's cdev. Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of_path: add of_find_path_by_node()Marc Kleine-Budde2015-11-271-1/+16
| | | | | | | | | This patch adds the function of_find_path_by_node(), which is similar to of_find_path(), but it translates a device tree node into a barebox device path directly. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of_path: of_find_path() factor out device detection logic into separate functionMarc Kleine-Budde2015-11-271-37/+44
| | | | | | | | This patch factors out the device detection logic into separate function, so that it can be used from another function. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of_path: Allow pointing directly to the partitionSascha Hauer2015-09-011-5/+9
| | | | | | | | We could only point to partitions in the device tree by using &norflash, "partname:barebox-environment". Allow to point to the partition directly without having to parse the partition labels. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of_path: of_find_path(): add possibility to return .bb deviceMarc Kleine-Budde2015-04-231-2/+10
| | | | | | | | | This patch adds a flags argument to the of_find_path() function. The only flag defined for now is OF_FIND_PATH_FLAGS_BB. When used on NAND devices, the function returns the bad block aware device (the ".bb" device). Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of_path: of_find_path(): remove unused variable lenMarc Kleine-Budde2015-03-031-2/+2
| | | | | Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Fix spelling: pathes -> pathsWadim Egorov2015-01-281-1/+1
| | | | | Signed-off-by: Wadim Egorov <w.egorov@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of_path: Allow to specify path with phandle onlySascha Hauer2014-04-281-0/+3
| | | | | | | | Instead of just allowing to specify an OF path with additional partname: property allow to specify a phandle to the partition directly. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: move of_find_device_by_node_path to drivers/of/of_path.cSascha Hauer2014-04-281-0/+14
| | | | | | | As it's generic helper function which should not stay in driver specific code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Add configurability via devicetreeSascha Hauer2013-07-181-0/+155
This adds the possibility to configure the place for the environment from the devicetree and to partition devices from the devicetree. Configuration has the general form of devices with a regular compatible property. This allows to later add additional drivers or drivers with different behaviour (for example to add support for redundant environment). The configuration is all in the /chosen/barebox/ hierarchy of the devicetree. This separates the configuration from the hardware description. Also it makes it possible to store the configuration in a completely separate devicetree (or devicetree overlay). For the same reason all configuration is done using nodepathes rather than phandles. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>