From 5fe7702eccf1bae5b10f0309cef03e02bfdfa6ef Mon Sep 17 00:00:00 2001 From: Jean-Jacques Hiblot Date: Fri, 9 Jun 2017 16:45:18 +0200 Subject: blk: dm: make blk_create_device() take a number of block instead of a size There is an overflow problem when taking the size instead of the number of blocks in blk_create_device(). This results in a wrong device size: the device apparent size is its real size modulo 4GB. Using the number of blocks instead of the device size fixes the problem and is more coherent with the internals of the block layer. Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Simon Glass --- include/blk.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/blk.h b/include/blk.h index 27abfddb94f..1965812a9d5 100644 --- a/include/blk.h +++ b/include/blk.h @@ -315,12 +315,12 @@ int blk_next_device(struct udevice **devp); * @devnum: Device number, specific to the interface type, or -1 to * allocate the next available number * @blksz: Block size of the device in bytes (typically 512) - * @size: Total size of the device in bytes + * @lba: Total number of blocks of the device * @devp: the new device (which has not been probed) */ int blk_create_device(struct udevice *parent, const char *drv_name, const char *name, int if_type, int devnum, int blksz, - lbaint_t size, struct udevice **devp); + lbaint_t lba, struct udevice **devp); /** * blk_create_devicef() - Create a new named block device @@ -332,12 +332,12 @@ int blk_create_device(struct udevice *parent, const char *drv_name, * @devnum: Device number, specific to the interface type, or -1 to * allocate the next available number * @blksz: Block size of the device in bytes (typically 512) - * @size: Total size of the device in bytes + * @lba: Total number of blocks of the device * @devp: the new device (which has not been probed) */ int blk_create_devicef(struct udevice *parent, const char *drv_name, const char *name, int if_type, int devnum, int blksz, - lbaint_t size, struct udevice **devp); + lbaint_t lba, struct udevice **devp); /** * blk_prepare_device() - Prepare a block device for use -- cgit v1.2.3 From 3991f42ed2e38aff28ba3c24369bfbd90620bea7 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 5 Aug 2017 15:45:54 -0600 Subject: dm: core: Add ofnode_for_each_subnode() Add a convenience macro to iterate over subnodes of a node. Make use of this where appropriate in the code. Signed-off-by: Simon Glass --- include/dm/ofnode.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'include') diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index de2769ed537..79374b8f91a 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -628,4 +628,28 @@ int ofnode_read_resource(ofnode node, uint index, struct resource *res); int ofnode_read_resource_byname(ofnode node, const char *name, struct resource *res); +/** + * ofnode_for_each_subnode() - iterate over all subnodes of a parent + * + * @node: child node (ofnode, lvalue) + * @parent: parent node (ofnode) + * + * This is a wrapper around a for loop and is used like so: + * + * ofnode node; + * + * ofnode_for_each_subnode(node, parent) { + * Use node + * ... + * } + * + * Note that this is implemented as a macro and @node is used as + * iterator in the loop. The parent variable can be a constant or even a + * literal. + */ +#define ofnode_for_each_subnode(node, parent) \ + for (node = ofnode_first_subnode(parent); \ + ofnode_valid(node); \ + node = ofnode_next_subnode(node)) + #endif -- cgit v1.2.3 From e81c98649b7a67d43c5baae407430a242d3b26b9 Mon Sep 17 00:00:00 2001 From: Patrice Chotard Date: Mon, 4 Sep 2017 14:55:56 +0200 Subject: dm: core: add clocks node scan Currently, all fixed-clock declared in "clocks" node in device tree can be binded by clk_fixed_rate.c driver only if each of them have the "simple-bus" compatible string. This constraint has been invoked here [1]. This patch offers a solution to avoid adding "simple-bus" compatible string to nodes that are not busses. [1] https://patchwork.ozlabs.org/patch/558837/ Signed-off-by: Patrice Chotard Reviewed-by: Simon Glass --- include/dm/root.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include') diff --git a/include/dm/root.h b/include/dm/root.h index 50a6011644f..b075eef2c1a 100644 --- a/include/dm/root.h +++ b/include/dm/root.h @@ -55,6 +55,20 @@ int dm_scan_platdata(bool pre_reloc_only); */ int dm_scan_fdt(const void *blob, bool pre_reloc_only); +/** + * dm_extended_scan_fdt() - Scan the device tree and bind drivers + * + * This calls dm_scna_dft() which scans the device tree and creates a driver + * for each node. the top-level subnodes are examined and also all sub-nodes + * of "clocks" node. + * + * @blob: Pointer to device tree blob + * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC + * flag. If false bind all drivers. + * @return 0 if OK, -ve on error + */ +int dm_extended_scan_fdt(const void *blob, bool pre_reloc_only); + /** * dm_scan_other() - Scan for other devices * -- cgit v1.2.3