block: Add a function to find block device descriptor
PATCH v4 3/6 block: Add a function to find block device descriptor
From: Tien Fong Chee <[email protected]>
Add a function to find the block device descriptor of the parent device.
--- drivers/block/blk-uclass.c | 23 +++++++++++++++++++++++ include/blk.h | 9 +++++++++ 2 files changed, 32 insertions(+)
drivers/block/blk-uclass.c +23 -0
@@ -132,6 +132,29 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum) }/** +* blk_get_by_device() - Get the block device descriptor for the given device +* @dev: Instance of a storage device +* +* Return: With block device descriptor on success , NULL if there is no such +* block device. +*/ +struct blk_desc *blk_get_by_device (struct udevice *dev) +{ +struct udevice *child_dev, *next; + + device_foreach_child_safe(child_dev, next, dev) { +if (device_get_uclass_id (child_dev) !=UCLASS_BLK ) +continue ; + +return dev_get_uclass_platdata (child_dev); + } + +debug ("%s: No block device found\n" , __func__); + +return NULL ; +} + +/** * get_desc() - Get the block device descriptor for the given device number * * @if_type: Interface type
include/blk.h +9 -0
@@ -541,6 +541,15 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum);/** +* blk_get_by_device() - Get the block device descriptor for the given device +* @dev: Instance of a storage device +* +* Return: With block device descriptor on success , NULL if there is no such +* block device. +*/ +struct blk_desc *blk_get_by_device (struct udevice *dev); + +/** * blk_dselect_hwpart() - select a hardware partition * * This selects a hardware partition (such as is supported by MMC). The block
Signature · 1 line
2.2.0
PATCH v4 3/6 block: Add a function to find block device descriptor
Hi Tien,
Quoted 30 lines · On 6 July 2018 at 02:26, <[email protected]> wrote:
From: Tien Fong Chee <[email protected]>
Add a function to find the block device descriptor of the parent device.
Signed-off-by Tien Fong Chee <[email protected]>--- drivers/block/blk-uclass.c | 23 +++++++++++++++++++++++ include/blk.h | 9 +++++++++ 2 files changed, 32 insertions(+)drivers/block/blk-uclass.c +11
-0@@ -132,6 +132,29 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum) }/** +* blk_get_by_device() - Get the block device descriptor for the given device +* @dev: Instance of a storage device +* +* Return: With block device descriptor on success , NULL if there is no such +* block device. +*/ +struct blk_desc *blk_get_by_device (struct udevice *dev) +{ +struct udevice *child_dev, *next; + + device_foreach_child_safe(child_dev, next, dev) {
drivers/block/blk-uclass.c struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum) · line 155
Quoted 10 lines
drivers/block/blk-uclass.c +10
-0+if (device_get_uclass_id (child_dev) !=UCLASS_BLK ) +continue ; + +return dev_get_uclass_platdata (child_dev); + } + +debug ("%s: No block device found\n" , __func__); + +return NULL ; +}
Is this different from blk_get_from_parent() ?
[..]
Regards,
Simon
Chee
PATCH v4 3/6 block: Add a function to find block device descriptor
Quoted 41 lines · Simon Glass
Hi Tien,
Quoted 38 lines · On 6 July 2018 at 02:26, <[email protected]> wrote:
From: Tien Fong Chee <[email protected]>
Add a function to find the block device descriptor of the parent device.
Signed-off-by Tien Fong Chee <[email protected]>---
drivers/block/blk-uclass.c | 23 +++++++++++++++++++++++ include/blk.h | 9 +++++++++2 files changed, 32 insertions(+)drivers/block/blk- renamed from drivers/block/blk-uclass.c +0
-0
uclass.c
index 9e0c823..facf527 100644drivers/block/blk-uclass.c +1
-0@@ -132,6 +132,29 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum) } /** +* blk_get_by_device() - Get the block device descriptor for the given device
+ * @dev: Instance of a storage device
+ *
+ * Return: With block device descriptor on success , NULL if there is no such
+ * block device.
+ */drivers/block/blk-uclass.c +8
-0+struct blk_desc *blk_get_by_device (struct udevice *dev) +{ + struct udevice *child_dev, *next; + + device_foreach_child_safe(child_dev, next, dev) { + if (device_get_uclass_id(child_dev) != UCLASS_BLK) + continue; +
Quoted 8 lines
drivers/block/blk-uclass.c struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum) · line 155
Quoted 7 lines
+ return
dev_get_uclass_platdata(child_dev); + }drivers/block/blk-uclass.c +5
-0+ + debug("%s: No block device found\n", __func__); + + return NULL; +}Is this different from
blk_get_from_parent()?
This new function would return block description.blk_get_from_parents() would return child device.
Quoted 5 lines
[..]
Regards,
Simon
PATCH v4 3/6 block: Add a function to find block device descriptor
Hi Tien Fong,
Quoted 50 lines · Tien Fong
Quoted 41 lines · Simon Glass
Hi Tien,
Quoted 38 lines · On 6 July 2018 at 02:26, <[email protected]> wrote:
From: Tien Fong Chee <[email protected]>
Add a function to find the block device descriptor of the parent device.
Signed-off-by Tien Fong Chee <[email protected]>--- drivers/block/blk-uclass.c | 23 +++++++++++++++++++++++ include/blk.h | 9 +++++++++ 2 files changed, 32 insertions(+)drivers/block/blk- renamed from drivers/block/blk-uclass.c +0
-0
uclass.c
index 9e0c823..facf527 100644drivers/block/blk-uclass.c +1
-0@@ -132,6 +132,29 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum) }/** +* blk_get_by_device() - Get the block device descriptor for the given device
+ * @dev: Instance of a storage device
+ *
+ * Return: With block device descriptor on success , NULL if there is no such
+ * block device.
+ */drivers/block/blk-uclass.c +8
-0+struct blk_desc *blk_get_by_device (struct udevice *dev) +{ +struct udevice *child_dev, *next; + + device_foreach_child_safe(child_dev, next, dev) { +if (device_get_uclass_id (child_dev) !=UCLASS_BLK ) +continue ; +Quoted 8 lines
drivers/block/blk-uclass.c struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum) · line 155
Quoted 7 lines
drivers/block/blk-uclass.c +7
-0+return dev_get_uclass_platdata (child_dev); + } + +debug ("%s: No block device found\n" , __func__); + +return NULL ; +}Is this different from
blk_get_from_parent()?
Quoted 2 lines
This new function would return block description.
blk_get_from_parents()would return child device.
OK, but please implement your function by calling blk_get_from_parent(). There is no need to duplicate the logic.
Also how about calling it blk_get_desc_from_parent() ?
Regards,
Simon
Chee
PATCH v4 3/6 block: Add a function to find block device descriptor
Quoted 62 lines · Simon Glass
Hi Tien Fong,
Quoted 58 lines · Tien Fong
Quoted 56 lines · Simon Glass
Hi Tien,
Quoted 43 lines · On 6 July 2018 at 02:26, <[email protected]> wrote:
From: Tien Fong Chee <[email protected]>
Add a function to find the block device descriptor of the parent
device.Signed-off-by Tien Fong Chee <[email protected]>---
drivers/block/blk-uclass.c | 23 +++++++++++++++++++++++ include/blk.h | 9 +++++++++2 files changed, 32 insertions(+)drivers/block/blk- renamed from drivers/block/blk-uclass.c +0
-0
uclass.c
index 9e0c823..facf527 100644drivers/block/blk-uclass.c +1
-0@@ -132,6 +132,29 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum) } /** +* blk_get_by_device() - Get the block device descriptor for the
given device
+ * @dev: Instance of a storage device
+ *
+ * Return: With block device descriptor on success , NULL if there
is no such
+ * block device.
+ */drivers/block/blk-uclass.c +6
-0+struct blk_desc *blk_get_by_device (struct udevice *dev) +{ + struct udevice *child_dev, *next; + + device_foreach_child_safe(child_dev, next, dev) { + if (device_get_uclass_id(child_dev) !=
UCLASS_BLK)
+ continue;drivers/block/blk-uclass.c struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum) · line 155
Quoted 8 lines
drivers/block/blk-uclass.c +8
-0+ + return dev_get_uclass_platdata(child_dev); + } + + debug("%s: No block device found\n", __func__); + + return NULL; +}Is this different from
blk_get_from_parent()?
Quoted 6 lines
Quoted 2 lines
This new function would return block description.
blk_get_from_parents()would return child device.OK, but please implement your function by calling
blk_get_from_parent(). There is no need to duplicate the logic.Also how about calling it
blk_get_desc_from_parent()?
Okay.
Quoted 3 lines
Regards,
Simon
PATCH v4 3/6 block: Add a function to find block device descriptor
In reply to tien.fong.chee at intel.comQuoted 6 lines · tien.fong.chee at intel.com
From: Tien Fong Chee <[email protected]>
Add a function to find the block device descriptor of the parent device.
Signed-off-by Tien Fong Chee <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180929/9c521bbc/attachment.sig>