Message ID | 92b72ede5f8ddf2b2f74cdb7422bc8ef5458b23c.1461163234.git.larper@axis.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 04/20/2016 04:53 PM, Lars Persson wrote: > Add a start_signal_voltage_switch() operation to support enabling of > UHS modes. > > Signed-off-by: Lars Persson <larper@axis.com> > --- > drivers/mmc/host/usdhi6rol0.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/drivers/mmc/host/usdhi6rol0.c b/drivers/mmc/host/usdhi6rol0.c > index 807c06e..2585ea4 100644 > --- a/drivers/mmc/host/usdhi6rol0.c > +++ b/drivers/mmc/host/usdhi6rol0.c > @@ -1147,12 +1147,25 @@ static void usdhi6_enable_sdio_irq(struct mmc_host *mmc, int enable) > } > } > > +static int usdhi6_sig_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios) > +{ > + int ret; > + To support boards without regulator we need to put a IS_ERR_OR_NULL(mmc->supply.vqmmc) check here and bail out with return 0. Missing vqmmc is OK according to our binding document, but treated as an error by mmc_regulator_set_vqmmc(). > + ret = mmc_regulator_set_vqmmc(mmc, ios); > + > + if (ret < 0) > + dev_warn(mmc_dev(mmc), "Voltage switch failed: %d\n", ret); > + > + return ret; > +} > + > static struct mmc_host_ops usdhi6_ops = { > .request = usdhi6_request, > .set_ios = usdhi6_set_ios, > .get_cd = usdhi6_get_cd, > .get_ro = usdhi6_get_ro, > .enable_sdio_irq = usdhi6_enable_sdio_irq, > + .start_signal_voltage_switch = usdhi6_sig_volt_switch, > }; > > /* State machine handlers */ > -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thursday 21 April 2016 09:12:52 Lars Persson wrote: > On 04/20/2016 04:53 PM, Lars Persson wrote: > > Add a start_signal_voltage_switch() operation to support enabling of > > UHS modes. > > > > Signed-off-by: Lars Persson <larper@axis.com> > > --- > > drivers/mmc/host/usdhi6rol0.c | 13 +++++++++++++ > > 1 file changed, 13 insertions(+) > > > > diff --git a/drivers/mmc/host/usdhi6rol0.c b/drivers/mmc/host/usdhi6rol0.c > > index 807c06e..2585ea4 100644 > > --- a/drivers/mmc/host/usdhi6rol0.c > > +++ b/drivers/mmc/host/usdhi6rol0.c > > @@ -1147,12 +1147,25 @@ static void usdhi6_enable_sdio_irq(struct mmc_host *mmc, int enable) > > } > > } > > > > +static int usdhi6_sig_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios) > > +{ > > + int ret; > > + > > To support boards without regulator we need to put a > IS_ERR_OR_NULL(mmc->supply.vqmmc) check here and bail out with return 0. > Missing vqmmc is OK according to our binding document, but treated as an > error by mmc_regulator_set_vqmmc(). mmc_regulator_set_vqmmc() should already take care of handling all the those cases. In general, it's almost always a bug to use IS_ERR_OR_NULL(): if you ever feel the need to use it, you should either fix the code that made the pointer ambiguous or you have misunderstood the interface. Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 04/21/2016 09:53 AM, Arnd Bergmann wrote: > On Thursday 21 April 2016 09:12:52 Lars Persson wrote: >> On 04/20/2016 04:53 PM, Lars Persson wrote: >>> Add a start_signal_voltage_switch() operation to support enabling of >>> UHS modes. >>> >>> Signed-off-by: Lars Persson <larper@axis.com> >>> --- >>> drivers/mmc/host/usdhi6rol0.c | 13 +++++++++++++ >>> 1 file changed, 13 insertions(+) >>> >>> diff --git a/drivers/mmc/host/usdhi6rol0.c b/drivers/mmc/host/usdhi6rol0.c >>> index 807c06e..2585ea4 100644 >>> --- a/drivers/mmc/host/usdhi6rol0.c >>> +++ b/drivers/mmc/host/usdhi6rol0.c >>> @@ -1147,12 +1147,25 @@ static void usdhi6_enable_sdio_irq(struct mmc_host *mmc, int enable) >>> } >>> } >>> >>> +static int usdhi6_sig_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios) >>> +{ >>> + int ret; >>> + >> >> To support boards without regulator we need to put a >> IS_ERR_OR_NULL(mmc->supply.vqmmc) check here and bail out with return 0. >> Missing vqmmc is OK according to our binding document, but treated as an >> error by mmc_regulator_set_vqmmc(). > > mmc_regulator_set_vqmmc() should already take care of handling > all the those cases. In general, it's almost always a bug to use > IS_ERR_OR_NULL(): if you ever feel the need to use it, you should > either fix the code that made the pointer ambiguous or you have > misunderstood the interface. > > Arnd > Yes it should of course be IS_ERR() rather than IS_ERR_OR_NULL(). It is a common pattern in all upstream mmc drivers to not make the call to mmc_regulator_set_vqmmc() when a regulator is missing. We basically want to log errors except for the EINVAL returned in case of a missing regulator. - Lars -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thursday 21 April 2016 10:26:55 Lars Persson wrote: > > It is a common pattern in all upstream mmc drivers to not make the call > to mmc_regulator_set_vqmmc() when a regulator is missing. We basically > want to log errors except for the EINVAL returned in case of a missing > regulator. > > I see what you mean here: two out of four drivers calling mmc_regulator_set_vqmmc() log errors to the console. If we want all drivers to behave consistently here, how about moving that error output into the mmc_regulator_set_vqmmc() function itself? Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 04/21/2016 11:52 AM, Arnd Bergmann wrote: > On Thursday 21 April 2016 10:26:55 Lars Persson wrote: >> >> It is a common pattern in all upstream mmc drivers to not make the call >> to mmc_regulator_set_vqmmc() when a regulator is missing. We basically >> want to log errors except for the EINVAL returned in case of a missing >> regulator. >> >> > > I see what you mean here: two out of four drivers calling > mmc_regulator_set_vqmmc() log errors to the console. > > If we want all drivers to behave consistently here, how about > moving that error output into the mmc_regulator_set_vqmmc() function > itself? > I will make a v4 that skips the error output and if Ulf agrees with your proposal I will make another patch series to move the dev_dbg() into mmc_regulator_set_vqmmc(). - Lars -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/mmc/host/usdhi6rol0.c b/drivers/mmc/host/usdhi6rol0.c index 807c06e..2585ea4 100644 --- a/drivers/mmc/host/usdhi6rol0.c +++ b/drivers/mmc/host/usdhi6rol0.c @@ -1147,12 +1147,25 @@ static void usdhi6_enable_sdio_irq(struct mmc_host *mmc, int enable) } } +static int usdhi6_sig_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios) +{ + int ret; + + ret = mmc_regulator_set_vqmmc(mmc, ios); + + if (ret < 0) + dev_warn(mmc_dev(mmc), "Voltage switch failed: %d\n", ret); + + return ret; +} + static struct mmc_host_ops usdhi6_ops = { .request = usdhi6_request, .set_ios = usdhi6_set_ios, .get_cd = usdhi6_get_cd, .get_ro = usdhi6_get_ro, .enable_sdio_irq = usdhi6_enable_sdio_irq, + .start_signal_voltage_switch = usdhi6_sig_volt_switch, }; /* State machine handlers */
Add a start_signal_voltage_switch() operation to support enabling of UHS modes. Signed-off-by: Lars Persson <larper@axis.com> --- drivers/mmc/host/usdhi6rol0.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)