[U-Boot] [PATCH 4/7] mmc: rescan fails on empty slot

Michael Jones michael.jones at matrix-vision.de
Wed Jul 20 10:51:29 CEST 2011


Hi Jaehoon Chung,

On 07/19/2011 04:06 AM, Jaehoon Chung wrote:
> 
> Hi Michael.
> 
> I have some question. there are some mmc_init().
> But you are only checked there..
> Did you have any special reason?
> 
> Regards,
> Jaehoon Chung

The purpose of my patch was to enable an if/else to detect whether there
was a card in the slot. Among the available mmc commands, I thought 'mmc
rescan' was the most logical to be able to use to detect whether a slot
was empty or not.

Below is a survey of other places where a similar check could be done. I
think that if a similar check is to be made in these cases, they could
be in separate patch(es) from this one.

- 'mmc read/write': These commands should fail anyway if the slot were
empty.
- 'mmc part' prints "## Unknown partition table" if the slot is empty,
although the command itself still returns successfully. I suppose the
check could make sense here.
- 'mmc dev': I thought there was perhaps a use case where it makes sense
to switch to a mmc device which is currently empty. If that is not true,
it would probably make sense to do the same check there.
- 'mmcinfo': Currently this basically prints '0' for all the fields when
the slot is empty. It probably would be more logical to print "device
init failed" or similar instead.

-Michael

> 
> Michael Jones wrote:
>> Fail in 'mmc rescan' if mmc_init() returns error
>>
>> Signed-off-by: Michael Jones <michael.jones at matrix-vision.de>
>> ---
>>  common/cmd_mmc.c |    6 ++++--
>>  1 files changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
>> index 176646d..28918f6 100644
>> --- a/common/cmd_mmc.c
>> +++ b/common/cmd_mmc.c
>> @@ -165,9 +165,11 @@ int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>>  		}
>>  
>>  		mmc->has_init = 0;
>> -		mmc_init(mmc);
>>  
>> -		return 0;
>> +		if (mmc_init(mmc))
>> +			return 1;
>> +		else
>> +			return 0;
>>  	} else if (strncmp(argv[1], "part", 4) == 0) {
>>  		block_dev_desc_t *mmc_dev;
>>  		struct mmc *mmc = find_mmc_device(curr_device);
> 


MATRIX VISION GmbH, Talstrasse 16, DE-71570 Oppenweiler
Registergericht: Amtsgericht Stuttgart, HRB 271090
Geschaeftsfuehrer: Gerhard Thullner, Werner Armingeon, Uwe Furtner, Erhard Meier


More information about the U-Boot mailing list