Re: [PATCH v5 4/4] mmc: mtk-sd: Protect crypto capability with crypto config
Neeraj Soni <[email protected]> Fri, 31 Jul 2026 11:31:58 +0530
| Newsgroups | org.kernel.vger.linux-mmc,org.kernel.vger.linux-arm-msm,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On 7/31/2026 12:40 AM, Eric Biggers wrote: > On Thu, Jul 30, 2026 at 07:38:22PM +0530, Neeraj Soni wrote: >> Host crypto capability can not be used if CONFIG_MMC_CRYPTO=n. >> So set MMC_CAP2_CRYPTO in mmc->caps2 only if CONFIG_MMC_CRYPTO=y. >> >> Signed-off-by: Neeraj Soni <[email protected]> >> --- >> drivers/mmc/host/mtk-sd.c | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c >> index 01ea3adbdf3b..c415ed97e3c2 100644 >> --- a/drivers/mmc/host/mtk-sd.c >> +++ b/drivers/mmc/host/mtk-sd.c >> @@ -3031,7 +3031,11 @@ static int msdc_drv_probe(struct platform_device *pdev) >> if (IS_ERR(host->crypto_clk)) >> return PTR_ERR(host->crypto_clk); >> else if (host->crypto_clk) >> +#ifdef CONFIG_MMC_CRYPTO >> mmc->caps2 |= MMC_CAP2_CRYPTO; >> +#else >> + dev_dbg(host->dev, "Enable necessary crypto config\n"); >> +#endif > > host->dev is still NULL at this point. So if the log message were to be > actually reached it would show '(NULL device *)'. > > But the message doesn't seem very useful anyway, especially when it's > logged only at debug level. So maybe just drop it. > > Is there a reason to even enable the crypto clock when CONFIG_MMC_CRYPTO > is disabled? If no, then the 'if' condition above could just be changed > to: > > if (IS_ENABLED(CONFIG_MMC_CRYPTO) && !(mmc->caps2 & MMC_CAP2_NO_MMC)) { > We will not need this patch if the i revert the change made around MMC_CAP2_CRYPTO here https://lore.kernel.org/linux-mmc/[email protected]/ since that change was not related to this series anyway. Will fix this in v6. > - Eric > Regards, Neeraj