blob: e9a3eab7b0cf407a0a9fa77cba37b96d2151bc34 [file] [log] [blame]
Alex Dubovbaf85322008-02-09 10:20:54 -08001/*
2 * Sony MemoryStick support
3 *
4 * Copyright (C) 2007 Alex Dubov <oakad@yahoo.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Special thanks to Carlos Corbacho for providing various MemoryStick cards
11 * that made this driver possible.
12 *
13 */
14
15#include <linux/memstick.h>
16#include <linux/idr.h>
17#include <linux/fs.h>
18#include <linux/delay.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090019#include <linux/slab.h>
Alex Dubovbaf85322008-02-09 10:20:54 -080020
21#define DRIVER_NAME "memstick"
Alex Dubovbaf85322008-02-09 10:20:54 -080022
23static unsigned int cmd_retries = 3;
24module_param(cmd_retries, uint, 0644);
25
26static struct workqueue_struct *workqueue;
27static DEFINE_IDR(memstick_host_idr);
28static DEFINE_SPINLOCK(memstick_host_lock);
29
30static int memstick_dev_match(struct memstick_dev *card,
31 struct memstick_device_id *id)
32{
33 if (id->match_flags & MEMSTICK_MATCH_ALL) {
34 if ((id->type == card->id.type)
35 && (id->category == card->id.category)
36 && (id->class == card->id.class))
37 return 1;
38 }
39
40 return 0;
41}
42
43static int memstick_bus_match(struct device *dev, struct device_driver *drv)
44{
45 struct memstick_dev *card = container_of(dev, struct memstick_dev,
46 dev);
47 struct memstick_driver *ms_drv = container_of(drv,
48 struct memstick_driver,
49 driver);
50 struct memstick_device_id *ids = ms_drv->id_table;
51
52 if (ids) {
53 while (ids->match_flags) {
54 if (memstick_dev_match(card, ids))
55 return 1;
56 ++ids;
57 }
58 }
59 return 0;
60}
61
62static int memstick_uevent(struct device *dev, struct kobj_uevent_env *env)
63{
64 struct memstick_dev *card = container_of(dev, struct memstick_dev,
65 dev);
66
67 if (add_uevent_var(env, "MEMSTICK_TYPE=%02X", card->id.type))
68 return -ENOMEM;
69
70 if (add_uevent_var(env, "MEMSTICK_CATEGORY=%02X", card->id.category))
71 return -ENOMEM;
72
73 if (add_uevent_var(env, "MEMSTICK_CLASS=%02X", card->id.class))
74 return -ENOMEM;
75
76 return 0;
77}
78
79static int memstick_device_probe(struct device *dev)
80{
81 struct memstick_dev *card = container_of(dev, struct memstick_dev,
82 dev);
83 struct memstick_driver *drv = container_of(dev->driver,
84 struct memstick_driver,
85 driver);
86 int rc = -ENODEV;
87
88 if (dev->driver && drv->probe) {
89 rc = drv->probe(card);
90 if (!rc)
91 get_device(dev);
92 }
93 return rc;
94}
95
96static int memstick_device_remove(struct device *dev)
97{
98 struct memstick_dev *card = container_of(dev, struct memstick_dev,
99 dev);
100 struct memstick_driver *drv = container_of(dev->driver,
101 struct memstick_driver,
102 driver);
103
104 if (dev->driver && drv->remove) {
105 drv->remove(card);
106 card->dev.driver = NULL;
107 }
108
109 put_device(dev);
110 return 0;
111}
112
113#ifdef CONFIG_PM
114
115static int memstick_device_suspend(struct device *dev, pm_message_t state)
116{
117 struct memstick_dev *card = container_of(dev, struct memstick_dev,
118 dev);
119 struct memstick_driver *drv = container_of(dev->driver,
120 struct memstick_driver,
121 driver);
122
123 if (dev->driver && drv->suspend)
124 return drv->suspend(card, state);
125 return 0;
126}
127
128static int memstick_device_resume(struct device *dev)
129{
130 struct memstick_dev *card = container_of(dev, struct memstick_dev,
131 dev);
132 struct memstick_driver *drv = container_of(dev->driver,
133 struct memstick_driver,
134 driver);
135
136 if (dev->driver && drv->resume)
137 return drv->resume(card);
138 return 0;
139}
140
141#else
142
143#define memstick_device_suspend NULL
144#define memstick_device_resume NULL
145
146#endif /* CONFIG_PM */
147
148#define MEMSTICK_ATTR(name, format) \
149static ssize_t name##_show(struct device *dev, struct device_attribute *attr, \
150 char *buf) \
151{ \
152 struct memstick_dev *card = container_of(dev, struct memstick_dev, \
153 dev); \
154 return sprintf(buf, format, card->id.name); \
155}
156
157MEMSTICK_ATTR(type, "%02X");
158MEMSTICK_ATTR(category, "%02X");
159MEMSTICK_ATTR(class, "%02X");
160
161#define MEMSTICK_ATTR_RO(name) __ATTR(name, S_IRUGO, name##_show, NULL)
162
163static struct device_attribute memstick_dev_attrs[] = {
164 MEMSTICK_ATTR_RO(type),
165 MEMSTICK_ATTR_RO(category),
166 MEMSTICK_ATTR_RO(class),
167 __ATTR_NULL
168};
169
170static struct bus_type memstick_bus_type = {
171 .name = "memstick",
172 .dev_attrs = memstick_dev_attrs,
173 .match = memstick_bus_match,
174 .uevent = memstick_uevent,
175 .probe = memstick_device_probe,
176 .remove = memstick_device_remove,
177 .suspend = memstick_device_suspend,
178 .resume = memstick_device_resume
179};
180
Greg Kroah-Hartmanc4c66cf2008-03-04 00:13:36 +0100181static void memstick_free(struct device *dev)
Alex Dubovbaf85322008-02-09 10:20:54 -0800182{
Greg Kroah-Hartmanc4c66cf2008-03-04 00:13:36 +0100183 struct memstick_host *host = container_of(dev, struct memstick_host,
184 dev);
Alex Dubovbaf85322008-02-09 10:20:54 -0800185 kfree(host);
186}
187
188static struct class memstick_host_class = {
Alex Dubov8e82f8c2008-09-13 02:33:26 -0700189 .name = "memstick_host",
Greg Kroah-Hartmanc4c66cf2008-03-04 00:13:36 +0100190 .dev_release = memstick_free
Alex Dubovbaf85322008-02-09 10:20:54 -0800191};
192
193static void memstick_free_card(struct device *dev)
194{
195 struct memstick_dev *card = container_of(dev, struct memstick_dev,
196 dev);
197 kfree(card);
198}
199
200static int memstick_dummy_check(struct memstick_dev *card)
201{
202 return 0;
203}
204
205/**
206 * memstick_detect_change - schedule media detection on memstick host
207 * @host - host to use
208 */
209void memstick_detect_change(struct memstick_host *host)
210{
211 queue_work(workqueue, &host->media_checker);
212}
213EXPORT_SYMBOL(memstick_detect_change);
214
215/**
216 * memstick_next_req - called by host driver to obtain next request to process
217 * @host - host to use
218 * @mrq - pointer to stick the request to
219 *
220 * Host calls this function from idle state (*mrq == NULL) or after finishing
221 * previous request (*mrq should point to it). If previous request was
222 * unsuccessful, it is retried for predetermined number of times. Return value
223 * of 0 means that new request was assigned to the host.
224 */
225int memstick_next_req(struct memstick_host *host, struct memstick_request **mrq)
226{
227 int rc = -ENXIO;
228
229 if ((*mrq) && (*mrq)->error && host->retries) {
230 (*mrq)->error = rc;
231 host->retries--;
232 return 0;
233 }
234
235 if (host->card && host->card->next_request)
236 rc = host->card->next_request(host->card, mrq);
237
238 if (!rc)
Alex Dubov29196dc2008-03-10 11:43:38 -0700239 host->retries = cmd_retries > 1 ? cmd_retries - 1 : 1;
Alex Dubovbaf85322008-02-09 10:20:54 -0800240 else
241 *mrq = NULL;
242
243 return rc;
244}
245EXPORT_SYMBOL(memstick_next_req);
246
247/**
248 * memstick_new_req - notify the host that some requests are pending
249 * @host - host to use
250 */
251void memstick_new_req(struct memstick_host *host)
252{
Alex Dubovf1d82692008-07-25 19:45:02 -0700253 if (host->card) {
254 host->retries = cmd_retries;
255 INIT_COMPLETION(host->card->mrq_complete);
256 host->request(host);
257 }
Alex Dubovbaf85322008-02-09 10:20:54 -0800258}
259EXPORT_SYMBOL(memstick_new_req);
260
261/**
262 * memstick_init_req_sg - set request fields needed for bulk data transfer
263 * @mrq - request to use
264 * @tpc - memstick Transport Protocol Command
265 * @sg - TPC argument
266 */
267void memstick_init_req_sg(struct memstick_request *mrq, unsigned char tpc,
Alex Dubov8e82f8c2008-09-13 02:33:26 -0700268 const struct scatterlist *sg)
Alex Dubovbaf85322008-02-09 10:20:54 -0800269{
270 mrq->tpc = tpc;
271 if (tpc & 8)
272 mrq->data_dir = WRITE;
273 else
274 mrq->data_dir = READ;
275
276 mrq->sg = *sg;
Alex Dubove1f19992008-03-10 11:43:37 -0700277 mrq->long_data = 1;
Alex Dubovbaf85322008-02-09 10:20:54 -0800278
279 if (tpc == MS_TPC_SET_CMD || tpc == MS_TPC_EX_SET_CMD)
280 mrq->need_card_int = 1;
281 else
282 mrq->need_card_int = 0;
Alex Dubovbaf85322008-02-09 10:20:54 -0800283}
284EXPORT_SYMBOL(memstick_init_req_sg);
285
286/**
287 * memstick_init_req - set request fields needed for short data transfer
288 * @mrq - request to use
289 * @tpc - memstick Transport Protocol Command
290 * @buf - TPC argument buffer
291 * @length - TPC argument size
292 *
293 * The intended use of this function (transfer of data items several bytes
294 * in size) allows us to just copy the value between request structure and
295 * user supplied buffer.
296 */
297void memstick_init_req(struct memstick_request *mrq, unsigned char tpc,
Alex Dubov8e82f8c2008-09-13 02:33:26 -0700298 const void *buf, size_t length)
Alex Dubovbaf85322008-02-09 10:20:54 -0800299{
300 mrq->tpc = tpc;
301 if (tpc & 8)
302 mrq->data_dir = WRITE;
303 else
304 mrq->data_dir = READ;
305
306 mrq->data_len = length > sizeof(mrq->data) ? sizeof(mrq->data) : length;
307 if (mrq->data_dir == WRITE)
308 memcpy(mrq->data, buf, mrq->data_len);
309
Alex Dubove1f19992008-03-10 11:43:37 -0700310 mrq->long_data = 0;
Alex Dubovbaf85322008-02-09 10:20:54 -0800311
312 if (tpc == MS_TPC_SET_CMD || tpc == MS_TPC_EX_SET_CMD)
313 mrq->need_card_int = 1;
314 else
315 mrq->need_card_int = 0;
Alex Dubovbaf85322008-02-09 10:20:54 -0800316}
317EXPORT_SYMBOL(memstick_init_req);
318
319/*
320 * Functions prefixed with "h_" are protocol callbacks. They can be called from
321 * interrupt context. Return value of 0 means that request processing is still
322 * ongoing, while special error value of -EAGAIN means that current request is
323 * finished (and request processor should come back some time later).
324 */
325
326static int h_memstick_read_dev_id(struct memstick_dev *card,
327 struct memstick_request **mrq)
328{
329 struct ms_id_register id_reg;
330
331 if (!(*mrq)) {
332 memstick_init_req(&card->current_mrq, MS_TPC_READ_REG, NULL,
333 sizeof(struct ms_id_register));
334 *mrq = &card->current_mrq;
335 return 0;
336 } else {
337 if (!(*mrq)->error) {
338 memcpy(&id_reg, (*mrq)->data, sizeof(id_reg));
339 card->id.match_flags = MEMSTICK_MATCH_ALL;
340 card->id.type = id_reg.type;
341 card->id.category = id_reg.category;
342 card->id.class = id_reg.class;
Jiri Slabyb873c2f2009-09-23 15:57:31 -0700343 dev_dbg(&card->dev, "if_mode = %02x\n", id_reg.if_mode);
Alex Dubovbaf85322008-02-09 10:20:54 -0800344 }
345 complete(&card->mrq_complete);
346 return -EAGAIN;
347 }
348}
349
350static int h_memstick_set_rw_addr(struct memstick_dev *card,
351 struct memstick_request **mrq)
352{
353 if (!(*mrq)) {
354 memstick_init_req(&card->current_mrq, MS_TPC_SET_RW_REG_ADRS,
355 (char *)&card->reg_addr,
356 sizeof(card->reg_addr));
357 *mrq = &card->current_mrq;
358 return 0;
359 } else {
360 complete(&card->mrq_complete);
361 return -EAGAIN;
362 }
363}
364
365/**
366 * memstick_set_rw_addr - issue SET_RW_REG_ADDR request and wait for it to
367 * complete
368 * @card - media device to use
369 */
370int memstick_set_rw_addr(struct memstick_dev *card)
371{
372 card->next_request = h_memstick_set_rw_addr;
373 memstick_new_req(card->host);
374 wait_for_completion(&card->mrq_complete);
375
376 return card->current_mrq.error;
377}
378EXPORT_SYMBOL(memstick_set_rw_addr);
379
380static struct memstick_dev *memstick_alloc_card(struct memstick_host *host)
381{
382 struct memstick_dev *card = kzalloc(sizeof(struct memstick_dev),
383 GFP_KERNEL);
384 struct memstick_dev *old_card = host->card;
385 struct ms_id_register id_reg;
386
387 if (card) {
388 card->host = host;
Kay Sievers0252c3b2009-01-06 10:44:38 -0800389 dev_set_name(&card->dev, "%s", dev_name(&host->dev));
Greg Kroah-Hartmanc4c66cf2008-03-04 00:13:36 +0100390 card->dev.parent = &host->dev;
Alex Dubovbaf85322008-02-09 10:20:54 -0800391 card->dev.bus = &memstick_bus_type;
392 card->dev.release = memstick_free_card;
393 card->check = memstick_dummy_check;
394
395 card->reg_addr.r_offset = offsetof(struct ms_register, id);
396 card->reg_addr.r_length = sizeof(id_reg);
397 card->reg_addr.w_offset = offsetof(struct ms_register, id);
398 card->reg_addr.w_length = sizeof(id_reg);
399
400 init_completion(&card->mrq_complete);
401
402 host->card = card;
403 if (memstick_set_rw_addr(card))
404 goto err_out;
405
406 card->next_request = h_memstick_read_dev_id;
407 memstick_new_req(host);
408 wait_for_completion(&card->mrq_complete);
409
410 if (card->current_mrq.error)
411 goto err_out;
412 }
413 host->card = old_card;
414 return card;
415err_out:
416 host->card = old_card;
417 kfree(card);
418 return NULL;
419}
420
Alex Dubovb7789992008-07-25 19:45:00 -0700421static int memstick_power_on(struct memstick_host *host)
Alex Dubovbaf85322008-02-09 10:20:54 -0800422{
Alex Dubovb7789992008-07-25 19:45:00 -0700423 int rc = host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_ON);
424
425 if (!rc)
426 rc = host->set_param(host, MEMSTICK_INTERFACE, MEMSTICK_SERIAL);
427
428 return rc;
Alex Dubovbaf85322008-02-09 10:20:54 -0800429}
430
431static void memstick_check(struct work_struct *work)
432{
433 struct memstick_host *host = container_of(work, struct memstick_host,
434 media_checker);
435 struct memstick_dev *card;
436
Greg Kroah-Hartmanc4c66cf2008-03-04 00:13:36 +0100437 dev_dbg(&host->dev, "memstick_check started\n");
Alex Dubovbaf85322008-02-09 10:20:54 -0800438 mutex_lock(&host->lock);
Alex Dubov17017d82008-07-25 19:45:01 -0700439 if (!host->card) {
440 if (memstick_power_on(host))
441 goto out_power_off;
Alex Dubov8e82f8c2008-09-13 02:33:26 -0700442 } else if (host->card->stop)
Alex Dubov17017d82008-07-25 19:45:01 -0700443 host->card->stop(host->card);
Alex Dubovbaf85322008-02-09 10:20:54 -0800444
445 card = memstick_alloc_card(host);
446
447 if (!card) {
448 if (host->card) {
449 device_unregister(&host->card->dev);
450 host->card = NULL;
451 }
452 } else {
Greg Kroah-Hartmanc4c66cf2008-03-04 00:13:36 +0100453 dev_dbg(&host->dev, "new card %02x, %02x, %02x\n",
Alex Dubovbaf85322008-02-09 10:20:54 -0800454 card->id.type, card->id.category, card->id.class);
455 if (host->card) {
456 if (memstick_set_rw_addr(host->card)
457 || !memstick_dev_match(host->card, &card->id)
458 || !(host->card->check(host->card))) {
459 device_unregister(&host->card->dev);
460 host->card = NULL;
Alex Dubov8e82f8c2008-09-13 02:33:26 -0700461 } else if (host->card->start)
Alex Dubov17017d82008-07-25 19:45:01 -0700462 host->card->start(host->card);
Alex Dubovbaf85322008-02-09 10:20:54 -0800463 }
464
465 if (!host->card) {
466 host->card = card;
467 if (device_register(&card->dev)) {
Vasiliy Kulikov01933832011-01-12 17:01:00 -0800468 put_device(&card->dev);
Alex Dubovbaf85322008-02-09 10:20:54 -0800469 kfree(host->card);
470 host->card = NULL;
471 }
472 } else
473 kfree(card);
474 }
475
Alex Dubov17017d82008-07-25 19:45:01 -0700476out_power_off:
Alex Dubovbaf85322008-02-09 10:20:54 -0800477 if (!host->card)
478 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF);
479
480 mutex_unlock(&host->lock);
Greg Kroah-Hartmanc4c66cf2008-03-04 00:13:36 +0100481 dev_dbg(&host->dev, "memstick_check finished\n");
Alex Dubovbaf85322008-02-09 10:20:54 -0800482}
483
484/**
485 * memstick_alloc_host - allocate a memstick_host structure
486 * @extra: size of the user private data to allocate
487 * @dev: parent device of the host
488 */
489struct memstick_host *memstick_alloc_host(unsigned int extra,
490 struct device *dev)
491{
492 struct memstick_host *host;
493
494 host = kzalloc(sizeof(struct memstick_host) + extra, GFP_KERNEL);
495 if (host) {
496 mutex_init(&host->lock);
497 INIT_WORK(&host->media_checker, memstick_check);
Greg Kroah-Hartmanc4c66cf2008-03-04 00:13:36 +0100498 host->dev.class = &memstick_host_class;
499 host->dev.parent = dev;
500 device_initialize(&host->dev);
Alex Dubovbaf85322008-02-09 10:20:54 -0800501 }
502 return host;
503}
504EXPORT_SYMBOL(memstick_alloc_host);
505
506/**
507 * memstick_add_host - start request processing on memstick host
508 * @host - host to use
509 */
510int memstick_add_host(struct memstick_host *host)
511{
512 int rc;
513
Alex Dubovd8256d42011-01-12 17:01:04 -0800514 while (1) {
515 if (!idr_pre_get(&memstick_host_idr, GFP_KERNEL))
516 return -ENOMEM;
Alex Dubovbaf85322008-02-09 10:20:54 -0800517
Alex Dubovd8256d42011-01-12 17:01:04 -0800518 spin_lock(&memstick_host_lock);
519 rc = idr_get_new(&memstick_host_idr, host, &host->id);
520 spin_unlock(&memstick_host_lock);
521 if (!rc)
522 break;
523 else if (rc != -EAGAIN)
524 return rc;
525 }
Alex Dubovbaf85322008-02-09 10:20:54 -0800526
Kay Sievers0252c3b2009-01-06 10:44:38 -0800527 dev_set_name(&host->dev, "memstick%u", host->id);
Alex Dubovbaf85322008-02-09 10:20:54 -0800528
Greg Kroah-Hartmanc4c66cf2008-03-04 00:13:36 +0100529 rc = device_add(&host->dev);
Alex Dubovbaf85322008-02-09 10:20:54 -0800530 if (rc) {
531 spin_lock(&memstick_host_lock);
532 idr_remove(&memstick_host_idr, host->id);
533 spin_unlock(&memstick_host_lock);
534 return rc;
535 }
536
537 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF);
538 memstick_detect_change(host);
539 return 0;
540}
541EXPORT_SYMBOL(memstick_add_host);
542
543/**
544 * memstick_remove_host - stop request processing on memstick host
545 * @host - host to use
546 */
547void memstick_remove_host(struct memstick_host *host)
548{
549 flush_workqueue(workqueue);
550 mutex_lock(&host->lock);
551 if (host->card)
552 device_unregister(&host->card->dev);
553 host->card = NULL;
554 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF);
555 mutex_unlock(&host->lock);
556
557 spin_lock(&memstick_host_lock);
558 idr_remove(&memstick_host_idr, host->id);
559 spin_unlock(&memstick_host_lock);
Greg Kroah-Hartmanc4c66cf2008-03-04 00:13:36 +0100560 device_del(&host->dev);
Alex Dubovbaf85322008-02-09 10:20:54 -0800561}
562EXPORT_SYMBOL(memstick_remove_host);
563
564/**
565 * memstick_free_host - free memstick host
566 * @host - host to use
567 */
568void memstick_free_host(struct memstick_host *host)
569{
570 mutex_destroy(&host->lock);
Greg Kroah-Hartmanc4c66cf2008-03-04 00:13:36 +0100571 put_device(&host->dev);
Alex Dubovbaf85322008-02-09 10:20:54 -0800572}
573EXPORT_SYMBOL(memstick_free_host);
574
Alex Dubovd114ad52008-03-10 11:43:38 -0700575/**
576 * memstick_suspend_host - notify bus driver of host suspension
577 * @host - host to use
578 */
579void memstick_suspend_host(struct memstick_host *host)
580{
581 mutex_lock(&host->lock);
582 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF);
583 mutex_unlock(&host->lock);
584}
585EXPORT_SYMBOL(memstick_suspend_host);
586
587/**
588 * memstick_resume_host - notify bus driver of host resumption
589 * @host - host to use
590 */
591void memstick_resume_host(struct memstick_host *host)
592{
Alex Dubovb7789992008-07-25 19:45:00 -0700593 int rc = 0;
594
Alex Dubovd114ad52008-03-10 11:43:38 -0700595 mutex_lock(&host->lock);
Alex Dubovead70772008-03-19 17:01:06 -0700596 if (host->card)
Alex Dubovb7789992008-07-25 19:45:00 -0700597 rc = memstick_power_on(host);
Alex Dubovd114ad52008-03-10 11:43:38 -0700598 mutex_unlock(&host->lock);
Alex Dubovb7789992008-07-25 19:45:00 -0700599
600 if (!rc)
601 memstick_detect_change(host);
Alex Dubovd114ad52008-03-10 11:43:38 -0700602}
603EXPORT_SYMBOL(memstick_resume_host);
604
Alex Dubovbaf85322008-02-09 10:20:54 -0800605int memstick_register_driver(struct memstick_driver *drv)
606{
607 drv->driver.bus = &memstick_bus_type;
608
609 return driver_register(&drv->driver);
610}
611EXPORT_SYMBOL(memstick_register_driver);
612
613void memstick_unregister_driver(struct memstick_driver *drv)
614{
615 driver_unregister(&drv->driver);
616}
617EXPORT_SYMBOL(memstick_unregister_driver);
618
619
620static int __init memstick_init(void)
621{
622 int rc;
623
624 workqueue = create_freezeable_workqueue("kmemstick");
625 if (!workqueue)
626 return -ENOMEM;
627
628 rc = bus_register(&memstick_bus_type);
629 if (!rc)
630 rc = class_register(&memstick_host_class);
631
632 if (!rc)
633 return 0;
634
635 bus_unregister(&memstick_bus_type);
636 destroy_workqueue(workqueue);
637
638 return rc;
639}
640
641static void __exit memstick_exit(void)
642{
643 class_unregister(&memstick_host_class);
644 bus_unregister(&memstick_bus_type);
645 destroy_workqueue(workqueue);
646 idr_destroy(&memstick_host_idr);
647}
648
649module_init(memstick_init);
650module_exit(memstick_exit);
651
652MODULE_AUTHOR("Alex Dubov");
653MODULE_LICENSE("GPL");
654MODULE_DESCRIPTION("Sony MemoryStick core driver");