Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: pwrseq_simple: Make reset-gpios optional to match doc

The DT binding doc says reset-gpios is an optional property but the code
currently bails out if it is omitted.

This is a regression since it breaks previously working device trees.
Fix it by restoring the original documented behaviour.

Fixes: ce037275861e ("mmc: pwrseq_simple: use GPIO descriptors array API")
Tested-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Martin Fuzzey <mfuzzey@parkeon.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Martin Fuzzey and committed by
Ulf Hansson
64a67d47 07cbeea5

+14 -8
+14 -8
drivers/mmc/core/pwrseq_simple.c
··· 29 29 static void mmc_pwrseq_simple_set_gpios_value(struct mmc_pwrseq_simple *pwrseq, 30 30 int value) 31 31 { 32 - int i; 33 32 struct gpio_descs *reset_gpios = pwrseq->reset_gpios; 34 - int values[reset_gpios->ndescs]; 35 33 36 - for (i = 0; i < reset_gpios->ndescs; i++) 37 - values[i] = value; 34 + if (!IS_ERR(reset_gpios)) { 35 + int i; 36 + int values[reset_gpios->ndescs]; 38 37 39 - gpiod_set_array_value_cansleep(reset_gpios->ndescs, reset_gpios->desc, 40 - values); 38 + for (i = 0; i < reset_gpios->ndescs; i++) 39 + values[i] = value; 40 + 41 + gpiod_set_array_value_cansleep( 42 + reset_gpios->ndescs, reset_gpios->desc, values); 43 + } 41 44 } 42 45 43 46 static void mmc_pwrseq_simple_pre_power_on(struct mmc_host *host) ··· 82 79 struct mmc_pwrseq_simple *pwrseq = container_of(host->pwrseq, 83 80 struct mmc_pwrseq_simple, pwrseq); 84 81 85 - gpiod_put_array(pwrseq->reset_gpios); 82 + if (!IS_ERR(pwrseq->reset_gpios)) 83 + gpiod_put_array(pwrseq->reset_gpios); 86 84 87 85 if (!IS_ERR(pwrseq->ext_clk)) 88 86 clk_put(pwrseq->ext_clk); ··· 116 112 } 117 113 118 114 pwrseq->reset_gpios = gpiod_get_array(dev, "reset", GPIOD_OUT_HIGH); 119 - if (IS_ERR(pwrseq->reset_gpios)) { 115 + if (IS_ERR(pwrseq->reset_gpios) && 116 + PTR_ERR(pwrseq->reset_gpios) != -ENOENT && 117 + PTR_ERR(pwrseq->reset_gpios) != -ENOSYS) { 120 118 ret = PTR_ERR(pwrseq->reset_gpios); 121 119 goto clk_put; 122 120 }