diff options
author | Simon Baatz <gmbnomis@gmail.com> | 2013-06-09 16:14:11 -0400 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2013-06-27 10:22:44 -0400 |
commit | ec0a7517dc25b4cca8a694fd61e09771bffba022 (patch) | |
tree | f0d9f2cc5624ce459320dd6ec9a038060f510fc0 /drivers | |
parent | fca9661c6c8926171a49f6ac57adc65290f10caf (diff) |
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mmc/core/host.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 2a3593d9f87d..89f58498409a 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c | |||
@@ -306,7 +306,7 @@ static inline void mmc_host_clk_sysfs_init(struct mmc_host *host) | |||
306 | * parse the properties and set respective generic mmc-host flags and | 306 | * parse the properties and set respective generic mmc-host flags and |
307 | * parameters. | 307 | * parameters. |
308 | */ | 308 | */ |
309 | void mmc_of_parse(struct mmc_host *host) | 309 | int mmc_of_parse(struct mmc_host *host) |
310 | { | 310 | { |
311 | struct device_node *np; | 311 | struct device_node *np; |
312 | u32 bus_width; | 312 | u32 bus_width; |
@@ -315,7 +315,7 @@ void mmc_of_parse(struct mmc_host *host) | |||
315 | int len, ret, gpio; | 315 | int len, ret, gpio; |
316 | 316 | ||
317 | if (!host->parent || !host->parent->of_node) | 317 | if (!host->parent || !host->parent->of_node) |
318 | return; | 318 | return 0; |
319 | 319 | ||
320 | np = host->parent->of_node; | 320 | np = host->parent->of_node; |
321 | 321 | ||
@@ -338,6 +338,7 @@ void mmc_of_parse(struct mmc_host *host) | |||
338 | default: | 338 | default: |
339 | dev_err(host->parent, | 339 | dev_err(host->parent, |
340 | "Invalid \"bus-width\" value %ud!\n", bus_width); | 340 | "Invalid \"bus-width\" value %ud!\n", bus_width); |
341 | return -EINVAL; | ||
341 | } | 342 | } |
342 | 343 | ||
343 | /* f_max is obtained from the optional "max-frequency" property */ | 344 | /* f_max is obtained from the optional "max-frequency" property */ |
@@ -367,18 +368,22 @@ void mmc_of_parse(struct mmc_host *host) | |||
367 | host->caps |= MMC_CAP_NEEDS_POLL; | 368 | host->caps |= MMC_CAP_NEEDS_POLL; |
368 | 369 | ||
369 | gpio = of_get_named_gpio_flags(np, "cd-gpios", 0, &flags); | 370 | gpio = of_get_named_gpio_flags(np, "cd-gpios", 0, &flags); |
371 | if (gpio == -EPROBE_DEFER) | ||
372 | return gpio; | ||
370 | if (gpio_is_valid(gpio)) { | 373 | if (gpio_is_valid(gpio)) { |
371 | if (!(flags & OF_GPIO_ACTIVE_LOW)) | 374 | if (!(flags & OF_GPIO_ACTIVE_LOW)) |
372 | gpio_inv_cd = true; | 375 | gpio_inv_cd = true; |
373 | 376 | ||
374 | ret = mmc_gpio_request_cd(host, gpio); | 377 | ret = mmc_gpio_request_cd(host, gpio); |
375 | if (ret < 0) | 378 | if (ret < 0) { |
376 | dev_err(host->parent, | 379 | dev_err(host->parent, |
377 | "Failed to request CD GPIO #%d: %d!\n", | 380 | "Failed to request CD GPIO #%d: %d!\n", |
378 | gpio, ret); | 381 | gpio, ret); |
379 | else | 382 | return ret; |
383 | } else { | ||
380 | dev_info(host->parent, "Got CD GPIO #%d.\n", | 384 | dev_info(host->parent, "Got CD GPIO #%d.\n", |
381 | gpio); | 385 | gpio); |
386 | } | ||
382 | } | 387 | } |
383 | 388 | ||
384 | if (explicit_inv_cd ^ gpio_inv_cd) | 389 | if (explicit_inv_cd ^ gpio_inv_cd) |
@@ -389,14 +394,23 @@ void mmc_of_parse(struct mmc_host *host) | |||
389 | explicit_inv_wp = of_property_read_bool(np, "wp-inverted"); | 394 | explicit_inv_wp = of_property_read_bool(np, "wp-inverted"); |
390 | 395 | ||
391 | gpio = of_get_named_gpio_flags(np, "wp-gpios", 0, &flags); | 396 | gpio = of_get_named_gpio_flags(np, "wp-gpios", 0, &flags); |
397 | if (gpio == -EPROBE_DEFER) { | ||
398 | ret = -EPROBE_DEFER; | ||
399 | goto out; | ||
400 | } | ||
392 | if (gpio_is_valid(gpio)) { | 401 | if (gpio_is_valid(gpio)) { |
393 | if (!(flags & OF_GPIO_ACTIVE_LOW)) | 402 | if (!(flags & OF_GPIO_ACTIVE_LOW)) |
394 | gpio_inv_wp = true; | 403 | gpio_inv_wp = true; |
395 | 404 | ||
396 | ret = mmc_gpio_request_ro(host, gpio); | 405 | ret = mmc_gpio_request_ro(host, gpio); |
397 | if (ret < 0) | 406 | if (ret < 0) { |
398 | dev_err(host->parent, | 407 | dev_err(host->parent, |
399 | "Failed to request WP GPIO: %d!\n", ret); | 408 | "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 | } | ||
400 | } | 414 | } |
401 | if (explicit_inv_wp ^ gpio_inv_wp) | 415 | if (explicit_inv_wp ^ gpio_inv_wp) |
402 | host->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; | 416 | host->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; |
@@ -413,6 +427,12 @@ void mmc_of_parse(struct mmc_host *host) | |||
413 | host->pm_caps |= MMC_PM_KEEP_POWER; | 427 | host->pm_caps |= MMC_PM_KEEP_POWER; |
414 | if (of_find_property(np, "enable-sdio-wakeup", &len)) | 428 | if (of_find_property(np, "enable-sdio-wakeup", &len)) |
415 | host->pm_caps |= MMC_PM_WAKE_SDIO_IRQ; | 429 | host->pm_caps |= MMC_PM_WAKE_SDIO_IRQ; |
430 | |||
431 | return 0; | ||
432 | |||
433 | out: | ||
434 | mmc_gpio_free_cd(host); | ||
435 | return ret; | ||
416 | } | 436 | } |
417 | 437 | ||
418 | EXPORT_SYMBOL(mmc_of_parse); | 438 | EXPORT_SYMBOL(mmc_of_parse); |