Skip to content

Commit ec0a751

Browse files
gmbnomiscjb
authored andcommitted
mmc: return mmc_of_parse() errors to caller
In addition to just logging errors encountered during DT parsing or allocating GPIO slots for CD/WP, mmc_of_parse() now returns with an error. In particular, this is needed if the GPIO allocation may return EPROBE_DEFER. Signed-off-by: Simon Baatz <gmbnomis@gmail.com> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Chris Ball <cjb@laptop.org>
1 parent fca9661 commit ec0a751

2 files changed

Lines changed: 26 additions & 6 deletions

File tree

‎drivers/mmc/core/host.c‎

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ static inline void mmc_host_clk_sysfs_init(struct mmc_host *host)
306306
* parse the properties and set respective generic mmc-host flags and
307307
* parameters.
308308
*/
309-
void mmc_of_parse(struct mmc_host *host)
309+
int mmc_of_parse(struct mmc_host *host)
310310
{
311311
struct device_node *np;
312312
u32 bus_width;
@@ -315,7 +315,7 @@ void mmc_of_parse(struct mmc_host *host)
315315
int len, ret, gpio;
316316

317317
if (!host->parent || !host->parent->of_node)
318-
return;
318+
return 0;
319319

320320
np = host->parent->of_node;
321321

@@ -338,6 +338,7 @@ void mmc_of_parse(struct mmc_host *host)
338338
default:
339339
dev_err(host->parent,
340340
"Invalid \"bus-width\" value %ud!\n", bus_width);
341+
return -EINVAL;
341342
}
342343

343344
/* f_max is obtained from the optional "max-frequency" property */
@@ -367,18 +368,22 @@ void mmc_of_parse(struct mmc_host *host)
367368
host->caps |= MMC_CAP_NEEDS_POLL;
368369

369370
gpio = of_get_named_gpio_flags(np, "cd-gpios", 0, &flags);
371+
if (gpio == -EPROBE_DEFER)
372+
return gpio;
370373
if (gpio_is_valid(gpio)) {
371374
if (!(flags & OF_GPIO_ACTIVE_LOW))
372375
gpio_inv_cd = true;
373376

374377
ret = mmc_gpio_request_cd(host, gpio);
375-
if (ret < 0)
378+
if (ret < 0) {
376379
dev_err(host->parent,
377380
"Failed to request CD GPIO #%d: %d!\n",
378381
gpio, ret);
379-
else
382+
return ret;
383+
} else {
380384
dev_info(host->parent, "Got CD GPIO #%d.\n",
381385
gpio);
386+
}
382387
}
383388

384389
if (explicit_inv_cd ^ gpio_inv_cd)
@@ -389,14 +394,23 @@ void mmc_of_parse(struct mmc_host *host)
389394
explicit_inv_wp = of_property_read_bool(np, "wp-inverted");
390395

391396
gpio = of_get_named_gpio_flags(np, "wp-gpios", 0, &flags);
397+
if (gpio == -EPROBE_DEFER) {
398+
ret = -EPROBE_DEFER;
399+
goto out;
400+
}
392401
if (gpio_is_valid(gpio)) {
393402
if (!(flags & OF_GPIO_ACTIVE_LOW))
394403
gpio_inv_wp = true;
395404

396405
ret = mmc_gpio_request_ro(host, gpio);
397-
if (ret < 0)
406+
if (ret < 0) {
398407
dev_err(host->parent,
399408
"Failed to request WP GPIO: %d!\n", ret);
409+
goto out;
410+
} else {
411+
dev_info(host->parent, "Got WP GPIO #%d.\n",
412+
gpio);
413+
}
400414
}
401415
if (explicit_inv_wp ^ gpio_inv_wp)
402416
host->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
@@ -413,6 +427,12 @@ void mmc_of_parse(struct mmc_host *host)
413427
host->pm_caps |= MMC_PM_KEEP_POWER;
414428
if (of_find_property(np, "enable-sdio-wakeup", &len))
415429
host->pm_caps |= MMC_PM_WAKE_SDIO_IRQ;
430+
431+
return 0;
432+
433+
out:
434+
mmc_gpio_free_cd(host);
435+
return ret;
416436
}
417437

418438
EXPORT_SYMBOL(mmc_of_parse);

‎include/linux/mmc/host.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *);
369369
int mmc_add_host(struct mmc_host *);
370370
void mmc_remove_host(struct mmc_host *);
371371
void mmc_free_host(struct mmc_host *);
372-
void mmc_of_parse(struct mmc_host *host);
372+
int mmc_of_parse(struct mmc_host *host);
373373

374374
static inline void *mmc_priv(struct mmc_host *host)
375375
{

0 commit comments

Comments
 (0)