diff options
Diffstat (limited to 'drivers/memstick/core/memstick.c')
-rw-r--r-- | drivers/memstick/core/memstick.c | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/drivers/memstick/core/memstick.c b/drivers/memstick/core/memstick.c index 61b98c333cb..a38005008a2 100644 --- a/drivers/memstick/core/memstick.c +++ b/drivers/memstick/core/memstick.c | |||
@@ -249,8 +249,11 @@ EXPORT_SYMBOL(memstick_next_req); | |||
249 | */ | 249 | */ |
250 | void memstick_new_req(struct memstick_host *host) | 250 | void memstick_new_req(struct memstick_host *host) |
251 | { | 251 | { |
252 | host->retries = cmd_retries; | 252 | if (host->card) { |
253 | host->request(host); | 253 | host->retries = cmd_retries; |
254 | INIT_COMPLETION(host->card->mrq_complete); | ||
255 | host->request(host); | ||
256 | } | ||
254 | } | 257 | } |
255 | EXPORT_SYMBOL(memstick_new_req); | 258 | EXPORT_SYMBOL(memstick_new_req); |
256 | 259 | ||
@@ -415,10 +418,14 @@ err_out: | |||
415 | return NULL; | 418 | return NULL; |
416 | } | 419 | } |
417 | 420 | ||
418 | static void memstick_power_on(struct memstick_host *host) | 421 | static int memstick_power_on(struct memstick_host *host) |
419 | { | 422 | { |
420 | host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_ON); | 423 | int rc = host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_ON); |
421 | host->set_param(host, MEMSTICK_INTERFACE, MEMSTICK_SERIAL); | 424 | |
425 | if (!rc) | ||
426 | rc = host->set_param(host, MEMSTICK_INTERFACE, MEMSTICK_SERIAL); | ||
427 | |||
428 | return rc; | ||
422 | } | 429 | } |
423 | 430 | ||
424 | static void memstick_check(struct work_struct *work) | 431 | static void memstick_check(struct work_struct *work) |
@@ -429,8 +436,11 @@ static void memstick_check(struct work_struct *work) | |||
429 | 436 | ||
430 | dev_dbg(&host->dev, "memstick_check started\n"); | 437 | dev_dbg(&host->dev, "memstick_check started\n"); |
431 | mutex_lock(&host->lock); | 438 | mutex_lock(&host->lock); |
432 | if (!host->card) | 439 | if (!host->card) { |
433 | memstick_power_on(host); | 440 | if (memstick_power_on(host)) |
441 | goto out_power_off; | ||
442 | } else | ||
443 | host->card->stop(host->card); | ||
434 | 444 | ||
435 | card = memstick_alloc_card(host); | 445 | card = memstick_alloc_card(host); |
436 | 446 | ||
@@ -448,7 +458,8 @@ static void memstick_check(struct work_struct *work) | |||
448 | || !(host->card->check(host->card))) { | 458 | || !(host->card->check(host->card))) { |
449 | device_unregister(&host->card->dev); | 459 | device_unregister(&host->card->dev); |
450 | host->card = NULL; | 460 | host->card = NULL; |
451 | } | 461 | } else |
462 | host->card->start(host->card); | ||
452 | } | 463 | } |
453 | 464 | ||
454 | if (!host->card) { | 465 | if (!host->card) { |
@@ -461,6 +472,7 @@ static void memstick_check(struct work_struct *work) | |||
461 | kfree(card); | 472 | kfree(card); |
462 | } | 473 | } |
463 | 474 | ||
475 | out_power_off: | ||
464 | if (!host->card) | 476 | if (!host->card) |
465 | host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF); | 477 | host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF); |
466 | 478 | ||
@@ -573,11 +585,15 @@ EXPORT_SYMBOL(memstick_suspend_host); | |||
573 | */ | 585 | */ |
574 | void memstick_resume_host(struct memstick_host *host) | 586 | void memstick_resume_host(struct memstick_host *host) |
575 | { | 587 | { |
588 | int rc = 0; | ||
589 | |||
576 | mutex_lock(&host->lock); | 590 | mutex_lock(&host->lock); |
577 | if (host->card) | 591 | if (host->card) |
578 | memstick_power_on(host); | 592 | rc = memstick_power_on(host); |
579 | mutex_unlock(&host->lock); | 593 | mutex_unlock(&host->lock); |
580 | memstick_detect_change(host); | 594 | |
595 | if (!rc) | ||
596 | memstick_detect_change(host); | ||
581 | } | 597 | } |
582 | EXPORT_SYMBOL(memstick_resume_host); | 598 | EXPORT_SYMBOL(memstick_resume_host); |
583 | 599 | ||