mirror of
https://github.com/torvalds/linux.git
synced 2026-06-07 22:14:04 +02:00
mmc: host: Return an error when ->enable_sdio_irq() ops is missing
[ Upstream commit d6c9219ca1 ]
Even if the current WARN() notifies the user that something is severely
wrong, we can still end up in a PANIC() when trying to invoke the missing
->enable_sdio_irq() ops. Therefore, let's also return an error code and
prevent the host from being added.
While at it, move the code into a separate function to prepare for
subsequent changes and for further host caps validations.
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20220303165142.129745-1-ulf.hansson@linaro.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
808990afd8
commit
2412a5d294
|
|
@ -513,6 +513,16 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
|
||||||
|
|
||||||
EXPORT_SYMBOL(mmc_alloc_host);
|
EXPORT_SYMBOL(mmc_alloc_host);
|
||||||
|
|
||||||
|
static int mmc_validate_host_caps(struct mmc_host *host)
|
||||||
|
{
|
||||||
|
if (host->caps & MMC_CAP_SDIO_IRQ && !host->ops->enable_sdio_irq) {
|
||||||
|
dev_warn(host->parent, "missing ->enable_sdio_irq() ops\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mmc_add_host - initialise host hardware
|
* mmc_add_host - initialise host hardware
|
||||||
* @host: mmc host
|
* @host: mmc host
|
||||||
|
|
@ -525,8 +535,9 @@ int mmc_add_host(struct mmc_host *host)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
WARN_ON((host->caps & MMC_CAP_SDIO_IRQ) &&
|
err = mmc_validate_host_caps(host);
|
||||||
!host->ops->enable_sdio_irq);
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
err = device_add(&host->class_dev);
|
err = device_add(&host->class_dev);
|
||||||
if (err)
|
if (err)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user