2 * Sony MemoryStick Pro storage support
4 * Copyright (C) 2007 Alex Dubov <oakad@yahoo.com>
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.
10 * Special thanks to Carlos Corbacho for providing various MemoryStick cards
11 * that made this driver possible.
15 #include <linux/blkdev.h>
16 #include <linux/idr.h>
17 #include <linux/hdreg.h>
18 #include <linux/kthread.h>
19 #include <linux/delay.h>
20 #include <linux/memstick.h>
22 #define DRIVER_NAME "mspro_block"
25 module_param(major
, int, 0644);
27 #define MSPRO_BLOCK_MAX_SEGS 32
28 #define MSPRO_BLOCK_MAX_PAGES ((2 << 16) - 1)
30 #define MSPRO_BLOCK_SIGNATURE 0xa5c3
31 #define MSPRO_BLOCK_MAX_ATTRIBUTES 41
33 #define MSPRO_BLOCK_PART_SHIFT 3
36 MSPRO_BLOCK_ID_SYSINFO
= 0x10,
37 MSPRO_BLOCK_ID_MODELNAME
= 0x15,
38 MSPRO_BLOCK_ID_MBR
= 0x20,
39 MSPRO_BLOCK_ID_PBR16
= 0x21,
40 MSPRO_BLOCK_ID_PBR32
= 0x22,
41 MSPRO_BLOCK_ID_SPECFILEVALUES1
= 0x25,
42 MSPRO_BLOCK_ID_SPECFILEVALUES2
= 0x26,
43 MSPRO_BLOCK_ID_DEVINFO
= 0x30
46 struct mspro_sys_attr
{
51 struct device_attribute dev_attr
;
54 struct mspro_attr_entry
{
58 unsigned char reserved
[3];
59 } __attribute__((packed
));
61 struct mspro_attribute
{
63 unsigned short version
;
65 unsigned char reserved
[11];
66 struct mspro_attr_entry entries
[];
67 } __attribute__((packed
));
69 struct mspro_sys_info
{
71 unsigned char reserved0
;
74 __be16 user_block_count
;
76 unsigned char reserved1
[2];
77 unsigned char assembly_date
[8];
79 unsigned char assembly_maker_code
;
80 unsigned char assembly_model_code
[3];
81 __be16 memory_maker_code
;
82 __be16 memory_model_code
;
83 unsigned char reserved2
[4];
86 __be16 controller_number
;
87 __be16 controller_function
;
90 unsigned char ms_sub_class
;
91 unsigned char reserved3
[4];
92 unsigned char interface_type
;
93 __be16 controller_code
;
94 unsigned char format_type
;
95 unsigned char reserved4
;
96 unsigned char device_type
;
97 unsigned char reserved5
[7];
98 unsigned char mspro_id
[16];
99 unsigned char reserved6
[16];
100 } __attribute__((packed
));
103 unsigned char boot_partition
;
104 unsigned char start_head
;
105 unsigned char start_sector
;
106 unsigned char start_cylinder
;
107 unsigned char partition_type
;
108 unsigned char end_head
;
109 unsigned char end_sector
;
110 unsigned char end_cylinder
;
111 unsigned int start_sectors
;
112 unsigned int sectors_per_partition
;
113 } __attribute__((packed
));
115 struct mspro_specfile
{
119 unsigned char reserved
[10];
122 unsigned short cluster
;
124 } __attribute__((packed
));
126 struct mspro_devinfo
{
129 __be16 bytes_per_track
;
130 __be16 bytes_per_sector
;
131 __be16 sectors_per_track
;
132 unsigned char reserved
[6];
133 } __attribute__((packed
));
135 struct mspro_block_data
{
136 struct memstick_dev
*card
;
137 unsigned int usage_count
;
139 struct gendisk
*disk
;
140 struct request_queue
*queue
;
141 struct request
*block_req
;
144 unsigned short page_size
;
145 unsigned short cylinders
;
146 unsigned short heads
;
147 unsigned short sectors_per_track
;
149 unsigned char system
;
150 unsigned char read_only
:1,
155 unsigned char transfer_cmd
;
157 int (*mrq_handler
)(struct memstick_dev
*card
,
158 struct memstick_request
**mrq
);
160 struct attribute_group attr_group
;
162 struct scatterlist req_sg
[MSPRO_BLOCK_MAX_SEGS
];
163 unsigned int seg_count
;
164 unsigned int current_seg
;
165 unsigned int current_page
;
168 static DEFINE_IDR(mspro_block_disk_idr
);
169 static DEFINE_MUTEX(mspro_block_disk_lock
);
171 static int mspro_block_complete_req(struct memstick_dev
*card
, int error
);
173 /*** Block device ***/
175 static int mspro_block_bd_open(struct block_device
*bdev
, fmode_t mode
)
177 struct gendisk
*disk
= bdev
->bd_disk
;
178 struct mspro_block_data
*msb
= disk
->private_data
;
181 mutex_lock(&mspro_block_disk_lock
);
183 if (msb
&& msb
->card
) {
185 if ((mode
& FMODE_WRITE
) && msb
->read_only
)
191 mutex_unlock(&mspro_block_disk_lock
);
197 static int mspro_block_disk_release(struct gendisk
*disk
)
199 struct mspro_block_data
*msb
= disk
->private_data
;
200 int disk_id
= MINOR(disk_devt(disk
)) >> MSPRO_BLOCK_PART_SHIFT
;
202 mutex_lock(&mspro_block_disk_lock
);
205 if (msb
->usage_count
)
208 if (!msb
->usage_count
) {
210 disk
->private_data
= NULL
;
211 idr_remove(&mspro_block_disk_idr
, disk_id
);
216 mutex_unlock(&mspro_block_disk_lock
);
221 static int mspro_block_bd_release(struct gendisk
*disk
, fmode_t mode
)
223 return mspro_block_disk_release(disk
);
226 static int mspro_block_bd_getgeo(struct block_device
*bdev
,
227 struct hd_geometry
*geo
)
229 struct mspro_block_data
*msb
= bdev
->bd_disk
->private_data
;
231 geo
->heads
= msb
->heads
;
232 geo
->sectors
= msb
->sectors_per_track
;
233 geo
->cylinders
= msb
->cylinders
;
238 static struct block_device_operations ms_block_bdops
= {
239 .open
= mspro_block_bd_open
,
240 .release
= mspro_block_bd_release
,
241 .getgeo
= mspro_block_bd_getgeo
,
245 /*** Information ***/
247 static struct mspro_sys_attr
*mspro_from_sysfs_attr(struct attribute
*attr
)
249 struct device_attribute
*dev_attr
250 = container_of(attr
, struct device_attribute
, attr
);
251 return container_of(dev_attr
, struct mspro_sys_attr
, dev_attr
);
254 static const char *mspro_block_attr_name(unsigned char tag
)
257 case MSPRO_BLOCK_ID_SYSINFO
:
258 return "attr_sysinfo";
259 case MSPRO_BLOCK_ID_MODELNAME
:
260 return "attr_modelname";
261 case MSPRO_BLOCK_ID_MBR
:
263 case MSPRO_BLOCK_ID_PBR16
:
265 case MSPRO_BLOCK_ID_PBR32
:
267 case MSPRO_BLOCK_ID_SPECFILEVALUES1
:
268 return "attr_specfilevalues1";
269 case MSPRO_BLOCK_ID_SPECFILEVALUES2
:
270 return "attr_specfilevalues2";
271 case MSPRO_BLOCK_ID_DEVINFO
:
272 return "attr_devinfo";
278 typedef ssize_t (*sysfs_show_t
)(struct device
*dev
,
279 struct device_attribute
*attr
,
282 static ssize_t
mspro_block_attr_show_default(struct device
*dev
,
283 struct device_attribute
*attr
,
286 struct mspro_sys_attr
*s_attr
= container_of(attr
,
287 struct mspro_sys_attr
,
292 for (cnt
= 0; cnt
< s_attr
->size
; cnt
++) {
293 if (cnt
&& !(cnt
% 16)) {
298 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "%02x ",
299 ((unsigned char *)s_attr
->data
)[cnt
]);
304 static ssize_t
mspro_block_attr_show_sysinfo(struct device
*dev
,
305 struct device_attribute
*attr
,
308 struct mspro_sys_attr
*x_attr
= container_of(attr
,
309 struct mspro_sys_attr
,
311 struct mspro_sys_info
*x_sys
= x_attr
->data
;
313 int date_tz
= 0, date_tz_f
= 0;
315 if (x_sys
->assembly_date
[0] > 0x80U
) {
316 date_tz
= (~x_sys
->assembly_date
[0]) + 1;
317 date_tz_f
= date_tz
& 3;
321 } else if (x_sys
->assembly_date
[0] < 0x80U
) {
322 date_tz
= x_sys
->assembly_date
[0];
323 date_tz_f
= date_tz
& 3;
328 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "class: %x\n",
330 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "block size: %x\n",
331 be16_to_cpu(x_sys
->block_size
));
332 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "block count: %x\n",
333 be16_to_cpu(x_sys
->block_count
));
334 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "user block count: %x\n",
335 be16_to_cpu(x_sys
->user_block_count
));
336 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "page size: %x\n",
337 be16_to_cpu(x_sys
->page_size
));
338 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "assembly date: "
339 "GMT%+d:%d %04u-%02u-%02u %02u:%02u:%02u\n",
341 be16_to_cpup((__be16
*)&x_sys
->assembly_date
[1]),
342 x_sys
->assembly_date
[3], x_sys
->assembly_date
[4],
343 x_sys
->assembly_date
[5], x_sys
->assembly_date
[6],
344 x_sys
->assembly_date
[7]);
345 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "serial number: %x\n",
346 be32_to_cpu(x_sys
->serial_number
));
347 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
,
348 "assembly maker code: %x\n",
349 x_sys
->assembly_maker_code
);
350 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "assembly model code: "
351 "%02x%02x%02x\n", x_sys
->assembly_model_code
[0],
352 x_sys
->assembly_model_code
[1],
353 x_sys
->assembly_model_code
[2]);
354 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "memory maker code: %x\n",
355 be16_to_cpu(x_sys
->memory_maker_code
));
356 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "memory model code: %x\n",
357 be16_to_cpu(x_sys
->memory_model_code
));
358 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "vcc: %x\n",
360 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "vpp: %x\n",
362 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "controller number: %x\n",
363 be16_to_cpu(x_sys
->controller_number
));
364 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
,
365 "controller function: %x\n",
366 be16_to_cpu(x_sys
->controller_function
));
367 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "start sector: %x\n",
368 be16_to_cpu(x_sys
->start_sector
));
369 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "unit size: %x\n",
370 be16_to_cpu(x_sys
->unit_size
));
371 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "sub class: %x\n",
372 x_sys
->ms_sub_class
);
373 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "interface type: %x\n",
374 x_sys
->interface_type
);
375 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "controller code: %x\n",
376 be16_to_cpu(x_sys
->controller_code
));
377 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "format type: %x\n",
379 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "device type: %x\n",
381 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "mspro id: %s\n",
386 static ssize_t
mspro_block_attr_show_modelname(struct device
*dev
,
387 struct device_attribute
*attr
,
390 struct mspro_sys_attr
*s_attr
= container_of(attr
,
391 struct mspro_sys_attr
,
394 return scnprintf(buffer
, PAGE_SIZE
, "%s", (char *)s_attr
->data
);
397 static ssize_t
mspro_block_attr_show_mbr(struct device
*dev
,
398 struct device_attribute
*attr
,
401 struct mspro_sys_attr
*x_attr
= container_of(attr
,
402 struct mspro_sys_attr
,
404 struct mspro_mbr
*x_mbr
= x_attr
->data
;
407 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "boot partition: %x\n",
408 x_mbr
->boot_partition
);
409 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "start head: %x\n",
411 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "start sector: %x\n",
412 x_mbr
->start_sector
);
413 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "start cylinder: %x\n",
414 x_mbr
->start_cylinder
);
415 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "partition type: %x\n",
416 x_mbr
->partition_type
);
417 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "end head: %x\n",
419 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "end sector: %x\n",
421 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "end cylinder: %x\n",
422 x_mbr
->end_cylinder
);
423 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "start sectors: %x\n",
424 x_mbr
->start_sectors
);
425 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
,
426 "sectors per partition: %x\n",
427 x_mbr
->sectors_per_partition
);
431 static ssize_t
mspro_block_attr_show_specfile(struct device
*dev
,
432 struct device_attribute
*attr
,
435 struct mspro_sys_attr
*x_attr
= container_of(attr
,
436 struct mspro_sys_attr
,
438 struct mspro_specfile
*x_spfile
= x_attr
->data
;
439 char name
[9], ext
[4];
442 memcpy(name
, x_spfile
->name
, 8);
444 memcpy(ext
, x_spfile
->ext
, 3);
447 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "name: %s\n", name
);
448 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "ext: %s\n", ext
);
449 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "attribute: %x\n",
451 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "time: %d:%d:%d\n",
452 x_spfile
->time
>> 11,
453 (x_spfile
->time
>> 5) & 0x3f,
454 (x_spfile
->time
& 0x1f) * 2);
455 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "date: %d-%d-%d\n",
456 (x_spfile
->date
>> 9) + 1980,
457 (x_spfile
->date
>> 5) & 0xf,
458 x_spfile
->date
& 0x1f);
459 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "start cluster: %x\n",
461 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "size: %x\n",
466 static ssize_t
mspro_block_attr_show_devinfo(struct device
*dev
,
467 struct device_attribute
*attr
,
470 struct mspro_sys_attr
*x_attr
= container_of(attr
,
471 struct mspro_sys_attr
,
473 struct mspro_devinfo
*x_devinfo
= x_attr
->data
;
476 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "cylinders: %x\n",
477 be16_to_cpu(x_devinfo
->cylinders
));
478 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "heads: %x\n",
479 be16_to_cpu(x_devinfo
->heads
));
480 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "bytes per track: %x\n",
481 be16_to_cpu(x_devinfo
->bytes_per_track
));
482 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "bytes per sector: %x\n",
483 be16_to_cpu(x_devinfo
->bytes_per_sector
));
484 rc
+= scnprintf(buffer
+ rc
, PAGE_SIZE
- rc
, "sectors per track: %x\n",
485 be16_to_cpu(x_devinfo
->sectors_per_track
));
489 static sysfs_show_t
mspro_block_attr_show(unsigned char tag
)
492 case MSPRO_BLOCK_ID_SYSINFO
:
493 return mspro_block_attr_show_sysinfo
;
494 case MSPRO_BLOCK_ID_MODELNAME
:
495 return mspro_block_attr_show_modelname
;
496 case MSPRO_BLOCK_ID_MBR
:
497 return mspro_block_attr_show_mbr
;
498 case MSPRO_BLOCK_ID_SPECFILEVALUES1
:
499 case MSPRO_BLOCK_ID_SPECFILEVALUES2
:
500 return mspro_block_attr_show_specfile
;
501 case MSPRO_BLOCK_ID_DEVINFO
:
502 return mspro_block_attr_show_devinfo
;
504 return mspro_block_attr_show_default
;
508 /*** Protocol handlers ***/
511 * Functions prefixed with "h_" are protocol callbacks. They can be called from
512 * interrupt context. Return value of 0 means that request processing is still
513 * ongoing, while special error value of -EAGAIN means that current request is
514 * finished (and request processor should come back some time later).
517 static int h_mspro_block_req_init(struct memstick_dev
*card
,
518 struct memstick_request
**mrq
)
520 struct mspro_block_data
*msb
= memstick_get_drvdata(card
);
522 *mrq
= &card
->current_mrq
;
523 card
->next_request
= msb
->mrq_handler
;
527 static int h_mspro_block_default(struct memstick_dev
*card
,
528 struct memstick_request
**mrq
)
530 return mspro_block_complete_req(card
, (*mrq
)->error
);
533 static int h_mspro_block_default_bad(struct memstick_dev
*card
,
534 struct memstick_request
**mrq
)
539 static int h_mspro_block_get_ro(struct memstick_dev
*card
,
540 struct memstick_request
**mrq
)
542 struct mspro_block_data
*msb
= memstick_get_drvdata(card
);
544 if (!(*mrq
)->error
) {
545 if ((*mrq
)->data
[offsetof(struct ms_status_register
, status0
)]
546 & MEMSTICK_STATUS0_WP
)
552 return mspro_block_complete_req(card
, (*mrq
)->error
);
555 static int h_mspro_block_wait_for_ced(struct memstick_dev
*card
,
556 struct memstick_request
**mrq
)
558 dev_dbg(&card
->dev
, "wait for ced: value %x\n", (*mrq
)->data
[0]);
560 if (!(*mrq
)->error
) {
561 if ((*mrq
)->data
[0] & (MEMSTICK_INT_CMDNAK
| MEMSTICK_INT_ERR
))
562 (*mrq
)->error
= -EFAULT
;
563 else if (!((*mrq
)->data
[0] & MEMSTICK_INT_CED
))
567 return mspro_block_complete_req(card
, (*mrq
)->error
);
570 static int h_mspro_block_transfer_data(struct memstick_dev
*card
,
571 struct memstick_request
**mrq
)
573 struct mspro_block_data
*msb
= memstick_get_drvdata(card
);
574 unsigned char t_val
= 0;
575 struct scatterlist t_sg
= { 0 };
579 return mspro_block_complete_req(card
, (*mrq
)->error
);
581 switch ((*mrq
)->tpc
) {
582 case MS_TPC_WRITE_REG
:
583 memstick_init_req(*mrq
, MS_TPC_SET_CMD
, &msb
->transfer_cmd
, 1);
584 (*mrq
)->need_card_int
= 1;
587 t_val
= (*mrq
)->int_reg
;
588 memstick_init_req(*mrq
, MS_TPC_GET_INT
, NULL
, 1);
589 if (msb
->caps
& MEMSTICK_CAP_AUTO_GET_INT
)
593 t_val
= (*mrq
)->data
[0];
595 if (t_val
& (MEMSTICK_INT_CMDNAK
| MEMSTICK_INT_ERR
)) {
596 t_val
= MSPRO_CMD_STOP
;
597 memstick_init_req(*mrq
, MS_TPC_SET_CMD
, &t_val
, 1);
598 card
->next_request
= h_mspro_block_default
;
602 if (msb
->current_page
603 == (msb
->req_sg
[msb
->current_seg
].length
605 msb
->current_page
= 0;
608 if (msb
->current_seg
== msb
->seg_count
) {
609 if (t_val
& MEMSTICK_INT_CED
) {
610 return mspro_block_complete_req(card
,
614 = h_mspro_block_wait_for_ced
;
615 memstick_init_req(*mrq
, MS_TPC_GET_INT
,
622 if (!(t_val
& MEMSTICK_INT_BREQ
)) {
623 memstick_init_req(*mrq
, MS_TPC_GET_INT
, NULL
, 1);
627 t_offset
= msb
->req_sg
[msb
->current_seg
].offset
;
628 t_offset
+= msb
->current_page
* msb
->page_size
;
631 nth_page(sg_page(&(msb
->req_sg
[msb
->current_seg
])),
632 t_offset
>> PAGE_SHIFT
),
633 msb
->page_size
, offset_in_page(t_offset
));
635 memstick_init_req_sg(*mrq
, msb
->data_dir
== READ
636 ? MS_TPC_READ_LONG_DATA
637 : MS_TPC_WRITE_LONG_DATA
,
639 (*mrq
)->need_card_int
= 1;
641 case MS_TPC_READ_LONG_DATA
:
642 case MS_TPC_WRITE_LONG_DATA
:
644 if (msb
->caps
& MEMSTICK_CAP_AUTO_GET_INT
) {
645 t_val
= (*mrq
)->int_reg
;
648 memstick_init_req(*mrq
, MS_TPC_GET_INT
, NULL
, 1);
657 /*** Data transfer ***/
659 static int mspro_block_issue_req(struct memstick_dev
*card
, int chunk
)
661 struct mspro_block_data
*msb
= memstick_get_drvdata(card
);
664 struct mspro_param_register param
;
668 msb
->current_page
= 0;
669 msb
->current_seg
= 0;
670 msb
->seg_count
= blk_rq_map_sg(msb
->block_req
->q
,
674 if (!msb
->seg_count
) {
675 chunk
= __blk_end_request(msb
->block_req
, -ENOMEM
,
676 blk_rq_cur_bytes(msb
->block_req
));
680 t_sec
= msb
->block_req
->sector
<< 9;
681 sector_div(t_sec
, msb
->page_size
);
683 count
= msb
->block_req
->nr_sectors
<< 9;
684 count
/= msb
->page_size
;
686 param
.system
= msb
->system
;
687 param
.data_count
= cpu_to_be16(count
);
688 param
.data_address
= cpu_to_be32((uint32_t)t_sec
);
691 msb
->data_dir
= rq_data_dir(msb
->block_req
);
692 msb
->transfer_cmd
= msb
->data_dir
== READ
693 ? MSPRO_CMD_READ_DATA
694 : MSPRO_CMD_WRITE_DATA
;
696 dev_dbg(&card
->dev
, "data transfer: cmd %x, "
697 "lba %x, count %x\n", msb
->transfer_cmd
,
698 be32_to_cpu(param
.data_address
), count
);
700 card
->next_request
= h_mspro_block_req_init
;
701 msb
->mrq_handler
= h_mspro_block_transfer_data
;
702 memstick_init_req(&card
->current_mrq
, MS_TPC_WRITE_REG
,
703 ¶m
, sizeof(param
));
704 memstick_new_req(card
->host
);
708 dev_dbg(&card
->dev
, "elv_next\n");
709 msb
->block_req
= elv_next_request(msb
->queue
);
710 if (!msb
->block_req
) {
711 dev_dbg(&card
->dev
, "issue end\n");
715 dev_dbg(&card
->dev
, "trying again\n");
720 static int mspro_block_complete_req(struct memstick_dev
*card
, int error
)
722 struct mspro_block_data
*msb
= memstick_get_drvdata(card
);
724 unsigned int t_len
= 0;
727 spin_lock_irqsave(&msb
->q_lock
, flags
);
728 dev_dbg(&card
->dev
, "complete %d, %d\n", msb
->has_request
? 1 : 0,
731 if (msb
->has_request
) {
732 /* Nothing to do - not really an error */
733 if (error
== -EAGAIN
)
736 if (error
|| (card
->current_mrq
.tpc
== MSPRO_CMD_STOP
)) {
737 if (msb
->data_dir
== READ
) {
738 for (cnt
= 0; cnt
< msb
->current_seg
; cnt
++)
739 t_len
+= msb
->req_sg
[cnt
].length
742 if (msb
->current_page
)
743 t_len
+= msb
->current_page
- 1;
745 t_len
*= msb
->page_size
;
748 t_len
= msb
->block_req
->nr_sectors
<< 9;
750 dev_dbg(&card
->dev
, "transferred %x (%d)\n", t_len
, error
);
753 t_len
= blk_rq_cur_bytes(msb
->block_req
);
755 chunk
= __blk_end_request(msb
->block_req
, error
, t_len
);
757 error
= mspro_block_issue_req(card
, chunk
);
762 msb
->has_request
= 0;
768 card
->next_request
= h_mspro_block_default_bad
;
769 complete_all(&card
->mrq_complete
);
771 spin_unlock_irqrestore(&msb
->q_lock
, flags
);
775 static void mspro_block_stop(struct memstick_dev
*card
)
777 struct mspro_block_data
*msb
= memstick_get_drvdata(card
);
782 spin_lock_irqsave(&msb
->q_lock
, flags
);
783 if (!msb
->has_request
) {
784 blk_stop_queue(msb
->queue
);
787 spin_unlock_irqrestore(&msb
->q_lock
, flags
);
792 wait_for_completion(&card
->mrq_complete
);
796 static void mspro_block_start(struct memstick_dev
*card
)
798 struct mspro_block_data
*msb
= memstick_get_drvdata(card
);
801 spin_lock_irqsave(&msb
->q_lock
, flags
);
802 blk_start_queue(msb
->queue
);
803 spin_unlock_irqrestore(&msb
->q_lock
, flags
);
806 static int mspro_block_prepare_req(struct request_queue
*q
, struct request
*req
)
808 if (!blk_fs_request(req
) && !blk_pc_request(req
)) {
809 blk_dump_rq_flags(req
, "MSPro unsupported request");
813 req
->cmd_flags
|= REQ_DONTPREP
;
818 static void mspro_block_submit_req(struct request_queue
*q
)
820 struct memstick_dev
*card
= q
->queuedata
;
821 struct mspro_block_data
*msb
= memstick_get_drvdata(card
);
822 struct request
*req
= NULL
;
824 if (msb
->has_request
)
828 while ((req
= elv_next_request(q
)) != NULL
)
829 __blk_end_request(req
, -ENODEV
, blk_rq_bytes(req
));
834 msb
->has_request
= 1;
835 if (mspro_block_issue_req(card
, 0))
836 msb
->has_request
= 0;
839 /*** Initialization ***/
841 static int mspro_block_wait_for_ced(struct memstick_dev
*card
)
843 struct mspro_block_data
*msb
= memstick_get_drvdata(card
);
845 card
->next_request
= h_mspro_block_req_init
;
846 msb
->mrq_handler
= h_mspro_block_wait_for_ced
;
847 memstick_init_req(&card
->current_mrq
, MS_TPC_GET_INT
, NULL
, 1);
848 memstick_new_req(card
->host
);
849 wait_for_completion(&card
->mrq_complete
);
850 return card
->current_mrq
.error
;
853 static int mspro_block_set_interface(struct memstick_dev
*card
,
854 unsigned char sys_reg
)
856 struct memstick_host
*host
= card
->host
;
857 struct mspro_block_data
*msb
= memstick_get_drvdata(card
);
858 struct mspro_param_register param
= {
865 card
->next_request
= h_mspro_block_req_init
;
866 msb
->mrq_handler
= h_mspro_block_default
;
867 memstick_init_req(&card
->current_mrq
, MS_TPC_WRITE_REG
, ¶m
,
869 memstick_new_req(host
);
870 wait_for_completion(&card
->mrq_complete
);
871 return card
->current_mrq
.error
;
874 static int mspro_block_switch_interface(struct memstick_dev
*card
)
876 struct memstick_host
*host
= card
->host
;
877 struct mspro_block_data
*msb
= memstick_get_drvdata(card
);
881 if (msb
->caps
& MEMSTICK_CAP_PAR4
)
882 rc
= mspro_block_set_interface(card
, MEMSTICK_SYS_PAR4
);
888 "%s: could not switch to 4-bit mode, error %d\n",
889 dev_name(&card
->dev
), rc
);
893 msb
->system
= MEMSTICK_SYS_PAR4
;
894 host
->set_param(host
, MEMSTICK_INTERFACE
, MEMSTICK_PAR4
);
895 printk(KERN_INFO
"%s: switching to 4-bit parallel mode\n",
896 dev_name(&card
->dev
));
898 if (msb
->caps
& MEMSTICK_CAP_PAR8
) {
899 rc
= mspro_block_set_interface(card
, MEMSTICK_SYS_PAR8
);
902 msb
->system
= MEMSTICK_SYS_PAR8
;
903 host
->set_param(host
, MEMSTICK_INTERFACE
,
906 "%s: switching to 8-bit parallel mode\n",
907 dev_name(&card
->dev
));
910 "%s: could not switch to 8-bit mode, error %d\n",
911 dev_name(&card
->dev
), rc
);
914 card
->next_request
= h_mspro_block_req_init
;
915 msb
->mrq_handler
= h_mspro_block_default
;
916 memstick_init_req(&card
->current_mrq
, MS_TPC_GET_INT
, NULL
, 1);
917 memstick_new_req(card
->host
);
918 wait_for_completion(&card
->mrq_complete
);
919 rc
= card
->current_mrq
.error
;
923 "%s: interface error, trying to fall back to serial\n",
924 dev_name(&card
->dev
));
925 msb
->system
= MEMSTICK_SYS_SERIAL
;
926 host
->set_param(host
, MEMSTICK_POWER
, MEMSTICK_POWER_OFF
);
928 host
->set_param(host
, MEMSTICK_POWER
, MEMSTICK_POWER_ON
);
929 host
->set_param(host
, MEMSTICK_INTERFACE
, MEMSTICK_SERIAL
);
931 rc
= memstick_set_rw_addr(card
);
933 rc
= mspro_block_set_interface(card
, msb
->system
);
937 rc
= mspro_block_wait_for_ced(card
);
941 if (msb
->caps
& MEMSTICK_CAP_PAR8
) {
942 msb
->caps
&= ~MEMSTICK_CAP_PAR8
;
950 /* Memory allocated for attributes by this function should be freed by
951 * mspro_block_data_clear, no matter if the initialization process succeded
954 static int mspro_block_read_attributes(struct memstick_dev
*card
)
956 struct mspro_block_data
*msb
= memstick_get_drvdata(card
);
957 struct mspro_param_register param
= {
958 .system
= msb
->system
,
959 .data_count
= cpu_to_be16(1),
963 struct mspro_attribute
*attr
= NULL
;
964 struct mspro_sys_attr
*s_attr
= NULL
;
965 unsigned char *buffer
= NULL
;
966 int cnt
, rc
, attr_count
;
968 unsigned short page_count
;
970 attr
= kmalloc(msb
->page_size
, GFP_KERNEL
);
974 sg_init_one(&msb
->req_sg
[0], attr
, msb
->page_size
);
976 msb
->current_seg
= 0;
977 msb
->current_page
= 0;
978 msb
->data_dir
= READ
;
979 msb
->transfer_cmd
= MSPRO_CMD_READ_ATRB
;
981 card
->next_request
= h_mspro_block_req_init
;
982 msb
->mrq_handler
= h_mspro_block_transfer_data
;
983 memstick_init_req(&card
->current_mrq
, MS_TPC_WRITE_REG
, ¶m
,
985 memstick_new_req(card
->host
);
986 wait_for_completion(&card
->mrq_complete
);
987 if (card
->current_mrq
.error
) {
988 rc
= card
->current_mrq
.error
;
992 if (be16_to_cpu(attr
->signature
) != MSPRO_BLOCK_SIGNATURE
) {
993 printk(KERN_ERR
"%s: unrecognized device signature %x\n",
994 dev_name(&card
->dev
), be16_to_cpu(attr
->signature
));
999 if (attr
->count
> MSPRO_BLOCK_MAX_ATTRIBUTES
) {
1000 printk(KERN_WARNING
"%s: way too many attribute entries\n",
1001 dev_name(&card
->dev
));
1002 attr_count
= MSPRO_BLOCK_MAX_ATTRIBUTES
;
1004 attr_count
= attr
->count
;
1006 msb
->attr_group
.attrs
= kzalloc((attr_count
+ 1)
1007 * sizeof(struct attribute
),
1009 if (!msb
->attr_group
.attrs
) {
1013 msb
->attr_group
.name
= "media_attributes";
1015 buffer
= kmalloc(msb
->page_size
, GFP_KERNEL
);
1020 memcpy(buffer
, (char *)attr
, msb
->page_size
);
1023 for (cnt
= 0; cnt
< attr_count
; ++cnt
) {
1024 s_attr
= kzalloc(sizeof(struct mspro_sys_attr
), GFP_KERNEL
);
1027 goto out_free_buffer
;
1030 msb
->attr_group
.attrs
[cnt
] = &s_attr
->dev_attr
.attr
;
1031 addr
= be32_to_cpu(attr
->entries
[cnt
].address
);
1032 rc
= be32_to_cpu(attr
->entries
[cnt
].size
);
1033 dev_dbg(&card
->dev
, "adding attribute %d: id %x, address %x, "
1034 "size %x\n", cnt
, attr
->entries
[cnt
].id
, addr
, rc
);
1035 s_attr
->id
= attr
->entries
[cnt
].id
;
1036 if (mspro_block_attr_name(s_attr
->id
))
1037 snprintf(s_attr
->name
, sizeof(s_attr
->name
), "%s",
1038 mspro_block_attr_name(attr
->entries
[cnt
].id
));
1040 snprintf(s_attr
->name
, sizeof(s_attr
->name
),
1041 "attr_x%02x", attr
->entries
[cnt
].id
);
1043 s_attr
->dev_attr
.attr
.name
= s_attr
->name
;
1044 s_attr
->dev_attr
.attr
.mode
= S_IRUGO
;
1045 s_attr
->dev_attr
.show
= mspro_block_attr_show(s_attr
->id
);
1051 s_attr
->data
= kmalloc(rc
, GFP_KERNEL
);
1052 if (!s_attr
->data
) {
1054 goto out_free_buffer
;
1057 if (((addr
/ msb
->page_size
)
1058 == be32_to_cpu(param
.data_address
))
1059 && (((addr
+ rc
- 1) / msb
->page_size
)
1060 == be32_to_cpu(param
.data_address
))) {
1061 memcpy(s_attr
->data
, buffer
+ addr
% msb
->page_size
,
1066 if (page_count
<= (rc
/ msb
->page_size
)) {
1068 page_count
= (rc
/ msb
->page_size
) + 1;
1069 buffer
= kmalloc(page_count
* msb
->page_size
,
1077 param
.system
= msb
->system
;
1078 param
.data_count
= cpu_to_be16((rc
/ msb
->page_size
) + 1);
1079 param
.data_address
= cpu_to_be32(addr
/ msb
->page_size
);
1080 param
.tpc_param
= 0;
1082 sg_init_one(&msb
->req_sg
[0], buffer
,
1083 be16_to_cpu(param
.data_count
) * msb
->page_size
);
1085 msb
->current_seg
= 0;
1086 msb
->current_page
= 0;
1087 msb
->data_dir
= READ
;
1088 msb
->transfer_cmd
= MSPRO_CMD_READ_ATRB
;
1090 dev_dbg(&card
->dev
, "reading attribute pages %x, %x\n",
1091 be32_to_cpu(param
.data_address
),
1092 be16_to_cpu(param
.data_count
));
1094 card
->next_request
= h_mspro_block_req_init
;
1095 msb
->mrq_handler
= h_mspro_block_transfer_data
;
1096 memstick_init_req(&card
->current_mrq
, MS_TPC_WRITE_REG
,
1097 (char *)¶m
, sizeof(param
));
1098 memstick_new_req(card
->host
);
1099 wait_for_completion(&card
->mrq_complete
);
1100 if (card
->current_mrq
.error
) {
1101 rc
= card
->current_mrq
.error
;
1102 goto out_free_buffer
;
1105 memcpy(s_attr
->data
, buffer
+ addr
% msb
->page_size
, rc
);
1116 static int mspro_block_init_card(struct memstick_dev
*card
)
1118 struct mspro_block_data
*msb
= memstick_get_drvdata(card
);
1119 struct memstick_host
*host
= card
->host
;
1122 msb
->system
= MEMSTICK_SYS_SERIAL
;
1123 card
->reg_addr
.r_offset
= offsetof(struct mspro_register
, status
);
1124 card
->reg_addr
.r_length
= sizeof(struct ms_status_register
);
1125 card
->reg_addr
.w_offset
= offsetof(struct mspro_register
, param
);
1126 card
->reg_addr
.w_length
= sizeof(struct mspro_param_register
);
1128 if (memstick_set_rw_addr(card
))
1131 msb
->caps
= host
->caps
;
1134 rc
= mspro_block_wait_for_ced(card
);
1138 rc
= mspro_block_switch_interface(card
);
1142 dev_dbg(&card
->dev
, "card activated\n");
1143 if (msb
->system
!= MEMSTICK_SYS_SERIAL
)
1144 msb
->caps
|= MEMSTICK_CAP_AUTO_GET_INT
;
1146 card
->next_request
= h_mspro_block_req_init
;
1147 msb
->mrq_handler
= h_mspro_block_get_ro
;
1148 memstick_init_req(&card
->current_mrq
, MS_TPC_READ_REG
, NULL
,
1149 sizeof(struct ms_status_register
));
1150 memstick_new_req(card
->host
);
1151 wait_for_completion(&card
->mrq_complete
);
1152 if (card
->current_mrq
.error
)
1153 return card
->current_mrq
.error
;
1155 dev_dbg(&card
->dev
, "card r/w status %d\n", msb
->read_only
? 0 : 1);
1157 msb
->page_size
= 512;
1158 rc
= mspro_block_read_attributes(card
);
1162 dev_dbg(&card
->dev
, "attributes loaded\n");
1167 static int mspro_block_init_disk(struct memstick_dev
*card
)
1169 struct mspro_block_data
*msb
= memstick_get_drvdata(card
);
1170 struct memstick_host
*host
= card
->host
;
1171 struct mspro_devinfo
*dev_info
= NULL
;
1172 struct mspro_sys_info
*sys_info
= NULL
;
1173 struct mspro_sys_attr
*s_attr
= NULL
;
1175 u64 limit
= BLK_BOUNCE_HIGH
;
1176 unsigned long capacity
;
1178 if (host
->dev
.dma_mask
&& *(host
->dev
.dma_mask
))
1179 limit
= *(host
->dev
.dma_mask
);
1181 for (rc
= 0; msb
->attr_group
.attrs
[rc
]; ++rc
) {
1182 s_attr
= mspro_from_sysfs_attr(msb
->attr_group
.attrs
[rc
]);
1184 if (s_attr
->id
== MSPRO_BLOCK_ID_DEVINFO
)
1185 dev_info
= s_attr
->data
;
1186 else if (s_attr
->id
== MSPRO_BLOCK_ID_SYSINFO
)
1187 sys_info
= s_attr
->data
;
1190 if (!dev_info
|| !sys_info
)
1193 msb
->cylinders
= be16_to_cpu(dev_info
->cylinders
);
1194 msb
->heads
= be16_to_cpu(dev_info
->heads
);
1195 msb
->sectors_per_track
= be16_to_cpu(dev_info
->sectors_per_track
);
1197 msb
->page_size
= be16_to_cpu(sys_info
->unit_size
);
1199 if (!idr_pre_get(&mspro_block_disk_idr
, GFP_KERNEL
))
1202 mutex_lock(&mspro_block_disk_lock
);
1203 rc
= idr_get_new(&mspro_block_disk_idr
, card
, &disk_id
);
1204 mutex_unlock(&mspro_block_disk_lock
);
1209 if ((disk_id
<< MSPRO_BLOCK_PART_SHIFT
) > 255) {
1211 goto out_release_id
;
1214 msb
->disk
= alloc_disk(1 << MSPRO_BLOCK_PART_SHIFT
);
1217 goto out_release_id
;
1220 msb
->queue
= blk_init_queue(mspro_block_submit_req
, &msb
->q_lock
);
1226 msb
->queue
->queuedata
= card
;
1227 blk_queue_prep_rq(msb
->queue
, mspro_block_prepare_req
);
1229 blk_queue_bounce_limit(msb
->queue
, limit
);
1230 blk_queue_max_sectors(msb
->queue
, MSPRO_BLOCK_MAX_PAGES
);
1231 blk_queue_max_phys_segments(msb
->queue
, MSPRO_BLOCK_MAX_SEGS
);
1232 blk_queue_max_hw_segments(msb
->queue
, MSPRO_BLOCK_MAX_SEGS
);
1233 blk_queue_max_segment_size(msb
->queue
,
1234 MSPRO_BLOCK_MAX_PAGES
* msb
->page_size
);
1236 msb
->disk
->major
= major
;
1237 msb
->disk
->first_minor
= disk_id
<< MSPRO_BLOCK_PART_SHIFT
;
1238 msb
->disk
->fops
= &ms_block_bdops
;
1239 msb
->usage_count
= 1;
1240 msb
->disk
->private_data
= msb
;
1241 msb
->disk
->queue
= msb
->queue
;
1242 msb
->disk
->driverfs_dev
= &card
->dev
;
1244 sprintf(msb
->disk
->disk_name
, "mspblk%d", disk_id
);
1246 blk_queue_hardsect_size(msb
->queue
, msb
->page_size
);
1248 capacity
= be16_to_cpu(sys_info
->user_block_count
);
1249 capacity
*= be16_to_cpu(sys_info
->block_size
);
1250 capacity
*= msb
->page_size
>> 9;
1251 set_capacity(msb
->disk
, capacity
);
1252 dev_dbg(&card
->dev
, "capacity set %ld\n", capacity
);
1254 add_disk(msb
->disk
);
1259 put_disk(msb
->disk
);
1261 mutex_lock(&mspro_block_disk_lock
);
1262 idr_remove(&mspro_block_disk_idr
, disk_id
);
1263 mutex_unlock(&mspro_block_disk_lock
);
1267 static void mspro_block_data_clear(struct mspro_block_data
*msb
)
1270 struct mspro_sys_attr
*s_attr
;
1272 if (msb
->attr_group
.attrs
) {
1273 for (cnt
= 0; msb
->attr_group
.attrs
[cnt
]; ++cnt
) {
1274 s_attr
= mspro_from_sysfs_attr(msb
->attr_group
1276 kfree(s_attr
->data
);
1279 kfree(msb
->attr_group
.attrs
);
1285 static int mspro_block_check_card(struct memstick_dev
*card
)
1287 struct mspro_block_data
*msb
= memstick_get_drvdata(card
);
1289 return (msb
->active
== 1);
1292 static int mspro_block_probe(struct memstick_dev
*card
)
1294 struct mspro_block_data
*msb
;
1297 msb
= kzalloc(sizeof(struct mspro_block_data
), GFP_KERNEL
);
1300 memstick_set_drvdata(card
, msb
);
1302 spin_lock_init(&msb
->q_lock
);
1304 rc
= mspro_block_init_card(card
);
1309 rc
= sysfs_create_group(&card
->dev
.kobj
, &msb
->attr_group
);
1313 rc
= mspro_block_init_disk(card
);
1315 card
->check
= mspro_block_check_card
;
1316 card
->stop
= mspro_block_stop
;
1317 card
->start
= mspro_block_start
;
1321 sysfs_remove_group(&card
->dev
.kobj
, &msb
->attr_group
);
1323 memstick_set_drvdata(card
, NULL
);
1324 mspro_block_data_clear(msb
);
1329 static void mspro_block_remove(struct memstick_dev
*card
)
1331 struct mspro_block_data
*msb
= memstick_get_drvdata(card
);
1332 unsigned long flags
;
1334 del_gendisk(msb
->disk
);
1335 dev_dbg(&card
->dev
, "mspro block remove\n");
1336 spin_lock_irqsave(&msb
->q_lock
, flags
);
1338 blk_start_queue(msb
->queue
);
1339 spin_unlock_irqrestore(&msb
->q_lock
, flags
);
1341 blk_cleanup_queue(msb
->queue
);
1344 sysfs_remove_group(&card
->dev
.kobj
, &msb
->attr_group
);
1346 mutex_lock(&mspro_block_disk_lock
);
1347 mspro_block_data_clear(msb
);
1348 mutex_unlock(&mspro_block_disk_lock
);
1350 mspro_block_disk_release(msb
->disk
);
1351 memstick_set_drvdata(card
, NULL
);
1356 static int mspro_block_suspend(struct memstick_dev
*card
, pm_message_t state
)
1358 struct mspro_block_data
*msb
= memstick_get_drvdata(card
);
1359 unsigned long flags
;
1361 spin_lock_irqsave(&msb
->q_lock
, flags
);
1362 blk_stop_queue(msb
->queue
);
1364 spin_unlock_irqrestore(&msb
->q_lock
, flags
);
1369 static int mspro_block_resume(struct memstick_dev
*card
)
1371 struct mspro_block_data
*msb
= memstick_get_drvdata(card
);
1372 unsigned long flags
;
1375 #ifdef CONFIG_MEMSTICK_UNSAFE_RESUME
1377 struct mspro_block_data
*new_msb
;
1378 struct memstick_host
*host
= card
->host
;
1379 struct mspro_sys_attr
*s_attr
, *r_attr
;
1382 mutex_lock(&host
->lock
);
1383 new_msb
= kzalloc(sizeof(struct mspro_block_data
), GFP_KERNEL
);
1389 new_msb
->card
= card
;
1390 memstick_set_drvdata(card
, new_msb
);
1391 if (mspro_block_init_card(card
))
1394 for (cnt
= 0; new_msb
->attr_group
.attrs
[cnt
]
1395 && msb
->attr_group
.attrs
[cnt
]; ++cnt
) {
1396 s_attr
= mspro_from_sysfs_attr(new_msb
->attr_group
.attrs
[cnt
]);
1397 r_attr
= mspro_from_sysfs_attr(msb
->attr_group
.attrs
[cnt
]);
1399 if (s_attr
->id
== MSPRO_BLOCK_ID_SYSINFO
1400 && r_attr
->id
== s_attr
->id
) {
1401 if (memcmp(s_attr
->data
, r_attr
->data
, s_attr
->size
))
1410 memstick_set_drvdata(card
, msb
);
1411 mspro_block_data_clear(new_msb
);
1414 mutex_unlock(&host
->lock
);
1416 #endif /* CONFIG_MEMSTICK_UNSAFE_RESUME */
1418 spin_lock_irqsave(&msb
->q_lock
, flags
);
1419 blk_start_queue(msb
->queue
);
1420 spin_unlock_irqrestore(&msb
->q_lock
, flags
);
1426 #define mspro_block_suspend NULL
1427 #define mspro_block_resume NULL
1429 #endif /* CONFIG_PM */
1431 static struct memstick_device_id mspro_block_id_tbl
[] = {
1432 {MEMSTICK_MATCH_ALL
, MEMSTICK_TYPE_PRO
, MEMSTICK_CATEGORY_STORAGE_DUO
,
1433 MEMSTICK_CLASS_DUO
},
1438 static struct memstick_driver mspro_block_driver
= {
1440 .name
= DRIVER_NAME
,
1441 .owner
= THIS_MODULE
1443 .id_table
= mspro_block_id_tbl
,
1444 .probe
= mspro_block_probe
,
1445 .remove
= mspro_block_remove
,
1446 .suspend
= mspro_block_suspend
,
1447 .resume
= mspro_block_resume
1450 static int __init
mspro_block_init(void)
1454 rc
= register_blkdev(major
, DRIVER_NAME
);
1456 printk(KERN_ERR DRIVER_NAME
": failed to register "
1457 "major %d, error %d\n", major
, rc
);
1463 rc
= memstick_register_driver(&mspro_block_driver
);
1465 unregister_blkdev(major
, DRIVER_NAME
);
1469 static void __exit
mspro_block_exit(void)
1471 memstick_unregister_driver(&mspro_block_driver
);
1472 unregister_blkdev(major
, DRIVER_NAME
);
1473 idr_destroy(&mspro_block_disk_idr
);
1476 module_init(mspro_block_init
);
1477 module_exit(mspro_block_exit
);
1479 MODULE_LICENSE("GPL");
1480 MODULE_AUTHOR("Alex Dubov");
1481 MODULE_DESCRIPTION("Sony MemoryStickPro block device driver");
1482 MODULE_DEVICE_TABLE(memstick
, mspro_block_id_tbl
);