84
82
flush_workqueue(workqueue);
87
#ifdef CONFIG_FAIL_MMC_REQUEST
89
static DECLARE_FAULT_ATTR(fail_mmc_request);
91
static int __init setup_fail_mmc_request(char *str)
93
return setup_fault_attr(&fail_mmc_request, str);
95
__setup("fail_mmc_request=", setup_fail_mmc_request);
97
static void mmc_should_fail_request(struct mmc_host *host,
98
struct mmc_request *mrq)
100
struct mmc_command *cmd = mrq->cmd;
101
struct mmc_data *data = mrq->data;
102
static const int data_errors[] = {
111
if (cmd->error || data->error || !host->make_it_fail ||
112
!should_fail(&fail_mmc_request, data->blksz * data->blocks))
115
data->error = data_errors[random32() % ARRAY_SIZE(data_errors)];
116
data->bytes_xfered = (random32() % (data->bytes_xfered >> 9)) << 9;
119
static int __init fail_mmc_request_debugfs(void)
121
return init_fault_attr_dentries(&fail_mmc_request,
125
late_initcall(fail_mmc_request_debugfs);
127
#else /* CONFIG_FAIL_MMC_REQUEST */
129
static void mmc_should_fail_request(struct mmc_host *host,
130
struct mmc_request *mrq)
134
#endif /* CONFIG_FAIL_MMC_REQUEST */
138
86
* mmc_request_done - finish processing an MMC request
139
87
* @host: MMC host which completed request
253
199
static void mmc_wait_done(struct mmc_request *mrq)
255
complete(&mrq->completion);
258
static void __mmc_start_req(struct mmc_host *host, struct mmc_request *mrq)
260
init_completion(&mrq->completion);
261
mrq->done = mmc_wait_done;
262
mmc_start_request(host, mrq);
265
static void mmc_wait_for_req_done(struct mmc_host *host,
266
struct mmc_request *mrq)
268
wait_for_completion(&mrq->completion);
272
* mmc_pre_req - Prepare for a new request
273
* @host: MMC host to prepare command
274
* @mrq: MMC request to prepare for
275
* @is_first_req: true if there is no previous started request
276
* that may run in parellel to this call, otherwise false
278
* mmc_pre_req() is called in prior to mmc_start_req() to let
279
* host prepare for the new request. Preparation of a request may be
280
* performed while another request is running on the host.
282
static void mmc_pre_req(struct mmc_host *host, struct mmc_request *mrq,
285
if (host->ops->pre_req)
286
host->ops->pre_req(host, mrq, is_first_req);
290
* mmc_post_req - Post process a completed request
291
* @host: MMC host to post process command
292
* @mrq: MMC request to post process for
293
* @err: Error, if non zero, clean up any resources made in pre_req
295
* Let the host post process a completed request. Post processing of
296
* a request may be performed while another reuqest is running.
298
static void mmc_post_req(struct mmc_host *host, struct mmc_request *mrq,
301
if (host->ops->post_req)
302
host->ops->post_req(host, mrq, err);
306
* mmc_start_req - start a non-blocking request
307
* @host: MMC host to start command
308
* @areq: async request to start
309
* @error: out parameter returns 0 for success, otherwise non zero
311
* Start a new MMC custom command request for a host.
312
* If there is on ongoing async request wait for completion
313
* of that request and start the new one and return.
314
* Does not wait for the new request to complete.
316
* Returns the completed async request, NULL in case of none completed.
318
struct mmc_async_req *mmc_start_req(struct mmc_host *host,
319
struct mmc_async_req *areq, int *error)
322
struct mmc_async_req *data = host->areq;
324
/* Prepare a new request */
326
mmc_pre_req(host, areq->mrq, !host->areq);
329
mmc_wait_for_req_done(host, host->areq->mrq);
330
err = host->areq->err_check(host->card, host->areq);
332
mmc_post_req(host, host->areq->mrq, 0);
334
mmc_post_req(host, areq->mrq, -EINVAL);
342
__mmc_start_req(host, areq->mrq);
345
mmc_post_req(host, host->areq->mrq, 0);
353
EXPORT_SYMBOL(mmc_start_req);
201
complete(mrq->done_data);
356
205
* mmc_wait_for_req - start a request and wait for completion
364
213
void mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq)
366
__mmc_start_req(host, mrq);
367
mmc_wait_for_req_done(host, mrq);
215
DECLARE_COMPLETION_ONSTACK(complete);
217
mrq->done_data = &complete;
218
mrq->done = mmc_wait_done;
220
mmc_start_request(host, mrq);
222
wait_for_completion(&complete);
369
225
EXPORT_SYMBOL(mmc_wait_for_req);