Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1645259
| From | Ulf Hansson <ulf.hansson@linaro.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 3/5] mmc: cavium: Prevent crash with incomplete DT |
| Date | 2017-05-19 09:20 +0200 |
| Message-ID | <tIKmB-7av-3@gated-at.bofh.it> (permalink) |
| References | <tHH7s-3Qc-5@gated-at.bofh.it> <tHH7s-3Qc-19@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 16 May 2017 at 11:36, Jan Glauber <jglauber@cavium.com> wrote:
> In case the DT specifies neither a regulator nor a gpio
> for the shared power the driver will crash accessing the regulator.
> Prevent the crash by checking the regulator before use.
>
> As the MMC devices would likely not be usable without power
> check for that condition during probe and print a warning.
>
> Signed-off-by: Jan Glauber <jglauber@cavium.com>
> ---
> drivers/mmc/host/cavium.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/cavium.c b/drivers/mmc/host/cavium.c
> index 58b51ba..63f96dc 100644
> --- a/drivers/mmc/host/cavium.c
> +++ b/drivers/mmc/host/cavium.c
> @@ -839,14 +839,14 @@ static void cvm_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
> cvm_mmc_reset_bus(slot);
> if (host->global_pwr_gpiod)
> host->set_shared_power(host, 0);
> - else
> + else if (mmc->supply.vmmc)
Please do this instead:
else if (!IS_ERR(mmc->supply.vmmc))
> mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0);
> break;
>
> case MMC_POWER_UP:
> if (host->global_pwr_gpiod)
> host->set_shared_power(host, 1);
> - else
> + else if (mmc->supply.vmmc)
Ditto
> mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd);
> break;
> }
> @@ -976,6 +976,7 @@ static int cvm_mmc_of_parse(struct device *dev, struct cvm_mmc_slot *slot)
> * Legacy Octeon firmware has no regulator entry, fall-back to
> * a hard-coded voltage to get a sane OCR.
> */
> + mmc->supply.vmmc = NULL;
... and then you shall remove this.
> mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
> } else {
> ret = mmc_regulator_get_ocrmask(mmc->supply.vmmc);
> @@ -983,6 +984,9 @@ static int cvm_mmc_of_parse(struct device *dev, struct cvm_mmc_slot *slot)
> mmc->ocr_avail = ret;
> }
>
> + if (!mmc->supply.vmmc && !slot->host->global_pwr_gpiod)
> + dev_warn(dev, "Missing power regulator or gpio, device may not work.\n");
> +
While you re-spins this, I suggest you to also convert to use the
mmc_regulator_get_supply() API.
That should simply the code a bit and also avoid you from needing to
print anything like this above, as there are already some printing
being done in mmc_regulator_get_supply().
> /* Common MMC bindings */
> ret = mmc_of_parse(mmc);
> if (ret)
> --
> 2.9.0.rc0.21.g7777322
>
Kind regards
Uffe
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/5] mmc: cavium: bug fixes for 4.12 Jan Glauber <jglauber@cavium.com> - 2017-05-16 11:40 +0200
[PATCH 4/5] of/platform: Make of_platform_device_destroy globally visible Jan Glauber <jglauber@cavium.com> - 2017-05-16 11:40 +0200
[PATCH 3/5] mmc: cavium: Prevent crash with incomplete DT Jan Glauber <jglauber@cavium.com> - 2017-05-16 11:40 +0200
Re: [PATCH 3/5] mmc: cavium: Prevent crash with incomplete DT Ulf Hansson <ulf.hansson@linaro.org> - 2017-05-19 09:20 +0200
[PATCH 2/5] mmc: cavium-octeon: Use proper GPIO name for power control Jan Glauber <jglauber@cavium.com> - 2017-05-16 11:40 +0200
[PATCH 5/5] mmc: cavium: Fix probing race with regulator Jan Glauber <jglauber@cavium.com> - 2017-05-16 11:40 +0200
Re: [PATCH 5/5] mmc: cavium: Fix probing race with regulator Rob Herring <robh+dt@kernel.org> - 2017-05-16 15:10 +0200
Re: [PATCH 5/5] mmc: cavium: Fix probing race with regulator Rob Herring <robh+dt@kernel.org> - 2017-05-16 16:50 +0200
Re: [PATCH 5/5] mmc: cavium: Fix probing race with regulator Rob Herring <robh+dt@kernel.org> - 2017-05-18 15:00 +0200
Re: [PATCH 0/5] mmc: cavium: bug fixes for 4.12 Ulf Hansson <ulf.hansson@linaro.org> - 2017-05-19 10:40 +0200
csiph-web