blob: 1cdfe69585ea666d63b8e16175f2705c1529461b [file] [log] [blame]
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -07001/*
2 * rspiusb.c
3 *
4 * Copyright (C) 2005, 2006 Princeton Instruments
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 as published by
8 * the Free Software Foundation version 2 of the License
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20#include <linux/vmalloc.h>
21#include <linux/kernel.h>
22#include <linux/errno.h>
23#include <linux/init.h>
24#include <linux/slab.h>
25#include <linux/module.h>
26#include <linux/smp_lock.h>
27#include <linux/completion.h>
28#include <linux/scatterlist.h>
29#include <linux/usb.h>
30#include <linux/mm.h>
31#include <linux/pagemap.h>
32#include <linux/ioctl.h>
33#include "rspiusb.h"
34
35#ifdef CONFIG_USB_DEBUG
36static int debug = 1;
37#else
38static int debug;
39#endif
40/* Use our own dbg macro */
41#undef dbg
Richard Genoudf2d46e22009-05-17 13:06:30 +020042#define dbg(format, arg...) \
43 do { \
44 if (debug) \
45 printk(KERN_DEBUG __FILE__ ": " format "\n" , ##arg); \
46 } while (0)
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -070047
48/* Version Information */
49#define DRIVER_VERSION "V1.0.1"
50#define DRIVER_AUTHOR "Princeton Instruments"
51#define DRIVER_DESC "PI USB2.0 Device Driver for Linux"
52
53/* Define these values to match your devices */
54#define VENDOR_ID 0x0BD7
55#define ST133_PID 0xA010
56#define PIXIS_PID 0xA026
57
58/* Get a minor range for your devices from the usb maintainer */
59#ifdef CONFIG_USB_DYNAMIC_MINORS
60#define PIUSB_MINOR_BASE 0
61#else
62#define PIUSB_MINOR_BASE 192
63#endif
64
65/* prevent races between open() and disconnect() */
66static DECLARE_MUTEX(disconnect_sem);
67
68/* Structure to hold all of our device specific stuff */
69struct device_extension {
Richard Genoudf2d46e22009-05-17 13:06:30 +020070 struct usb_device *udev; /* save off the usb device pointer */
71 struct usb_interface *interface; /* the interface for this device */
72 unsigned char minor; /* the starting minor number
73 * for this device
74 */
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -070075 size_t bulk_in_size_returned;
76 int bulk_in_byte_trk;
77 struct urb ***PixelUrb;
78 int frameIdx;
79 int urbIdx;
80 unsigned int *maplist_numPagesMapped;
Richard Genoudf2d46e22009-05-17 13:06:30 +020081 int open; /* if the port is open or not */
82 int present; /* if the device is not disconnected */
83 int userBufMapped; /* has the user buffer been mapped ? */
84 struct scatterlist **sgl; /* scatter-gather list for user buffer */
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -070085 unsigned int *sgEntries;
86 struct kref kref;
87 int gotPixelData;
88 int pendingWrite;
89 char **pendedPixelUrbs;
Richard Genoudf2d46e22009-05-17 13:06:30 +020090 int iama; /* PIXIS or ST133 */
91 int num_frames; /* the number of frames that will fit
92 * in the user buffer
93 */
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -070094 int active_frame;
95 unsigned long frameSize;
96 struct semaphore sem;
Richard Genoudf2d46e22009-05-17 13:06:30 +020097 unsigned int hEP[8]; /* FX2 specific endpoints */
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -070098};
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -070099
Richard Genoudf2d46e22009-05-17 13:06:30 +0200100#define to_pi_dev(d) container_of(d, struct device_extension, kref)
101
102/* Prototypes */
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700103static int MapUserBuffer(struct ioctl_struct *, struct device_extension *);
104static int UnMapUserBuffer(struct device_extension *);
105static int piusb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
106 unsigned long arg);
Richard Genoudf2d46e22009-05-17 13:06:30 +0200107static int piusb_output(struct ioctl_struct *, unsigned char *, int,
108 struct device_extension *);
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700109static struct usb_driver piusb_driver;
110
111/* table of devices that work with this driver */
112static struct usb_device_id pi_device_table[] = {
113 {USB_DEVICE(VENDOR_ID, ST133_PID)},
114 {USB_DEVICE(VENDOR_ID, PIXIS_PID)},
Richard Genoudf2d46e22009-05-17 13:06:30 +0200115 {0, } /* Terminating entry */
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700116};
117
118MODULE_DEVICE_TABLE(usb, pi_device_table);
119
Richard Genoudf2d46e22009-05-17 13:06:30 +0200120static int lastErr;
121static int errCnt;
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700122
123static void piusb_delete(struct kref *kref)
124{
125 struct device_extension *pdx = to_pi_dev(kref);
126
127 dev_dbg(&pdx->udev->dev, "%s\n", __func__);
128 usb_put_dev(pdx->udev);
129 kfree(pdx);
130}
131
132static int piusb_open(struct inode *inode, struct file *file)
133{
134 struct device_extension *pdx = NULL;
135 struct usb_interface *interface;
136 int subminor;
137 int retval = 0;
138
139 dbg("Piusb_Open()");
140 subminor = iminor(inode);
141 interface = usb_find_interface(&piusb_driver, subminor);
142 if (!interface) {
143 printk(KERN_ERR "%s - error, can't find device for minor %d\n",
144 __func__, subminor);
145 retval = -ENODEV;
146 goto exit_no_device;
147 }
148
149 pdx = usb_get_intfdata(interface);
150 if (!pdx) {
151 retval = -ENODEV;
152 goto exit_no_device;
153 }
154 dbg("Alternate Setting = %d", interface->num_altsetting);
155
Richard Genoudf2d46e22009-05-17 13:06:30 +0200156 pdx->bulk_in_size_returned = 0;
157 pdx->bulk_in_byte_trk = 0;
158 pdx->PixelUrb = NULL;
159 pdx->frameIdx = 0;
160 pdx->urbIdx = 0;
161 pdx->maplist_numPagesMapped = NULL;
162 pdx->userBufMapped = 0;
163 pdx->sgl = NULL;
164 pdx->sgEntries = NULL;
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700165 pdx->gotPixelData = 0;
166 pdx->pendingWrite = 0;
Richard Genoudf2d46e22009-05-17 13:06:30 +0200167 pdx->pendedPixelUrbs = NULL;
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700168 pdx->num_frames = 0;
169 pdx->active_frame = 0;
Richard Genoudf2d46e22009-05-17 13:06:30 +0200170 pdx->frameSize = 0;
171
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700172 /* increment our usage count for the device */
173 kref_get(&pdx->kref);
Richard Genoudf2d46e22009-05-17 13:06:30 +0200174
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700175 /* save our object in the file's private structure */
176 file->private_data = pdx;
Richard Genoudf2d46e22009-05-17 13:06:30 +0200177
178exit_no_device:
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700179 return retval;
180}
181
182static int piusb_release(struct inode *inode, struct file *file)
183{
184 struct device_extension *pdx;
185 int retval = 0;
186
187 dbg("Piusb_Release()");
188 pdx = (struct device_extension *)file->private_data;
189 if (pdx == NULL) {
190 dbg("%s - object is NULL", __func__);
Richard Genoudf2d46e22009-05-17 13:06:30 +0200191 retval = -ENODEV;
192 goto object_null;
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700193 }
194 /* decrement the count on our device */
195 kref_put(&pdx->kref, piusb_delete);
Richard Genoudf2d46e22009-05-17 13:06:30 +0200196
197object_null:
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700198 return retval;
199}
200
Richard Genoudc854b5e2009-05-17 13:06:31 +0200201static int pixis_io(struct ioctl_struct *ctrl, struct device_extension *pdx,
202 struct ioctl_struct *arg)
203{
204 unsigned int numToRead = 0;
205 unsigned int totalRead = 0;
206 unsigned char *uBuf;
207 int numbytes;
208 int i;
209
210 uBuf = kmalloc(ctrl->numbytes, GFP_KERNEL);
211 if (!uBuf) {
212 dbg("Alloc for uBuf failed");
213 return 0;
214 }
215 numbytes = (int) ctrl->numbytes;
216 numToRead = (unsigned int) ctrl->numbytes;
217 dbg("numbytes to read = %d", numbytes);
218 dbg("endpoint # %d", ctrl->endpoint);
219
vibi sreenivasan7a80bfc2009-06-04 20:59:17 +0530220 if (copy_from_user(uBuf, ctrl->pData, numbytes)) {
Richard Genoudc854b5e2009-05-17 13:06:31 +0200221 dbg("copying ctrl->pData to dummyBuf failed");
vibi sreenivasan7a80bfc2009-06-04 20:59:17 +0530222 return -EFAULT;
223 }
Richard Genoudc854b5e2009-05-17 13:06:31 +0200224
225 do {
226 i = usb_bulk_msg(pdx->udev, pdx->hEP[ctrl->endpoint],
227 (uBuf + totalRead),
228 /* EP0 can only handle 64 bytes at a time */
229 (numToRead > 64) ? 64 : numToRead,
230 &numbytes, HZ * 10);
231 if (i) {
232 dbg("CMD = %s, Address = 0x%02X",
233 ((uBuf[3] == 0x02) ? "WRITE" : "READ"),
234 uBuf[1]);
235 dbg("Number of bytes Attempted to read = %d",
236 (int)ctrl->numbytes);
237 dbg("Blocking ReadI/O Failed with status %d", i);
238 kfree(uBuf);
239 return -1;
240 }
241 dbg("Pixis EP0 Read %d bytes", numbytes);
242 totalRead += numbytes;
243 numToRead -= numbytes;
244 } while (numToRead);
245
246 memcpy(ctrl->pData, uBuf, totalRead);
247 dbg("Total Bytes Read from PIXIS EP0 = %d", totalRead);
248 ctrl->numbytes = totalRead;
249
250 if (copy_to_user(arg, ctrl, sizeof(struct ioctl_struct)))
251 dbg("copy_to_user failed in IORB");
252
253 kfree(uBuf);
254 return ctrl->numbytes;
255}
256
Richard Genoudc854b5e2009-05-17 13:06:31 +0200257static int pixel_data(struct ioctl_struct *ctrl, struct device_extension *pdx)
258{
259 int i;
260
261 if (!pdx->gotPixelData)
262 return 0;
263
264 pdx->gotPixelData = 0;
265 ctrl->numbytes = pdx->bulk_in_size_returned;
266 pdx->bulk_in_size_returned -= pdx->frameSize;
267
268 for (i = 0; i < pdx->maplist_numPagesMapped[pdx->active_frame]; i++)
vibi sreenivasan8d2db512009-06-04 20:56:45 +0530269 SetPageDirty(sg_page(&pdx->sgl[pdx->active_frame][i]));
Richard Genoudc854b5e2009-05-17 13:06:31 +0200270
271 pdx->active_frame = ((pdx->active_frame + 1) % pdx->num_frames);
272
273 return ctrl->numbytes;
274}
275
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700276/**
277 * piusb_ioctl
278 */
279static int piusb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
280 unsigned long arg)
281{
282 struct device_extension *pdx;
283 char dummyCtlBuf[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
284 unsigned long devRB = 0;
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700285 int err = 0;
286 int retval = 0;
287 struct ioctl_struct ctrl;
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700288 unsigned short controlData = 0;
289
290 pdx = (struct device_extension *)file->private_data;
291 /* verify that the device wasn't unplugged */
292 if (!pdx->present) {
293 dbg("No Device Present\n");
294 return -ENODEV;
295 }
296 /* fill in your device specific stuff here */
297 if (_IOC_DIR(cmd) & _IOC_READ)
Richard Genoudf2d46e22009-05-17 13:06:30 +0200298 err = !access_ok(VERIFY_WRITE, (void __user *)arg,
299 _IOC_SIZE(cmd));
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700300 else if (_IOC_DIR(cmd) & _IOC_WRITE)
Richard Genoudf2d46e22009-05-17 13:06:30 +0200301 err = !access_ok(VERIFY_READ, (void __user *)arg,
302 _IOC_SIZE(cmd));
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700303 if (err) {
304 dev_err(&pdx->udev->dev, "return with error = %d\n", err);
305 return -EFAULT;
306 }
307 switch (cmd) {
308 case PIUSB_GETVNDCMD:
vibi sreenivasan7a80bfc2009-06-04 20:59:17 +0530309 if (__copy_from_user
310 (&ctrl, (void __user *)arg, sizeof(struct ioctl_struct))) {
J.R. Mauro6546f082009-03-28 00:10:35 -0400311 dev_err(&pdx->udev->dev, "copy_from_user failed\n");
vibi sreenivasan7a80bfc2009-06-04 20:59:17 +0530312 return -EFAULT;
313 }
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700314 dbg("%s %x\n", "Get Vendor Command = ", ctrl.cmd);
315 retval =
316 usb_control_msg(pdx->udev, usb_rcvctrlpipe(pdx->udev, 0),
317 ctrl.cmd, USB_DIR_IN, 0, 0, &devRB,
318 ctrl.numbytes, HZ * 10);
319 if (ctrl.cmd == 0xF1) {
320 dbg("FW Version returned from HW = %ld.%ld",
321 (devRB >> 8), (devRB & 0xFF));
322 }
Richard Genoudf2d46e22009-05-17 13:06:30 +0200323 if (retval >= 0)
324 retval = (int)devRB;
325 return retval;
326
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700327 case PIUSB_SETVNDCMD:
vibi sreenivasan7a80bfc2009-06-04 20:59:17 +0530328 if (__copy_from_user
329 (&ctrl, (void __user *)arg, sizeof(struct ioctl_struct))) {
J.R. Mauro6546f082009-03-28 00:10:35 -0400330 dev_err(&pdx->udev->dev, "copy_from_user failed\n");
vibi sreenivasan7a80bfc2009-06-04 20:59:17 +0530331 return -EFAULT;
332 }
Richard Genoudf2d46e22009-05-17 13:06:30 +0200333 /* dbg( "%s %x", "Set Vendor Command = ",ctrl.cmd ); */
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700334 controlData = ctrl.pData[0];
335 controlData |= (ctrl.pData[1] << 8);
Richard Genoudf2d46e22009-05-17 13:06:30 +0200336 /* dbg( "%s %d", "Vendor Data =",controlData ); */
337 retval = usb_control_msg(pdx->udev,
338 usb_sndctrlpipe(pdx->udev, 0),
339 ctrl.cmd,
340 (USB_DIR_OUT | USB_TYPE_VENDOR
341 /* | USB_RECIP_ENDPOINT */),
342 controlData, 0,
343 &dummyCtlBuf, ctrl.numbytes, HZ * 10);
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700344 return retval;
Richard Genoudf2d46e22009-05-17 13:06:30 +0200345
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700346 case PIUSB_ISHIGHSPEED:
347 return ((pdx->udev->speed == USB_SPEED_HIGH) ? 1 : 0);
Richard Genoudf2d46e22009-05-17 13:06:30 +0200348
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700349 case PIUSB_WRITEPIPE:
vibi sreenivasan7a80bfc2009-06-04 20:59:17 +0530350 if (__copy_from_user(&ctrl, (void __user *)arg, _IOC_SIZE(cmd))) {
Richard Genoudf2d46e22009-05-17 13:06:30 +0200351 dev_err(&pdx->udev->dev,
352 "copy_from_user WRITE_DUMMY failed\n");
vibi sreenivasan7a80bfc2009-06-04 20:59:17 +0530353 return -EFAULT;
354 }
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700355 if (!access_ok(VERIFY_READ, ctrl.pData, ctrl.numbytes)) {
356 dbg("can't access pData");
357 return 0;
358 }
Richard Genoudf2d46e22009-05-17 13:06:30 +0200359 piusb_output(&ctrl, ctrl.pData /* uBuf */, ctrl.numbytes, pdx);
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700360 return ctrl.numbytes;
Richard Genoudf2d46e22009-05-17 13:06:30 +0200361
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700362 case PIUSB_USERBUFFER:
vibi sreenivasan7a80bfc2009-06-04 20:59:17 +0530363 if (__copy_from_user
364 (&ctrl, (void __user *)arg, sizeof(struct ioctl_struct))) {
J.R. Mauro6546f082009-03-28 00:10:35 -0400365 dev_err(&pdx->udev->dev, "copy_from_user failed\n");
vibi sreenivasan7a80bfc2009-06-04 20:59:17 +0530366 return -EFAULT;
367 }
Richard Genoudf2d46e22009-05-17 13:06:30 +0200368 return MapUserBuffer((struct ioctl_struct *) &ctrl, pdx);
369
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700370 case PIUSB_UNMAP_USERBUFFER:
Richard Genoudf2d46e22009-05-17 13:06:30 +0200371 retval = UnMapUserBuffer(pdx);
372 return retval;
373
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700374 case PIUSB_READPIPE:
vibi sreenivasan7a80bfc2009-06-04 20:59:17 +0530375 if (__copy_from_user(&ctrl, (void __user *)arg,
376 sizeof(struct ioctl_struct))) {
J.R. Mauro6546f082009-03-28 00:10:35 -0400377 dev_err(&pdx->udev->dev, "copy_from_user failed\n");
vibi sreenivasan7a80bfc2009-06-04 20:59:17 +0530378 return -EFAULT;
379 }
Richard Genoud14e8bcd2009-05-17 13:06:32 +0200380 if (((0 == ctrl.endpoint) && (PIXIS_PID == pdx->iama)) ||
381 (1 == ctrl.endpoint) || /* ST133IO */
382 (4 == ctrl.endpoint)) /* PIXIS IO */
383 return pixis_io(&ctrl, pdx,
384 (struct ioctl_struct *)arg);
385 else if ((0 == ctrl.endpoint) || /* ST133 Pixel Data */
386 (2 == ctrl.endpoint) || /* PIXIS Ping */
387 (3 == ctrl.endpoint)) /* PIXIS Pong */
Richard Genoudc854b5e2009-05-17 13:06:31 +0200388 return pixel_data(&ctrl, pdx);
Richard Genoudf2d46e22009-05-17 13:06:30 +0200389
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700390 break;
Richard Genoudf2d46e22009-05-17 13:06:30 +0200391
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700392 case PIUSB_WHATCAMERA:
393 return pdx->iama;
Richard Genoudf2d46e22009-05-17 13:06:30 +0200394
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700395 case PIUSB_SETFRAMESIZE:
396 dbg("PIUSB_SETFRAMESIZE");
vibi sreenivasan7a80bfc2009-06-04 20:59:17 +0530397 if (__copy_from_user
398 (&ctrl, (void __user *)arg, sizeof(struct ioctl_struct))) {
J.R. Mauro6546f082009-03-28 00:10:35 -0400399 dev_err(&pdx->udev->dev, "copy_from_user failed\n");
vibi sreenivasan7a80bfc2009-06-04 20:59:17 +0530400 return -EFAULT;
401 }
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700402 pdx->frameSize = ctrl.numbytes;
403 pdx->num_frames = ctrl.numFrames;
404 if (!pdx->sgl)
405 pdx->sgl =
406 kmalloc(sizeof(struct scatterlist *) *
407 pdx->num_frames, GFP_KERNEL);
408 if (!pdx->sgEntries)
409 pdx->sgEntries =
410 kmalloc(sizeof(unsigned int) * pdx->num_frames,
411 GFP_KERNEL);
412 if (!pdx->PixelUrb)
413 pdx->PixelUrb =
414 kmalloc(sizeof(struct urb **) * pdx->num_frames,
415 GFP_KERNEL);
416 if (!pdx->maplist_numPagesMapped)
417 pdx->maplist_numPagesMapped =
418 vmalloc(sizeof(unsigned int) * pdx->num_frames);
419 if (!pdx->pendedPixelUrbs)
420 pdx->pendedPixelUrbs =
421 kmalloc(sizeof(char *) * pdx->num_frames,
422 GFP_KERNEL);
423 return 0;
Richard Genoudf2d46e22009-05-17 13:06:30 +0200424
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700425 default:
426 dbg("%s\n", "No IOCTL found");
427 break;
428
429 }
430 /* return that we did not understand this ioctl call */
431 dbg("Returning -ENOTTY");
432 return -ENOTTY;
433}
434
435static void piusb_write_bulk_callback(struct urb *urb)
436{
437 struct device_extension *pdx = urb->context;
438 int status = urb->status;
439
440 /* sync/async unlink faults aren't errors */
441 if (status && !(status == -ENOENT || status == -ECONNRESET))
442 dev_dbg(&urb->dev->dev,
443 "%s - nonzero write bulk status received: %d",
444 __func__, status);
445
446 pdx->pendingWrite = 0;
447 usb_buffer_free(urb->dev, urb->transfer_buffer_length,
448 urb->transfer_buffer, urb->transfer_dma);
449}
450
Richard Genoudf2d46e22009-05-17 13:06:30 +0200451int piusb_output(struct ioctl_struct *io, unsigned char *uBuf, int len,
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700452 struct device_extension *pdx)
453{
454 struct urb *urb = NULL;
455 int err = 0;
456 unsigned char *kbuf = NULL;
457
458 urb = usb_alloc_urb(0, GFP_KERNEL);
459 if (urb != NULL) {
460 kbuf =
461 usb_buffer_alloc(pdx->udev, len, GFP_KERNEL,
462 &urb->transfer_dma);
463 if (!kbuf) {
J.R. Mauro6546f082009-03-28 00:10:35 -0400464 dev_err(&pdx->udev->dev, "buffer_alloc failed\n");
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700465 return -ENOMEM;
466 }
vibi sreenivasan7a80bfc2009-06-04 20:59:17 +0530467 if(__copy_from_user(kbuf, uBuf, len)) {
468 dev_err(&pdx->udev->dev, "__copy_from_user failed\n");
469 return -EFAULT;
470 }
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700471 usb_fill_bulk_urb(urb, pdx->udev, pdx->hEP[io->endpoint], kbuf,
472 len, piusb_write_bulk_callback, pdx);
473 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
474 err = usb_submit_urb(urb, GFP_KERNEL);
475 if (err) {
476 dev_err(&pdx->udev->dev,
477 "WRITE ERROR:submit urb error = %d\n", err);
478 }
479 pdx->pendingWrite = 1;
480 usb_free_urb(urb);
481 }
482 return -EINPROGRESS;
483}
484
485static int UnMapUserBuffer(struct device_extension *pdx)
486{
487 int i = 0;
488 int k = 0;
489 unsigned int epAddr;
Richard Genoudf2d46e22009-05-17 13:06:30 +0200490
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700491 for (k = 0; k < pdx->num_frames; k++) {
492 dbg("Killing Urbs for Frame %d", k);
493 for (i = 0; i < pdx->sgEntries[k]; i++) {
494 usb_kill_urb(pdx->PixelUrb[k][i]);
495 usb_free_urb(pdx->PixelUrb[k][i]);
496 pdx->pendedPixelUrbs[k][i] = 0;
497 }
498 dbg("Urb error count = %d", errCnt);
499 errCnt = 0;
500 dbg("Urbs free'd and Killed for Frame %d", k);
501 }
502
503 for (k = 0; k < pdx->num_frames; k++) {
Richard Genoudf2d46e22009-05-17 13:06:30 +0200504 if (pdx->iama == PIXIS_PID)
505 /* which EP should we map this frame to ? */
506 /* PONG, odd frames: hEP[3] */
507 /* PING, even frames and zero hEP[2] */
508 epAddr = (k % 2) ? pdx->hEP[3] : pdx->hEP[2];
509 else
510 /* ST133 only has 1 endpoint for Pixel data transfer */
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700511 epAddr = pdx->hEP[0];
Richard Genoudf2d46e22009-05-17 13:06:30 +0200512
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700513 usb_buffer_unmap_sg(pdx->udev, epAddr, pdx->sgl[k],
514 pdx->maplist_numPagesMapped[k]);
Richard Genoudf2d46e22009-05-17 13:06:30 +0200515 for (i = 0; i < pdx->maplist_numPagesMapped[k]; i++)
vibi sreenivasan8d2db512009-06-04 20:56:45 +0530516 page_cache_release(sg_page(&pdx->sgl[k][i]));
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700517 kfree(pdx->sgl[k]);
518 kfree(pdx->PixelUrb[k]);
519 kfree(pdx->pendedPixelUrbs[k]);
520 pdx->sgl[k] = NULL;
521 pdx->PixelUrb[k] = NULL;
522 pdx->pendedPixelUrbs[k] = NULL;
523 }
Richard Genoudf2d46e22009-05-17 13:06:30 +0200524
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700525 kfree(pdx->sgEntries);
526 vfree(pdx->maplist_numPagesMapped);
527 pdx->sgEntries = NULL;
528 pdx->maplist_numPagesMapped = NULL;
529 kfree(pdx->sgl);
530 kfree(pdx->pendedPixelUrbs);
531 kfree(pdx->PixelUrb);
532 pdx->sgl = NULL;
533 pdx->pendedPixelUrbs = NULL;
534 pdx->PixelUrb = NULL;
Richard Genoudf2d46e22009-05-17 13:06:30 +0200535
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700536 return 0;
537}
538
539static void piusb_readPIXEL_callback(struct urb *urb)
540{
541 int i = 0;
542 struct device_extension *pdx = urb->context;
543 int status = urb->status;
544
545 if (status && !(status == -ENOENT || status == -ECONNRESET)) {
546 dbg("%s - nonzero read bulk status received: %d", __func__,
547 status);
548 dbg("Error in read EP2 callback");
549 dbg("FrameIndex = %d", pdx->frameIdx);
550 dbg("Bytes received before problem occurred = %d",
551 pdx->bulk_in_byte_trk);
552 dbg("Urb Idx = %d", pdx->urbIdx);
553 pdx->pendedPixelUrbs[pdx->frameIdx][pdx->urbIdx] = 0;
554 } else {
555 pdx->bulk_in_byte_trk += urb->actual_length;
Richard Genoudf2d46e22009-05-17 13:06:30 +0200556 i = usb_submit_urb(urb, GFP_ATOMIC); /* resubmit the URB */
557 if (i) {
558 errCnt++;
559 if (i != lastErr) {
560 dbg("submit urb in callback failed "
561 "with error code %d", i);
562 lastErr = i;
563 }
564 } else {
565 pdx->urbIdx++; /* point to next URB when we callback */
566 if (pdx->bulk_in_byte_trk >= pdx->frameSize) {
567 pdx->bulk_in_size_returned =
568 pdx->bulk_in_byte_trk;
569 pdx->bulk_in_byte_trk = 0;
570 pdx->gotPixelData = 1;
571 pdx->frameIdx =
572 ((pdx->frameIdx +
573 1) % pdx->num_frames);
574 pdx->urbIdx = 0;
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700575 }
576 }
577 }
578}
579
580/* MapUserBuffer(
581 inputs:
Richard Genoudf2d46e22009-05-17 13:06:30 +0200582 struct ioctl_struct *io - structure containing user address,
583 frame #, and size
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700584 struct device_extension *pdx - the PIUSB device extension
Richard Genoudf2d46e22009-05-17 13:06:30 +0200585
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700586 returns:
587 int - status of the task
Richard Genoudf2d46e22009-05-17 13:06:30 +0200588
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700589 Notes:
Richard Genoudf2d46e22009-05-17 13:06:30 +0200590 MapUserBuffer maps a buffer passed down through an ioctl.
591 The user buffer is Page Aligned by the app and then passed down.
592 The function get_free_pages(...) does the actual mapping of the buffer
593 from user space to kernel space.
594 From there a scatterlist is created from all the pages.
595 The next function called is to usb_buffer_map_sg which allocated
596 DMA addresses for each page, even coalescing them if possible.
597 The DMA address is placed in the scatterlist structure.
598 The function returns the number of DMA addresses.
599 This may or may not be equal to the number of pages that
600 the user buffer uses.
601 We then build an URB for each DMA address and then submit them.
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700602*/
Richard Genoudf2d46e22009-05-17 13:06:30 +0200603
604/*
605int MapUserBuffer(unsigned long uaddr, unsigned long numbytes,
606 unsigned long frameInfo, struct device_extension *pdx)
607*/
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700608static int MapUserBuffer(struct ioctl_struct *io, struct device_extension *pdx)
609{
610 unsigned long uaddr;
611 unsigned long numbytes;
Richard Genoudf2d46e22009-05-17 13:06:30 +0200612 int frameInfo; /* which frame we're mapping */
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700613 unsigned int epAddr = 0;
614 unsigned long count = 0;
615 int i = 0;
616 int k = 0;
617 int err = 0;
618 struct page **maplist_p;
619 int numPagesRequired;
Richard Genoudf2d46e22009-05-17 13:06:30 +0200620
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700621 frameInfo = io->numFrames;
622 uaddr = (unsigned long)io->pData;
623 numbytes = io->numbytes;
624
Richard Genoudf2d46e22009-05-17 13:06:30 +0200625 if (pdx->iama == PIXIS_PID) {
626 /* which EP should we map this frame to ? */
627 /* PONG, odd frames: hEP[3] */
628 /* PING, even frames and zero hEP[2] */
629 epAddr = (frameInfo % 2) ? pdx->hEP[3] : pdx->hEP[2];
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700630 dbg("Pixis Frame #%d: EP=%d", frameInfo,
631 (epAddr == pdx->hEP[2]) ? 2 : 4);
Richard Genoudf2d46e22009-05-17 13:06:30 +0200632 } else { /* ST133 only has 1 endpoint for Pixel data transfer */
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700633 epAddr = pdx->hEP[0];
634 dbg("ST133 Frame #%d: EP=2", frameInfo);
635 }
636 count = numbytes;
637 dbg("UserAddress = 0x%08lX", uaddr);
638 dbg("numbytes = %d", (int)numbytes);
Richard Genoudf2d46e22009-05-17 13:06:30 +0200639
640 /* number of pages to map the entire user space DMA buffer */
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700641 numPagesRequired =
642 ((uaddr & ~PAGE_MASK) + count + ~PAGE_MASK) >> PAGE_SHIFT;
643 dbg("Number of pages needed = %d", numPagesRequired);
Richard Genoudf2d46e22009-05-17 13:06:30 +0200644 maplist_p = vmalloc(numPagesRequired * sizeof(struct page));
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700645 if (!maplist_p) {
646 dbg("Can't Allocate Memory for maplist_p");
647 return -ENOMEM;
648 }
Richard Genoudf2d46e22009-05-17 13:06:30 +0200649
650 /* map the user buffer to kernel memory */
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700651 down_write(&current->mm->mmap_sem);
Richard Genoudf2d46e22009-05-17 13:06:30 +0200652 pdx->maplist_numPagesMapped[frameInfo] = get_user_pages(current,
653 current->mm, (uaddr & PAGE_MASK), numPagesRequired,
654 WRITE, 0 /* Don't Force*/, maplist_p, NULL);
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700655 up_write(&current->mm->mmap_sem);
656 dbg("Number of pages mapped = %d",
657 pdx->maplist_numPagesMapped[frameInfo]);
Richard Genoudf2d46e22009-05-17 13:06:30 +0200658
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700659 for (i = 0; i < pdx->maplist_numPagesMapped[frameInfo]; i++)
660 flush_dcache_page(maplist_p[i]);
661 if (!pdx->maplist_numPagesMapped[frameInfo]) {
662 dbg("get_user_pages() failed");
663 vfree(maplist_p);
664 return -ENOMEM;
665 }
Richard Genoudf2d46e22009-05-17 13:06:30 +0200666
667 /* need to create a scatterlist that spans each frame
668 * that can fit into the mapped buffer
669 */
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700670 pdx->sgl[frameInfo] =
671 kmalloc((pdx->maplist_numPagesMapped[frameInfo] *
672 sizeof(struct scatterlist)), GFP_ATOMIC);
673 if (!pdx->sgl[frameInfo]) {
674 vfree(maplist_p);
675 dbg("can't allocate mem for sgl");
676 return -ENOMEM;
677 }
vibi sreenivasan8d2db512009-06-04 20:56:45 +0530678 sg_assign_page(&pdx->sgl[frameInfo][0], maplist_p[0]);
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700679 pdx->sgl[frameInfo][0].offset = uaddr & ~PAGE_MASK;
680 if (pdx->maplist_numPagesMapped[frameInfo] > 1) {
681 pdx->sgl[frameInfo][0].length =
682 PAGE_SIZE - pdx->sgl[frameInfo][0].offset;
683 count -= pdx->sgl[frameInfo][0].length;
684 for (k = 1; k < pdx->maplist_numPagesMapped[frameInfo]; k++) {
685 pdx->sgl[frameInfo][k].offset = 0;
vibi sreenivasan8d2db512009-06-04 20:56:45 +0530686 sg_assign_page(&pdx->sgl[frameInfo][k], maplist_p[k]);
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700687 pdx->sgl[frameInfo][k].length =
688 (count < PAGE_SIZE) ? count : PAGE_SIZE;
Richard Genoudf2d46e22009-05-17 13:06:30 +0200689 count -= PAGE_SIZE; /* example had PAGE_SIZE here */
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700690 }
691 } else {
692 pdx->sgl[frameInfo][0].length = count;
693 }
694 pdx->sgEntries[frameInfo] =
695 usb_buffer_map_sg(pdx->udev, epAddr, pdx->sgl[frameInfo],
696 pdx->maplist_numPagesMapped[frameInfo]);
697 dbg("number of sgEntries = %d", pdx->sgEntries[frameInfo]);
698 pdx->userBufMapped = 1;
699 vfree(maplist_p);
Richard Genoudf2d46e22009-05-17 13:06:30 +0200700
701 /* Create and Send the URB's for each s/g entry */
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700702 pdx->PixelUrb[frameInfo] =
703 kmalloc(pdx->sgEntries[frameInfo] * sizeof(struct urb *),
704 GFP_KERNEL);
705 if (!pdx->PixelUrb[frameInfo]) {
706 dbg("Can't Allocate Memory for Urb");
707 return -ENOMEM;
708 }
709 for (i = 0; i < pdx->sgEntries[frameInfo]; i++) {
Richard Genoudf2d46e22009-05-17 13:06:30 +0200710 /* 0 iso packets because we're using BULK transfers */
711 pdx->PixelUrb[frameInfo][i] = usb_alloc_urb(0, GFP_KERNEL);
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700712 usb_fill_bulk_urb(pdx->PixelUrb[frameInfo][i],
713 pdx->udev,
714 epAddr,
715 (dma_addr_t *) sg_dma_address(&pdx->
716 sgl[frameInfo]
717 [i]),
718 sg_dma_len(&pdx->sgl[frameInfo][i]),
719 piusb_readPIXEL_callback, (void *)pdx);
720 pdx->PixelUrb[frameInfo][i]->transfer_dma =
721 sg_dma_address(&pdx->sgl[frameInfo][i]);
722 pdx->PixelUrb[frameInfo][i]->transfer_flags =
723 URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT;
724 }
Richard Genoudf2d46e22009-05-17 13:06:30 +0200725 /* only interrupt when last URB completes */
726 pdx->PixelUrb[frameInfo][--i]->transfer_flags &= ~URB_NO_INTERRUPT;
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700727 pdx->pendedPixelUrbs[frameInfo] =
728 kmalloc((pdx->sgEntries[frameInfo] * sizeof(char)), GFP_KERNEL);
729 if (!pdx->pendedPixelUrbs[frameInfo])
730 dbg("Can't allocate Memory for pendedPixelUrbs");
731 for (i = 0; i < pdx->sgEntries[frameInfo]; i++) {
732 err = usb_submit_urb(pdx->PixelUrb[frameInfo][i], GFP_ATOMIC);
733 if (err) {
734 dbg("%s %d\n", "submit urb error =", err);
735 pdx->pendedPixelUrbs[frameInfo][i] = 0;
736 return err;
Richard Genoudf2d46e22009-05-17 13:06:30 +0200737 }
738 pdx->pendedPixelUrbs[frameInfo][i] = 1;
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700739 }
740 return 0;
741}
742
Richard Genoudf2d46e22009-05-17 13:06:30 +0200743static const struct file_operations piusb_fops = {
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700744 .owner = THIS_MODULE,
745 .ioctl = piusb_ioctl,
746 .open = piusb_open,
747 .release = piusb_release,
748};
749
750static struct usb_class_driver piusb_class = {
751 .name = "usb/rspiusb%d",
752 .fops = &piusb_fops,
753 .minor_base = PIUSB_MINOR_BASE,
754};
755
756/**
757 * piusb_probe
758 *
759 * Called by the usb core when a new device is connected that it thinks
760 * this driver might be interested in.
761 */
762static int piusb_probe(struct usb_interface *interface,
763 const struct usb_device_id *id)
764{
765 struct device_extension *pdx = NULL;
766 struct usb_host_interface *iface_desc;
767 struct usb_endpoint_descriptor *endpoint;
768 int i;
769 int retval = -ENOMEM;
770
771 dev_dbg(&interface->dev, "%s - Looking for PI USB Hardware", __func__);
772
773 pdx = kzalloc(sizeof(struct device_extension), GFP_KERNEL);
774 if (pdx == NULL) {
775 dev_err(&interface->dev, "Out of memory\n");
776 goto error;
777 }
778 kref_init(&pdx->kref);
779 pdx->udev = usb_get_dev(interface_to_usbdev(interface));
780 pdx->interface = interface;
781 iface_desc = interface->cur_altsetting;
782
783 /* See if the device offered us matches what we can accept */
784 if ((pdx->udev->descriptor.idVendor != VENDOR_ID)
785 || ((pdx->udev->descriptor.idProduct != PIXIS_PID)
Richard Genoudf2d46e22009-05-17 13:06:30 +0200786 && (pdx->udev->descriptor.idProduct != ST133_PID)))
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700787 return -ENODEV;
Richard Genoudf2d46e22009-05-17 13:06:30 +0200788
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700789 pdx->iama = pdx->udev->descriptor.idProduct;
790
791 if (debug) {
792 if (pdx->udev->descriptor.idProduct == PIXIS_PID)
793 dbg("PIUSB:Pixis Camera Found");
794 else
795 dbg("PIUSB:ST133 USB Controller Found");
796 if (pdx->udev->speed == USB_SPEED_HIGH)
797 dbg("Highspeed(USB2.0) Device Attached");
798 else
799 dbg("Lowspeed (USB1.1) Device Attached");
800
801 dbg("NumEndpoints in Configuration: %d",
802 iface_desc->desc.bNumEndpoints);
803 }
804 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
805 endpoint = &iface_desc->endpoint[i].desc;
806 if (debug) {
807 dbg("Endpoint[%d]->bDescriptorType = %d", i,
808 endpoint->bDescriptorType);
809 dbg("Endpoint[%d]->bEndpointAddress = 0x%02X", i,
810 endpoint->bEndpointAddress);
811 dbg("Endpoint[%d]->bbmAttributes = %d", i,
812 endpoint->bmAttributes);
813 dbg("Endpoint[%d]->MaxPacketSize = %d\n", i,
814 endpoint->wMaxPacketSize);
815 }
Julia Lawallc62d8432008-12-29 11:21:52 +0100816 if (usb_endpoint_xfer_bulk(endpoint)) {
817 if (usb_endpoint_dir_in(endpoint))
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700818 pdx->hEP[i] =
819 usb_rcvbulkpipe(pdx->udev,
820 endpoint->bEndpointAddress);
821 else
822 pdx->hEP[i] =
823 usb_sndbulkpipe(pdx->udev,
824 endpoint->bEndpointAddress);
825 }
826 }
827 usb_set_intfdata(interface, pdx);
828 retval = usb_register_dev(interface, &piusb_class);
829 if (retval) {
830 err("Not able to get a minor for this device.");
831 usb_set_intfdata(interface, NULL);
832 goto error;
833 }
834 pdx->present = 1;
835
836 /* we can register the device now, as it is ready */
837 pdx->minor = interface->minor;
838 /* let the user know what node this device is now attached to */
839 dbg("PI USB2.0 device now attached to piusb-%d", pdx->minor);
840 return 0;
841
Richard Genoudf2d46e22009-05-17 13:06:30 +0200842error:
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700843 if (pdx)
844 kref_put(&pdx->kref, piusb_delete);
845 return retval;
846}
847
848/**
849 * piusb_disconnect
850 *
851 * Called by the usb core when the device is removed from the system.
852 *
853 * This routine guarantees that the driver will not submit any more urbs
854 * by clearing pdx->udev. It is also supposed to terminate any currently
855 * active urbs. Unfortunately, usb_bulk_msg(), used in piusb_read(), does
856 * not provide any way to do this. But at least we can cancel an active
857 * write.
858 */
859static void piusb_disconnect(struct usb_interface *interface)
860{
861 struct device_extension *pdx;
862 int minor = interface->minor;
Richard Genoudf2d46e22009-05-17 13:06:30 +0200863
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700864 lock_kernel();
Richard Genoudf2d46e22009-05-17 13:06:30 +0200865
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700866 pdx = usb_get_intfdata(interface);
867 usb_set_intfdata(interface, NULL);
Richard Genoudf2d46e22009-05-17 13:06:30 +0200868
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700869 /* give back our minor */
870 usb_deregister_dev(interface, &piusb_class);
Richard Genoudf2d46e22009-05-17 13:06:30 +0200871
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700872 unlock_kernel();
Richard Genoudf2d46e22009-05-17 13:06:30 +0200873
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700874 /* prevent device read, write and ioctl */
875 pdx->present = 0;
876 kref_put(&pdx->kref, piusb_delete);
877 dbg("PI USB2.0 device #%d now disconnected\n", minor);
878}
879
880static struct usb_driver piusb_driver = {
881 .name = "sub",
882 .probe = piusb_probe,
883 .disconnect = piusb_disconnect,
884 .id_table = pi_device_table,
885};
886
887/**
888 * piusb_init
889 */
890static int __init piusb_init(void)
891{
892 int result;
Richard Genoudf2d46e22009-05-17 13:06:30 +0200893
894 lastErr = 0;
895 errCnt = 0;
896
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700897 /* register this driver with the USB subsystem */
898 result = usb_register(&piusb_driver);
Richard Genoudf2d46e22009-05-17 13:06:30 +0200899 if (result)
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700900 printk(KERN_ERR KBUILD_MODNAME
Richard Genoudf2d46e22009-05-17 13:06:30 +0200901 ": usb_register failed. Error number %d\n",
902 result);
903 else
904 printk(KERN_INFO KBUILD_MODNAME ":%s: %s\n", DRIVER_DESC,
905 DRIVER_VERSION);
906 return result;
Greg Kroah-Hartman28397ff2008-08-21 14:04:55 -0700907}
908
909/**
910 * piusb_exit
911 */
912static void __exit piusb_exit(void)
913{
914 /* deregister this driver with the USB subsystem */
915 usb_deregister(&piusb_driver);
916}
917
918module_init(piusb_init);
919module_exit(piusb_exit);
920
921/* Module parameters */
922module_param(debug, int, 0);
923MODULE_PARM_DESC(debug, "Debug enabled or not");
924
925MODULE_AUTHOR(DRIVER_AUTHOR);
926MODULE_DESCRIPTION(DRIVER_DESC);
927MODULE_LICENSE("GPL v2");