All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/3] dm: mmc: Tidy up use of block devices
@ 2017-05-27 17:37 ` Simon Glass
  2017-05-27 17:37   ` [U-Boot] [PATCH 1/3] dm: blk: Add a way to obtain a block device from its parent Simon Glass
                     ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Simon Glass @ 2017-05-27 17:37 UTC (permalink / raw)
  To: u-boot

A recent series added a patch to avoid probing block devices in
find_mmc_device(). This is because callers should obtain the block device
itself, not the MMC device. But for now the environment code has not been
converted.

The patch caused problems on some boards so was dropped.

This series reinstates that patch, but ensures that the block device is
probed first.


Simon Glass (3):
  dm: blk: Add a way to obtain a block device from its parent
  dm: mmc: Ensure that block device is probed
  dm: mmc: Avoid probing block devices in find_mmc_device()

 common/env_mmc.c           |  7 ++++++-
 drivers/block/blk-uclass.c | 26 ++++++++++++++++++++++++++
 drivers/mmc/mmc-uclass.c   |  6 ++++--
 include/blk.h              |  7 +++++++
 test/dm/blk.c              | 18 ++++++++++++++++++
 5 files changed, 61 insertions(+), 3 deletions(-)

-- 
2.13.0.219.gdb65acc882-goog

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

* [U-Boot] [PATCH 1/3] dm: blk: Add a way to obtain a block device from its parent
  2017-05-27 17:37 ` [U-Boot] [PATCH 0/3] dm: mmc: Tidy up use of block devices Simon Glass
@ 2017-05-27 17:37   ` Simon Glass
  2017-05-28 11:43     ` Tom Rini
  2017-06-07  3:49     ` Jaehoon Chung
  2017-05-27 17:37   ` [U-Boot] [PATCH 2/3] dm: mmc: Ensure that block device is probed Simon Glass
                     ` (2 subsequent siblings)
  3 siblings, 2 replies; 13+ messages in thread
From: Simon Glass @ 2017-05-27 17:37 UTC (permalink / raw)
  To: u-boot

Many devices support a child block device (e.g. MMC, USB). Add a
convenient way to get this device given the parent device.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/block/blk-uclass.c | 26 ++++++++++++++++++++++++++
 include/blk.h              |  7 +++++++
 test/dm/blk.c              | 18 ++++++++++++++++++
 3 files changed, 51 insertions(+)

diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 6145675271..23f131b7ad 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -453,6 +453,32 @@ int blk_prepare_device(struct udevice *dev)
 	return 0;
 }
 
+int blk_get_from_parent(struct udevice *parent, struct udevice **devp)
+{
+	struct udevice *dev;
+	enum uclass_id id;
+	int ret;
+
+	device_find_first_child(parent, &dev);
+	if (!dev) {
+		debug("%s: No block device found for parent '%s'\n", __func__,
+		      parent->name);
+		return -ENODEV;
+	}
+	id = device_get_uclass_id(dev);
+	if (id != UCLASS_BLK) {
+		debug("%s: Incorrect uclass %s for block device '%s'\n",
+		      __func__, uclass_get_name(id), dev->name);
+		return -ENOTBLK;
+	}
+	ret = device_probe(dev);
+	if (ret)
+		return ret;
+	*devp = dev;
+
+	return 0;
+}
+
 int blk_find_max_devnum(enum if_type if_type)
 {
 	struct udevice *dev;
diff --git a/include/blk.h b/include/blk.h
index a128ee4841..4d60987f61 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -616,4 +616,11 @@ ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
  */
 int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart);
 
+/**
+ * blk_get_from_parent() - obtain a block device by looking up its parent
+ *
+ * All devices with
+ */
+int blk_get_from_parent(struct udevice *parent, struct udevice **devp);
+
 #endif
diff --git a/test/dm/blk.c b/test/dm/blk.c
index 5c5eb829a0..923e8d95f0 100644
--- a/test/dm/blk.c
+++ b/test/dm/blk.c
@@ -150,3 +150,21 @@ static int dm_test_blk_devnum(struct unit_test_state *uts)
 	return 0;
 }
 DM_TEST(dm_test_blk_devnum, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test that we can get a block from its parent */
+static int dm_test_blk_get_from_parent(struct unit_test_state *uts)
+{
+	struct udevice *dev, *blk;
+
+	ut_assertok(uclass_get_device(UCLASS_MMC, 0, &dev));
+	ut_assertok(blk_get_from_parent(dev, &blk));
+
+	ut_assertok(uclass_get_device(UCLASS_I2C, 0, &dev));
+	ut_asserteq(-ENOTBLK, blk_get_from_parent(dev, &blk));
+
+	ut_assertok(uclass_get_device(UCLASS_GPIO, 0, &dev));
+	ut_asserteq(-ENODEV, blk_get_from_parent(dev, &blk));
+
+	return 0;
+}
+DM_TEST(dm_test_blk_get_from_parent, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
-- 
2.13.0.219.gdb65acc882-goog

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

* [U-Boot] [PATCH 2/3] dm: mmc: Ensure that block device is probed
  2017-05-27 17:37 ` [U-Boot] [PATCH 0/3] dm: mmc: Tidy up use of block devices Simon Glass
  2017-05-27 17:37   ` [U-Boot] [PATCH 1/3] dm: blk: Add a way to obtain a block device from its parent Simon Glass
@ 2017-05-27 17:37   ` Simon Glass
  2017-05-28 11:43     ` Tom Rini
  2017-05-27 17:37   ` [U-Boot] [PATCH 3/3] dm: mmc: Avoid probing block devices in find_mmc_device() Simon Glass
  2017-06-02  3:18   ` [U-Boot] [PATCH 0/3] dm: mmc: Tidy up use of block devices Jaehoon Chung
  3 siblings, 1 reply; 13+ messages in thread
From: Simon Glass @ 2017-05-27 17:37 UTC (permalink / raw)
  To: u-boot

Make sure that we probe the block device before using it when reading
the environment.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/env_mmc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/common/env_mmc.c b/common/env_mmc.c
index 1611886e22..3763b12278 100644
--- a/common/env_mmc.c
+++ b/common/env_mmc.c
@@ -98,7 +98,12 @@ static const char *init_mmc_for_env(struct mmc *mmc)
 	if (!mmc)
 		return "!No MMC card found";
 
-#ifndef CONFIG_BLK
+#ifdef CONFIG_BLK
+	struct udevice *dev;
+
+	if (blk_get_from_parent(mmc->dev, &dev))
+		return "!No block device";
+#else
 	if (mmc_init(mmc))
 		return "!MMC init failed";
 #endif
-- 
2.13.0.219.gdb65acc882-goog

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

* [U-Boot] [PATCH 3/3] dm: mmc: Avoid probing block devices in find_mmc_device()
  2017-05-27 17:37 ` [U-Boot] [PATCH 0/3] dm: mmc: Tidy up use of block devices Simon Glass
  2017-05-27 17:37   ` [U-Boot] [PATCH 1/3] dm: blk: Add a way to obtain a block device from its parent Simon Glass
  2017-05-27 17:37   ` [U-Boot] [PATCH 2/3] dm: mmc: Ensure that block device is probed Simon Glass
@ 2017-05-27 17:37   ` Simon Glass
  2017-05-28 11:43     ` Tom Rini
  2017-06-02  3:18   ` [U-Boot] [PATCH 0/3] dm: mmc: Tidy up use of block devices Jaehoon Chung
  3 siblings, 1 reply; 13+ messages in thread
From: Simon Glass @ 2017-05-27 17:37 UTC (permalink / raw)
  To: u-boot

We do not need to probe the block device here, so avoid doing so. The MMC
device itself must be active, but the block device can come later.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/mmc/mmc-uclass.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index 4dc3925fe6..994d2686f4 100644
--- a/drivers/mmc/mmc-uclass.c
+++ b/drivers/mmc/mmc-uclass.c
@@ -97,7 +97,7 @@ struct mmc *find_mmc_device(int dev_num)
 	struct udevice *dev, *mmc_dev;
 	int ret;
 
-	ret = blk_get_device(IF_TYPE_MMC, dev_num, &dev);
+	ret = blk_find_device(IF_TYPE_MMC, dev_num, &dev);
 
 	if (ret) {
 #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
@@ -108,7 +108,9 @@ struct mmc *find_mmc_device(int dev_num)
 
 	mmc_dev = dev_get_parent(dev);
 
-	return mmc_get_mmc_dev(mmc_dev);
+	struct mmc *mmc = mmc_get_mmc_dev(mmc_dev);
+
+	return mmc;
 }
 
 int get_mmc_num(void)
-- 
2.13.0.219.gdb65acc882-goog

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

* [U-Boot] [PATCH 3/3] dm: mmc: Avoid probing block devices in find_mmc_device()
  2017-05-27 17:37   ` [U-Boot] [PATCH 3/3] dm: mmc: Avoid probing block devices in find_mmc_device() Simon Glass
@ 2017-05-28 11:43     ` Tom Rini
  0 siblings, 0 replies; 13+ messages in thread
From: Tom Rini @ 2017-05-28 11:43 UTC (permalink / raw)
  To: u-boot

On Sat, May 27, 2017 at 11:37:19AM -0600, Simon Glass wrote:

> We do not need to probe the block device here, so avoid doing so. The MMC
> device itself must be active, but the block device can come later.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> 
>  drivers/mmc/mmc-uclass.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
> index 4dc3925fe6..994d2686f4 100644
> --- a/drivers/mmc/mmc-uclass.c
> +++ b/drivers/mmc/mmc-uclass.c
> @@ -97,7 +97,7 @@ struct mmc *find_mmc_device(int dev_num)
>  	struct udevice *dev, *mmc_dev;
>  	int ret;
>  
> -	ret = blk_get_device(IF_TYPE_MMC, dev_num, &dev);
> +	ret = blk_find_device(IF_TYPE_MMC, dev_num, &dev);
>  
>  	if (ret) {
>  #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
> @@ -108,7 +108,9 @@ struct mmc *find_mmc_device(int dev_num)
>  
>  	mmc_dev = dev_get_parent(dev);
>  
> -	return mmc_get_mmc_dev(mmc_dev);
> +	struct mmc *mmc = mmc_get_mmc_dev(mmc_dev);
> +
> +	return mmc;

We should declare new variables at the top of the function here, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170528/b4186341/attachment.sig>

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

* [U-Boot] [PATCH 1/3] dm: blk: Add a way to obtain a block device from its parent
  2017-05-27 17:37   ` [U-Boot] [PATCH 1/3] dm: blk: Add a way to obtain a block device from its parent Simon Glass
@ 2017-05-28 11:43     ` Tom Rini
  2017-06-07  3:49     ` Jaehoon Chung
  1 sibling, 0 replies; 13+ messages in thread
From: Tom Rini @ 2017-05-28 11:43 UTC (permalink / raw)
  To: u-boot

On Sat, May 27, 2017 at 11:37:17AM -0600, Simon Glass wrote:

> Many devices support a child block device (e.g. MMC, USB). Add a
> convenient way to get this device given the parent device.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170528/c4254653/attachment.sig>

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

* [U-Boot] [PATCH 2/3] dm: mmc: Ensure that block device is probed
  2017-05-27 17:37   ` [U-Boot] [PATCH 2/3] dm: mmc: Ensure that block device is probed Simon Glass
@ 2017-05-28 11:43     ` Tom Rini
  0 siblings, 0 replies; 13+ messages in thread
From: Tom Rini @ 2017-05-28 11:43 UTC (permalink / raw)
  To: u-boot

On Sat, May 27, 2017 at 11:37:18AM -0600, Simon Glass wrote:

> Make sure that we probe the block device before using it when reading
> the environment.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170528/6e6f48ba/attachment.sig>

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

* [U-Boot] [PATCH 0/3] dm: mmc: Tidy up use of block devices
  2017-05-27 17:37 ` [U-Boot] [PATCH 0/3] dm: mmc: Tidy up use of block devices Simon Glass
                     ` (2 preceding siblings ...)
  2017-05-27 17:37   ` [U-Boot] [PATCH 3/3] dm: mmc: Avoid probing block devices in find_mmc_device() Simon Glass
@ 2017-06-02  3:18   ` Jaehoon Chung
  2017-06-02  3:29     ` Simon Glass
  3 siblings, 1 reply; 13+ messages in thread
From: Jaehoon Chung @ 2017-06-02  3:18 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On 05/28/2017 02:37 AM, Simon Glass wrote:
> A recent series added a patch to avoid probing block devices in
> find_mmc_device(). This is because callers should obtain the block device
> itself, not the MMC device. But for now the environment code has not been
> converted.
> 
> The patch caused problems on some boards so was dropped.
> 
> This series reinstates that patch, but ensures that the block device is
> probed first.
> 

Is there a patch before applying these patches?
When i tried to apply patches from patchwork, it doesn't apply.

Best Regards,
Jaehoon Chung

> 
> Simon Glass (3):
>   dm: blk: Add a way to obtain a block device from its parent
>   dm: mmc: Ensure that block device is probed
>   dm: mmc: Avoid probing block devices in find_mmc_device()
> 
>  common/env_mmc.c           |  7 ++++++-
>  drivers/block/blk-uclass.c | 26 ++++++++++++++++++++++++++
>  drivers/mmc/mmc-uclass.c   |  6 ++++--
>  include/blk.h              |  7 +++++++
>  test/dm/blk.c              | 18 ++++++++++++++++++
>  5 files changed, 61 insertions(+), 3 deletions(-)
> 

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

* [U-Boot] [PATCH 0/3] dm: mmc: Tidy up use of block devices
  2017-06-02  3:18   ` [U-Boot] [PATCH 0/3] dm: mmc: Tidy up use of block devices Jaehoon Chung
@ 2017-06-02  3:29     ` Simon Glass
  0 siblings, 0 replies; 13+ messages in thread
From: Simon Glass @ 2017-06-02  3:29 UTC (permalink / raw)
  To: u-boot

Hi Jaehoon,

On 1 June 2017 at 21:18, Jaehoon Chung <jh80.chung@samsung.com> wrote:
> Hi Simon,
>
> On 05/28/2017 02:37 AM, Simon Glass wrote:
>> A recent series added a patch to avoid probing block devices in
>> find_mmc_device(). This is because callers should obtain the block device
>> itself, not the MMC device. But for now the environment code has not been
>> converted.
>>
>> The patch caused problems on some boards so was dropped.
>>
>> This series reinstates that patch, but ensures that the block device is
>> probed first.
>>
>
> Is there a patch before applying these patches?
> When i tried to apply patches from patchwork, it doesn't apply.
>
> Best Regards,
> Jaehoon Chung
>
>>
>> Simon Glass (3):
>>   dm: blk: Add a way to obtain a block device from its parent
>>   dm: mmc: Ensure that block device is probed
>>   dm: mmc: Avoid probing block devices in find_mmc_device()
>>
>>  common/env_mmc.c           |  7 ++++++-
>>  drivers/block/blk-uclass.c | 26 ++++++++++++++++++++++++++
>>  drivers/mmc/mmc-uclass.c   |  6 ++++--
>>  include/blk.h              |  7 +++++++
>>  test/dm/blk.c              | 18 ++++++++++++++++++
>>  5 files changed, 61 insertions(+), 3 deletions(-)
>>
>

Yes - it is at u-boot-dm/mmc-working. I think the prerequisites will
land in master tonight.

Regards,
Simon

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

* [U-Boot] [PATCH 1/3] dm: blk: Add a way to obtain a block device from its parent
  2017-05-27 17:37   ` [U-Boot] [PATCH 1/3] dm: blk: Add a way to obtain a block device from its parent Simon Glass
  2017-05-28 11:43     ` Tom Rini
@ 2017-06-07  3:49     ` Jaehoon Chung
  2017-06-09  3:06       ` Simon Glass
  1 sibling, 1 reply; 13+ messages in thread
From: Jaehoon Chung @ 2017-06-07  3:49 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On 05/28/2017 02:37 AM, Simon Glass wrote:
> Many devices support a child block device (e.g. MMC, USB). Add a
> convenient way to get this device given the parent device.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> 
>  drivers/block/blk-uclass.c | 26 ++++++++++++++++++++++++++
>  include/blk.h              |  7 +++++++
>  test/dm/blk.c              | 18 ++++++++++++++++++
>  3 files changed, 51 insertions(+)
> 
> diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
> index 6145675271..23f131b7ad 100644
> --- a/drivers/block/blk-uclass.c
> +++ b/drivers/block/blk-uclass.c
> @@ -453,6 +453,32 @@ int blk_prepare_device(struct udevice *dev)
>  	return 0;
>  }
>  
> +int blk_get_from_parent(struct udevice *parent, struct udevice **devp)
> +{
> +	struct udevice *dev;
> +	enum uclass_id id;
> +	int ret;
> +
> +	device_find_first_child(parent, &dev);
> +	if (!dev) {
> +		debug("%s: No block device found for parent '%s'\n", __func__,
> +		      parent->name);
> +		return -ENODEV;
> +	}
> +	id = device_get_uclass_id(dev);
> +	if (id != UCLASS_BLK) {
> +		debug("%s: Incorrect uclass %s for block device '%s'\n",
> +		      __func__, uclass_get_name(id), dev->name);
> +		return -ENOTBLK;
> +	}
> +	ret = device_probe(dev);
> +	if (ret)
> +		return ret;
> +	*devp = dev;
> +
> +	return 0;
> +}
> +
>  int blk_find_max_devnum(enum if_type if_type)
>  {
>  	struct udevice *dev;
> diff --git a/include/blk.h b/include/blk.h
> index a128ee4841..4d60987f61 100644
> --- a/include/blk.h
> +++ b/include/blk.h
> @@ -616,4 +616,11 @@ ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
>   */
>  int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart);
>  
> +/**
> + * blk_get_from_parent() - obtain a block device by looking up its parent
> + *
> + * All devices with
> + */
> +int blk_get_from_parent(struct udevice *parent, struct udevice **devp);

Don't need to consider whether CONFIG_BLK is defined or not?
blk_get_from_parent() is declared in blk-uclass.c

Best Regards,
Jaehoon Chung

> +
>  #endif
> diff --git a/test/dm/blk.c b/test/dm/blk.c
> index 5c5eb829a0..923e8d95f0 100644
> --- a/test/dm/blk.c
> +++ b/test/dm/blk.c
> @@ -150,3 +150,21 @@ static int dm_test_blk_devnum(struct unit_test_state *uts)
>  	return 0;
>  }
>  DM_TEST(dm_test_blk_devnum, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
> +
> +/* Test that we can get a block from its parent */
> +static int dm_test_blk_get_from_parent(struct unit_test_state *uts)
> +{
> +	struct udevice *dev, *blk;
> +
> +	ut_assertok(uclass_get_device(UCLASS_MMC, 0, &dev));
> +	ut_assertok(blk_get_from_parent(dev, &blk));
> +
> +	ut_assertok(uclass_get_device(UCLASS_I2C, 0, &dev));
> +	ut_asserteq(-ENOTBLK, blk_get_from_parent(dev, &blk));
> +
> +	ut_assertok(uclass_get_device(UCLASS_GPIO, 0, &dev));
> +	ut_asserteq(-ENODEV, blk_get_from_parent(dev, &blk));
> +
> +	return 0;
> +}
> +DM_TEST(dm_test_blk_get_from_parent, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
> 

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

* [U-Boot] [PATCH 1/3] dm: blk: Add a way to obtain a block device from its parent
  2017-06-07  3:49     ` Jaehoon Chung
@ 2017-06-09  3:06       ` Simon Glass
  2017-06-09  3:38         ` Jaehoon Chung
  0 siblings, 1 reply; 13+ messages in thread
From: Simon Glass @ 2017-06-09  3:06 UTC (permalink / raw)
  To: u-boot

Hi Jaehoon,

On 6 June 2017 at 21:49, Jaehoon Chung <jh80.chung@samsung.com> wrote:
> Hi Simon,
>
> On 05/28/2017 02:37 AM, Simon Glass wrote:
>> Many devices support a child block device (e.g. MMC, USB). Add a
>> convenient way to get this device given the parent device.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>>  drivers/block/blk-uclass.c | 26 ++++++++++++++++++++++++++
>>  include/blk.h              |  7 +++++++
>>  test/dm/blk.c              | 18 ++++++++++++++++++
>>  3 files changed, 51 insertions(+)
>>
>> diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
>> index 6145675271..23f131b7ad 100644
>> --- a/drivers/block/blk-uclass.c
>> +++ b/drivers/block/blk-uclass.c
>> @@ -453,6 +453,32 @@ int blk_prepare_device(struct udevice *dev)
>>       return 0;
>>  }
>>
>> +int blk_get_from_parent(struct udevice *parent, struct udevice **devp)
>> +{
>> +     struct udevice *dev;
>> +     enum uclass_id id;
>> +     int ret;
>> +
>> +     device_find_first_child(parent, &dev);
>> +     if (!dev) {
>> +             debug("%s: No block device found for parent '%s'\n", __func__,
>> +                   parent->name);
>> +             return -ENODEV;
>> +     }
>> +     id = device_get_uclass_id(dev);
>> +     if (id != UCLASS_BLK) {
>> +             debug("%s: Incorrect uclass %s for block device '%s'\n",
>> +                   __func__, uclass_get_name(id), dev->name);
>> +             return -ENOTBLK;
>> +     }
>> +     ret = device_probe(dev);
>> +     if (ret)
>> +             return ret;
>> +     *devp = dev;
>> +
>> +     return 0;
>> +}
>> +
>>  int blk_find_max_devnum(enum if_type if_type)
>>  {
>>       struct udevice *dev;
>> diff --git a/include/blk.h b/include/blk.h
>> index a128ee4841..4d60987f61 100644
>> --- a/include/blk.h
>> +++ b/include/blk.h
>> @@ -616,4 +616,11 @@ ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
>>   */
>>  int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart);
>>
>> +/**
>> + * blk_get_from_parent() - obtain a block device by looking up its parent
>> + *
>> + * All devices with
>> + */
>> +int blk_get_from_parent(struct udevice *parent, struct udevice **devp);
>
> Don't need to consider whether CONFIG_BLK is defined or not?
> blk_get_from_parent() is declared in blk-uclass.c

Well in that case this function will not be called, so I think it is OK.

>
> Best Regards,
> Jaehoon Chung

- Simon

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

* [U-Boot] [PATCH 1/3] dm: blk: Add a way to obtain a block device from its parent
  2017-06-09  3:06       ` Simon Glass
@ 2017-06-09  3:38         ` Jaehoon Chung
  2017-06-21  1:49           ` Simon Glass
  0 siblings, 1 reply; 13+ messages in thread
From: Jaehoon Chung @ 2017-06-09  3:38 UTC (permalink / raw)
  To: u-boot

On 06/09/2017 12:06 PM, Simon Glass wrote:
> Hi Jaehoon,
> 
> On 6 June 2017 at 21:49, Jaehoon Chung <jh80.chung@samsung.com> wrote:
>> Hi Simon,
>>
>> On 05/28/2017 02:37 AM, Simon Glass wrote:
>>> Many devices support a child block device (e.g. MMC, USB). Add a
>>> convenient way to get this device given the parent device.
>>>
>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>> ---
>>>
>>>  drivers/block/blk-uclass.c | 26 ++++++++++++++++++++++++++
>>>  include/blk.h              |  7 +++++++
>>>  test/dm/blk.c              | 18 ++++++++++++++++++
>>>  3 files changed, 51 insertions(+)
>>>
>>> diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
>>> index 6145675271..23f131b7ad 100644
>>> --- a/drivers/block/blk-uclass.c
>>> +++ b/drivers/block/blk-uclass.c
>>> @@ -453,6 +453,32 @@ int blk_prepare_device(struct udevice *dev)
>>>       return 0;
>>>  }
>>>
>>> +int blk_get_from_parent(struct udevice *parent, struct udevice **devp)
>>> +{
>>> +     struct udevice *dev;
>>> +     enum uclass_id id;
>>> +     int ret;
>>> +
>>> +     device_find_first_child(parent, &dev);
>>> +     if (!dev) {
>>> +             debug("%s: No block device found for parent '%s'\n", __func__,
>>> +                   parent->name);
>>> +             return -ENODEV;
>>> +     }
>>> +     id = device_get_uclass_id(dev);
>>> +     if (id != UCLASS_BLK) {
>>> +             debug("%s: Incorrect uclass %s for block device '%s'\n",
>>> +                   __func__, uclass_get_name(id), dev->name);
>>> +             return -ENOTBLK;
>>> +     }
>>> +     ret = device_probe(dev);
>>> +     if (ret)
>>> +             return ret;
>>> +     *devp = dev;
>>> +
>>> +     return 0;
>>> +}
>>> +
>>>  int blk_find_max_devnum(enum if_type if_type)
>>>  {
>>>       struct udevice *dev;
>>> diff --git a/include/blk.h b/include/blk.h
>>> index a128ee4841..4d60987f61 100644
>>> --- a/include/blk.h
>>> +++ b/include/blk.h
>>> @@ -616,4 +616,11 @@ ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
>>>   */
>>>  int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart);
>>>
>>> +/**
>>> + * blk_get_from_parent() - obtain a block device by looking up its parent
>>> + *
>>> + * All devices with
>>> + */
>>> +int blk_get_from_parent(struct udevice *parent, struct udevice **devp);
>>
>> Don't need to consider whether CONFIG_BLK is defined or not?
>> blk_get_from_parent() is declared in blk-uclass.c
> 
> Well in that case this function will not be called, so I think it is OK.

include/blk.h:624:32: warning: 'struct udevice' declared inside parameter list will not be visible outside of this definition or declaration
 int blk_get_from_parent(struct udevice *parent, struct udevice **devp);

Plz, check this.. :)

Best Regards,
Jaehoon Chung

> 
>>
>> Best Regards,
>> Jaehoon Chung
> 
> - Simon
> 
> 
> 

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

* [U-Boot] [PATCH 1/3] dm: blk: Add a way to obtain a block device from its parent
  2017-06-09  3:38         ` Jaehoon Chung
@ 2017-06-21  1:49           ` Simon Glass
  0 siblings, 0 replies; 13+ messages in thread
From: Simon Glass @ 2017-06-21  1:49 UTC (permalink / raw)
  To: u-boot

Hi Jaehoon,

On 8 June 2017 at 21:38, Jaehoon Chung <jh80.chung@samsung.com> wrote:
> On 06/09/2017 12:06 PM, Simon Glass wrote:
>> Hi Jaehoon,
>>
>> On 6 June 2017 at 21:49, Jaehoon Chung <jh80.chung@samsung.com> wrote:
>>> Hi Simon,
>>>
>>> On 05/28/2017 02:37 AM, Simon Glass wrote:
>>>> Many devices support a child block device (e.g. MMC, USB). Add a
>>>> convenient way to get this device given the parent device.
>>>>
>>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>>> ---
>>>>
>>>>  drivers/block/blk-uclass.c | 26 ++++++++++++++++++++++++++
>>>>  include/blk.h              |  7 +++++++
>>>>  test/dm/blk.c              | 18 ++++++++++++++++++
>>>>  3 files changed, 51 insertions(+)
>>>>
>>>> diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
>>>> index 6145675271..23f131b7ad 100644
>>>> --- a/drivers/block/blk-uclass.c
>>>> +++ b/drivers/block/blk-uclass.c
>>>> @@ -453,6 +453,32 @@ int blk_prepare_device(struct udevice *dev)
>>>>       return 0;
>>>>  }
>>>>
>>>> +int blk_get_from_parent(struct udevice *parent, struct udevice **devp)
>>>> +{
>>>> +     struct udevice *dev;
>>>> +     enum uclass_id id;
>>>> +     int ret;
>>>> +
>>>> +     device_find_first_child(parent, &dev);
>>>> +     if (!dev) {
>>>> +             debug("%s: No block device found for parent '%s'\n", __func__,
>>>> +                   parent->name);
>>>> +             return -ENODEV;
>>>> +     }
>>>> +     id = device_get_uclass_id(dev);
>>>> +     if (id != UCLASS_BLK) {
>>>> +             debug("%s: Incorrect uclass %s for block device '%s'\n",
>>>> +                   __func__, uclass_get_name(id), dev->name);
>>>> +             return -ENOTBLK;
>>>> +     }
>>>> +     ret = device_probe(dev);
>>>> +     if (ret)
>>>> +             return ret;
>>>> +     *devp = dev;
>>>> +
>>>> +     return 0;
>>>> +}
>>>> +
>>>>  int blk_find_max_devnum(enum if_type if_type)
>>>>  {
>>>>       struct udevice *dev;
>>>> diff --git a/include/blk.h b/include/blk.h
>>>> index a128ee4841..4d60987f61 100644
>>>> --- a/include/blk.h
>>>> +++ b/include/blk.h
>>>> @@ -616,4 +616,11 @@ ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
>>>>   */
>>>>  int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart);
>>>>
>>>> +/**
>>>> + * blk_get_from_parent() - obtain a block device by looking up its parent
>>>> + *
>>>> + * All devices with
>>>> + */
>>>> +int blk_get_from_parent(struct udevice *parent, struct udevice **devp);
>>>
>>> Don't need to consider whether CONFIG_BLK is defined or not?
>>> blk_get_from_parent() is declared in blk-uclass.c
>>
>> Well in that case this function will not be called, so I think it is OK.
>
> include/blk.h:624:32: warning: 'struct udevice' declared inside parameter list will not be visible outside of this definition or declaration
>  int blk_get_from_parent(struct udevice *parent, struct udevice **devp);
>
> Plz, check this.. :)

Which board is this, please?

Regards,
Simon

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

end of thread, other threads:[~2017-06-21  1:49 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20170527173728epcas1p21e089a94bc187a94c282bb9ed160787a@epcas1p2.samsung.com>
2017-05-27 17:37 ` [U-Boot] [PATCH 0/3] dm: mmc: Tidy up use of block devices Simon Glass
2017-05-27 17:37   ` [U-Boot] [PATCH 1/3] dm: blk: Add a way to obtain a block device from its parent Simon Glass
2017-05-28 11:43     ` Tom Rini
2017-06-07  3:49     ` Jaehoon Chung
2017-06-09  3:06       ` Simon Glass
2017-06-09  3:38         ` Jaehoon Chung
2017-06-21  1:49           ` Simon Glass
2017-05-27 17:37   ` [U-Boot] [PATCH 2/3] dm: mmc: Ensure that block device is probed Simon Glass
2017-05-28 11:43     ` Tom Rini
2017-05-27 17:37   ` [U-Boot] [PATCH 3/3] dm: mmc: Avoid probing block devices in find_mmc_device() Simon Glass
2017-05-28 11:43     ` Tom Rini
2017-06-02  3:18   ` [U-Boot] [PATCH 0/3] dm: mmc: Tidy up use of block devices Jaehoon Chung
2017-06-02  3:29     ` Simon Glass

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.