[U-Boot] [PATCH] dm: mmc: Add the function for getting current device number

Jaehoon Chung jh80.chung at samsung.com
Fri Jul 15 03:28:50 CEST 2016


On 07/13/2016 06:57 AM, Simon Glass wrote:
> Hi Jaehoon,
> 
> On 4 July 2016 at 01:40, Jaehoon Chung <jh80.chung at 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 at 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
> 
> 
> 



More information about the U-Boot mailing list