// SPDX-License-Identifier: GPL-2.0-only /* * Sony MemoryStick support * * Copyright (C) 2007 Alex Dubov <oakad@yahoo.com> * * Special thanks to Carlos Corbacho for providing various MemoryStick cards * that made this driver possible.
*/
/** * memstick_detect_change - schedule media detection on memstick host * @host: host to use
*/ void memstick_detect_change(struct memstick_host *host)
{
queue_work(workqueue, &host->media_checker);
}
EXPORT_SYMBOL(memstick_detect_change);
/** * memstick_next_req - called by host driver to obtain next request to process * @host: host to use * @mrq: pointer to stick the request to * * Host calls this function from idle state (*mrq == NULL) or after finishing * previous request (*mrq should point to it). If previous request was * unsuccessful, it is retried for predetermined number of times. * * Returns: value of 0 means that new request was assigned to the host. * Otherwise a negative error code is returned.
*/ int memstick_next_req(struct memstick_host *host, struct memstick_request **mrq)
{ int rc = -ENXIO;
/** * memstick_new_req - notify the host that some requests are pending * @host: host to use
*/ void memstick_new_req(struct memstick_host *host)
{ if (host->card) {
host->retries = cmd_retries;
reinit_completion(&host->card->mrq_complete);
host->request(host);
}
}
EXPORT_SYMBOL(memstick_new_req);
/** * memstick_init_req_sg - set request fields needed for bulk data transfer * @mrq: request to use * @tpc: memstick Transport Protocol Command * @sg: TPC argument
*/ void memstick_init_req_sg(struct memstick_request *mrq, unsignedchar tpc, conststruct scatterlist *sg)
{
mrq->tpc = tpc; if (tpc & 8)
mrq->data_dir = WRITE; else
mrq->data_dir = READ;
/** * memstick_init_req - set request fields needed for short data transfer * @mrq: request to use * @tpc: memstick Transport Protocol Command * @buf: TPC argument buffer * @length: TPC argument size * * The intended use of this function (transfer of data items several bytes * in size) allows us to just copy the value between request structure and * user supplied buffer.
*/ void memstick_init_req(struct memstick_request *mrq, unsignedchar tpc, constvoid *buf, size_t length)
{
mrq->tpc = tpc; if (tpc & 8)
mrq->data_dir = WRITE; else
mrq->data_dir = READ;
/* * Functions prefixed with "h_" are protocol callbacks. They can be called from * interrupt context. Return value of 0 means that request processing is still * ongoing, while special error value of -EAGAIN means that current request is * finished (and request processor should come back some time later).
*/
/** * memstick_set_rw_addr - issue SET_RW_REG_ADDR request and wait for it to * complete * @card: media device to use * * Returns: error setting for the current request
*/ int memstick_set_rw_addr(struct memstick_dev *card)
{
card->next_request = h_memstick_set_rw_addr;
memstick_new_req(card->host); if (!wait_for_completion_timeout(&card->mrq_complete,
msecs_to_jiffies(500)))
card->current_mrq.error = -ETIMEDOUT;
/** * memstick_alloc_host - allocate a memstick_host structure * @extra: size of the user private data to allocate * @dev: parent device of the host * * Returns: %NULL on failure or the allocated &memstick_host pointer on success
*/ struct memstick_host *memstick_alloc_host(unsignedint extra, struct device *dev)
{ struct memstick_host *host;
/** * memstick_add_host - start request processing on memstick host * @host: host to use * * Returns: %0 on success or a negative error code on failure
*/ int memstick_add_host(struct memstick_host *host)
{ int rc;
/** * memstick_suspend_host - notify bus driver of host suspension * @host: host to use
*/ void memstick_suspend_host(struct memstick_host *host)
{
mutex_lock(&host->lock);
host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF);
mutex_unlock(&host->lock);
}
EXPORT_SYMBOL(memstick_suspend_host);
/** * memstick_resume_host - notify bus driver of host resumption * @host: host to use
*/ void memstick_resume_host(struct memstick_host *host)
{ int rc = 0;
mutex_lock(&host->lock); if (host->card)
rc = memstick_power_on(host);
mutex_unlock(&host->lock);
if (!rc)
memstick_detect_change(host);
}
EXPORT_SYMBOL(memstick_resume_host);
int memstick_register_driver(struct memstick_driver *drv)
{
drv->driver.bus = &memstick_bus_type;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.