Lines Matching full:host
179 struct memstick_host *host = container_of(dev, struct memstick_host, in memstick_free() local
181 kfree(host); in memstick_free()
202 * memstick_detect_change - schedule media detection on memstick host
203 * @host: host to use
205 void memstick_detect_change(struct memstick_host *host) in memstick_detect_change() argument
207 queue_work(workqueue, &host->media_checker); in memstick_detect_change()
212 * memstick_next_req - called by host driver to obtain next request to process
213 * @host: host to use
216 * Host calls this function from idle state (*mrq == NULL) or after finishing
220 * Returns: value of 0 means that new request was assigned to the host.
223 int memstick_next_req(struct memstick_host *host, struct memstick_request **mrq) in memstick_next_req() argument
227 if ((*mrq) && (*mrq)->error && host->retries) { in memstick_next_req()
229 host->retries--; in memstick_next_req()
233 if (host->card && host->card->next_request) in memstick_next_req()
234 rc = host->card->next_request(host->card, mrq); in memstick_next_req()
237 host->retries = cmd_retries > 1 ? cmd_retries - 1 : 1; in memstick_next_req()
246 * memstick_new_req - notify the host that some requests are pending
247 * @host: host to use
249 void memstick_new_req(struct memstick_host *host) in memstick_new_req() argument
251 if (host->card) { in memstick_new_req()
252 host->retries = cmd_retries; in memstick_new_req()
253 reinit_completion(&host->card->mrq_complete); in memstick_new_req()
254 host->request(host); in memstick_new_req()
372 memstick_new_req(card->host); in memstick_set_rw_addr()
381 static struct memstick_dev *memstick_alloc_card(struct memstick_host *host) in memstick_alloc_card() argument
384 struct memstick_dev *old_card = host->card; in memstick_alloc_card()
388 card->host = host; in memstick_alloc_card()
389 dev_set_name(&card->dev, "%s", dev_name(&host->dev)); in memstick_alloc_card()
390 card->dev.parent = &host->dev; in memstick_alloc_card()
402 host->card = card; in memstick_alloc_card()
407 memstick_new_req(host); in memstick_alloc_card()
415 host->card = old_card; in memstick_alloc_card()
418 host->card = old_card; in memstick_alloc_card()
424 static int memstick_power_on(struct memstick_host *host) in memstick_power_on() argument
426 int rc = host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_ON); in memstick_power_on()
429 rc = host->set_param(host, MEMSTICK_INTERFACE, MEMSTICK_SERIAL); in memstick_power_on()
436 struct memstick_host *host = container_of(work, struct memstick_host, in memstick_check() local
440 dev_dbg(&host->dev, "memstick_check started\n"); in memstick_check()
441 pm_runtime_get_noresume(host->dev.parent); in memstick_check()
442 mutex_lock(&host->lock); in memstick_check()
443 if (!host->card) { in memstick_check()
444 if (memstick_power_on(host)) in memstick_check()
446 } else if (host->card->stop) in memstick_check()
447 host->card->stop(host->card); in memstick_check()
449 if (host->removing) in memstick_check()
452 card = memstick_alloc_card(host); in memstick_check()
455 if (host->card) { in memstick_check()
456 device_unregister(&host->card->dev); in memstick_check()
457 host->card = NULL; in memstick_check()
460 dev_dbg(&host->dev, "new card %02x, %02x, %02x\n", in memstick_check()
462 if (host->card) { in memstick_check()
463 if (memstick_set_rw_addr(host->card) in memstick_check()
464 || !memstick_dev_match(host->card, &card->id) in memstick_check()
465 || !(host->card->check(host->card))) { in memstick_check()
466 device_unregister(&host->card->dev); in memstick_check()
467 host->card = NULL; in memstick_check()
468 } else if (host->card->start) in memstick_check()
469 host->card->start(host->card); in memstick_check()
472 if (!host->card) { in memstick_check()
473 host->card = card; in memstick_check()
476 host->card = NULL; in memstick_check()
485 if (!host->card) in memstick_check()
486 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF); in memstick_check()
488 mutex_unlock(&host->lock); in memstick_check()
489 pm_runtime_put(host->dev.parent); in memstick_check()
490 dev_dbg(&host->dev, "memstick_check finished\n"); in memstick_check()
496 * @dev: parent device of the host
503 struct memstick_host *host; in memstick_alloc_host() local
505 host = kzalloc(sizeof(struct memstick_host) + extra, GFP_KERNEL); in memstick_alloc_host()
506 if (host) { in memstick_alloc_host()
507 mutex_init(&host->lock); in memstick_alloc_host()
508 INIT_WORK(&host->media_checker, memstick_check); in memstick_alloc_host()
509 host->dev.class = &memstick_host_class; in memstick_alloc_host()
510 host->dev.parent = dev; in memstick_alloc_host()
511 device_initialize(&host->dev); in memstick_alloc_host()
513 return host; in memstick_alloc_host()
518 * memstick_add_host - start request processing on memstick host
519 * @host: host to use
523 int memstick_add_host(struct memstick_host *host) in memstick_add_host() argument
530 rc = idr_alloc(&memstick_host_idr, host, 0, 0, GFP_NOWAIT); in memstick_add_host()
532 host->id = rc; in memstick_add_host()
539 dev_set_name(&host->dev, "memstick%u", host->id); in memstick_add_host()
541 rc = device_add(&host->dev); in memstick_add_host()
544 idr_remove(&memstick_host_idr, host->id); in memstick_add_host()
549 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF); in memstick_add_host()
550 memstick_detect_change(host); in memstick_add_host()
556 * memstick_remove_host - stop request processing on memstick host
557 * @host: host to use
559 void memstick_remove_host(struct memstick_host *host) in memstick_remove_host() argument
562 mutex_lock(&host->lock); in memstick_remove_host()
563 if (host->card) in memstick_remove_host()
564 device_unregister(&host->card->dev); in memstick_remove_host()
565 host->card = NULL; in memstick_remove_host()
566 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF); in memstick_remove_host()
567 mutex_unlock(&host->lock); in memstick_remove_host()
570 idr_remove(&memstick_host_idr, host->id); in memstick_remove_host()
572 device_del(&host->dev); in memstick_remove_host()
577 * memstick_free_host - free memstick host
578 * @host: host to use
580 void memstick_free_host(struct memstick_host *host) in memstick_free_host() argument
582 mutex_destroy(&host->lock); in memstick_free_host()
583 put_device(&host->dev); in memstick_free_host()
588 * memstick_suspend_host - notify bus driver of host suspension
589 * @host: host to use
591 void memstick_suspend_host(struct memstick_host *host) in memstick_suspend_host() argument
593 mutex_lock(&host->lock); in memstick_suspend_host()
594 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF); in memstick_suspend_host()
595 mutex_unlock(&host->lock); in memstick_suspend_host()
600 * memstick_resume_host - notify bus driver of host resumption
601 * @host: host to use
603 void memstick_resume_host(struct memstick_host *host) in memstick_resume_host() argument
607 mutex_lock(&host->lock); in memstick_resume_host()
608 if (host->card) in memstick_resume_host()
609 rc = memstick_power_on(host); in memstick_resume_host()
610 mutex_unlock(&host->lock); in memstick_resume_host()
613 memstick_detect_change(host); in memstick_resume_host()