mmc: slot-gpio: Allow non-sleeping GPIO ro

This change uses the appropriate _cansleep or non-sleeping API for
reading GPIO read-only state. This allows users with GPIOs that
never sleepbeing called in atomic context.

Implement the same mechanism as in commit 52af318c93 ("mmc: Allow
non-sleeping GPIO cd").

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20240206083912.2543142-1-alexander.stein@ew.tq-group.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
Alexander Stein 2024-02-06 09:39:12 +01:00 committed by Ulf Hansson
parent 58aeb5623c
commit cc9432c4fb
1 changed files with 5 additions and 1 deletions

View File

@ -75,11 +75,15 @@ EXPORT_SYMBOL(mmc_gpio_set_cd_irq);
int mmc_gpio_get_ro(struct mmc_host *host)
{
struct mmc_gpio *ctx = host->slot.handler_priv;
int cansleep;
if (!ctx || !ctx->ro_gpio)
return -ENOSYS;
return gpiod_get_value_cansleep(ctx->ro_gpio);
cansleep = gpiod_cansleep(ctx->ro_gpio);
return cansleep ?
gpiod_get_value_cansleep(ctx->ro_gpio) :
gpiod_get_value(ctx->ro_gpio);
}
EXPORT_SYMBOL(mmc_gpio_get_ro);