dm: mmc: Add the function for getting current device number
PATCH 1/1 dm: mmc: Add the function for getting current device number
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.
--- drivers/mmc/mmc-uclass.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/mmc/mmc-uclass.c +11 -1
@@ -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;
Signature · 1 line
1.9.1
PATCH 1/1 dm: mmc: Add the function for getting current device number
Hi Jaehoon,
Quoted 6 lines · Jaehoon Chung
get_mmc_numcan be returned 0. Then if you use the "mmcinfo" command, it can't print the mmc information.
Ifget_mmc_numis 0, it means that there is not mmc device. So it added theget_mmc_curr_num()function for getting current device number(index). Andget_mmc_num()is returned the number of device.
Quoted 8 lines
This patch is only tested with mmc block..so i didn't touch the
blk-uclass.c.Signed-off-by Jaehoon Chung <[email protected]>--- 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?
Quoted 22 lines
drivers/mmc/mmc-uclass.c +10
-0@@ -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 ); }
drivers/mmc/mmc-uclass.c int mmc_get_next_devnum(void) · line 133
Quoted 7 lines
drivers/mmc/mmc-uclass.c +1
-1@@ -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
Quoted 4 lines
drivers/mmc/mmc-uclass.c +0
-1--1.9.1
Regards,
Simon
PATCH 1/1 dm: mmc: Add the function for getting current device number
Quoted 18 lines · Simon Glass
Hi Jaehoon,
Quoted 6 lines · Jaehoon Chung
get_mmc_numcan be returned 0. Then if you use the "mmcinfo" command, it can't print the mmc information.
Ifget_mmc_numis 0, it means that there is not mmc device. So it added theget_mmc_curr_num()function for getting current device number(index). Andget_mmc_num()is returned the number of device.Quoted 8 lines
This patch is only tested with mmc block..so i didn't touch the
blk-uclass.c.Signed-off-by Jaehoon Chung <[email protected]>--- drivers/mmc/mmc-uclass.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
Quoted 6 lines
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.
Quoted 2 lines
Can you repeat this problem with sandbox?
I will check this problem with sandbox. After that, i will share..
Quoted 26 lines
Quoted 26 lines
drivers/mmc/mmc-uclass.c +10
-0@@ -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;
Quoted 6 lines
drivers/mmc/mmc-uclass.c int mmc_get_next_devnum(void) · line 133
Quoted 4 lines
drivers/mmc/mmc-uclass.c +1
-1- 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
Quoted 11 lines
Quoted 5 lines
drivers/mmc/mmc-uclass.c +0
-1--1.9.1
Regards,
Simon