Messages in this thread | | | From | Masahiro Yamada <> | Date | Wed, 6 Dec 2017 00:03:29 +0900 | Subject | Re: [PATCH v2 10/22] mmc: tmio: support IP-builtin card detection logic |
| |
2017-12-05 0:13 GMT+09:00 Wolfram Sang <wsa@the-dreams.de>: >> +static int tmio_mmc_get_cd(struct mmc_host *mmc) >> +{ >> + struct tmio_mmc_host *host = mmc_priv(mmc); >> + int ret; >> + >> + ret = mmc_gpio_get_cd(mmc); >> + if (ret >= 0) >> + return ret; >> + >> + return !!(sd_ctrl_read16_and_16_as_32(host, CTL_STATUS) & >> + TMIO_STAT_SIGSTATE); >> +}
I just followed tmio_mmc_get_ro() implementation.
If we do not care the symmetry between _get_ro() and _get_cd() hooks, yes, your suggestion makes sense.
> I wonder if we shouldn't do something like: > > if (mmc_can_gpio_cd()) > return mmc_gpio_get_cd() > else > return !!(sd_ctrl_read16_and_16_as_32...) > > If we have a GPIO CD defined, I think we want the value of > mmc_gpio_get_cd() in all cases. It makes clearer that this is an > 'either-or' case and not a fallback mechanism. >
Another possibility would select this in _probe(). We would need to evaluate mmc_can_gpio_cd() only once when probing.
I will follow your suggestion, though. Either way is fine with me.
static int tmio_mmc_get_cd(struct mmc_host *mmc) { struct tmio_mmc_host *host = mmc_priv(mmc);
return !!(sd_ctrl_read16_and_16_as_32(host, CTL_STATUS) & TMIO_STAT_SIGSTATE); }
static const struct mmc_host_ops tmio_mmc_ops = { ... .get_cd = tmio_mmc_get_cd, ... };
int tmio_mmc_host_probe( ... ) { ....
/* replace get_cd hook when we use GPIO for card detection */ if (mmc_can_gpio_cd(mmc)) _host->ops.get_cd = mmc_gpio_get_cd;
}
-- Best Regards Masahiro Yamada
| |