1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42#ifndef _USB_H_
43#define _USB_H_
44
45#include <linux/usb.h>
46#include <linux/usb_usual.h>
47#include <linux/blkdev.h>
48#include <linux/completion.h>
49#include <linux/mutex.h>
50#include <scsi/scsi_host.h>
51
52struct us_data;
53struct scsi_cmnd;
54
55
56
57
58
59struct us_unusual_dev {
60 const char* vendorName;
61 const char* productName;
62 __u8 useProtocol;
63 __u8 useTransport;
64 int (*initFunction)(struct us_data *);
65};
66
67
68
69#define US_FLIDX_URB_ACTIVE 0
70#define US_FLIDX_SG_ACTIVE 1
71#define US_FLIDX_ABORTING 2
72#define US_FLIDX_DISCONNECTING 3
73#define US_FLIDX_RESETTING 4
74#define US_FLIDX_TIMED_OUT 5
75#define US_FLIDX_DONT_SCAN 6
76
77#define USB_STOR_STRING_LEN 32
78
79
80
81
82
83
84
85
86#define US_IOBUF_SIZE 64
87#define US_SENSE_SIZE 18
88
89typedef int (*trans_cmnd)(struct scsi_cmnd *, struct us_data*);
90typedef int (*trans_reset)(struct us_data*);
91typedef void (*proto_cmnd)(struct scsi_cmnd*, struct us_data*);
92typedef void (*extra_data_destructor)(void *);
93typedef void (*pm_hook)(struct us_data *, int);
94
95#define US_SUSPEND 0
96#define US_RESUME 1
97
98
99struct us_data {
100
101
102
103
104 struct mutex dev_mutex;
105 struct usb_device *pusb_dev;
106 struct usb_interface *pusb_intf;
107 struct us_unusual_dev *unusual_dev;
108 unsigned long fflags;
109 unsigned long dflags;
110 unsigned int send_bulk_pipe;
111 unsigned int recv_bulk_pipe;
112 unsigned int send_ctrl_pipe;
113 unsigned int recv_ctrl_pipe;
114 unsigned int recv_intr_pipe;
115
116
117 char *transport_name;
118 char *protocol_name;
119 __le32 bcs_signature;
120 u8 subclass;
121 u8 protocol;
122 u8 max_lun;
123
124 u8 ifnum;
125 u8 ep_bInterval;
126
127
128 trans_cmnd transport;
129 trans_reset transport_reset;
130 proto_cmnd proto_handler;
131
132
133 struct scsi_cmnd *srb;
134 unsigned int tag;
135
136
137 struct urb *current_urb;
138 struct usb_ctrlrequest *cr;
139 struct usb_sg_request current_sg;
140 unsigned char *iobuf;
141 dma_addr_t cr_dma;
142 dma_addr_t iobuf_dma;
143 struct task_struct *ctl_thread;
144
145
146 struct completion cmnd_ready;
147 struct completion notify;
148 wait_queue_head_t delay_wait;
149 struct completion scanning_done;
150
151
152 void *extra;
153 extra_data_destructor extra_destructor;
154#ifdef CONFIG_PM
155 pm_hook suspend_resume_hook;
156#endif
157
158
159 int use_last_sector_hacks;
160 int last_sector_retries;
161};
162
163
164static inline struct Scsi_Host *us_to_host(struct us_data *us) {
165 return container_of((void *) us, struct Scsi_Host, hostdata);
166}
167static inline struct us_data *host_to_us(struct Scsi_Host *host) {
168 return (struct us_data *) host->hostdata;
169}
170
171
172extern void fill_inquiry_response(struct us_data *us,
173 unsigned char *data, unsigned int data_len);
174
175
176
177#define scsi_unlock(host) spin_unlock_irq(host->host_lock)
178#define scsi_lock(host) spin_lock_irq(host->host_lock)
179
180
181#ifdef CONFIG_PM
182extern int usb_stor_suspend(struct usb_interface *iface, pm_message_t message);
183extern int usb_stor_resume(struct usb_interface *iface);
184extern int usb_stor_reset_resume(struct usb_interface *iface);
185#else
186#define usb_stor_suspend NULL
187#define usb_stor_resume NULL
188#define usb_stor_reset_resume NULL
189#endif
190
191extern int usb_stor_pre_reset(struct usb_interface *iface);
192extern int usb_stor_post_reset(struct usb_interface *iface);
193
194extern int usb_stor_probe1(struct us_data **pus,
195 struct usb_interface *intf,
196 const struct usb_device_id *id,
197 struct us_unusual_dev *unusual_dev);
198extern int usb_stor_probe2(struct us_data *us);
199extern void usb_stor_disconnect(struct usb_interface *intf);
200
201#endif
202