Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]
  1 /*
  2  *  linux/drivers/mmc/core/core.c
  3  *
  4  *  Copyright (C) 2003-2004 Russell King, All Rights Reserved.
  5  *  SD support Copyright (C) 2004 Ian Molton, All Rights Reserved.
  6  *  Copyright (C) 2005-2007 Pierre Ossman, All Rights Reserved.
  7  *  MMCv4 support Copyright (C) 2006 Philip Langdale, All Rights Reserved.
  8  *
  9  * This program is free software; you can redistribute it and/or modify
 10  * it under the terms of the GNU General Public License version 2 as
 11  * published by the Free Software Foundation.
 12  */
 13 #include <linux/module.h>
 14 #include <linux/init.h>
 15 #include <linux/interrupt.h>
 16 #include <linux/completion.h>
 17 #include <linux/device.h>
 18 #include <linux/delay.h>
 19 #include <linux/pagemap.h>
 20 #include <linux/err.h>
 21 #include <linux/leds.h>
 22 #include <linux/scatterlist.h>
 23 
 24 #include <linux/mmc/card.h>
 25 #include <linux/mmc/host.h>
 26 #include <linux/mmc/mmc.h>
 27 #include <linux/mmc/sd.h>
 28 
 29 #include "core.h"
 30 #include "bus.h"
 31 #include "host.h"
 32 #include "sdio_bus.h"
 33 
 34 #include "mmc_ops.h"
 35 #include "sd_ops.h"
 36 #include "sdio_ops.h"
 37 
 38 extern int mmc_attach_mmc(struct mmc_host *host, u32 ocr);
 39 extern int mmc_attach_sd(struct mmc_host *host, u32 ocr);
 40 extern int mmc_attach_sdio(struct mmc_host *host, u32 ocr);
 41 
 42 static struct workqueue_struct *workqueue;
 43 
 44 /*
 45  * Enabling software CRCs on the data blocks can be a significant (30%)
 46  * performance cost, and for other reasons may not always be desired.
 47  * So we allow it it to be disabled.
 48  */
 49 int use_spi_crc = 1;
 50 module_param(use_spi_crc, bool, 0);
 51 
 52 /*
 53  * Internal function. Schedule delayed work in the MMC work queue.
 54  */
 55 static int mmc_schedule_delayed_work(struct delayed_work *work,
 56                                      unsigned long delay)
 57 {
 58         return queue_delayed_work(workqueue, work, delay);
 59 }
 60 
 61 /*
 62  * Internal function. Flush all scheduled work from the MMC work queue.
 63  */
 64 static void mmc_flush_scheduled_work(void)
 65 {
 66         flush_workqueue(workqueue);
 67 }
 68 
 69 /**
 70  *      mmc_request_done - finish processing an MMC request
 71  *      @host: MMC host which completed request
 72  *      @mrq: MMC request which request
 73  *
 74  *      MMC drivers should call this function when they have completed
 75  *      their processing of a request.
 76  */
 77 void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq)
 78 {
 79         struct mmc_command *cmd = mrq->cmd;
 80         int err = cmd->error;
 81 
 82         if (err && cmd->retries && mmc_host_is_spi(host)) {
 83                 if (cmd->resp[0] & R1_SPI_ILLEGAL_COMMAND)
 84                         cmd->retries = 0;
 85         }
 86 
 87         if (err && cmd->retries) {
 88                 pr_debug("%s: req failed (CMD%u): %d, retrying...\n",
 89                         mmc_hostname(host), cmd->opcode, err);
 90 
 91                 cmd->retries--;
 92                 cmd->error = 0;
 93                 host->ops->request(host, mrq);
 94         } else {
 95                 led_trigger_event(host->led, LED_OFF);
 96 
 97                 pr_debug("%s: req done (CMD%u): %d: %08x %08x %08x %08x\n",
 98                         mmc_hostname(host), cmd->opcode, err,
 99                         cmd->resp[0], cmd->resp[1],
100                         cmd->resp[2], cmd->resp[3]);
101 
102                 if (mrq->data) {
103                         pr_debug("%s:     %d bytes transferred: %d\n",
104                                 mmc_hostname(host),
105                                 mrq->data->bytes_xfered, mrq->data->error);
106                 }
107 
108                 if (mrq->stop) {
109                         pr_debug("%s:     (CMD%u): %d: %08x %08x %08x %08x\n",
110                                 mmc_hostname(host), mrq->stop->opcode,
111                                 mrq->stop->error,
112                                 mrq->stop->resp[0], mrq->stop->resp[1],
113                                 mrq->stop->resp[2], mrq->stop->resp[3]);
114                 }
115 
116                 if (mrq->done)
117                         mrq->done(mrq);
118         }
119 }
120 
121 EXPORT_SYMBOL(mmc_request_done);
122 
123 static void
124 mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
125 {
126 #ifdef CONFIG_MMC_DEBUG
127         unsigned int i, sz;
128 #endif
129 
130         pr_debug("%s: starting CMD%u arg %08x flags %08x\n",
131                  mmc_hostname(host), mrq->cmd->opcode,
132                  mrq->cmd->arg, mrq->cmd->flags);
133 
134         if (mrq->data) {
135                 pr_debug("%s:     blksz %d blocks %d flags %08x "
136                         "tsac %d ms nsac %d\n",
137                         mmc_hostname(host), mrq->data->blksz,
138                         mrq->data->blocks, mrq->data->flags,
139                         mrq->data->timeout_ns / 1000000,
140                         mrq->data->timeout_clks);
141         }
142 
143         if (mrq->stop) {
144                 pr_debug("%s:     CMD%u arg %08x flags %08x\n",
145                          mmc_hostname(host), mrq->stop->opcode,
146                          mrq->stop->arg, mrq->stop->flags);
147         }
148 
149         WARN_ON(!host->claimed);
150 
151         led_trigger_event(host->led, LED_FULL);
152 
153         mrq->cmd->error = 0;
154         mrq->cmd->mrq = mrq;
155         if (mrq->data) {
156                 BUG_ON(mrq->data->blksz > host->max_blk_size);
157                 BUG_ON(mrq->data->blocks > host->max_blk_count);
158                 BUG_ON(mrq->data->blocks * mrq->data->blksz >
159                         host->max_req_size);
160 
161 #ifdef CONFIG_MMC_DEBUG
162                 sz = 0;
163                 for (i = 0;i < mrq->data->sg_len;i++)
164                         sz += mrq->data->sg[i].length;
165                 BUG_ON(sz != mrq->data->blocks * mrq->data->blksz);
166 #endif
167 
168                 mrq->cmd->data = mrq->data;
169                 mrq->data->error = 0;
170                 mrq->data->mrq = mrq;
171                 if (mrq->stop) {
172                         mrq->data->stop = mrq->stop;
173                         mrq->stop->error = 0;
174                         mrq->stop->mrq = mrq;
175                 }
176         }
177         host->ops->request(host, mrq);
178 }
179 
180 static void mmc_wait_done(struct mmc_request *mrq)
181 {
182         complete(mrq->done_data);
183 }
184 
185 /**
186  *      mmc_wait_for_req - start a request and wait for completion
187  *      @host: MMC host to start command
188  *      @mrq: MMC request to start
189  *
190  *      Start a new MMC custom command request for a host, and wait
191  *      for the command to complete. Does not attempt to parse the
192  *      response.
193  */
194 void mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq)
195 {
196         DECLARE_COMPLETION_ONSTACK(complete);
197 
198         mrq->done_data = &complete;
199         mrq->done = mmc_wait_done;
200 
201         mmc_start_request(host, mrq);
202 
203         wait_for_completion(&complete);
204 }
205 
206 EXPORT_SYMBOL(mmc_wait_for_req);
207 
208 /**
209  *      mmc_wait_for_cmd - start a command and wait for completion
210  *      @host: MMC host to start command
211  *      @cmd: MMC command to start
212  *      @retries: maximum number of retries
213  *
214  *      Start a new MMC command for a host, and wait for the command
215  *      to complete.  Return any error that occurred while the command
216  *      was executing.  Do not attempt to parse the response.
217  */
218 int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, int retries)
219 {
220         struct mmc_request mrq;
221 
222         WARN_ON(!host->claimed);
223 
224         memset(&mrq, 0, sizeof(struct mmc_request));
225 
226         memset(cmd->resp, 0, sizeof(cmd->resp));
227         cmd->retries = retries;
228 
229         mrq.cmd = cmd;
230         cmd->data = NULL;
231 
232         mmc_wait_for_req(host, &mrq);
233 
234         return cmd->error;
235 }
236 
237 EXPORT_SYMBOL(mmc_wait_for_cmd);
238 
239 /**
240  *      mmc_set_data_timeout - set the timeout for a data command
241  *      @data: data phase for command
242  *      @card: the MMC card associated with the data transfer
243  *
244  *      Computes the data timeout parameters according to the
245  *      correct algorithm given the card type.
246  */
247 void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card)
248 {
249         unsigned int mult;
250 
251         /*
252          * SDIO cards only define an upper 1 s limit on access.
253          */
254         if (mmc_card_sdio(card)) {
255                 data->timeout_ns = 1000000000;
256                 data->timeout_clks = 0;
257                 return;
258         }
259 
260         /*
261          * SD cards use a 100 multiplier rather than 10
262          */
263         mult = mmc_card_sd(card) ? 100 : 10;
264 
265         /*
266          * Scale up the multiplier (and therefore the timeout) by
267          * the r2w factor for writes.
268          */
269         if (data->flags & MMC_DATA_WRITE)
270                 mult <<= card->csd.r2w_factor;
271 
272         data->timeout_ns = card->csd.tacc_ns * mult;
273         data->timeout_clks = card->csd.tacc_clks * mult;
274 
275         /*
276          * SD cards also have an upper limit on the timeout.
277          */
278         if (mmc_card_sd(card)) {
279                 unsigned int timeout_us, limit_us;
280 
281                 timeout_us = data->timeout_ns / 1000;
282                 timeout_us += data->timeout_clks * 1000 /
283                         (card->host->ios.clock / 1000);
284 
285                 if (data->flags & MMC_DATA_WRITE)
286                         limit_us = 250000;
287                 else
288                         limit_us = 100000;
289 
290                 /*
291                  * SDHC cards always use these fixed values.
292                  */
293                 if (timeout_us > limit_us || mmc_card_blockaddr(card)) {
294                         data->timeout_ns = limit_us * 1000;
295                         data->timeout_clks = 0;
296                 }
297         }
298 }
299 EXPORT_SYMBOL(mmc_set_data_timeout);
300 
301 /**
302  *      __mmc_claim_host - exclusively claim a host
303  *      @host: mmc host to claim
304  *      @abort: whether or not the operation should be aborted
305  *
306  *      Claim a host for a set of operations.  If @abort is non null and
307  *      dereference a non-zero value then this will return prematurely with
308  *      that non-zero value without acquiring the lock.  Returns zero
309  *      with the lock held otherwise.
310  */
311 int __mmc_claim_host(struct mmc_host *host, atomic_t *abort)
312 {
313         DECLARE_WAITQUEUE(wait, current);
314         unsigned long flags;
315         int stop;
316 
317         might_sleep();
318 
319         add_wait_queue(&host->wq, &wait);
320         spin_lock_irqsave(&host->lock, flags);
321         while (1) {
322                 set_current_state(TASK_UNINTERRUPTIBLE);
323                 stop = abort ? atomic_read(abort) : 0;
324                 if (stop || !host->claimed)
325                         break;
326                 spin_unlock_irqrestore(&host->lock, flags);
327                 schedule();
328                 spin_lock_irqsave(&host->lock, flags);
329         }
330         set_current_state(TASK_RUNNING);
331         if (!stop)
332                 host->claimed = 1;
333         else
334                 wake_up(&host->wq);
335         spin_unlock_irqrestore(&host->lock, flags);
336         remove_wait_queue(&host->wq, &wait);
337         return stop;
338 }
339 
340 EXPORT_SYMBOL(__mmc_claim_host);
341 
342 /**
343  *      mmc_release_host - release a host
344  *      @host: mmc host to release
345  *
346  *      Release a MMC host, allowing others to claim the host
347  *      for their operations.
348  */
349 void mmc_release_host(struct mmc_host *host)
350 {
351         unsigned long flags;
352 
353         WARN_ON(!host->claimed);
354 
355         spin_lock_irqsave(&host->lock, flags);
356         host->claimed = 0;
357         spin_unlock_irqrestore(&host->lock, flags);
358 
359         wake_up(&host->wq);
360 }
361 
362 EXPORT_SYMBOL(mmc_release_host);
363 
364 /*
365  * Internal function that does the actual ios call to the host driver,
366  * optionally printing some debug output.
367  */
368 static inline void mmc_set_ios(struct mmc_host *host)
369 {
370         struct mmc_ios *ios = &host->ios;
371 
372         pr_debug("%s: clock %uHz busmode %u powermode %u cs %u Vdd %u "
373                 "width %u timing %u\n",
374                  mmc_hostname(host), ios->clock, ios->bus_mode,
375                  ios->power_mode, ios->chip_select, ios->vdd,
376                  ios->bus_width, ios->timing);
377 
378         host->ops->set_ios(host, ios);
379 }
380 
381 /*
382  * Control chip select pin on a host.
383  */
384 void mmc_set_chip_select(struct mmc_host *host, int mode)
385 {
386         host->ios.chip_select = mode;
387         mmc_set_ios(host);
388 }
389 
390 /*
391  * Sets the host clock to the highest possible frequency that
392  * is below "hz".
393  */
394 void mmc_set_clock(struct mmc_host *host, unsigned int hz)
395 {
396         WARN_ON(hz < host->f_min);
397 
398         if (hz > host->f_max)
399                 hz = host->f_max;
400 
401         host->ios.clock = hz;
402         mmc_set_ios(host);
403 }
404 
405 /*
406  * Change the bus mode (open drain/push-pull) of a host.
407  */
408 void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode)
409 {
410         host->ios.bus_mode = mode;
411         mmc_set_ios(host);
412 }
413 
414 /*
415  * Change data bus width of a host.
416  */
417 void mmc_set_bus_width(struct mmc_host *host, unsigned int width)
418 {
419         host->ios.bus_width = width;
420         mmc_set_ios(host);
421 }
422 
423 /*
424  * Mask off any voltages we don't support and select
425  * the lowest voltage
426  */
427 u32 mmc_select_voltage(struct mmc_host *host, u32 ocr)
428 {
429         int bit;
430 
431         ocr &= host->ocr_avail;
432 
433         bit = ffs(ocr);
434         if (bit) {
435                 bit -= 1;
436 
437                 ocr &= 3 << bit;
438 
439                 host->ios.vdd = bit;
440                 mmc_set_ios(host);
441         } else {
442                 ocr = 0;
443         }
444 
445         return ocr;
446 }
447 
448 /*
449  * Select timing parameters for host.
450  */
451 void mmc_set_timing(struct mmc_host *host, unsigned int timing)
452 {
453         host->ios.timing = timing;
454         mmc_set_ios(host);
455 }
456 
457 /*
458  * Apply power to the MMC stack.  This is a two-stage process.
459  * First, we enable power to the card without the clock running.
460  * We then wait a bit for the power to stabilise.  Finally,
461  * enable the bus drivers and clock to the card.
462  *
463  * We must _NOT_ enable the clock prior to power stablising.
464  *
465  * If a host does all the power sequencing itself, ignore the
466  * initial MMC_POWER_UP stage.
467  */
468 static void mmc_power_up(struct mmc_host *host)
469 {
470         int bit = fls(host->ocr_avail) - 1;
471 
472         host->ios.vdd = bit;
473         if (mmc_host_is_spi(host)) {
474                 host->ios.chip_select = MMC_CS_HIGH;
475                 host->ios.bus_mode = MMC_BUSMODE_PUSHPULL;
476         } else {
477                 host->ios.chip_select = MMC_CS_DONTCARE;
478                 host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
479         }
480         host->ios.power_mode = MMC_POWER_UP;
481         host->ios.bus_width = MMC_BUS_WIDTH_1;
482         host->ios.timing = MMC_TIMING_LEGACY;
483         mmc_set_ios(host);
484 
485         /*
486          * This delay should be sufficient to allow the power supply
487          * to reach the minimum voltage.
488          */
489         mmc_delay(2);
490 
491         host->ios.clock = host->f_min;
492         host->ios.power_mode = MMC_POWER_ON;
493         mmc_set_ios(host);
494 
495         /*
496          * This delay must be at least 74 clock sizes, or 1 ms, or the
497          * time required to reach a stable voltage.
498          */
499         mmc_delay(2);
500 }
501 
502 static void mmc_power_off(struct mmc_host *host)
503 {
504         host->ios.clock = 0;
505         host->ios.vdd = 0;
506         if (!mmc_host_is_spi(host)) {
507                 host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
508                 host->ios.chip_select = MMC_CS_DONTCARE;
509         }
510         host->ios.power_mode = MMC_POWER_OFF;
511         host->ios.bus_width = MMC_BUS_WIDTH_1;
512         host->ios.timing = MMC_TIMING_LEGACY;
513         mmc_set_ios(host);
514 }
515 
516 /*
517  * Cleanup when the last reference to the bus operator is dropped.
518  */
519 void __mmc_release_bus(struct mmc_host *host)
520 {
521         BUG_ON(!host);
522         BUG_ON(host->bus_refs);
523         BUG_ON(!host->bus_dead);
524 
525         host->bus_ops = NULL;
526 }
527 
528 /*
529  * Increase reference count of bus operator
530  */
531 static inline void mmc_bus_get(struct mmc_host *host)
532 {
533         unsigned long flags;
534 
535         spin_lock_irqsave(&host->lock, flags);
536         host->bus_refs++;
537         spin_unlock_irqrestore(&host->lock, flags);
538 }
539 
540 /*
541  * Decrease reference count of bus operator and free it if
542  * it is the last reference.
543  */
544 static inline void mmc_bus_put(struct mmc_host *host)
545 {
546         unsigned long flags;
547 
548         spin_lock_irqsave(&host->lock, flags);
549         host->bus_refs--;
550         if ((host->bus_refs == 0) && host->bus_ops)
551                 __mmc_release_bus(host);
552         spin_unlock_irqrestore(&host->lock, flags);
553 }
554 
555 /*
556  * Assign a mmc bus handler to a host. Only one bus handler may control a
557  * host at any given time.
558  */
559 void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops)
560 {
561         unsigned long flags;
562 
563         BUG_ON(!host);
564         BUG_ON(!ops);
565 
566         WARN_ON(!host->claimed);
567 
568         spin_lock_irqsave(&host->lock, flags);
569 
570         BUG_ON(host->bus_ops);
571         BUG_ON(host->bus_refs);
572 
573         host->bus_ops = ops;
574         host->bus_refs = 1;
575         host->bus_dead = 0;
576 
577         spin_unlock_irqrestore(&host->lock, flags);
578 }
579 
580 /*
581  * Remove the current bus handler from a host. Assumes that there are
582  * no interesting cards left, so the bus is powered down.
583  */
584 void mmc_detach_bus(struct mmc_host *host)
585 {
586         unsigned long flags;
587 
588         BUG_ON(!host);
589 
590         WARN_ON(!host->claimed);
591         WARN_ON(!host->bus_ops);
592 
593         spin_lock_irqsave(&host->lock, flags);
594 
595         host->bus_dead = 1;
596 
597         spin_unlock_irqrestore(&host->lock, flags);
598 
599         mmc_power_off(host);
600 
601         mmc_bus_put(host);
602 }
603 
604 /**
605  *      mmc_detect_change - process change of state on a MMC socket
606  *      @host: host which changed state.
607  *      @delay: optional delay to wait before detection (jiffies)
608  *
609  *      MMC drivers should call this when they detect a card has been
610  *      inserted or removed. The MMC layer will confirm that any
611  *      present card is still functional, and initialize any newly
612  *      inserted.
613  */
614 void mmc_detect_change(struct mmc_host *host, unsigned long delay)
615 {
616 #ifdef CONFIG_MMC_DEBUG
617         unsigned long flags;
618         spin_lock_irqsave(&host->lock, flags);
619         WARN_ON(host->removed);
620         spin_unlock_irqrestore(&host->lock, flags);
621 #endif
622 
623         mmc_schedule_delayed_work(&host->detect, delay);
624 }
625 
626 EXPORT_SYMBOL(mmc_detect_change);
627 
628 
629 void mmc_rescan(struct work_struct *work)
630 {
631         struct mmc_host *host =
632                 container_of(work, struct mmc_host, detect.work);
633         u32 ocr;
634         int err;
635 
636         mmc_bus_get(host);
637 
638         if (host->bus_ops == NULL) {
639                 /*
640                  * Only we can add a new handler, so it's safe to
641                  * release the lock here.
642                  */
643                 mmc_bus_put(host);
644 
645                 mmc_claim_host(host);
646 
647                 mmc_power_up(host);
648                 mmc_go_idle(host);
649 
650                 mmc_send_if_cond(host, host->ocr_avail);
651 
652                 /*
653                  * First we search for SDIO...
654                  */
655                 err = mmc_send_io_op_cond(host, 0, &ocr);
656                 if (!err) {
657                         if (mmc_attach_sdio(host, ocr))
658                                 mmc_power_off(host);
659                         return;
660                 }
661 
662                 /*
663                  * ...then normal SD...
664                  */
665                 err = mmc_send_app_op_cond(host, 0, &ocr);
666                 if (!err) {
667                         if (mmc_attach_sd(host, ocr))
668                                 mmc_power_off(host);
669                         return;
670                 }
671 
672                 /*
673                  * ...and finally MMC.
674                  */
675                 err = mmc_send_op_cond(host, 0, &ocr);
676                 if (!err) {
677                         if (mmc_attach_mmc(host, ocr))
678                                 mmc_power_off(host);
679                         return;
680                 }
681 
682                 mmc_release_host(host);
683                 mmc_power_off(host);
684         } else {
685                 if (host->bus_ops->detect && !host->bus_dead)
686                         host->bus_ops->detect(host);
687 
688                 mmc_bus_put(host);
689         }
690 }
691 
692 void mmc_start_host(struct mmc_host *host)
693 {
694         mmc_power_off(host);
695         mmc_detect_change(host, 0);
696 }
697 
698 void mmc_stop_host(struct mmc_host *host)
699 {
700 #ifdef CONFIG_MMC_DEBUG
701         unsigned long flags;
702         spin_lock_irqsave(&host->lock, flags);
703         host->removed = 1;
704         spin_unlock_irqrestore(&host->lock, flags);
705 #endif
706 
707         mmc_flush_scheduled_work();
708 
709         mmc_bus_get(host);
710         if (host->bus_ops && !host->bus_dead) {
711                 if (host->bus_ops->remove)
712                         host->bus_ops->remove(host);
713 
714                 mmc_claim_host(host);
715                 mmc_detach_bus(host);
716                 mmc_release_host(host);
717         }
718         mmc_bus_put(host);
719 
720         BUG_ON(host->card);
721 
722         mmc_power_off(host);
723 }
724 
725 #ifdef CONFIG_PM
726 
727 /**
728  *      mmc_suspend_host - suspend a host
729  *      @host: mmc host
730  *      @state: suspend mode (PM_SUSPEND_xxx)
731  */
732 int mmc_suspend_host(struct mmc_host *host, pm_message_t state)
733 {
734         mmc_flush_scheduled_work();
735 
736         mmc_bus_get(host);
737         if (host->bus_ops && !host->bus_dead) {
738                 if (host->bus_ops->suspend)
739                         host->bus_ops->suspend(host);
740                 if (!host->bus_ops->resume) {
741                         if (host->bus_ops->remove)
742                                 host->bus_ops->remove(host);
743 
744                         mmc_claim_host(host);
745                         mmc_detach_bus(host);
746                         mmc_release_host(host);
747                 }
748         }
749         mmc_bus_put(host);
750 
751         mmc_power_off(host);
752 
753         return 0;
754 }
755 
756 EXPORT_SYMBOL(mmc_suspend_host);
757 
758 /**
759  *      mmc_resume_host - resume a previously suspended host
760  *      @host: mmc host
761  */
762 int mmc_resume_host(struct mmc_host *host)
763 {
764         mmc_bus_get(host);
765         if (host->bus_ops && !host->bus_dead) {
766                 mmc_power_up(host);
767                 BUG_ON(!host->bus_ops->resume);
768                 host->bus_ops->resume(host);
769         }
770         mmc_bus_put(host);
771 
772         /*
773          * We add a slight delay here so that resume can progress
774          * in parallel.
775          */
776         mmc_detect_change(host, 1);
777 
778         return 0;
779 }
780 
781 EXPORT_SYMBOL(mmc_resume_host);
782 
783 #endif
784 
785 static int __init mmc_init(void)
786 {
787         int ret;
788 
789         workqueue = create_singlethread_workqueue("kmmcd");
790         if (!workqueue)
791                 return -ENOMEM;
792 
793         ret = mmc_register_bus();
794         if (ret)
795                 goto destroy_workqueue;
796 
797         ret = mmc_register_host_class();
798         if (ret)
799                 goto unregister_bus;
800 
801         ret = sdio_register_bus();
802         if (ret)
803                 goto unregister_host_class;
804 
805         return 0;
806 
807 unregister_host_class:
808         mmc_unregister_host_class();
809 unregister_bus:
810         mmc_unregister_bus();
811 destroy_workqueue:
812         destroy_workqueue(workqueue);
813 
814         return ret;
815 }
816 
817 static void __exit mmc_exit(void)
818 {
819         sdio_unregister_bus();
820         mmc_unregister_host_class();
821         mmc_unregister_bus();
822         destroy_workqueue(workqueue);
823 }
824 
825 subsys_initcall(mmc_init);
826 module_exit(mmc_exit);
827 
828 MODULE_LICENSE("GPL");
829 
  This page was automatically generated by the LXR engine.