diff mbox series

[RFC,v2,05/20] mmc: call device_probe() after scanning

Message ID 20211210064947.73361-6-takahiro.akashi@linaro.org
State New
Headers show
Series efi_loader: more tightly integrate UEFI disks to driver model | expand

Commit Message

AKASHI Takahiro Dec. 10, 2021, 6:49 a.m. UTC
Every time a mmc bus/port is scanned and a new device is detected,
we want to call device_probe() as it will give us a chance to run
additional post-processings for some purposes.

In particular, support for creating partitions on a device will be added.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
---
 drivers/mmc/mmc-uclass.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Heinrich Schuchardt Dec. 18, 2021, 9:48 a.m. UTC | #1
On 12/10/21 07:49, AKASHI Takahiro wrote:
> Every time a mmc bus/port is scanned and a new device is detected,
> we want to call device_probe() as it will give us a chance to run
> additional post-processings for some purposes.
>
> In particular, support for creating partitions on a device will be added.
>
> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> ---
>   drivers/mmc/mmc-uclass.c | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
>
> diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
> index 3ee92d03ca23..6c907b65fde7 100644
> --- a/drivers/mmc/mmc-uclass.c
> +++ b/drivers/mmc/mmc-uclass.c
> @@ -418,6 +418,7 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg)
>   	bdesc->part_type = cfg->part_type;
>   	mmc->dev = dev;
>   	mmc->user_speed_mode = MMC_MODES_END;
> +
>   	return 0;
>   }
>
> @@ -467,6 +468,18 @@ static int mmc_blk_probe(struct udevice *dev)
>   		return ret;
>   	}
>
> +	ret = device_probe(dev);
> +	if (ret) {
> +		debug("Can't probe\n");
> +
> +		if (IS_ENABLED(CONFIG_MMC_UHS_SUPPORT) ||
> +		    IS_ENABLED(CONFIG_MMC_HS200_SUPPORT) ||
> +		    IS_ENABLED(CONFIG_MMC_HS400_SUPPORT))

Not even sandbox_defconfig builds with your patch:

drivers/mmc/mmc-uclass.c: In function ‘mmc_blk_probe’:
drivers/mmc/mmc-uclass.c:478:25: warning: implicit declaration of
function ‘mmc_deinit’; did you mean ‘mmc_reinit’?
[-Wimplicit-function-declaration]
   478 |                         mmc_deinit(mmc);
       |                         ^~~~~~~~~~
       |                         mmc_reinit

Please, have a look at include/mmc.h:

790 #if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) || \
791     CONFIG_IS_ENABLED(MMC_HS200_SUPPORT) || \
792     CONFIG_IS_ENABLED(MMC_HS400_SUPPORT)
793 int mmc_deinit(struct mmc *mmc);
794 #endif

mmc_deinit() may not be defined.

We should fix include/mmc.h first.

Best regards

Heinrich

> +			mmc_deinit(mmc);
> +
> +		return ret;
> +	}
> +
>   	return 0;
>   }
>
Heinrich Schuchardt Dec. 18, 2021, 10:03 a.m. UTC | #2
On 12/18/21 10:48, Heinrich Schuchardt wrote:
> On 12/10/21 07:49, AKASHI Takahiro wrote:
>> Every time a mmc bus/port is scanned and a new device is detected,
>> we want to call device_probe() as it will give us a chance to run
>> additional post-processings for some purposes.
>>
>> In particular, support for creating partitions on a device will be added.
>>
>> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

Cc: Jaehoon Chung <jh80.chung@samsung.com>, Peng Fan <peng.fan@nxp.com>

Please, use scripts/get_maintainers.pl to identify whom to send patches.

>> ---
>>   drivers/mmc/mmc-uclass.c | 13 +++++++++++++
>>   1 file changed, 13 insertions(+)
>>
>> diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
>> index 3ee92d03ca23..6c907b65fde7 100644
>> --- a/drivers/mmc/mmc-uclass.c
>> +++ b/drivers/mmc/mmc-uclass.c
>> @@ -418,6 +418,7 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc,
>> const struct mmc_config *cfg)
>>       bdesc->part_type = cfg->part_type;
>>       mmc->dev = dev;
>>       mmc->user_speed_mode = MMC_MODES_END;
>> +

Please avoid unrelated changes.

>>       return 0;
>>   }
>>
>> @@ -467,6 +468,18 @@ static int mmc_blk_probe(struct udevice *dev)
>>           return ret;
>>       }
>>
>> +    ret = device_probe(dev);
>> +    if (ret) {
>> +        debug("Can't probe\n");
>> +
>> +        if (IS_ENABLED(CONFIG_MMC_UHS_SUPPORT) ||
>> +            IS_ENABLED(CONFIG_MMC_HS200_SUPPORT) ||
>> +            IS_ENABLED(CONFIG_MMC_HS400_SUPPORT))
>
> Not even sandbox_defconfig builds with your patch:
>
> drivers/mmc/mmc-uclass.c: In function ‘mmc_blk_probe’:
> drivers/mmc/mmc-uclass.c:478:25: warning: implicit declaration of
> function ‘mmc_deinit’; did you mean ‘mmc_reinit’?
> [-Wimplicit-function-declaration]
>    478 |                         mmc_deinit(mmc);
>        |                         ^~~~~~~~~~
>        |                         mmc_reinit
>
> Please, have a look at include/mmc.h:
>
> 790 #if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) || \
> 791     CONFIG_IS_ENABLED(MMC_HS200_SUPPORT) || \
> 792     CONFIG_IS_ENABLED(MMC_HS400_SUPPORT)
> 793 int mmc_deinit(struct mmc *mmc);
> 794 #endif
>
> mmc_deinit() may not be defined.
>
> We should fix include/mmc.h first.

See
[PATCH 1/1] mmc: unconditionally define mmc_deinit()
https://lists.denx.de/pipermail/u-boot/2021-December/469919.html

Best regards

Heinrich

>> +            mmc_deinit(mmc);
>> +
>> +        return ret;
>> +    }
>> +
>>       return 0;
>>   }
>>
>
Heinrich Schuchardt Jan. 2, 2022, 9:47 a.m. UTC | #3
On 12/10/21 07:49, AKASHI Takahiro wrote:
> Every time a mmc bus/port is scanned and a new device is detected,
> we want to call device_probe() as it will give us a chance to run
> additional post-processings for some purposes.
>
> In particular, support for creating partitions on a device will be added.
>
> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> ---
>   drivers/mmc/mmc-uclass.c | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
>
> diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
> index 3ee92d03ca23..6c907b65fde7 100644
> --- a/drivers/mmc/mmc-uclass.c
> +++ b/drivers/mmc/mmc-uclass.c
> @@ -418,6 +418,7 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg)
>   	bdesc->part_type = cfg->part_type;
>   	mmc->dev = dev;
>   	mmc->user_speed_mode = MMC_MODES_END;
> +
>   	return 0;
>   }
>
> @@ -467,6 +468,18 @@ static int mmc_blk_probe(struct udevice *dev)
>   		return ret;
>   	}
>
> +	ret = device_probe(dev);
> +	if (ret) {
> +		debug("Can't probe\n");
> +
> +		if (IS_ENABLED(CONFIG_MMC_UHS_SUPPORT) ||
> +		    IS_ENABLED(CONFIG_MMC_HS200_SUPPORT) ||
> +		    IS_ENABLED(CONFIG_MMC_HS400_SUPPORT))
> +			mmc_deinit(mmc);

This results in a warning when compiling sandbox_spl_defconfig:

drivers/mmc/mmc-uclass.c: In function ‘mmc_blk_probe’:
drivers/mmc/mmc-uclass.c:478:25: warning: implicit declaration of
function ‘mmc_deinit’; did you mean ‘mmc_reinit’?
[-Wimplicit-function-declaration]
   478 |                         mmc_deinit(mmc);
       |                         ^~~~~~~~~~
       |                         mmc_reinit

Best regards

Heinrich

> +
> +		return ret;
> +	}
> +
>   	return 0;
>   }
>
Jaehoon Chung Jan. 3, 2022, 10:09 a.m. UTC | #4
Dear AKASHI,

On 12/10/21 3:49 PM, AKASHI Takahiro wrote:
> Every time a mmc bus/port is scanned and a new device is detected,
> we want to call device_probe() as it will give us a chance to run
> additional post-processings for some purposes.
> 
> In particular, support for creating partitions on a device will be added.

If add me and Peng as Cc when you sent the patches related with mmc, it's more helpful to review.

Best Regards,
Jaehoon Chung

> 
> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> ---
>  drivers/mmc/mmc-uclass.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
> index 3ee92d03ca23..6c907b65fde7 100644
> --- a/drivers/mmc/mmc-uclass.c
> +++ b/drivers/mmc/mmc-uclass.c
> @@ -418,6 +418,7 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg)
>  	bdesc->part_type = cfg->part_type;
>  	mmc->dev = dev;
>  	mmc->user_speed_mode = MMC_MODES_END;
> +
>  	return 0;
>  }
>  
> @@ -467,6 +468,18 @@ static int mmc_blk_probe(struct udevice *dev)
>  		return ret;
>  	}
>  
> +	ret = device_probe(dev);
> +	if (ret) {
> +		debug("Can't probe\n");
> +
> +		if (IS_ENABLED(CONFIG_MMC_UHS_SUPPORT) ||
> +		    IS_ENABLED(CONFIG_MMC_HS200_SUPPORT) ||
> +		    IS_ENABLED(CONFIG_MMC_HS400_SUPPORT))
> +			mmc_deinit(mmc);
> +
> +		return ret;
> +	}
> +
>  	return 0;
>  }
>  
>
diff mbox series

Patch

diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index 3ee92d03ca23..6c907b65fde7 100644
--- a/drivers/mmc/mmc-uclass.c
+++ b/drivers/mmc/mmc-uclass.c
@@ -418,6 +418,7 @@  int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg)
 	bdesc->part_type = cfg->part_type;
 	mmc->dev = dev;
 	mmc->user_speed_mode = MMC_MODES_END;
+
 	return 0;
 }
 
@@ -467,6 +468,18 @@  static int mmc_blk_probe(struct udevice *dev)
 		return ret;
 	}
 
+	ret = device_probe(dev);
+	if (ret) {
+		debug("Can't probe\n");
+
+		if (IS_ENABLED(CONFIG_MMC_UHS_SUPPORT) ||
+		    IS_ENABLED(CONFIG_MMC_HS200_SUPPORT) ||
+		    IS_ENABLED(CONFIG_MMC_HS400_SUPPORT))
+			mmc_deinit(mmc);
+
+		return ret;
+	}
+
 	return 0;
 }