Re: [PATCH v5 4/4] mmc: mtk-sd: Protect crypto capability with crypto config
Eric Biggers <[email protected]> Thu, 30 Jul 2026 12:10:30 -0700
| Newsgroups | org.kernel.vger.linux-mmc,org.kernel.vger.linux-arm-msm,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <20260730191030.GC3139@sol> |
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)) { - Eric