All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] dm: mmc: Add the function for getting current device number
@ 2016-07-04  7:40 Jaehoon Chung
  2016-07-12 21:57 ` Simon Glass
  0 siblings, 1 reply; 3+ messages in thread
From: Jaehoon Chung @ 2016-07-04  7:40 UTC (permalink / raw)
  To: u-boot

get_mmc_num can be returned 0. Then if you use the "mmcinfo" command, it
can't print the mmc information.
If get_mmc_num is 0, it means that there is not mmc device.
So it added the get_mmc_curr_num() function for getting current device
number(index). And get_mmc_num() is returned the number of device.

This patch is only tested with mmc block..so i didn't touch the
blk-uclass.c.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
---
 drivers/mmc/mmc-uclass.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index 38ced41..a3f2463 100644
--- a/drivers/mmc/mmc-uclass.c
+++ b/drivers/mmc/mmc-uclass.c
@@ -111,6 +111,16 @@ struct mmc *find_mmc_device(int dev_num)
 
 int get_mmc_num(void)
 {
+	int devnum = blk_find_max_devnum(IF_TYPE_MMC);
+
+	if (devnum < 0)
+		return devnum;
+
+	return devnum + 1;
+}
+
+static int get_mmc_curr_num(void)
+{
 	return max(blk_find_max_devnum(IF_TYPE_MMC), 0);
 }
 
@@ -118,7 +128,7 @@ int mmc_get_next_devnum(void)
 {
 	int ret;
 
-	ret = get_mmc_num();
+	ret = get_mmc_curr_num();
 	if (ret < 0)
 		return ret;
 
-- 
1.9.1

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

* [U-Boot] [PATCH] dm: mmc: Add the function for getting current device number
  2016-07-04  7:40 [U-Boot] [PATCH] dm: mmc: Add the function for getting current device number Jaehoon Chung
@ 2016-07-12 21:57 ` Simon Glass
  2016-07-15  1:28   ` Jaehoon Chung
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Glass @ 2016-07-12 21:57 UTC (permalink / raw)
  To: u-boot

Hi Jaehoon,

On 4 July 2016 at 01:40, Jaehoon Chung <jh80.chung@samsung.com> wrote:
> get_mmc_num can be returned 0. Then if you use the "mmcinfo" command, it
> can't print the mmc information.
> If get_mmc_num is 0, it means that there is not mmc device.
> So it added the get_mmc_curr_num() function for getting current device
> number(index). And get_mmc_num() is returned the number of device.
>
> This patch is only tested with mmc block..so i didn't touch the
> blk-uclass.c.
>
> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
> ---
>  drivers/mmc/mmc-uclass.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
>

Can you please add a function comment for get_mmc_num() in the header
file? It's not really clear what is supposed to return.

Also there are two implementations - one in the uclass and one in
mmc_legacy.c. If the latter does not need changing, can you please add
a comment in your commit as to why?

Can you repeat this problem with sandbox?

> diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
> index 38ced41..a3f2463 100644
> --- a/drivers/mmc/mmc-uclass.c
> +++ b/drivers/mmc/mmc-uclass.c
> @@ -111,6 +111,16 @@ struct mmc *find_mmc_device(int dev_num)
>
>  int get_mmc_num(void)
>  {
> +       int devnum = blk_find_max_devnum(IF_TYPE_MMC);
> +
> +       if (devnum < 0)
> +               return devnum;
> +
> +       return devnum + 1;
> +}
> +
> +static int get_mmc_curr_num(void)
> +{
>         return max(blk_find_max_devnum(IF_TYPE_MMC), 0);
>  }
>
> @@ -118,7 +128,7 @@ int mmc_get_next_devnum(void)
>  {
>         int ret;
>
> -       ret = get_mmc_num();
> +       ret = get_mmc_curr_num();
>         if (ret < 0)
>                 return ret;

But get_mmc_curr_num() cannot return < 0

>
> --
> 1.9.1
>

Regards,
Simon

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

* [U-Boot] [PATCH] dm: mmc: Add the function for getting current device number
  2016-07-12 21:57 ` Simon Glass
@ 2016-07-15  1:28   ` Jaehoon Chung
  0 siblings, 0 replies; 3+ messages in thread
From: Jaehoon Chung @ 2016-07-15  1:28 UTC (permalink / raw)
  To: u-boot

On 07/13/2016 06:57 AM, Simon Glass wrote:
> Hi Jaehoon,
> 
> On 4 July 2016 at 01:40, Jaehoon Chung <jh80.chung@samsung.com> wrote:
>> get_mmc_num can be returned 0. Then if you use the "mmcinfo" command, it
>> can't print the mmc information.
>> If get_mmc_num is 0, it means that there is not mmc device.
>> So it added the get_mmc_curr_num() function for getting current device
>> number(index). And get_mmc_num() is returned the number of device.
>>
>> This patch is only tested with mmc block..so i didn't touch the
>> blk-uclass.c.
>>
>> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
>> ---
>>  drivers/mmc/mmc-uclass.c | 12 +++++++++++-
>>  1 file changed, 11 insertions(+), 1 deletion(-)
>>
> 
> Can you please add a function comment for get_mmc_num() in the header
> file? It's not really clear what is supposed to return.
> 
> Also there are two implementations - one in the uclass and one in
> mmc_legacy.c. If the latter does not need changing, can you please add
> a comment in your commit as to why?

Ok, I will add the explanation in more detail.

> 
> Can you repeat this problem with sandbox?

I will check this problem with sandbox. After that, i will share..

> 
>> diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
>> index 38ced41..a3f2463 100644
>> --- a/drivers/mmc/mmc-uclass.c
>> +++ b/drivers/mmc/mmc-uclass.c
>> @@ -111,6 +111,16 @@ struct mmc *find_mmc_device(int dev_num)
>>
>>  int get_mmc_num(void)
>>  {
>> +       int devnum = blk_find_max_devnum(IF_TYPE_MMC);
>> +
>> +       if (devnum < 0)
>> +               return devnum;
>> +
>> +       return devnum + 1;
>> +}
>> +
>> +static int get_mmc_curr_num(void)
>> +{
>>         return max(blk_find_max_devnum(IF_TYPE_MMC), 0);
>>  }
>>
>> @@ -118,7 +128,7 @@ int mmc_get_next_devnum(void)
>>  {
>>         int ret;
>>
>> -       ret = get_mmc_num();
>> +       ret = get_mmc_curr_num();
>>         if (ret < 0)
>>                 return ret;
> 
> But get_mmc_curr_num() cannot return < 0

You're right. It's my mistake.

Best Regards,
Jaehoon Chung

> 
>>
>> --
>> 1.9.1
>>
> 
> Regards,
> Simon
> 
> 
> 

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

end of thread, other threads:[~2016-07-15  1:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-04  7:40 [U-Boot] [PATCH] dm: mmc: Add the function for getting current device number Jaehoon Chung
2016-07-12 21:57 ` Simon Glass
2016-07-15  1:28   ` Jaehoon Chung

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.