datafab.c (7a9787e1eba95a166265e6a260cf30af04ef0a99) datafab.c (2cbbf3576aa9eae9a92f2669f38a453b6cb8e956)
1/* Driver for Datafab USB Compact Flash reader
2 *
3 * datafab driver v0.1:
4 *
5 * First release
6 *
7 * Current development and maintenance by:
8 * (c) 2000 Jimmie Mayfield (mayfield+datafab@sackheads.org)

--- 35 unchanged lines hidden (view full) ---

44 *
45 * This driver supports reading and writing. If you're truly paranoid,
46 * however, you can force the driver into a write-protected state by setting
47 * the WP enable bits in datafab_handle_mode_sense(). See the comments
48 * in that routine.
49 */
50
51#include <linux/errno.h>
1/* Driver for Datafab USB Compact Flash reader
2 *
3 * datafab driver v0.1:
4 *
5 * First release
6 *
7 * Current development and maintenance by:
8 * (c) 2000 Jimmie Mayfield (mayfield+datafab@sackheads.org)

--- 35 unchanged lines hidden (view full) ---

44 *
45 * This driver supports reading and writing. If you're truly paranoid,
46 * however, you can force the driver into a write-protected state by setting
47 * the WP enable bits in datafab_handle_mode_sense(). See the comments
48 * in that routine.
49 */
50
51#include <linux/errno.h>
52#include <linux/module.h>
52#include <linux/slab.h>
53
54#include <scsi/scsi.h>
55#include <scsi/scsi_cmnd.h>
56
57#include "usb.h"
58#include "transport.h"
59#include "protocol.h"
60#include "debug.h"
53#include <linux/slab.h>
54
55#include <scsi/scsi.h>
56#include <scsi/scsi_cmnd.h>
57
58#include "usb.h"
59#include "transport.h"
60#include "protocol.h"
61#include "debug.h"
61#include "datafab.h"
62
62
63struct datafab_info {
64 unsigned long sectors; /* total sector count */
65 unsigned long ssize; /* sector size in bytes */
66 signed char lun; /* used for dual-slot readers */
67
68 /* the following aren't used yet */
69 unsigned char sense_key;
70 unsigned long sense_asc; /* additional sense code */
71 unsigned long sense_ascq; /* additional sense code qualifier */
72};
73
63static int datafab_determine_lun(struct us_data *us,
64 struct datafab_info *info);
65
66
74static int datafab_determine_lun(struct us_data *us,
75 struct datafab_info *info);
76
77
78/*
79 * The table of devices
80 */
81#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
82 vendorName, productName, useProtocol, useTransport, \
83 initFunction, flags) \
84{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
85 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
86
87struct usb_device_id datafab_usb_ids[] = {
88# include "unusual_datafab.h"
89 { } /* Terminating entry */
90};
91MODULE_DEVICE_TABLE(usb, datafab_usb_ids);
92
93#undef UNUSUAL_DEV
94
95/*
96 * The flags table
97 */
98#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
99 vendor_name, product_name, use_protocol, use_transport, \
100 init_function, Flags) \
101{ \
102 .vendorName = vendor_name, \
103 .productName = product_name, \
104 .useProtocol = use_protocol, \
105 .useTransport = use_transport, \
106 .initFunction = init_function, \
107}
108
109static struct us_unusual_dev datafab_unusual_dev_list[] = {
110# include "unusual_datafab.h"
111 { } /* Terminating entry */
112};
113
114#undef UNUSUAL_DEV
115
116
67static inline int
68datafab_bulk_read(struct us_data *us, unsigned char *data, unsigned int len) {
69 if (len == 0)
70 return USB_STOR_XFER_GOOD;
71
72 US_DEBUGP("datafab_bulk_read: len = %d\n", len);
73 return usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
74 data, len, NULL);

--- 420 unchanged lines hidden (view full) ---

495{
496 // this routine is a placeholder...
497 // currently, we don't allocate any extra memory so we're okay
498}
499
500
501// Transport for the Datafab MDCFE-B
502//
117static inline int
118datafab_bulk_read(struct us_data *us, unsigned char *data, unsigned int len) {
119 if (len == 0)
120 return USB_STOR_XFER_GOOD;
121
122 US_DEBUGP("datafab_bulk_read: len = %d\n", len);
123 return usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
124 data, len, NULL);

--- 420 unchanged lines hidden (view full) ---

545{
546 // this routine is a placeholder...
547 // currently, we don't allocate any extra memory so we're okay
548}
549
550
551// Transport for the Datafab MDCFE-B
552//
503int datafab_transport(struct scsi_cmnd * srb, struct us_data *us)
553static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us)
504{
505 struct datafab_info *info;
506 int rc;
507 unsigned long block, blocks;
508 unsigned char *ptr = us->iobuf;
509 static unsigned char inquiry_reply[8] = {
510 0x00, 0x80, 0x00, 0x01, 0x1F, 0x00, 0x00, 0x00
511 };

--- 148 unchanged lines hidden (view full) ---

660
661 US_DEBUGP("datafab_transport: Gah! Unknown command: %d (0x%x)\n",
662 srb->cmnd[0], srb->cmnd[0]);
663 info->sense_key = 0x05;
664 info->sense_asc = 0x20;
665 info->sense_ascq = 0x00;
666 return USB_STOR_TRANSPORT_FAILED;
667}
554{
555 struct datafab_info *info;
556 int rc;
557 unsigned long block, blocks;
558 unsigned char *ptr = us->iobuf;
559 static unsigned char inquiry_reply[8] = {
560 0x00, 0x80, 0x00, 0x01, 0x1F, 0x00, 0x00, 0x00
561 };

--- 148 unchanged lines hidden (view full) ---

710
711 US_DEBUGP("datafab_transport: Gah! Unknown command: %d (0x%x)\n",
712 srb->cmnd[0], srb->cmnd[0]);
713 info->sense_key = 0x05;
714 info->sense_asc = 0x20;
715 info->sense_ascq = 0x00;
716 return USB_STOR_TRANSPORT_FAILED;
717}
718
719static int datafab_probe(struct usb_interface *intf,
720 const struct usb_device_id *id)
721{
722 struct us_data *us;
723 int result;
724
725 result = usb_stor_probe1(&us, intf, id,
726 (id - datafab_usb_ids) + datafab_unusual_dev_list);
727 if (result)
728 return result;
729
730 us->transport_name = "Datafab Bulk-Only";
731 us->transport = datafab_transport;
732 us->transport_reset = usb_stor_Bulk_reset;
733 us->max_lun = 1;
734
735 result = usb_stor_probe2(us);
736 return result;
737}
738
739static struct usb_driver datafab_driver = {
740 .name = "ums-datafab",
741 .probe = datafab_probe,
742 .disconnect = usb_stor_disconnect,
743 .suspend = usb_stor_suspend,
744 .resume = usb_stor_resume,
745 .reset_resume = usb_stor_reset_resume,
746 .pre_reset = usb_stor_pre_reset,
747 .post_reset = usb_stor_post_reset,
748 .id_table = datafab_usb_ids,
749 .soft_unbind = 1,
750};
751
752static int __init datafab_init(void)
753{
754 return usb_register(&datafab_driver);
755}
756
757static void __exit datafab_exit(void)
758{
759 usb_deregister(&datafab_driver);
760}
761
762module_init(datafab_init);
763module_exit(datafab_exit);