Commit 381e3554750930e0579aa06f78afc9d6215fc62a

Authored by Linus Torvalds

Merge tag 'mmc-v3.18-2' of git://git.linaro.org/people/ulf.hansson/mmc

Pull MMC fix from Ulf Hansson:
 "Fix card detection regression in the MMC core.

  The MMC_CAP2_CD_ACTIVE_HIGH and MMC_CAP2_RO_ACTIVE_HIGH could under
  some circumstances be set incorrectly, causing the card detection to
  fail"

* tag 'mmc-v3.18-2' of git://git.linaro.org/people/ulf.hansson/mmc:
  mmc: core: fix card detection regression

Showing 1 changed file Side-by-side Diff

drivers/mmc/core/host.c
... ... @@ -311,7 +311,8 @@
311 311 struct device_node *np;
312 312 u32 bus_width;
313 313 int len, ret;
314   - bool cap_invert, gpio_invert;
  314 + bool cd_cap_invert, cd_gpio_invert = false;
  315 + bool ro_cap_invert, ro_gpio_invert = false;
315 316  
316 317 if (!host->parent || !host->parent->of_node)
317 318 return 0;
318 319  
... ... @@ -359,16 +360,13 @@
359 360 if (of_find_property(np, "non-removable", &len)) {
360 361 host->caps |= MMC_CAP_NONREMOVABLE;
361 362 } else {
362   - if (of_property_read_bool(np, "cd-inverted"))
363   - cap_invert = true;
364   - else
365   - cap_invert = false;
  363 + cd_cap_invert = of_property_read_bool(np, "cd-inverted");
366 364  
367 365 if (of_find_property(np, "broken-cd", &len))
368 366 host->caps |= MMC_CAP_NEEDS_POLL;
369 367  
370 368 ret = mmc_gpiod_request_cd(host, "cd", 0, true,
371   - 0, &gpio_invert);
  369 + 0, &cd_gpio_invert);
372 370 if (ret) {
373 371 if (ret == -EPROBE_DEFER)
374 372 return ret;
375 373  
376 374  
... ... @@ -391,17 +389,14 @@
391 389 * both inverted, the end result is that the CD line is
392 390 * not inverted.
393 391 */
394   - if (cap_invert ^ gpio_invert)
  392 + if (cd_cap_invert ^ cd_gpio_invert)
395 393 host->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH;
396 394 }
397 395  
398 396 /* Parse Write Protection */
399   - if (of_property_read_bool(np, "wp-inverted"))
400   - cap_invert = true;
401   - else
402   - cap_invert = false;
  397 + ro_cap_invert = of_property_read_bool(np, "wp-inverted");
403 398  
404   - ret = mmc_gpiod_request_ro(host, "wp", 0, false, 0, &gpio_invert);
  399 + ret = mmc_gpiod_request_ro(host, "wp", 0, false, 0, &ro_gpio_invert);
405 400 if (ret) {
406 401 if (ret == -EPROBE_DEFER)
407 402 goto out;
... ... @@ -414,7 +409,7 @@
414 409 dev_info(host->parent, "Got WP GPIO\n");
415 410  
416 411 /* See the comment on CD inversion above */
417   - if (cap_invert ^ gpio_invert)
  412 + if (ro_cap_invert ^ ro_gpio_invert)
418 413 host->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
419 414  
420 415 if (of_find_property(np, "cap-sd-highspeed", &len))