Hi Guennadi,
On 25 May 2012 17:14, Guennadi Liakhovetski <[email protected]> wrote:
> Add a function to get a regulator, supplying card's Vdd on a specific host.
> If such a regulator is found, the function checks, whether a valid OCR mask
> can be obtained from this regulator.
>
> Signed-off-by: Guennadi Liakhovetski <[email protected]>
> ---
>
> v3: remove bogus attempts to ignore the dummy regulator, drop the check
> for whether the regulator can change status, do not assign
> MMC_CAP_POWER_OFF_CARD automatically. Thanks to Mark and Magnus for
> comments.
>
> drivers/mmc/core/core.c | 17 +++++++++++++++++
> include/linux/mmc/host.h | 6 ++++++
> 2 files changed, 23 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 0b6141d..0f92ec0 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -1013,6 +1013,23 @@ int mmc_regulator_set_ocr(struct mmc_host *mmc,
> }
> EXPORT_SYMBOL(mmc_regulator_set_ocr);
>
> +struct regulator *mmc_regulator_get_vmmc(struct mmc_host *mmc)
> +{
> + struct device *dev = mmc_dev(mmc);
> + struct regulator *supply = devm_regulator_get(dev, "vmmc");
> + int ret;
> +
> + if (IS_ERR(supply))
> + return NULL;
> +
> + ret = mmc_regulator_get_ocrmask(supply);
> + if (ret > 0)
Could we have an "else" were a dev_warn prints some info and as well
the "ret" maybe?
> + mmc->ocr_avail = ret;
> +
> + return supply;
> +}
> +EXPORT_SYMBOL(mmc_regulator_get_vmmc);
> +
> #endif /* CONFIG_REGULATOR */
>
> /*
> diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
> index 0707d22..368b317 100644
> --- a/include/linux/mmc/host.h
> +++ b/include/linux/mmc/host.h
> @@ -364,6 +364,7 @@ int mmc_regulator_get_ocrmask(struct regulator *supply);
> int mmc_regulator_set_ocr(struct mmc_host *mmc,
> struct regulator *supply,
> unsigned short vdd_bit);
> +struct regulator *mmc_regulator_get_vmmc(struct mmc_host *mmc);
> #else
> static inline int mmc_regulator_get_ocrmask(struct regulator *supply)
> {
> @@ -376,6 +377,11 @@ static inline int mmc_regulator_set_ocr(struct mmc_host
> *mmc,
> {
> return 0;
> }
> +
> +static inline struct regulator *mmc_regulator_get_vmmc(struct mmc_host *mmc)
> +{
> + return NULL;
> +}
> #endif
>
Some follow-up thoughts, if mmc_regulator_get_vmmc is supposed to be
used from the host drivers, the mmc_regulator_get_ocrmask function do
no longer have to be an exported function, but instead a static
function on core.c I suppose this can be fixed in separate patch,
where we also add mmc_regulator_get_vmmc for all host drivers?
Kind regards
Ulf Hansson
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html