All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v4 3/6] block: Add a function to find block device descriptor
@ 2018-07-06  8:26 tien.fong.chee at intel.com
  2018-07-11 14:02 ` Simon Glass
  2018-09-29 15:43 ` [U-Boot] [U-Boot, v4, " Tom Rini
  0 siblings, 2 replies; 6+ messages in thread
From: tien.fong.chee at intel.com @ 2018-07-06  8:26 UTC (permalink / raw)
  To: u-boot

From: Tien Fong Chee <tien.fong.chee@intel.com>

Add a function to find the block device descriptor of the parent
device.

Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com>
---
 drivers/block/blk-uclass.c | 23 +++++++++++++++++++++++
 include/blk.h              |  9 +++++++++
 2 files changed, 32 insertions(+)

diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 9e0c823..facf527 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -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
diff --git a/include/blk.h b/include/blk.h
index 86f6d50..8ba9ab9 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -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
-- 
2.2.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH v4 3/6] block: Add a function to find block device descriptor
  2018-07-06  8:26 [U-Boot] [PATCH v4 3/6] block: Add a function to find block device descriptor tien.fong.chee at intel.com
@ 2018-07-11 14:02 ` Simon Glass
  2018-07-11 14:23   ` Chee, Tien Fong
  2018-09-29 15:43 ` [U-Boot] [U-Boot, v4, " Tom Rini
  1 sibling, 1 reply; 6+ messages in thread
From: Simon Glass @ 2018-07-11 14:02 UTC (permalink / raw)
  To: u-boot

Hi Tien,

On 6 July 2018 at 02:26,  <tien.fong.chee@intel.com> wrote:
> From: Tien Fong Chee <tien.fong.chee@intel.com>
>
> Add a function to find the block device descriptor of the parent
> device.
>
> Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com>
> ---
>  drivers/block/blk-uclass.c | 23 +++++++++++++++++++++++
>  include/blk.h              |  9 +++++++++
>  2 files changed, 32 insertions(+)
>
> diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
> index 9e0c823..facf527 100644
> --- a/drivers/block/blk-uclass.c
> +++ b/drivers/block/blk-uclass.c
> @@ -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;
> +}

Is this different from blk_get_from_parent() ?

[..]

Regards,
Simon

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH v4 3/6] block: Add a function to find block device descriptor
  2018-07-11 14:02 ` Simon Glass
@ 2018-07-11 14:23   ` Chee, Tien Fong
  2018-07-11 20:13     ` Simon Glass
  0 siblings, 1 reply; 6+ messages in thread
From: Chee, Tien Fong @ 2018-07-11 14:23 UTC (permalink / raw)
  To: u-boot

On Wed, 2018-07-11 at 08:02 -0600, Simon Glass wrote:
> Hi Tien,
> 
> On 6 July 2018 at 02:26,  <tien.fong.chee@intel.com> wrote:
> > 
> > From: Tien Fong Chee <tien.fong.chee@intel.com>
> > 
> > Add a function to find the block device descriptor of the parent
> > device.
> > 
> > Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com>
> > ---
> >  drivers/block/blk-uclass.c | 23 +++++++++++++++++++++++
> >  include/blk.h              |  9 +++++++++
> >  2 files changed, 32 insertions(+)
> > 
> > diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-
> > uclass.c
> > index 9e0c823..facf527 100644
> > --- a/drivers/block/blk-uclass.c
> > +++ b/drivers/block/blk-uclass.c
> > @@ -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;
> > +}
> Is this different from blk_get_from_parent() ?
This new function would return block description. 
blk_get_from_parents() would return child device.
> 
> [..]
> 
> Regards,
> Simon

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH v4 3/6] block: Add a function to find block device descriptor
  2018-07-11 14:23   ` Chee, Tien Fong
@ 2018-07-11 20:13     ` Simon Glass
  2018-07-12  5:30       ` Chee, Tien Fong
  0 siblings, 1 reply; 6+ messages in thread
From: Simon Glass @ 2018-07-11 20:13 UTC (permalink / raw)
  To: u-boot

Hi Tien Fong,

On 11 July 2018 at 08:23, Chee, Tien Fong <tien.fong.chee@intel.com> wrote:
> On Wed, 2018-07-11 at 08:02 -0600, Simon Glass wrote:
>> Hi Tien,
>>
>> On 6 July 2018 at 02:26,  <tien.fong.chee@intel.com> wrote:
>> >
>> > From: Tien Fong Chee <tien.fong.chee@intel.com>
>> >
>> > Add a function to find the block device descriptor of the parent
>> > device.
>> >
>> > Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com>
>> > ---
>> >  drivers/block/blk-uclass.c | 23 +++++++++++++++++++++++
>> >  include/blk.h              |  9 +++++++++
>> >  2 files changed, 32 insertions(+)
>> >
>> > diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-
>> > uclass.c
>> > index 9e0c823..facf527 100644
>> > --- a/drivers/block/blk-uclass.c
>> > +++ b/drivers/block/blk-uclass.c
>> > @@ -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;
>> > +}
>> Is this different from blk_get_from_parent() ?
> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH v4 3/6] block: Add a function to find block device descriptor
  2018-07-11 20:13     ` Simon Glass
@ 2018-07-12  5:30       ` Chee, Tien Fong
  0 siblings, 0 replies; 6+ messages in thread
From: Chee, Tien Fong @ 2018-07-12  5:30 UTC (permalink / raw)
  To: u-boot

On Wed, 2018-07-11 at 14:13 -0600, Simon Glass wrote:
> Hi Tien Fong,
> 
> On 11 July 2018 at 08:23, Chee, Tien Fong <tien.fong.chee@intel.com>
> wrote:
> > 
> > On Wed, 2018-07-11 at 08:02 -0600, Simon Glass wrote:
> > > 
> > > Hi Tien,
> > > 
> > > On 6 July 2018 at 02:26,  <tien.fong.chee@intel.com> wrote:
> > > > 
> > > > 
> > > > From: Tien Fong Chee <tien.fong.chee@intel.com>
> > > > 
> > > > Add a function to find the block device descriptor of the
> > > > parent
> > > > device.
> > > > 
> > > > Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com>
> > > > ---
> > > >  drivers/block/blk-uclass.c | 23 +++++++++++++++++++++++
> > > >  include/blk.h              |  9 +++++++++
> > > >  2 files changed, 32 insertions(+)
> > > > 
> > > > diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-
> > > > uclass.c
> > > > index 9e0c823..facf527 100644
> > > > --- a/drivers/block/blk-uclass.c
> > > > +++ b/drivers/block/blk-uclass.c
> > > > @@ -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;
> > > > +}
> > > Is this different from blk_get_from_parent() ?
> > 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.
> 
> Regards,
> Simon

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [U-Boot, v4, 3/6] block: Add a function to find block device descriptor
  2018-07-06  8:26 [U-Boot] [PATCH v4 3/6] block: Add a function to find block device descriptor tien.fong.chee at intel.com
  2018-07-11 14:02 ` Simon Glass
@ 2018-09-29 15:43 ` Tom Rini
  1 sibling, 0 replies; 6+ messages in thread
From: Tom Rini @ 2018-09-29 15:43 UTC (permalink / raw)
  To: u-boot

On Fri, Jul 06, 2018 at 04:26:36PM +0800, tien.fong.chee at intel.com wrote:

> From: Tien Fong Chee <tien.fong.chee@intel.com>
> 
> Add a function to find the block device descriptor of the parent
> device.
> 
> Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com>

Applied to u-boot/master, thanks!

-- 
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>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-09-29 15:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-06  8:26 [U-Boot] [PATCH v4 3/6] block: Add a function to find block device descriptor tien.fong.chee at intel.com
2018-07-11 14:02 ` Simon Glass
2018-07-11 14:23   ` Chee, Tien Fong
2018-07-11 20:13     ` Simon Glass
2018-07-12  5:30       ` Chee, Tien Fong
2018-09-29 15:43 ` [U-Boot] [U-Boot, v4, " Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.