]> git.neil.brown.name Git - history.git/commitdiff
v2.5.0.7 -> v2.5.0.8
authorLinus Torvalds <torvalds@athlon.transmeta.com>
Tue, 5 Feb 2002 07:58:35 +0000 (23:58 -0800)
committerLinus Torvalds <torvalds@athlon.transmeta.com>
Tue, 5 Feb 2002 07:58:35 +0000 (23:58 -0800)
- Greg KH: USB updates
- Jens Axboe: more bio updates
- Christoph Rohland: fix up proper shmat semantics

80 files changed:
Documentation/usb/error-codes.txt
Documentation/usb/scanner.txt
Makefile
arch/i386/defconfig
drivers/block/DAC960.c
drivers/block/block_ioctl.c
drivers/block/cciss.c
drivers/block/cpqarray.c
drivers/block/genhd.c
drivers/block/ll_rw_blk.c
drivers/block/nbd.c
drivers/block/xd.c
drivers/cdrom/sbpcd.c
drivers/ide/ide-cd.c
drivers/ide/ide-cd.h
drivers/isdn/hisax/st5481_b.c
drivers/isdn/hisax/st5481_d.c
drivers/isdn/hisax/st5481_usb.c
drivers/message/i2o/i2o_block.c
drivers/net/irda/irda-usb.c
drivers/s390/block/dasd.c
drivers/s390/block/xpram.c
drivers/s390/char/tapeblock.c
drivers/sbus/char/jsflash.c
drivers/scsi/ide-scsi.c
drivers/scsi/imm.c
drivers/scsi/scsi.c
drivers/scsi/scsi_lib.c
drivers/scsi/sd.c
drivers/usb/CDCEther.c
drivers/usb/Config.in
drivers/usb/audio.c
drivers/usb/bluetooth.c
drivers/usb/dc2xx.c
drivers/usb/devices.c
drivers/usb/devio.c
drivers/usb/hid-core.c
drivers/usb/hid.h
drivers/usb/inode.c
drivers/usb/kaweth.c
drivers/usb/mdc800.c
drivers/usb/pegasus.c
drivers/usb/pegasus.h
drivers/usb/rio500.c
drivers/usb/scanner.c
drivers/usb/scanner.h
drivers/usb/serial/belkin_sa.c
drivers/usb/serial/cyberjack.c
drivers/usb/serial/digi_acceleport.c
drivers/usb/serial/empeg.c
drivers/usb/serial/ftdi_sio.c
drivers/usb/serial/io_edgeport.c
drivers/usb/serial/ir-usb.c
drivers/usb/serial/keyspan.c
drivers/usb/serial/keyspan_pda.c
drivers/usb/serial/mct_u232.c
drivers/usb/serial/mct_u232.h
drivers/usb/serial/omninet.c
drivers/usb/serial/pl2303.c
drivers/usb/serial/usb-serial.h
drivers/usb/serial/usbserial.c
drivers/usb/serial/visor.c
drivers/usb/serial/whiteheat.c
drivers/usb/usb-ohci.c
drivers/usb/usb-ohci.h
drivers/usb/usb.c
drivers/usb/usbkbd.c
drivers/usb/usbmouse.c
drivers/usb/usbnet.c
drivers/usb/uss720.c
fs/bio.c
include/asm-alpha/page.h
include/asm-i386/page.h
include/linux/bio.h
include/linux/blk.h
include/linux/kernel.h
include/linux/usb.h
init/do_mounts.c
ipc/shm.c
mm/highmem.c

index a89dce8cc994a70f86e7c27002e062dd202cdc73..8eed59f1747693f7957b892cefeab67b5dc9f22f 100644 (file)
@@ -1,14 +1,9 @@
-Revised: 2000-Dec-05.
+Revised: 2001-Dec-06.
 
 This is the documentation of (hopefully) all possible error codes (and
 their interpretation) that can be returned from the host controller drivers 
 and from usbcore.
 
-NOTE:
-The USB_ST_* codes are deprecated and are only listed for compatibility;
-new software should use only -E* instead!
-
-
 
 **************************************************************************
 *                   Error codes returned by usb_submit_urb               *
@@ -16,7 +11,6 @@ new software should use only -E* instead!
 
 Non-USB-specific:
 
-USB_ST_NOERROR
 0              URB submission went fine
 
 -ENOMEM                no memory for allocation of internal structures 
@@ -25,12 +19,10 @@ USB-specific:
 
 -ENODEV                specified USB-device or bus doesn't exist
 
-USB_ST_REQUEST_ERROR
 -ENXIO         a control or interrupt URB is already queued to this endpoint; or
                  a bulk URB is already queued to this endpoint and
                  USB_QUEUE_BULK wasn't used (UHCI HCDs only)
 
-USB_ST_URB_INVALID_ERROR
 -EINVAL                a) Invalid transfer type specified (or not supported)
                b) Invalid interrupt interval (0<=n<256)
                c) more than one interrupt packet requested
@@ -42,12 +34,10 @@ USB_ST_URB_INVALID_ERROR
 
 -EFBIG         too much ISO frames requested (currently uhci>900)
 
-USB_ST_STALL
 -EPIPE         specified pipe-handle is already stalled
 
 -EMSGSIZE      endpoint message size is zero, do interface/alternate setting
 
-USB_ST_BANDWIDTH_ERROR
 -ENOSPC                The host controller's bandwidth is already consumed and
                this request would push it past its allowed limit.
 
@@ -60,60 +50,43 @@ USB_ST_BANDWIDTH_ERROR
 *                   or in iso_frame_desc[n].status (for ISO)             *
 **************************************************************************
 
-USB_ST_NOERROR
 0                      Transfer completed successfully
 
-USB_ST_URB_KILLED
 -ENOENT                        URB was canceled by usb_unlink_urb
 
-USB_ST_URB_PENDING
 -EINPROGRESS           URB still pending, no results yet
                        (actually no error until now;-)
 
-USB_ST_BITSTUFF
-USB_ST_INTERNALERROR
 -EPROTO                        a) bitstuff error
                        b) unknown USB error 
 
-USB_ST_CRC
 -EILSEQ                        CRC mismatch
 
-USB_ST_STALL
 -EPIPE                 endpoint stalled
 
-USB_ST_BUFFEROVERRUN
 -ECOMM                 During an IN transfer, the host controller
                        received data from an endpoint faster than it
                        could be written to system memory
 
-USB_ST_BUFFERUNDERRUN
 -ENOSR                 During an OUT transfer, the host controller
                        could not retrieve data from system memory fast
                        enough to keep up with the USB data rate
 
-USB_ST_DATAOVERRUN
 -EOVERFLOW             The amount of data returned by the endpoint was
                        greater than either the max packet size of the
                        endpoint or the remaining buffer size.  "Babble".
 
-USB_ST_DATAUNDERRUN
 -EREMOTEIO             The endpoint returned less than max packet size
                        and that amount did not fill the specified buffer
-USB_ST_NORESPONSE
-USB_ST_TIMEOUT
 -ETIMEDOUT             transfer timed out, NAK
 
-USB_ST_REMOVED 
 -ENODEV                        device was removed
 
-USB_ST_SHORT_PACKET
 -EREMOTEIO             short packet detected
 
-USB_ST_PARTIAL_ERROR
 -EXDEV                 ISO transfer only partially completed
                        look at individual frame status for details
 
-USB_ST_URB_INVALID_ERROR
 -EINVAL                        ISO madness, if this happens: Log off and go home
 
 -ECONNRESET            the URB is being unlinked asynchronously
index 5f03dd670298865e9672f4c97cc02f612bba8293..e8d6945ee14b92c362a2c2b0adb4a5ac0ebe7816 100644 (file)
@@ -83,7 +83,7 @@ If you intend to use more than one scanner at a time w/o devfs support:
        `mknod /dev/usbscanner1 c 180 49`
                       . 
                       .
-       `mknod /dev/usbscanner15 180 63`
+       `mknod /dev/usbscanner15 180 63`
 
 
 If you foresee using only one scanner it is best to:
index 6f809123df89189418de0ba86922f322af177822..8fe142a3a71b5ef2db3b74169432008e222f5a38 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 5
 SUBLEVEL = 1
-EXTRAVERSION =-pre7
+EXTRAVERSION =-pre8
 
 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 
index 8b7fe15bd824a71d95b36e346ff03ec505f7b88a..c73c7bb74f5468e25c1f9d838cbfe7bab51d0bfc 100644 (file)
@@ -496,9 +496,6 @@ CONFIG_PCMCIA_RAYCS=y
 # IrDA (infrared) support
 #
 # CONFIG_IRDA is not set
-CONFIG_IRDA_CACHE_LAST_LSAP=y
-CONFIG_IRDA_FAST_RR=y
-CONFIG_IRDA_DEBUG=y
 
 #
 # ISDN subsystem
index 20dde72f2288fcf84a0450424b504f48b3f7a1aa..55d3fbe7e7d47c372ee1160e8c8ca3d88e768ada 100644 (file)
@@ -1947,7 +1947,6 @@ static boolean DAC960_RegisterBlockDevice(DAC960_Controller_T *Controller)
   */
   RequestQueue = BLK_DEFAULT_QUEUE(MajorNumber);
   blk_init_queue(RequestQueue, DAC960_RequestFunction);
-  blk_queue_headactive(RequestQueue, 0);
   RequestQueue->queuedata = Controller;
   RequestQueue->max_segments = Controller->DriverScatterGatherLimit;
   RequestQueue->max_sectors = Controller->MaxBlocksPerCommand;
index dae22fbdd4d160b93afaae4e8f3d6fc268d31e1b..a894888483c979ca0eb1a9e030afab95b29c2651 100644 (file)
@@ -37,7 +37,7 @@ int blk_do_rq(request_queue_t *q, struct request *rq)
 
        rq->flags |= REQ_BARRIER;
        rq->waiting = &wait;
-       elv_add_request(q, rq);
+       elv_add_request(q, rq, 1);
        generic_unplug_device(q);
        wait_for_completion(&wait);
 
index e9a0648eeed5576293a1735dd7c438b3dde66597..371755761a53d64fa6675ebed03092c5e5be1a70 100644 (file)
@@ -1867,7 +1867,6 @@ static int __init cciss_init_one(struct pci_dev *pdev,
        q = BLK_DEFAULT_QUEUE(MAJOR_NR + i);
         q->queuedata = hba[i];
         blk_init_queue(q, do_cciss_request);
-        blk_queue_headactive(q, 0);            
        blk_queue_bounce_limit(q, hba[i]->pdev->dma_mask);
        blk_queue_max_segments(q, MAXSGENTRIES);
        blk_queue_max_sectors(q, 512);
index a62c9c7671ecfd4df6cbf9d4ac3396cbc8ff638e..4ff77277d51905c38b9ef69d64e85ecf821d5fb8 100644 (file)
@@ -468,7 +468,6 @@ int __init cpqarray_init(void)
                q = BLK_DEFAULT_QUEUE(MAJOR_NR + i);
                q->queuedata = hba[i];
                blk_init_queue(q, do_ida_request);
-               blk_queue_headactive(q, 0);
                blk_queue_bounce_limit(q, hba[i]->pci_dev->dma_mask);
                blk_queue_max_segments(q, SG_MAX);
                blksize_size[MAJOR_NR+i] = ida_blocksizes + (i*256);
index 5838ff5cea39844e14778aa2c1519dd51ebc4241..2ecc7c6d3f01209bc7b85cd8b5c36f3c7e177fb6 100644 (file)
@@ -149,8 +149,7 @@ get_partition_list(char *page, char **start, off_t offset, int count)
        char buf[64];
        int len, n;
 
-       len = sprintf(page, "major minor   #blocks  start_sect   nr_sects  "
-                       "name\n\n");
+       len = sprintf(page, "major minor  #blocks  name\n\n");
        read_lock(&gendisk_lock);
        for (gp = gendisk_head; gp; gp = gp->next) {
                for (n = 0; n < (gp->nr_real << gp->minor_shift); n++) {
@@ -158,10 +157,8 @@ get_partition_list(char *page, char **start, off_t offset, int count)
                                continue;
 
                        len += snprintf(page + len, 63,
-                                       "%4d  %4d %10d  %10lu %10lu  %s\n",
+                                       "%4d  %4d %10d %s\n",
                                        gp->major, n, gp->sizes[n],
-                                       gp->part[n].start_sect,
-                                       gp->part[n].nr_sects,
                                        disk_name(gp, n, buf));
                        if (len < offset)
                                offset -= len, len = 0;
index 6b92a30291c66f7c610afb1eda90fba13e26dbeb..98a96fbaa4e24cd2728167a183a3f3f39b6d294e 100644 (file)
@@ -562,6 +562,7 @@ void blk_cleanup_queue(request_queue_t * q)
 
 static int blk_init_free_list(request_queue_t *q)
 {
+       struct request_list *rl;
        struct request *rq;
        int i;
 
@@ -573,20 +574,22 @@ static int blk_init_free_list(request_queue_t *q)
        /*
         * Divide requests in half between read and write
         */
+       rl = &q->rq[READ];
        for (i = 0; i < queue_nr_requests; i++) {
                rq = kmem_cache_alloc(request_cachep, SLAB_KERNEL);
                if (!rq)
                        goto nomem;
 
+               /*
+                * half way through, switch to WRITE list
+                */
+               if (i == queue_nr_requests / 2)
+                       rl = &q->rq[WRITE];
+
                memset(rq, 0, sizeof(struct request));
                rq->rq_status = RQ_INACTIVE;
-               if (i < queue_nr_requests >> 1) {
-                       list_add(&rq->queuelist, &q->rq[READ].free);
-                       q->rq[READ].count++;
-               } else {
-                       list_add(&rq->queuelist, &q->rq[WRITE].free);
-                       q->rq[WRITE].count++;
-               }
+               list_add(&rq->queuelist, &rl->free);
+               rl->count++;
        }
 
        init_waitqueue_head(&q->rq[READ].wait);
@@ -692,21 +695,22 @@ static inline struct request *get_request(request_queue_t *q, int rw)
 static struct request *get_request_wait(request_queue_t *q, int rw)
 {
        DECLARE_WAITQUEUE(wait, current);
+       struct request_list *rl = &q->rq[rw];
        struct request *rq;
 
        spin_lock_prefetch(&q->queue_lock);
 
        generic_unplug_device(q);
-       add_wait_queue(&q->rq[rw].wait, &wait);
+       add_wait_queue(&rl->wait, &wait);
        do {
                set_current_state(TASK_UNINTERRUPTIBLE);
-               if (q->rq[rw].count < batch_requests)
+               if (rl->count < batch_requests)
                        schedule();
                spin_lock_irq(&q->queue_lock);
                rq = get_request(q, rw);
                spin_unlock_irq(&q->queue_lock);
        } while (rq == NULL);
-       remove_wait_queue(&q->rq[rw].wait, &wait);
+       remove_wait_queue(&rl->wait, &wait);
        current->state = TASK_RUNNING;
        return rq;
 }
@@ -1234,7 +1238,6 @@ int submit_bio(int rw, struct bio *bio)
         */
        BUG_ON(!bio->bi_end_io);
 
-       BIO_BUG_ON(bio_offset(bio) > PAGE_SIZE);
        BIO_BUG_ON(!bio->bi_size);
        BIO_BUG_ON(!bio->bi_io_vec);
 
@@ -1397,6 +1400,28 @@ sorry:
 extern int stram_device_init (void);
 #endif
 
+inline void blk_recalc_request(struct request *rq, int nsect)
+{
+       rq->hard_sector += nsect;
+       rq->hard_nr_sectors -= nsect;
+       rq->sector = rq->hard_sector;
+       rq->nr_sectors = rq->hard_nr_sectors;
+
+       rq->current_nr_sectors = bio_iovec(rq->bio)->bv_len >> 9;
+       rq->hard_cur_sectors = rq->current_nr_sectors;
+
+       /*
+        * if total number of sectors is less than the first segment
+        * size, something has gone terribly wrong
+        */
+       if (rq->nr_sectors < rq->current_nr_sectors) {
+               printk("blk: request botched\n");
+               rq->nr_sectors = rq->current_nr_sectors;
+       }
+
+       rq->buffer = bio_data(rq->bio);
+}
+
 /**
  * end_that_request_first - end I/O on one buffer.
  * @req:      the request being processed
@@ -1414,53 +1439,55 @@ extern int stram_device_init (void);
 
 int end_that_request_first(struct request *req, int uptodate, int nr_sectors)
 {
-       struct bio *bio, *nxt;
-       int nsect, total_nsect = 0;
+       int nsect, total_nsect;
+       struct bio *bio;
 
        req->errors = 0;
        if (!uptodate)
                printk("end_request: I/O error, dev %s, sector %lu\n",
                        kdevname(req->rq_dev), req->sector);
 
-       if ((bio = req->bio) != NULL) {
-next_chunk:
+       total_nsect = 0;
+       while ((bio = req->bio)) {
                nsect = bio_iovec(bio)->bv_len >> 9;
 
+               bio->bi_size -= bio_iovec(bio)->bv_len;
+
+               /*
+                * not a complete bvec done
+                */
+               if (unlikely(nsect > nr_sectors)) {
+                       int residual = (nsect - nr_sectors) << 9;
+
+                       bio_iovec(bio)->bv_offset += residual;
+                       bio_iovec(bio)->bv_len -= residual;
+                       blk_recalc_request(req, nr_sectors);
+                       return 1;
+               }
+
                nr_sectors -= nsect;
                total_nsect += nsect;
 
                if (++bio->bi_idx >= bio->bi_vcnt) {
-                       nxt = bio->bi_next;
-                       if (!bio_endio(bio, uptodate, total_nsect)) {
-                               total_nsect = 0;
-                               req->bio = nxt;
-                       } else
+                       req->bio = bio->bi_next;
+
+                       if (unlikely(bio_endio(bio, uptodate, total_nsect)))
                                BUG();
+
+                       total_nsect = 0;
                }
 
-               if ((bio = req->bio) != NULL) {
-                       req->hard_sector += nsect;
-                       req->hard_nr_sectors -= nsect;
-                       req->sector = req->hard_sector;
-                       req->nr_sectors = req->hard_nr_sectors;
-
-                       req->current_nr_sectors = bio_iovec(bio)->bv_len >> 9;
-                       req->hard_cur_sectors = req->current_nr_sectors;
-                       if (req->nr_sectors < req->current_nr_sectors) {
-                               printk("end_request: buffer-list destroyed\n");
-                               req->nr_sectors = req->current_nr_sectors;
-                       }
+               if ((bio = req->bio)) {
+                       blk_recalc_request(req, nsect);
 
-                       req->buffer = bio_data(bio);
                        /*
                         * end more in this run, or just return 'not-done'
                         */
-                       if (nr_sectors > 0)
-                               goto next_chunk;
-
-                       return 1;
+                       if (unlikely(nr_sectors <= 0))
+                               return 1;
                }
        }
+
        return 0;
 }
 
@@ -1544,3 +1571,4 @@ EXPORT_SYMBOL(blk_queue_hardsect_size);
 EXPORT_SYMBOL(blk_rq_map_sg);
 EXPORT_SYMBOL(blk_nohighio);
 EXPORT_SYMBOL(blk_dump_rq_flags);
+EXPORT_SYMBOL(submit_bio);
index acabd014f969479a8f8bc3bc6010e9757a0beb2b..22e5b4a60718fc992d18127fedaf5b4f094a4525 100644 (file)
@@ -516,7 +516,6 @@ static int __init nbd_init(void)
        blksize_size[MAJOR_NR] = nbd_blksizes;
        blk_size[MAJOR_NR] = nbd_sizes;
        blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), do_nbd_request);
-       blk_queue_headactive(BLK_DEFAULT_QUEUE(MAJOR_NR), 0);
        for (i = 0; i < MAX_NBD; i++) {
                nbd_dev[i].refcnt = 0;
                nbd_dev[i].file = NULL;
index 3c7fdc4a2d5acee6f26cf6066ad900ff16e41136..4357b317b28c4a4555940421bf801cb1440c1ac9 100644 (file)
@@ -121,7 +121,6 @@ static unsigned int xd_bases[] __initdata =
 static struct hd_struct xd_struct[XD_MAXDRIVES << 6];
 static int xd_sizes[XD_MAXDRIVES << 6], xd_access[XD_MAXDRIVES];
 static int xd_blocksizes[XD_MAXDRIVES << 6];
-static int xd_maxsect[XD_MAXDRIVES << 6];
 
 extern struct block_device_operations xd_fops;
 
@@ -246,8 +245,7 @@ static void __init xd_geninit (void)
        }
 
        /* xd_maxsectors depends on controller - so set after detection */
-       for(i=0; i<(XD_MAXDRIVES << 6); i++) xd_maxsect[i] = xd_maxsectors;
-       max_sectors[MAJOR_NR] = xd_maxsect;
+       blk_queue_max_sectors(BLK_DEFAULT_QUEUE(MAJOR_NR), xd_maxsectors);
 
        for (i = 0; i < xd_drives; i++) {
                xd_valid[i] = 1;
@@ -294,11 +292,11 @@ static void do_xd_request (request_queue_t * q)
                        block = CURRENT->sector;
                        count = CURRENT->nr_sectors;
 
-                       switch (CURRENT->cmd) {
+                       switch (rq_data_dir(CURRENT)) {
                                case READ:
                                case WRITE:
                                        for (retry = 0; (retry < XD_RETRIES) && !code; retry++)
-                                               code = xd_readwrite(CURRENT->cmd,CURRENT_DEV,CURRENT->buffer,block,count);
+                                               code = xd_readwrite(rq_data_dir(CURRENT),CURRENT_DEV,CURRENT->buffer,block,count);
                                        break;
                                default:
                                        printk("do_xd_request: unknown request\n");
index 2de5d498d7172ab47ab49ed2f6c35e0dd9399963..b79c01f8b6dda4db78c4f6905c7fcf11b30b5665 100644 (file)
@@ -5870,7 +5870,6 @@ int __init SBPCD_INIT(void)
        (BLK_DEFAULT_QUEUE(MAJOR_NR))->front_merge_fn = dont_bh_merge_fn;
        (BLK_DEFAULT_QUEUE(MAJOR_NR))->merge_requests_fn = dont_merge_requests_fn;
 #endif
-       blk_queue_headactive(BLK_DEFAULT_QUEUE(MAJOR_NR), 0);
        read_ahead[MAJOR_NR] = buffers * (CD_FRAMESIZE / 512);
        
        request_region(CDo_command,4,major_name);
index f4729ef8408d54b555fcbce13fc7d29a83e2e8aa..6046904e3e4b861ec21baf4b3ec676c06f539c7d 100644 (file)
@@ -1615,7 +1615,7 @@ static ide_startstop_t cdrom_start_write(ide_drive_t *drive, struct request *rq)
 /*
  * just wrap this around cdrom_do_packet_command
  */
-static int cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
+static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
 {
        struct packet_command pc;
        ide_startstop_t startstop;
@@ -2145,7 +2145,8 @@ static int ide_cdrom_packet(struct cdrom_device_info *cdi,
        pc.timeout = cgc->timeout;
        pc.sense = cgc->sense;
        cgc->stat = cdrom_queue_packet_command(drive, &pc);
-       cgc->buflen -= pc.buflen;
+       if (!cgc->stat)
+               cgc->buflen -= pc.buflen;
        return cgc->stat;
 }
 
index ea0ae0024bc79fcecb500ff75986720abcd9b2f4..9a5de53a6527dde3b0df85de19939ef978de74f9 100644 (file)
@@ -435,7 +435,7 @@ struct atapi_mechstat_header {
 
        byte     curlba[3];
        byte     nslots;
-       __u16 short slot_tablelen;
+       __u16 slot_tablelen;
 };
 
 
index 0aa033579d6f9f700db0ba085aed0d4acc32640d..06670d18003f46859aaf8b15b367470b21cd9e6f 100644 (file)
@@ -168,7 +168,7 @@ static void usb_b_out_complete(struct urb *urb)
        test_and_clear_bit(buf_nr, &b_out->busy);
 
        if (urb->status < 0) {
-               if (urb->status != USB_ST_URB_KILLED) {
+               if (urb->status != -ENOENT) {
                        WARN("urb status %d",urb->status);
                        if (b_out->busy == 0) {
                                st5481_usb_pipe_reset(adapter, (bcs->channel+1)*2 | USB_DIR_OUT, NULL, NULL);
index 1079bae6eacd7b9d9d2971e1c882d5dad2e10db7..b0b3d06627395e814f01e1723d2119911ba576b6 100644 (file)
@@ -382,7 +382,7 @@ static void usb_d_out_complete(struct urb *urb)
        test_and_clear_bit(buf_nr, &d_out->busy);
 
        if (urb->status < 0) {
-               if (urb->status != USB_ST_URB_KILLED) {
+               if (urb->status != -ENOENT) {
                        WARN("urb status %d",urb->status);
                        if (d_out->busy == 0) {
                                st5481_usb_pipe_reset(adapter, EP_D_OUT | USB_DIR_OUT, fifo_reseted, adapter);
index a3098071f451f28374c5719333894ffb6fa815a2..902b6be6bd1a54994758bd02cbaaeccc383057c1 100644 (file)
@@ -130,7 +130,7 @@ static void usb_ctrl_complete(struct urb *urb)
        struct ctrl_msg *ctrl_msg;
        
        if (urb->status < 0) {
-               if (urb->status != USB_ST_URB_KILLED) {
+               if (urb->status != -ENOENT) {
                        WARN("urb status %d",urb->status);
                } else {
                        DBG(1,"urb killed");
@@ -184,7 +184,7 @@ static void usb_int_complete(struct urb *urb)
        int j;
 
        if (urb->status < 0) {
-               if (urb->status != USB_ST_URB_KILLED) {
+               if (urb->status != -ENOENT) {
                        WARN("urb status %d",urb->status);
                        urb->actual_length = 0;
                } else {
@@ -470,7 +470,7 @@ static void usb_in_complete(struct urb *urb)
        int len, count, status;
 
        if (urb->status < 0) {
-               if (urb->status != USB_ST_URB_KILLED) {
+               if (urb->status != -ENOENT) {
                        WARN("urb status %d",urb->status);
                } else {
                        DBG(1,"urb killed");
index 1d112a2001f4a2d4eaf30cdbff326c84573b0701..bdf52592bd26b17d49519acfe7d4fc07a9009943 100644 (file)
@@ -1423,7 +1423,6 @@ static int i2ob_init_iop(unsigned int unit)
        atomic_set(&i2ob_queues[unit]->queue_depth, 0);
 
        blk_init_queue(&i2ob_queues[unit]->req_queue, i2ob_request);
-       blk_queue_headactive(&i2ob_queues[unit]->req_queue, 0);
        i2ob_queues[unit]->req_queue.queuedata = &i2ob_queues[unit];
 
        return 0;
@@ -1822,7 +1821,6 @@ int i2o_block_init(void)
        blk_dev[MAJOR_NR].queue = i2ob_get_queue;
        
        blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), i2ob_request);
-       blk_queue_headactive(BLK_DEFAULT_QUEUE(MAJOR_NR), 0);
 
        for (i = 0; i < MAX_I2OB << 4; i++) {
                i2ob_dev[i].refcnt = 0;
index 8c6fd51055d44c260ae20e50289ef5e75391f68e..60defc2ad73bc6a4c46da225acf059c4740bcc7a 100644 (file)
@@ -256,7 +256,7 @@ static void irda_usb_change_speed_xbofs(struct irda_usb_cb *self)
 
        /* Grab the speed URB */
        purb = &self->speed_urb;
-       if (purb->status != USB_ST_NOERROR) {
+       if (purb->status != 0) {
                WARNING(__FUNCTION__ "(), URB still in use!\n");
                return;
        }
@@ -301,7 +301,7 @@ static void speed_bulk_callback(purb_t purb)
        }
 
        /* Check for timeout and other USB nasties */
-       if(purb->status != USB_ST_NOERROR) {
+       if (purb->status != 0) {
                /* I get a lot of -ECONNABORTED = -103 here - Jean II */
                IRDA_DEBUG(0, __FUNCTION__ "(), URB complete status %d, transfer_flags 0x%04X\n", purb->status, purb->transfer_flags);
 
@@ -314,7 +314,7 @@ static void speed_bulk_callback(purb_t purb)
        }
 
        /* urb is now available */
-       purb->status = USB_ST_NOERROR;
+       purb->status = 0;
 
        /* If it was the speed URB, allow the stack to send more packets */
        if(purb == &self->speed_urb) {
@@ -372,7 +372,7 @@ static int irda_usb_hard_xmit(struct sk_buff *skb, struct net_device *netdev)
                }
        }
 
-       if (purb->status != USB_ST_NOERROR) {
+       if (purb->status != 0) {
                WARNING(__FUNCTION__ "(), URB still in use!\n");
                dev_kfree_skb(skb);
                return 0;
@@ -490,7 +490,7 @@ static void write_bulk_callback(purb_t purb)
        purb->context = NULL;
 
        /* Check for timeout and other USB nasties */
-       if(purb->status != USB_ST_NOERROR) {
+       if (purb->status != 0) {
                /* I get a lot of -ECONNABORTED = -103 here - Jean II */
                IRDA_DEBUG(0, __FUNCTION__ "(), URB complete status %d, transfer_flags 0x%04X\n", purb->status, purb->transfer_flags);
 
@@ -504,7 +504,7 @@ static void write_bulk_callback(purb_t purb)
        }
 
        /* urb is now available */
-       purb->status = USB_ST_NOERROR;
+       purb->status = 0;
 
        /* If the network is closed, stop everything */
        if ((!self->netopen) || (!self->present)) {
@@ -547,11 +547,11 @@ static void irda_usb_net_timeout(struct net_device *netdev)
 
        /* Check speed URB */
        purb = &(self->speed_urb);
-       if (purb->status != USB_ST_NOERROR) {
+       if (purb->status != 0) {
                IRDA_DEBUG(0, "%s: Speed change timed out, urb->status=%d, urb->transfer_flags=0x%04X\n", netdev->name, purb->status, purb->transfer_flags);
 
                switch (purb->status) {
-               case USB_ST_URB_PENDING:        /* -EINPROGRESS == -115 */
+               case -EINPROGRESS:
                        usb_unlink_urb(purb);
                        /* Note : above will  *NOT* call netif_wake_queue()
                         * in completion handler, we will come back here.
@@ -563,7 +563,7 @@ static void irda_usb_net_timeout(struct net_device *netdev)
                case -ETIMEDOUT:                /* -110 */
                case -ENOENT:                   /* -2 (urb unlinked by us)  */
                default:                        /* ??? - Play safe */
-                       purb->status = USB_ST_NOERROR;
+                       purb->status = 0;
                        netif_wake_queue(self->netdev);
                        done = 1;
                        break;
@@ -572,7 +572,7 @@ static void irda_usb_net_timeout(struct net_device *netdev)
 
        /* Check Tx URB */
        purb = &(self->tx_urb);
-       if (purb->status != USB_ST_NOERROR) {
+       if (purb->status != 0) {
                struct sk_buff *skb = purb->context;
 
                IRDA_DEBUG(0, "%s: Tx timed out, urb->status=%d, urb->transfer_flags=0x%04X\n", netdev->name, purb->status, purb->transfer_flags);
@@ -590,7 +590,7 @@ static void irda_usb_net_timeout(struct net_device *netdev)
 #endif /* IU_BUG_KICK_TIMEOUT */
 
                switch (purb->status) {
-               case USB_ST_URB_PENDING:        /* -EINPROGRESS == -115 */
+               case -EINPROGRESS:
                        usb_unlink_urb(purb);
                        /* Note : above will  *NOT* call netif_wake_queue()
                         * in completion handler, because purb->status will
@@ -610,7 +610,7 @@ static void irda_usb_net_timeout(struct net_device *netdev)
                                dev_kfree_skb_any(skb);
                                purb->context = NULL;
                        }
-                       purb->status = USB_ST_NOERROR;
+                       purb->status = 0;
                        netif_wake_queue(self->netdev);
                        done = 1;
                        break;
@@ -727,7 +727,7 @@ static void irda_usb_submit(struct irda_usb_cb *self, struct sk_buff *skb, purb_
        purb->transfer_flags = USB_QUEUE_BULK;
        /* Note : unlink *must* be synchronous because of the code in 
         * irda_usb_net_close() -> free the skb - Jean II */
-       purb->status = USB_ST_NOERROR;
+       purb->status = 0;
        purb->next = NULL;      /* Don't auto resubmit URBs */
        
        ret = usb_submit_urb(purb);
@@ -768,9 +768,9 @@ static void irda_usb_receive(purb_t purb)
        }
        
        /* Check the status */
-       if(purb->status != USB_ST_NOERROR) {
+       if (purb->status != 0) {
                switch (purb->status) {
-               case USB_ST_CRC:                /* -EILSEQ */
+               case -EILSEQ:
                        self->stats.rx_errors++;
                        self->stats.rx_crc_errors++;    
                        break;
@@ -1442,9 +1442,9 @@ static void *irda_usb_probe(struct usb_device *dev, unsigned int ifnum,
        ret = usb_set_interface(dev, ifnum, 0);
        IRDA_DEBUG(1, "usb-irda: set interface %d result %d\n", ifnum, ret);
        switch (ret) {
-               case USB_ST_NOERROR:            /* 0 */
+               case 0:
                        break;
-               case USB_ST_STALL:              /* -EPIPE = -32 */
+               case -EPIPE:            /* -EPIPE = -32 */
                        usb_clear_halt(dev, usb_sndctrlpipe(dev, 0));
                        IRDA_DEBUG(0, __FUNCTION__ "(), Clearing stall on control interface\n" );
                        break;
index 3eb554eb11d54d49253018a42dbed884f38a7898..8a0d94cf12ad99b1e6144189ccb9b8d970db9c0c 100644 (file)
@@ -3343,7 +3343,6 @@ dasd_setup_blkdev (dasd_device_t *device )
         device->request_queue = kmalloc(sizeof(request_queue_t),GFP_KERNEL);
         device->request_queue->queuedata = device;
         blk_init_queue (device->request_queue, do_dasd_request);
-        blk_queue_headactive (device->request_queue, 0);
         elevator_init (&(device->request_queue->elevator),ELEVATOR_NOOP);
 
         for (i = 0; i < (1 << DASD_PARTN_BITS); i++) {
index 383ad62166c594b5d344174efa53a8ca751c9dee..d6715d169e9d53a97b69545fae4d020c6c3df0fa 100644 (file)
@@ -1041,7 +1041,6 @@ int xpram_init(void)
 #elif (XPRAM_VERSION == 24)
        q = BLK_DEFAULT_QUEUE (major);
        blk_init_queue (q, xpram_request);
-       blk_queue_headactive (BLK_DEFAULT_QUEUE (major), 0);
 #endif /* V22/V24 */
        read_ahead[major] = xpram_rahead;
 
index 8f7ee813a5a352a4227f10cef85f6e4e3ac26b7b..133348595c71734c1c1125be0bc1864e8592172f 100644 (file)
@@ -77,7 +77,6 @@ tapeblock_setup(tape_info_t* ti) {
     blksize_size[tapeblock_major][ti->blk_minor]=2048; // blocks are 2k by default.
     hardsect_size[tapeblock_major][ti->blk_minor]=512;
     blk_init_queue (&ti->request_queue, tape_request_fn); 
-    blk_queue_headactive (&ti->request_queue, 0); 
 #ifdef CONFIG_DEVFS_FS
     tapeblock_mkdevfstree(ti);
 #endif
index 7ebbaf0641f225771b1cd449ab18e23d57fb2af7..cc42d1577e342bbe0b3926b8640fc644bfa35b9a 100644 (file)
@@ -662,7 +662,6 @@ int jsfd_init(void) {
        blk_size[JSFD_MAJOR] = jsfd_sizes;
 
        blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), DEVICE_REQUEST);
-       /* blk_queue_headactive(BLK_DEFAULT_QUEUE(MAJOR_NR), 0); */
        for (i = 0; i < JSF_MAX; i++) {
                if ((i & JSF_PART_MASK) >= JSF_NPART) continue;
                jsf = &jsf0;    /* actually, &jsfv[i >> JSF_PART_BITS] */
index 18184a2b699970ba36a50dbb05c6947d34bcd3b9..d52e503fb24d57af99313c356b378a855a707e5e 100644 (file)
@@ -429,7 +429,7 @@ static ide_startstop_t idescsi_issue_pc (ide_drive_t *drive, idescsi_pc_t *pc)
        pc->current_position=pc->buffer;
        bcount = IDE_MIN (pc->request_transfer, 63 * 1024);             /* Request to transfer the entire buffer at once */
 
-       if (drive->using_dma && rq->special)
+       if (drive->using_dma && rq->bio)
                dma_ok=!HWIF(drive)->dmaproc(test_bit (PC_WRITING, &pc->flags) ? ide_dma_write : ide_dma_read, drive);
 
        SELECT_DRIVE(HWIF(drive), drive);
index 9290a59c0f3d1814ec189a1807b34bd42104e605..933d02eb8eccedc65334158cb0f15f44d2e4d295 100644 (file)
@@ -124,11 +124,6 @@ int imm_detect(Scsi_Host_Template * host)
     int i, nhosts, try_again;
     struct parport *pb;
 
-    /*
-     * unlock to allow the lowlevel parport driver to probe
-     * the irqs
-     */
-    spin_unlock_irq(&io_request_lock);
     pb = parport_enumerate();
 
     printk("imm: Version %s\n", IMM_VERSION);
@@ -137,7 +132,6 @@ int imm_detect(Scsi_Host_Template * host)
 
     if (!pb) {
        printk("imm: parport reports no devices.\n");
-       spin_lock_irq(&io_request_lock);
        return 0;
     }
   retry_entry:
@@ -163,7 +157,6 @@ int imm_detect(Scsi_Host_Template * host)
                      "pardevice is owning the port for too longtime!\n",
                           i);
                    parport_unregister_device (imm_hosts[i].dev);
-                   spin_lock_irq(&io_request_lock);
                    return 0;
                }
            }
@@ -219,13 +212,11 @@ int imm_detect(Scsi_Host_Template * host)
     }
     if (nhosts == 0) {
        if (try_again == 1) {
-           spin_lock_irq(&io_request_lock);
            return 0;
        }
        try_again = 1;
        goto retry_entry;
     } else {
-       spin_lock_irq (&io_request_lock);
        return 1;               /* return number of hosts detected */
     }
 }
@@ -834,7 +825,7 @@ static int imm_completion(Scsi_Cmnd * cmd)
            if (cmd->SCp.buffers_residual--) {
                cmd->SCp.buffer++;
                cmd->SCp.this_residual = cmd->SCp.buffer->length;
-               cmd->SCp.ptr = cmd->SCp.buffer->address;
+               cmd->SCp.ptr = page_address(cmd->SCp.buffer->page) + cmd->SCp.buffer->offset;
 
                /*
                 * Make sure that we transfer even number of bytes
@@ -897,6 +888,7 @@ static void imm_interrupt(void *data)
 {
     imm_struct *tmp = (imm_struct *) data;
     Scsi_Cmnd *cmd = tmp->cur_cmd;
+    struct Scsi_Host *host = cmd->host;
     unsigned long flags;
 
     if (!cmd) {
@@ -948,10 +940,10 @@ static void imm_interrupt(void *data)
     if (cmd->SCp.phase > 0)
        imm_pb_release(cmd->host->unique_id);
 
-    spin_lock_irqsave(&io_request_lock, flags);
+    spin_lock_irqsave(&host->host_lock, flags);
     tmp->cur_cmd = 0;
     cmd->scsi_done(cmd);
-    spin_unlock_irqrestore(&io_request_lock, flags);
+    spin_unlock_irqrestore(&host->host_lock, flags);
     return;
 }
 
@@ -1008,7 +1000,7 @@ static int imm_engine(imm_struct * tmp, Scsi_Cmnd * cmd)
            /* if many buffers are available, start filling the first */
            cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer;
            cmd->SCp.this_residual = cmd->SCp.buffer->length;
-           cmd->SCp.ptr = cmd->SCp.buffer->address;
+           cmd->SCp.ptr = page_address(cmd->SCp.buffer->page) + cmd->SCp.buffer->offset;
        } else {
            /* else fill the only available buffer */
            cmd->SCp.buffer = NULL;
index 506f7d9ba43e1f1bd495fee9c7e3dc608f648f92..db5ec9c2703f392a12494a117ea51d92e20f9264 100644 (file)
@@ -183,7 +183,6 @@ void  scsi_initialize_queue(Scsi_Device * SDpnt, struct Scsi_Host * SHpnt)
        request_queue_t *q = &SDpnt->request_queue;
 
        blk_init_queue(q, scsi_request_fn);
-       blk_queue_headactive(q, 0);
        q->queuedata = (void *) SDpnt;
 #ifdef DMA_CHUNK_SIZE
        blk_queue_max_segments(q, 64);
@@ -231,7 +230,8 @@ static void scsi_wait_done(Scsi_Cmnd * SCpnt)
        req = &SCpnt->request;
        req->rq_status = RQ_SCSI_DONE;  /* Busy, but indicate request done */
 
-       complete(req->waiting);
+       if (req->waiting)
+               complete(req->waiting);
 }
 
 /*
index f33384ddf33bbd87b99e634b71f07af456d2ae80..a723b3404227a95555e082799a2ce7b11ceb755a 100644 (file)
@@ -72,7 +72,13 @@ static void __scsi_insert_special(request_queue_t *q, struct request *rq,
 
        ASSERT_LOCK(&q->queue_lock, 0);
 
-       rq->flags = REQ_SPECIAL | REQ_NOMERGE | REQ_BARRIER;
+       /*
+        * tell I/O scheduler that this isn't a regular read/write (ie it
+        * must not attempt merges on this) and that it acts as a soft
+        * barrier
+        */
+       rq->flags = REQ_SPECIAL | REQ_BARRIER;
+
        rq->special = data;
        rq->q = NULL;
        rq->bio = rq->biotail = NULL;
@@ -86,12 +92,7 @@ static void __scsi_insert_special(request_queue_t *q, struct request *rq,
         * device, or a host that is unable to accept a particular command.
         */
        spin_lock_irqsave(&q->queue_lock, flags);
-
-       if (at_head)
-               list_add(&rq->queuelist, &q->queue_head);
-       else
-               list_add_tail(&rq->queuelist, &q->queue_head);
-
+       __elv_add_request(q, rq, !at_head, 0);
        q->request_fn(q);
        spin_unlock_irqrestore(&q->queue_lock, flags);
 }
@@ -261,10 +262,7 @@ void scsi_queue_next_request(request_queue_t * q, Scsi_Cmnd * SCpnt)
                 * the bad sector.
                 */
                SCpnt->request.special = (void *) SCpnt;
-#if 0
-               SCpnt->request.flags |= REQ_SPECIAL;
-#endif
-               list_add(&SCpnt->request.queuelist, &q->queue_head);
+               __elv_add_request(q, &SCpnt->request, 0, 0);
        }
 
        /*
@@ -360,23 +358,15 @@ static Scsi_Cmnd *__scsi_end_request(Scsi_Cmnd * SCpnt,
                                     int frequeue)
 {
        request_queue_t *q = &SCpnt->device->request_queue;
-       struct request *req;
+       struct request *req = &SCpnt->request;
 
        ASSERT_LOCK(&q->queue_lock, 0);
 
-       req = &SCpnt->request;
-       while (end_that_request_first(req, 1, sectors)) {
-               if (!req->bio) {
-                       printk("scsi_end_request: missing bio\n");
-                       break;
-               }
-       }
-
        /*
         * If there are blocks left over at the end, set up the command
         * to queue the remainder of them.
         */
-       if (req->bio) {
+       if (end_that_request_first(req, 1, sectors)) {
                if (!requeue)
                        return SCpnt;
 
@@ -835,13 +825,6 @@ void scsi_request_fn(request_queue_t * q)
                if (SHpnt->in_recovery || blk_queue_plugged(q))
                        return;
 
-               /*
-                * if we are at the max queue depth, don't attempt to queue
-                * more
-                */
-               if (SHpnt->host_busy == SDpnt->queue_depth)
-                       break;
-
                /*
                 * If the device cannot accept another request, then quit.
                 */
index c3b38e308c20f8c0f590529d3920405f60b632f8..eb93a833a086f0c8f890856c4658a37f5b2e010c 100644 (file)
@@ -286,6 +286,12 @@ static int sd_init_command(Scsi_Cmnd * SCpnt)
        char nbuff[6];
 #endif
 
+       /*
+        * don't support specials for nwo
+        */
+       if (!(SCpnt->request.flags & REQ_CMD))
+               return 0;
+
        devm = SD_PARTITION(SCpnt->request.rq_dev);
        dev = DEVICE_NR(SCpnt->request.rq_dev);
 
index f00b3fceb3cd2fc2a0b40cbcbbe7ebb11008c77c..f8eda80f0d45153b91772253e8ecf077d645f9cf 100644 (file)
@@ -82,9 +82,9 @@ static void read_bulk_callback( struct urb *urb )
        ether_dev->flags |= CDC_ETHER_RX_BUSY;
 
        switch ( urb->status ) {
-               case USB_ST_NOERROR:
+               case 0:
                        break;
-               case USB_ST_NORESPONSE:
+               case -ETIMEDOUT:
                        dbg( "no repsonse in BULK IN" );
                        ether_dev->flags &= ~CDC_ETHER_RX_BUSY;
                        break;
@@ -179,9 +179,9 @@ static void write_bulk_callback( struct urb *urb )
 //             return;
 //             
 //     switch ( urb->status ) {
-//             case USB_ST_NOERROR:
+//             case 0:
 //                     break;
-//             case USB_ST_URB_KILLED:
+//             case -ENOENT:
 //                     return;
 //             default:
 //                     info("intr status %d", urb->status);
@@ -337,13 +337,9 @@ static int CDCEther_open(struct net_device *net)
        ether_dev_t *ether_dev = (ether_dev_t *)net->priv;
        int     res;
 
-       // We are finally getting used!
-       MOD_INC_USE_COUNT;
-
        // Turn on the USB and let the packets flow!!!
        if ( (res = enable_net_traffic( ether_dev )) ) {
                err( __FUNCTION__ "can't enable_net_traffic() - %d", res );
-               MOD_DEC_USE_COUNT;
                return -EIO;
        }
 
@@ -391,9 +387,6 @@ static int CDCEther_close( struct net_device *net )
        usb_unlink_urb( &ether_dev->tx_urb );
        usb_unlink_urb( &ether_dev->intr_urb );
        
-       // We are not being used now.
-       MOD_DEC_USE_COUNT;
-
        // That's it.  I'm done.
        return 0;
 }
@@ -480,6 +473,7 @@ static void CDCEther_set_multicast( struct net_device *net )
                      i++, mclist = mclist->next) {
                        memcpy(&mclist->dmi_addr, &buff[i * 6], 6);
                }
+#if 0
                usb_control_msg(ether_dev->usb,
                                usb_sndctrlpipe(ether_dev->usb, 0),
                                SET_ETHERNET_MULTICAST_FILTER, /* request */
@@ -489,11 +483,13 @@ static void CDCEther_set_multicast( struct net_device *net )
                                buff,
                                (6* net->mc_count), /* size */
                                HZ); /* timeout */
+#endif
                kfree(buff);
        }
+
+#if 0 
        CDC_SetEthernetPacketFilter(ether_dev);
-       
+#endif 
         // Tell the kernel to start giving frames to us again.
        netif_wake_queue(net);
 }
@@ -1210,6 +1206,7 @@ static void * CDCEther_probe( struct usb_device *usb, unsigned int ifnum,
        // Now that we have an ethernet device, let's set it up
        // (And I don't mean "set [it] up the bomb".)
        net->priv = ether_dev;
+       SET_MODULE_OWNER(net);
        net->open = CDCEther_open;
        net->stop = CDCEther_close;
        net->watchdog_timeo = CDC_ETHER_TX_TIMEOUT;
index c15da6f3ca0ac4f79a0ee4bfb0d2baa42e22d955..c1792a6223a1d0bb8cc89f77b484b20d22aa365f 100644 (file)
@@ -9,7 +9,7 @@ if [ "$CONFIG_USB" = "y" -o  "$CONFIG_USB" = "m" ]; then
    bool '  USB verbose debug messages' CONFIG_USB_DEBUG
 
 comment 'Miscellaneous USB options'
-   bool '  Preliminary USB device filesystem' CONFIG_USB_DEVICEFS
+   bool '  USB device filesystem' CONFIG_USB_DEVICEFS
    if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
       bool '  Enforce USB bandwidth allocation (EXPERIMENTAL)' CONFIG_USB_BANDWIDTH
    else
index 2f9aa3cfe64be2081f9efdcf79955dad2c5a7a24..593e4671d98979c2e1388c5e6a6f834a2e677a90 100644 (file)
@@ -899,7 +899,7 @@ static void usbin_completed(struct urb *urb)
        struct usbin *u = &as->usbin;
        unsigned long flags;
        unsigned int mask;
-       int suret = USB_ST_NOERROR;
+       int suret = 0;
 
 #if 0
        printk(KERN_DEBUG "usbin_completed: status %d errcnt %d flags 0x%x\n", urb->status, urb->error_count, u->flags);
@@ -917,7 +917,7 @@ static void usbin_completed(struct urb *urb)
        if (!usbin_retire_desc(u, urb) &&
            u->flags & FLG_RUNNING &&
            !usbin_prepare_desc(u, urb) && 
-           (suret = usb_submit_urb(urb)) == USB_ST_NOERROR) {
+           (suret = usb_submit_urb(urb)) == 0) {
                u->flags |= mask;
        } else {
                u->flags &= ~(mask | FLG_RUNNING);
@@ -964,7 +964,7 @@ static void usbin_sync_completed(struct urb *urb)
        struct usbin *u = &as->usbin;
        unsigned long flags;
        unsigned int mask;
-       int suret = USB_ST_NOERROR;
+       int suret = 0;
 
 #if 0
        printk(KERN_DEBUG "usbin_sync_completed: status %d errcnt %d flags 0x%x\n", urb->status, urb->error_count, u->flags);
@@ -982,7 +982,7 @@ static void usbin_sync_completed(struct urb *urb)
        if (!usbin_sync_retire_desc(u, urb) &&
            u->flags & FLG_RUNNING &&
            !usbin_sync_prepare_desc(u, urb) && 
-           (suret = usb_submit_urb(urb)) == USB_ST_NOERROR) {
+           (suret = usb_submit_urb(urb)) == 0) {
                u->flags |= mask;
        } else {
                u->flags &= ~(mask | FLG_RUNNING);
@@ -1257,7 +1257,7 @@ static void usbout_completed(struct urb *urb)
        struct usbout *u = &as->usbout;
        unsigned long flags;
        unsigned int mask;
-       int suret = USB_ST_NOERROR;
+       int suret = 0;
 
 #if 0
        printk(KERN_DEBUG "usbout_completed: status %d errcnt %d flags 0x%x\n", urb->status, urb->error_count, u->flags);
@@ -1275,7 +1275,7 @@ static void usbout_completed(struct urb *urb)
        if (!usbout_retire_desc(u, urb) &&
            u->flags & FLG_RUNNING &&
            !usbout_prepare_desc(u, urb) && 
-           (suret = usb_submit_urb(urb)) == USB_ST_NOERROR) {
+           (suret = usb_submit_urb(urb)) == 0) {
                u->flags |= mask;
        } else {
                u->flags &= ~(mask | FLG_RUNNING);
@@ -1329,7 +1329,7 @@ static void usbout_sync_completed(struct urb *urb)
        struct usbout *u = &as->usbout;
        unsigned long flags;
        unsigned int mask;
-       int suret = USB_ST_NOERROR;
+       int suret = 0;
 
 #if 0
        printk(KERN_DEBUG "usbout_sync_completed: status %d errcnt %d flags 0x%x\n", urb->status, urb->error_count, u->flags);
@@ -1347,7 +1347,7 @@ static void usbout_sync_completed(struct urb *urb)
        if (!usbout_sync_retire_desc(u, urb) &&
            u->flags & FLG_RUNNING &&
            !usbout_sync_prepare_desc(u, urb) && 
-           (suret = usb_submit_urb(urb)) == USB_ST_NOERROR) {
+           (suret = usb_submit_urb(urb)) == 0) {
                u->flags |= mask;
        } else {
                u->flags &= ~(mask | FLG_RUNNING);
@@ -3362,28 +3362,48 @@ static void usb_audio_featureunit(struct consmixstate *state, unsigned char *ftr
        struct usb_device *dev = state->s->usbdev;
        unsigned char data[1];
 #endif
+       unsigned char nr_logical_channels, i;
 
        usb_audio_recurseunit(state, ftr[4]);
+
+       if (ftr[5] == 0 ) {
+               printk(KERN_ERR "usbaudio: wrong controls size in feature unit %u\n",ftr[3]);
+               return;
+       }
+
        if (state->nrchannels == 0) {
                printk(KERN_ERR "usbaudio: feature unit %u source has no channels\n", ftr[3]);
                return;
        }
        if (state->nrchannels > 2)
                printk(KERN_WARNING "usbaudio: feature unit %u: OSS mixer interface does not support more than 2 channels\n", ftr[3]);
-       if (state->nrchannels == 1 && ftr[0] == 7+ftr[5]) {
-               printk(KERN_DEBUG "usbaudio: workaround for Philips camera microphone descriptor enabled\n");
-               mchftr = ftr[6];
-               chftr = 0;
-       } else {
-               if (ftr[0] < 7+ftr[5]*(1+state->nrchannels)) {
-                       printk(KERN_ERR "usbaudio: unit %u: invalid FEATURE_UNIT descriptor\n", ftr[3]);
-                       return;
+
+       nr_logical_channels=(ftr[0]-7)/ftr[5]-1;
+
+       if (nr_logical_channels != state->nrchannels) {
+               printk(KERN_WARNING "usbaudio: warning: found %d of %d logical channels.\n", state->nrchannels,nr_logical_channels);
+
+               if (state->nrchannels == 1 && nr_logical_channels==0) {
+                       printk(KERN_INFO "usbaudio: assuming the channel found is the master channel (got a Philips camera?). Should be fine.\n");
+               } else if (state->nrchannels == 1 && nr_logical_channels==2) {
+                       printk(KERN_INFO "usbaudio: assuming that a stereo channel connected directly to a mixer is missing in search (got Labtec headset?). Should be fine.\n");
+                       state->nrchannels=nr_logical_channels;
+               } else {
+                       printk(KERN_WARNING "usbaudio: no idea what's going on..., contact linux-usb-devel@lists.sourceforge.net\n");
                }
-               mchftr = ftr[6];
+       }
+
+       /* There is always a master channel */
+       mchftr = ftr[6];
+       /* Binary AND over logical channels if they exist */
+       if (nr_logical_channels) {
                chftr = ftr[6+ftr[5]];
-               if (state->nrchannels > 1)
-                       chftr &= ftr[6+2*ftr[5]];
+               for (i = 2; i <= nr_logical_channels; i++)
+                       chftr &= ftr[6+i*ftr[5]];
+       } else {
+               chftr = 0;
        }
+
        /* volume control */
        if (chftr & 2) {
                ch = getmixchannel(state, getvolchannel(state));
index 1b8e8190a58e9bcc65b280b0b662aa688d02716a..c4786295edbeb0f169c4f8ad318d9dcbf6fe359d 100644 (file)
@@ -1,11 +1,15 @@
 /*
- * bluetooth.c   Version 0.12
+ * bluetooth.c   Version 0.13
  *
  * Copyright (c) 2000, 2001 Greg Kroah-Hartman <greg@kroah.com>
  * Copyright (c) 2000 Mark Douglas Corner      <mcorner@umich.edu>
  *
  * USB Bluetooth driver, based on the Bluetooth Spec version 1.0B
  * 
+ * (2001/11/30) Version 0.13 gkh
+ *     - added locking patch from Masoodur Rahman <rmasoodu@in.ibm.com>
+ *     - removed active variable, as open_count will do.
+ *
  * (2001/07/09) Version 0.12 gkh
  *     - removed in_interrupt() call, as it doesn't make sense to do 
  *       that anymore.
 /*
  * Version Information
  */
-#define DRIVER_VERSION "v0.12"
+#define DRIVER_VERSION "v0.13"
 #define DRIVER_AUTHOR "Greg Kroah-Hartman, Mark Douglas Corner"
 #define DRIVER_DESC "USB Bluetooth tty driver"
 
@@ -170,8 +174,8 @@ struct usb_bluetooth {
        struct tty_struct *     tty;            /* the coresponding tty for this port */
 
        unsigned char           minor;          /* the starting minor number for this device */
-       char                    active;         /* someone has this device open */
        int                     throttle;       /* throttled by tty layer */
+       int                     open_count;
        
        __u8                    control_out_bInterfaceNum;
        struct urb *            control_urb_pool[NUM_CONTROL_URBS];
@@ -200,6 +204,7 @@ struct usb_bluetooth {
        unsigned char           int_buffer[EVENT_BUFFER_SIZE];
        unsigned int            bulk_packet_pos;
        unsigned char           bulk_buffer[ACL_BUFFER_SIZE];   /* 64k preallocated, fix? */
+       struct semaphore        lock;
 };
 
 
@@ -361,43 +366,46 @@ static int bluetooth_open (struct tty_struct *tty, struct file * filp)
                return -ENODEV;
        }
 
-       if (bluetooth->active) {
-               dbg (__FUNCTION__ " - device already open");
-               return -EINVAL;
-       }
-
-       /* set up our structure making the tty driver remember our object, and us it */
-       tty->driver_data = bluetooth;
-       bluetooth->tty = tty;
+       down (&bluetooth->lock);
+       ++bluetooth->open_count;
+       if (bluetooth->open_count == 1) {
+               /* set up our structure making the tty driver remember our object, and us it */
+               tty->driver_data = bluetooth;
+               bluetooth->tty = tty;
 
-       /* force low_latency on so that our tty_push actually forces the data through, 
-        * otherwise it is scheduled, and with high data rates (like with OHCI) data
-        * can get lost. */
-       bluetooth->tty->low_latency = 1;
+               /* force low_latency on so that our tty_push actually forces the data through, 
+               * otherwise it is scheduled, and with high data rates (like with OHCI) data
+               * can get lost. */
+               bluetooth->tty->low_latency = 1;
        
-       bluetooth->active = 1;
-
-       /* Reset the packet position counters */
-       bluetooth->int_packet_pos = 0;
-       bluetooth->bulk_packet_pos = 0;
+               /* Reset the packet position counters */
+               bluetooth->int_packet_pos = 0;
+               bluetooth->bulk_packet_pos = 0;
 
 #ifndef BTBUGGYHARDWARE
-       /* Start reading from the device */
-       FILL_BULK_URB(bluetooth->read_urb, bluetooth->dev, 
-                     usb_rcvbulkpipe(bluetooth->dev, bluetooth->bulk_in_endpointAddress),
-                     bluetooth->bulk_in_buffer, bluetooth->bulk_in_buffer_size, 
-                     bluetooth_read_bulk_callback, bluetooth);
-       result = usb_submit_urb(bluetooth->read_urb);
-       if (result)
-               dbg(__FUNCTION__ " - usb_submit_urb(read bulk) failed with status %d", result);
+               /* Start reading from the device */
+               FILL_BULK_URB (bluetooth->read_urb, bluetooth->dev, 
+                              usb_rcvbulkpipe(bluetooth->dev, bluetooth->bulk_in_endpointAddress),
+                              bluetooth->bulk_in_buffer,
+                              bluetooth->bulk_in_buffer_size,
+                              bluetooth_read_bulk_callback, bluetooth);
+               result = usb_submit_urb(bluetooth->read_urb);
+               if (result)
+                       dbg(__FUNCTION__ " - usb_submit_urb(read bulk) failed with status %d", result);
 #endif
-       FILL_INT_URB(bluetooth->interrupt_in_urb, bluetooth->dev, 
-                    usb_rcvintpipe(bluetooth->dev, bluetooth->interrupt_in_endpointAddress),
-                    bluetooth->interrupt_in_buffer, bluetooth->interrupt_in_buffer_size, 
-                    bluetooth_int_callback, bluetooth, bluetooth->interrupt_in_interval);
-       result = usb_submit_urb(bluetooth->interrupt_in_urb);
-       if (result)
-               dbg(__FUNCTION__ " - usb_submit_urb(interrupt in) failed with status %d", result);
+               FILL_INT_URB (bluetooth->interrupt_in_urb, bluetooth->dev,
+                             usb_rcvintpipe(bluetooth->dev, bluetooth->interrupt_in_endpointAddress),
+                             bluetooth->interrupt_in_buffer,
+                             bluetooth->interrupt_in_buffer_size,
+                             bluetooth_int_callback, bluetooth,
+                             bluetooth->interrupt_in_interval);
+               result = usb_submit_urb(bluetooth->interrupt_in_urb);
+               if (result)
+                       dbg(__FUNCTION__ " - usb_submit_urb(interrupt in) failed with status %d", result);
+       }
+       
+       up(&bluetooth->lock);
 
        return 0;
 }
@@ -414,18 +422,24 @@ static void bluetooth_close (struct tty_struct *tty, struct file * filp)
 
        dbg(__FUNCTION__);
 
-       if (!bluetooth->active) {
+       if (!bluetooth->open_count) {
                dbg (__FUNCTION__ " - device not opened");
                return;
        }
 
-       /* shutdown any bulk reads and writes that might be going on */
-       for (i = 0; i < NUM_BULK_URBS; ++i)
-               usb_unlink_urb (bluetooth->write_urb_pool[i]);
-       usb_unlink_urb (bluetooth->read_urb);
-       usb_unlink_urb (bluetooth->interrupt_in_urb);
+       down (&bluetooth->lock);
+       --bluetooth->open_count;
+       if (bluetooth->open_count <= 0) {
+               bluetooth->open_count = 0;
 
-       bluetooth->active = 0;
+               /* shutdown any bulk reads and writes that might be going on */
+               for (i = 0; i < NUM_BULK_URBS; ++i)
+                       usb_unlink_urb (bluetooth->write_urb_pool[i]);
+               usb_unlink_urb (bluetooth->read_urb);
+               usb_unlink_urb (bluetooth->interrupt_in_urb);
+       }
+       up(&bluetooth->lock);
 }
 
 
@@ -447,7 +461,7 @@ static int bluetooth_write (struct tty_struct * tty, int from_user, const unsign
 
        dbg(__FUNCTION__ " - %d byte(s)", count);
 
-       if (!bluetooth->active) {
+       if (!bluetooth->open_count) {
                dbg (__FUNCTION__ " - device not opened");
                return -EINVAL;
        }
@@ -572,7 +586,7 @@ static int bluetooth_write_room (struct tty_struct *tty)
 
        dbg(__FUNCTION__);
 
-       if (!bluetooth->active) {
+       if (!bluetooth->open_count) {
                dbg (__FUNCTION__ " - device not open");
                return -EINVAL;
        }
@@ -598,7 +612,7 @@ static int bluetooth_chars_in_buffer (struct tty_struct *tty)
                return -ENODEV;
        }
 
-       if (!bluetooth->active) {
+       if (!bluetooth->open_count) {
                dbg (__FUNCTION__ " - device not open");
                return -EINVAL;
        }
@@ -624,7 +638,7 @@ static void bluetooth_throttle (struct tty_struct * tty)
 
        dbg(__FUNCTION__);
 
-       if (!bluetooth->active) {
+       if (!bluetooth->open_count) {
                dbg (__FUNCTION__ " - device not open");
                return;
        }
@@ -645,7 +659,7 @@ static void bluetooth_unthrottle (struct tty_struct * tty)
 
        dbg(__FUNCTION__);
 
-       if (!bluetooth->active) {
+       if (!bluetooth->open_count) {
                dbg (__FUNCTION__ " - device not open");
                return;
        }
@@ -664,7 +678,7 @@ static int bluetooth_ioctl (struct tty_struct *tty, struct file * file, unsigned
 
        dbg(__FUNCTION__ " - cmd 0x%.4x", cmd);
 
-       if (!bluetooth->active) {
+       if (!bluetooth->open_count) {
                dbg (__FUNCTION__ " - device not open");
                return -ENODEV;
        }
@@ -684,7 +698,7 @@ static void bluetooth_set_termios (struct tty_struct *tty, struct termios * old)
 
        dbg(__FUNCTION__);
 
-       if (!bluetooth->active) {
+       if (!bluetooth->open_count) {
                dbg (__FUNCTION__ " - device not open");
                return;
        }
@@ -706,7 +720,7 @@ void btusb_enable_bulk_read(struct tty_struct *tty){
 
        dbg(__FUNCTION__);
 
-       if (!bluetooth->active) {
+       if (!bluetooth->open_count) {
                dbg (__FUNCTION__ " - device not open");
                return;
        }
@@ -731,7 +745,7 @@ void btusb_disable_bulk_read(struct tty_struct *tty){
 
        dbg(__FUNCTION__);
 
-       if (!bluetooth->active) {
+       if (!bluetooth->open_count) {
                dbg (__FUNCTION__ " - device not open");
                return;
        }
@@ -961,7 +975,7 @@ static void bluetooth_read_bulk_callback (struct urb *urb)
        }       
 
 exit:
-       if (!bluetooth || !bluetooth->active)
+       if (!bluetooth || !bluetooth->open_count)
                return;
 
        FILL_BULK_URB(bluetooth->read_urb, bluetooth->dev, 
@@ -1102,6 +1116,7 @@ static void * usb_bluetooth_probe(struct usb_device *dev, unsigned int ifnum,
        bluetooth->minor = minor;
        bluetooth->tqueue.routine = bluetooth_softint;
        bluetooth->tqueue.data = bluetooth;
+       init_MUTEX(&bluetooth->lock);
 
        /* record the interface number for the control out */
        bluetooth->control_out_bInterfaceNum = control_out_endpoint;
@@ -1217,10 +1232,10 @@ static void usb_bluetooth_disconnect(struct usb_device *dev, void *ptr)
        int i;
 
        if (bluetooth) {
-               if ((bluetooth->active) && (bluetooth->tty))
+               if ((bluetooth->open_count) && (bluetooth->tty))
                        tty_hangup(bluetooth->tty);
 
-               bluetooth->active = 0;
+               bluetooth->open_count = 0;
 
                if (bluetooth->read_urb) {
                        usb_unlink_urb (bluetooth->read_urb);
index e8549748a561821761e72304cf56b7ea2ceca871..931a274dcc8dfae1059ab8bc94ccd78cdb10ae92 100644 (file)
@@ -199,7 +199,7 @@ static ssize_t camera_read (struct file *file,
                                retval = count;
                        break;
                }
-               if (retval != USB_ST_TIMEOUT)
+               if (retval != -ETIMEDOUT)
                        break;
                interruptible_sleep_on_timeout (&camera->wait, RETRY_TIMEOUT);
 
@@ -267,7 +267,7 @@ static ssize_t camera_write (struct file *file,
                        } else if (!result)
                                break;
                                
-                       if (result == USB_ST_TIMEOUT) { /* NAK - delay a bit */
+                       if (result == -ETIMEDOUT) {     /* NAK - delay a bit */
                                if (!maxretry--) {
                                        if (!bytes_written)
                                                bytes_written = -ETIME;
index e3071c87491e64f4d847a514a5b3b00d8d7ec518..c732e45be9869d4dfdc7af5860da0d2fa91b8bca 100644 (file)
@@ -139,9 +139,12 @@ static const struct class_info clas_info[] =
        {USB_CLASS_PHYSICAL,            "PID"},
        {USB_CLASS_PRINTER,             "print"},
        {USB_CLASS_MASS_STORAGE,        "stor."},
-       {USB_CLASS_DATA,                "data"},
+       {USB_CLASS_CDC_DATA,            "data"},
        {USB_CLASS_APP_SPEC,            "app."},
        {USB_CLASS_VENDOR_SPEC,         "vend."},
+       {USB_CLASS_STILL_IMAGE,         "still"},
+       {USB_CLASS_CSCID,               "scard"},
+       {USB_CLASS_CONTENT_SEC,         "c-sec"},
        {-1,                            "unk."}         /* leave as last */
 };
 
index 7978a9bd72d5fa32e3e1e8e13674b877f61339f5..f88e4691042daad75bbfa8940d564c26edc2c0e5 100644 (file)
@@ -276,7 +276,7 @@ static void destroy_all_async(struct dev_state *ps)
                 list_del(&as->asynclist);
                 INIT_LIST_HEAD(&as->asynclist);
                 spin_unlock_irqrestore(&ps->lock, flags);
-                /* usb_unlink_urb calls the completion handler with status == USB_ST_URB_KILLED */
+                /* usb_unlink_urb calls the completion handler with status == -ENOENT */
                 usb_unlink_urb(&as->urb);
                 spin_lock_irqsave(&ps->lock, flags);
         }
@@ -299,11 +299,12 @@ static void driver_disconnect(struct usb_device *dev, void *context)
 {
        struct dev_state *ps = (struct dev_state *)context;
 
-       ps->ifclaimed = 0;
+       if (ps)
+               ps->ifclaimed = 0;
 }
 
 struct usb_driver usbdevfs_driver = {
-       name:           "usbdevfs",
+       name:           "usbfs",
        probe:          driver_probe,
        disconnect:     driver_disconnect,
 };
index 47d039e4f98f35831b955594c9555d1bc8495cc9..7c40af27abb2b10884e70e61ba152c7fbcc106fd 100644 (file)
@@ -897,7 +897,7 @@ void hid_read_report(struct hid_device *hid, struct hid_report *report)
        u8 data[len];
        int read;
 
-       if ((read = usb_get_report(hid->dev, hid->ifnum, report->type + 1, report->id, data, len)) != len) {
+       if ((read = hid_get_report(hid->dev, hid->ifnum, report->type + 1, report->id, data, len)) != len) {
                dbg("reading report type %d id %d failed len %d read %d", report->type + 1, report->id, len, read);
                return;
        }
@@ -1064,7 +1064,7 @@ void hid_init_reports(struct hid_device *hid)
                        list = report_enum->report_list.next;
                        while (list != &report_enum->report_list) {
                                report = (struct hid_report *) list;
-                               usb_set_idle(hid->dev, hid->ifnum, 0, report->id);
+                               hid_set_idle(hid->dev, hid->ifnum, 0, report->id);
                                hid_read_report(hid, report);
                                list = list->next;
                        }
@@ -1089,6 +1089,16 @@ struct hid_blacklist {
        { 0, 0 }
 };
 
+static int get_class_descriptor(struct usb_device *dev, int ifnum,
+               unsigned char type, void *buf, int size)
+{
+       return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
+               USB_REQ_GET_DESCRIPTOR, USB_RECIP_INTERFACE | USB_DIR_IN,
+               (type << 8), ifnum, buf, size,
+               HZ * USB_CTRL_GET_TIMEOUT);
+}
+
+
 static struct hid_device *usb_hid_configure(struct usb_device *dev, int ifnum)
 {
        struct usb_interface_descriptor *interface = dev->actconfig->interface[ifnum].altsetting + 0;
@@ -1102,14 +1112,14 @@ static struct hid_device *usb_hid_configure(struct usb_device *dev, int ifnum)
                if ((hid_blacklist[n].idVendor == dev->descriptor.idVendor) &&
                        (hid_blacklist[n].idProduct == dev->descriptor.idProduct)) return NULL;
 
-       if (usb_get_extra_descriptor(interface, USB_DT_HID, &hdesc) && ((!interface->bNumEndpoints) ||
-               usb_get_extra_descriptor(&interface->endpoint[0], USB_DT_HID, &hdesc))) {
+       if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) && ((!interface->bNumEndpoints) ||
+               usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) {
                        dbg("class descriptor not present\n");
                        return NULL;
        }
 
        for (n = 0; n < hdesc->bNumDescriptors; n++)
-               if (hdesc->desc[n].bDescriptorType == USB_DT_REPORT)
+               if (hdesc->desc[n].bDescriptorType == HID_DT_REPORT)
                        rsize = le16_to_cpu(hdesc->desc[n].wDescriptorLength);
 
        if (!rsize || rsize > HID_MAX_DESCRIPTOR_SIZE) {
@@ -1120,7 +1130,7 @@ static struct hid_device *usb_hid_configure(struct usb_device *dev, int ifnum)
        {
                __u8 rdesc[rsize];
 
-               if ((n = usb_get_class_descriptor(dev, interface->bInterfaceNumber, USB_DT_REPORT, 0, rdesc, rsize)) < 0) {
+               if ((n = get_class_descriptor(dev, interface->bInterfaceNumber, HID_DT_REPORT, rdesc, rsize)) < 0) {
                        dbg("reading report descriptor failed");
                        return NULL;
                }
@@ -1170,7 +1180,7 @@ static struct hid_device *usb_hid_configure(struct usb_device *dev, int ifnum)
 
        for (n = 0; n < HID_CONTROL_FIFO_SIZE; n++) {
                hid->out[n].dr.requesttype = USB_TYPE_CLASS | USB_RECIP_INTERFACE;
-               hid->out[n].dr.request = USB_REQ_SET_REPORT;
+               hid->out[n].dr.request = HID_REQ_SET_REPORT;
                hid->out[n].dr.index = cpu_to_le16(hid->ifnum);
        }
 
@@ -1198,7 +1208,7 @@ static struct hid_device *usb_hid_configure(struct usb_device *dev, int ifnum)
 
 #if 0
        if (interface->bInterfaceSubClass == 1)
-               usb_set_protocol(dev, hid->ifnum, 1);
+               hid_set_protocol(dev, hid->ifnum, 1);
 #endif
 
        return hid;
@@ -1236,7 +1246,7 @@ static void* hid_probe(struct usb_device *dev, unsigned int ifnum,
 
        c = "Device";
        for (i = 0; i < hid->maxapplication; i++)
-               if (IS_INPUT_APPLICATION(hid->application[i])) {
+               if ((hid->application[i] & 0xffff) < ARRAY_SIZE(hid_types)) {
                        c = hid_types[hid->application[i] & 0xffff];
                        break;
                }
index 529a1112a8028d681fdf2441892d1b04f1790668..7eb085fced2d838515702e845f8d86fb776a70e3 100644 (file)
  * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
  */
 
+/*
+ * HID class requests
+ */
+#define HID_REQ_GET_REPORT             0x01
+#define HID_REQ_GET_IDLE               0x02
+#define HID_REQ_GET_PROTOCOL           0x03
+#define HID_REQ_SET_REPORT             0x09
+#define HID_REQ_SET_IDLE               0x0A
+#define HID_REQ_SET_PROTOCOL           0x0B
+
+/*
+ * HID class descriptor types
+ */
+#define HID_DT_HID                     (USB_TYPE_CLASS | 0x01)
+#define HID_DT_REPORT                  (USB_TYPE_CLASS | 0x02)
+#define HID_DT_PHYSICAL                        (USB_TYPE_CLASS | 0x03)
+
+/*
+ * Utilities for class control messaging
+ */
+static inline int
+hid_set_idle(struct usb_device *dev, int ifnum, int duration, int report_id)
+{
+       return usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+               HID_REQ_SET_IDLE, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+               (duration << 8) | report_id, ifnum, NULL, 0,
+               HZ * USB_CTRL_SET_TIMEOUT);
+}
+
+static inline int
+hid_get_protocol(struct usb_device *dev, int ifnum)
+{
+       unsigned char type;
+       int ret;
+
+       if ((ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
+                       HID_REQ_GET_PROTOCOL,
+                       USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+                       0, ifnum, &type, 1, 
+                       HZ * USB_CTRL_GET_TIMEOUT)) < 0)
+               return ret;
+
+       return type;
+}
+
+static inline int
+hid_set_protocol(struct usb_device *dev, int ifnum, int protocol)
+{
+       return usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+               HID_REQ_SET_PROTOCOL, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+               protocol, ifnum, NULL, 0, 
+               HZ * USB_CTRL_SET_TIMEOUT);
+}
+
+static inline int
+hid_get_report(struct usb_device *dev, int ifnum, unsigned char type,
+       unsigned char id, void *buf, int size)
+{
+       return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
+               HID_REQ_GET_REPORT,
+               USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+               (type << 8) + id, ifnum, buf, size, 
+               HZ * USB_CTRL_GET_TIMEOUT);
+}
+
+static inline int
+hid_set_report(struct usb_device *dev, int ifnum, unsigned char type,
+       unsigned char id, void *buf, int size)
+{
+       return usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+               HID_REQ_SET_REPORT, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+               (type << 8) + id, ifnum, buf, size, HZ);
+               // FIXME USB_CTRL_SET_TIMEOUT
+}
+
+
+/*
+ * "Boot Protocol" keyboard/mouse drivers use don't use all of HID;
+ * they're a lot smaller but can't support all the device features.
+ */
+#ifndef        _HID_BOOT_PROTOCOL
+
 #include <linux/types.h>
 #include <linux/slab.h>
 #include <linux/list.h>
@@ -359,9 +441,7 @@ void hidinput_disconnect(struct hid_device *);
 #else
 #define hid_dump_input(a,b)    do { } while (0)
 #define hid_dump_device(c)     do { } while (0)
-#endif
-
-#endif
+#endif /* DEBUG */
 
 #define IS_INPUT_APPLICATION(a) (((a >= 0x00010000) && (a <= 0x00010008)) || (a == 0x00010080) || ( a == 0x000c0001))
 
@@ -372,3 +452,8 @@ int hid_set_field(struct hid_field *, unsigned, __s32);
 void hid_write_report(struct hid_device *, struct hid_report *);
 void hid_read_report(struct hid_device *, struct hid_report *);
 void hid_init_reports(struct hid_device *hid);
+
+#endif /* !_HID_BOOT_PROTOCOL */
+
+#endif /* !__HID_H */
+
index 0c348ed80ff3878e96f08277cdd7633434475224..cd38ce06a7833bb09512d089659ec9c3f8c385d9 100644 (file)
@@ -654,7 +654,13 @@ struct super_block *usbdevfs_read_super(struct super_block *s, void *data, int s
         return NULL;
 }
 
+/*
+ * The usbdevfs name is now depreciated (as of 2.5.1).
+ * It will be removed when the 2.7.x development cycle is started.
+ * You have been warned :)
+ */
 static DECLARE_FSTYPE(usbdevice_fs_type, "usbdevfs", usbdevfs_read_super, FS_SINGLE);
+static DECLARE_FSTYPE(usb_fs_type, "usbfs", usbdevfs_read_super, FS_SINGLE);
 
 /* --------------------------------------------------------------------- */
 
@@ -747,7 +753,12 @@ int __init usbdevfs_init(void)
        }
        if ((ret = usb_register(&usbdevfs_driver)))
                return ret;
+       if ((ret = register_filesystem(&usb_fs_type))) {
+               usb_deregister(&usbdevfs_driver);
+               return ret;
+       }
        if ((ret = register_filesystem(&usbdevice_fs_type))) {
+               unregister_filesystem(&usb_fs_type);
                usb_deregister(&usbdevfs_driver);
                return ret;
        }
@@ -761,6 +772,7 @@ int __init usbdevfs_init(void)
 void __exit usbdevfs_cleanup(void)
 {
        usb_deregister(&usbdevfs_driver);
+       unregister_filesystem(&usb_fs_type);
        unregister_filesystem(&usbdevice_fs_type);
 #ifdef CONFIG_PROC_FS  
         if (usbdir)
@@ -768,7 +780,3 @@ void __exit usbdevfs_cleanup(void)
 #endif
 }
 
-#if 0
-module_init(usbdevfs_init);
-module_exit(usbdevfs_cleanup);
-#endif
index df36984addf3f4a3c2840fb381c4062bbf22ae26..7289dcd3847a76ea52eff3265cf880858da48fd4 100644 (file)
@@ -944,6 +944,13 @@ static void kaweth_disconnect(struct usb_device *dev, void *ptr)
 }
 
 
+// FIXME this completion stuff is a modified clone of
+// an OLD version of some stuff in usb.c ... 
+struct usb_api_data {
+       wait_queue_head_t wqh;
+       int done;
+};
+
 /*-------------------------------------------------------------------*
  * completion handler for compatibility wrappers (sync control/bulk) *
  *-------------------------------------------------------------------*/
index cc458b385fdfc44cc34d1302b3cd63f4273d8c1d..d2a1ebe71ed80e5fd96bedfd53838d16e056c77b 100644 (file)
  *
  * The driver supports only one camera.
  * 
- * (08/04/2001) gb
+ * Fix: mdc800 used sleep_on and slept with io_lock held.
+ * Converted sleep_on to waitqueues with schedule_timeout and made io_lock
+ * a semaphore from a spinlock.
+ * by Oliver Neukum <520047054719-0001@t-online.de>
+ * (02/12/2001)
+ * 
  * Identify version on module load.
+ * (08/04/2001) gb
  *
  * version 0.7.5
  * Fixed potential SMP races with Spinlocks.
@@ -136,6 +142,7 @@ struct mdc800_data
 
        purb_t                  irq_urb;
        wait_queue_head_t       irq_wait;
+       int                     irq_woken;
        char*                   irq_urb_buffer;
 
        int                     camera_busy;          // is camera busy ?
@@ -145,11 +152,13 @@ struct mdc800_data
        purb_t                  write_urb;
        char*                   write_urb_buffer;
        wait_queue_head_t       write_wait;
+       int                     written;
 
 
        purb_t                  download_urb;
        char*                   download_urb_buffer;
        wait_queue_head_t       download_wait;
+       int                     downloaded;
        int                     download_left;          // Bytes left to download ?
 
 
@@ -159,7 +168,7 @@ struct mdc800_data
        int                     out_count;      // Bytes in the buffer
 
        int                     open;           // Camera device open ?
-       spinlock_t              io_lock;        // IO -lock     
+       struct semaphore        io_lock;        // IO -lock
 
        char                    in [8];         // Command Input Buffer
        int                     in_count;
@@ -284,6 +293,7 @@ static void mdc800_usb_irq (struct urb *urb)
        if (wake_up)
        {
                mdc800->camera_request_ready=0;
+               mdc800->irq_woken=1;
                wake_up_interruptible (&mdc800->irq_wait);
        }
 }
@@ -300,9 +310,19 @@ static void mdc800_usb_irq (struct urb *urb)
  */
 static int mdc800_usb_waitForIRQ (int mode, int msec)
 {
+        DECLARE_WAITQUEUE(wait, current);
+
        mdc800->camera_request_ready=1+mode;
 
-       interruptible_sleep_on_timeout (&mdc800->irq_wait, msec*HZ/1000);
+       add_wait_queue(&mdc800->irq_wait, &wait);
+       set_current_state(TASK_INTERRUPTIBLE);
+       if (!mdc800->irq_woken)
+       {
+               schedule_timeout (msec*HZ/1000);
+       }
+        remove_wait_queue(&mdc800->irq_wait, &wait);
+       set_current_state(TASK_RUNNING);
+       mdc800->irq_woken = 0;
 
        if (mdc800->camera_request_ready>0)
        {
@@ -337,6 +357,7 @@ static void mdc800_usb_write_notify (struct urb *urb)
        {       
                mdc800->state=READY;
        }
+       mdc800->written = 1;
        wake_up_interruptible (&mdc800->write_wait);
 }
 
@@ -364,6 +385,7 @@ static void mdc800_usb_download_notify (struct urb *urb)
        {
                err ("request bytes fails (status:%i)", urb->status);
        }
+       mdc800->downloaded = 1;
        wake_up_interruptible (&mdc800->download_wait);
 }
 
@@ -445,7 +467,7 @@ static void* mdc800_usb_probe (struct usb_device *dev ,unsigned int ifnum,
 
        info ("Found Mustek MDC800 on USB.");
 
-       spin_lock (&mdc800->io_lock);
+       down (&mdc800->io_lock);
 
        mdc800->dev=dev;
        mdc800->open=0;
@@ -484,7 +506,7 @@ static void* mdc800_usb_probe (struct usb_device *dev ,unsigned int ifnum,
 
        mdc800->state=READY;
 
-       spin_unlock (&mdc800->io_lock);
+       up (&mdc800->io_lock);
        
        return mdc800;
 }
@@ -558,7 +580,7 @@ static int mdc800_device_open (struct inode* inode, struct file *file)
        int retval=0;
        int errn=0;
 
-       spin_lock (&mdc800->io_lock);
+       down (&mdc800->io_lock);
        
        if (mdc800->state == NOT_CONNECTED)
        {
@@ -594,7 +616,7 @@ static int mdc800_device_open (struct inode* inode, struct file *file)
        dbg ("Mustek MDC800 device opened.");
 
 error_out:
-       spin_unlock (&mdc800->io_lock);
+       up (&mdc800->io_lock);
        return errn;
 }
 
@@ -607,10 +629,9 @@ static int mdc800_device_release (struct inode* inode, struct file *file)
        int retval=0;
        dbg ("Mustek MDC800 device closed.");
 
-       spin_lock (&mdc800->io_lock);
+       down (&mdc800->io_lock);
        if (mdc800->open && (mdc800->state != NOT_CONNECTED))
        {
-               spin_unlock(&mdc800->io_lock);
                usb_unlink_urb (mdc800->irq_urb);
                usb_unlink_urb (mdc800->write_urb);
                usb_unlink_urb (mdc800->download_urb);
@@ -618,11 +639,10 @@ static int mdc800_device_release (struct inode* inode, struct file *file)
        }
        else
        {
-               spin_unlock (&mdc800->io_lock);
                retval=-EIO;
        }
 
-
+       up(&mdc800->io_lock);
        return retval;
 }
 
@@ -634,22 +654,23 @@ static ssize_t mdc800_device_read (struct file *file, char *buf, size_t len, lof
 {
        int   left=len, sts=len; /* single transfer size */
        char* ptr=buf;
+       DECLARE_WAITQUEUE(wait, current);
 
-       spin_lock (&mdc800->io_lock);
+       down (&mdc800->io_lock);
        if (mdc800->state == NOT_CONNECTED)
        {
-               spin_unlock (&mdc800->io_lock);
+               up (&mdc800->io_lock);
                return -EBUSY;
        }
        if (mdc800->state == WORKING)
        {
                warn ("Illegal State \"working\" reached during read ?!");
-               spin_unlock (&mdc800->io_lock);
+               up (&mdc800->io_lock);
                return -EBUSY;
        }
        if (!mdc800->open)
        {
-               spin_unlock (&mdc800->io_lock);
+               up (&mdc800->io_lock);
                return -EBUSY;
        }
 
@@ -657,7 +678,7 @@ static ssize_t mdc800_device_read (struct file *file, char *buf, size_t len, lof
        {
                if (signal_pending (current)) 
                {
-                       spin_unlock (&mdc800->io_lock);
+                       up (&mdc800->io_lock);
                        return -EINTR;
                }
 
@@ -676,21 +697,29 @@ static ssize_t mdc800_device_read (struct file *file, char *buf, size_t len, lof
                                if (usb_submit_urb (mdc800->download_urb))
                                {
                                        err ("Can't submit download urb (status=%i)",mdc800->download_urb->status);
-                                       spin_unlock (&mdc800->io_lock);
+                                       up (&mdc800->io_lock);
                                        return len-left;
                                }
-                               interruptible_sleep_on_timeout (&mdc800->download_wait, TO_DOWNLOAD_GET_READY*HZ/1000);
+                               add_wait_queue(&mdc800->download_wait, &wait);
+                               set_current_state(TASK_INTERRUPTIBLE);
+                               if (!mdc800->downloaded)
+                               {
+                                       schedule_timeout (TO_DOWNLOAD_GET_READY*HZ/1000);
+                               }
+                               set_current_state(TASK_RUNNING);
+                               remove_wait_queue(&mdc800->download_wait, &wait);
+                               mdc800->downloaded = 0;
                                if (mdc800->download_urb->status != 0)
                                {
                                        err ("request download-bytes fails (status=%i)",mdc800->download_urb->status);
-                                       spin_unlock (&mdc800->io_lock);
+                                       up (&mdc800->io_lock);
                                        return len-left;
                                }
                        }
                        else
                        {
                                /* No more bytes -> that's an error*/
-                               spin_unlock (&mdc800->io_lock);
+                               up (&mdc800->io_lock);
                                return -EIO;
                        }
                }
@@ -704,7 +733,7 @@ static ssize_t mdc800_device_read (struct file *file, char *buf, size_t len, lof
                }
        }
 
-       spin_unlock (&mdc800->io_lock);
+       up (&mdc800->io_lock);
        return len-left;
 }
 
@@ -718,16 +747,17 @@ static ssize_t mdc800_device_read (struct file *file, char *buf, size_t len, lof
 static ssize_t mdc800_device_write (struct file *file, const char *buf, size_t len, loff_t *pos)
 {
        int i=0;
+       DECLARE_WAITQUEUE(wait, current);
 
-       spin_lock (&mdc800->io_lock);
+       down (&mdc800->io_lock);
        if (mdc800->state != READY)
        {
-               spin_unlock (&mdc800->io_lock);
+               up (&mdc800->io_lock);
                return -EBUSY;
        }
        if (!mdc800->open )
        {
-               spin_unlock (&mdc800->io_lock);
+               up (&mdc800->io_lock);
                return -EBUSY;
        }
 
@@ -735,7 +765,7 @@ static ssize_t mdc800_device_write (struct file *file, const char *buf, size_t l
        {
                if (signal_pending (current)) 
                {
-                       spin_unlock (&mdc800->io_lock);
+                       up (&mdc800->io_lock);
                        return -EINTR;
                }
 
@@ -757,7 +787,7 @@ static ssize_t mdc800_device_write (struct file *file, const char *buf, size_t l
                else
                {
                        err ("Command is to long !\n");
-                       spin_unlock (&mdc800->io_lock);
+                       up (&mdc800->io_lock);
                        return -EIO;
                }
 
@@ -769,7 +799,7 @@ static ssize_t mdc800_device_write (struct file *file, const char *buf, size_t l
                        if (mdc800_usb_waitForIRQ (0,TO_GET_READY))
                        {
                                err ("Camera didn't get ready.\n");
-                               spin_unlock (&mdc800->io_lock);
+                               up (&mdc800->io_lock);
                                return -EIO;
                        }
 
@@ -781,14 +811,22 @@ static ssize_t mdc800_device_write (struct file *file, const char *buf, size_t l
                        if (usb_submit_urb (mdc800->write_urb))
                        {
                                err ("submitting write urb fails (status=%i)", mdc800->write_urb->status);
-                               spin_unlock (&mdc800->io_lock);
+                               up (&mdc800->io_lock);
                                return -EIO;
                        }
-                       interruptible_sleep_on_timeout (&mdc800->write_wait, TO_WRITE_GET_READY*HZ/1000);
+                       add_wait_queue(&mdc800->write_wait, &wait);
+                       set_current_state(TASK_INTERRUPTIBLE);
+                       if (!mdc800->written)
+                       {
+                               schedule_timeout (TO_WRITE_GET_READY*HZ/1000);
+                       }
+                        set_current_state(TASK_RUNNING);
+                       remove_wait_queue(&mdc800->write_wait, &wait);
+                       mdc800->written = 0;
                        if (mdc800->state == WORKING)
                        {
                                usb_unlink_urb (mdc800->write_urb);
-                               spin_unlock (&mdc800->io_lock);
+                               up (&mdc800->io_lock);
                                return -EIO;
                        }
 
@@ -800,7 +838,7 @@ static ssize_t mdc800_device_write (struct file *file, const char *buf, size_t l
                                        {
                                                err ("call 0x07 before 0x05,0x3e");
                                                mdc800->state=READY;
-                                               spin_unlock (&mdc800->io_lock);
+                                               up (&mdc800->io_lock);
                                                return -EIO;
                                        }
                                        mdc800->pic_len=-1;
@@ -819,7 +857,7 @@ static ssize_t mdc800_device_write (struct file *file, const char *buf, size_t l
                                                if (mdc800_usb_waitForIRQ (1,TO_READ_FROM_IRQ))
                                                {
                                                        err ("requesting answer from irq fails");
-                                                       spin_unlock (&mdc800->io_lock);
+                                                       up (&mdc800->io_lock);
                                                        return -EIO;
                                                }
 
@@ -847,7 +885,7 @@ static ssize_t mdc800_device_write (struct file *file, const char *buf, size_t l
                                                if (mdc800_usb_waitForIRQ (0,TO_DEFAULT_COMMAND))
                                                {
                                                        err ("Command Timeout.");
-                                                       spin_unlock (&mdc800->io_lock);
+                                                       up (&mdc800->io_lock);
                                                        return -EIO;
                                                }
                                        }
@@ -857,7 +895,7 @@ static ssize_t mdc800_device_write (struct file *file, const char *buf, size_t l
                }
                i++;
        }
-       spin_unlock (&mdc800->io_lock);
+       up (&mdc800->io_lock);
        return i;
 }
 
@@ -916,12 +954,16 @@ int __init usb_mdc800_init (void)
        mdc800->dev=0;
        mdc800->open=0;
        mdc800->state=NOT_CONNECTED;
-       spin_lock_init (&mdc800->io_lock);
+       init_MUTEX (&mdc800->io_lock);
 
        init_waitqueue_head (&mdc800->irq_wait);
        init_waitqueue_head (&mdc800->write_wait);
        init_waitqueue_head (&mdc800->download_wait);
 
+       mdc800->irq_woken = 0;
+       mdc800->downloaded = 0;
+       mdc800->written = 0;
+
        try (mdc800->irq_urb_buffer=kmalloc (8, GFP_KERNEL));
        try (mdc800->write_urb_buffer=kmalloc (8, GFP_KERNEL));
        try (mdc800->download_urb_buffer=kmalloc (64, GFP_KERNEL));
index bb8d84cff5954986abea8116b05f5d0581281a42..7ae85febb7bac82308120683ba381b67630b790c 100644 (file)
@@ -53,7 +53,7 @@
 /*
  * Version Information
  */
-#define DRIVER_VERSION "v0.4.21 (2001/08/27)"
+#define DRIVER_VERSION "v0.4.22 (2001/12/07)"
 #define DRIVER_AUTHOR "Petko Manolov <pmanolov@lnxw.com>"
 #define DRIVER_DESC "Pegasus/Pegasus II USB Ethernet driver"
 
@@ -102,7 +102,7 @@ static void ctrl_callback( urb_t *urb )
                return;
 
        switch ( urb->status ) {
-               case USB_ST_NOERROR:
+               case 0:
                        if ( pegasus->flags & ETH_REGS_CHANGE ) {
                                pegasus->flags &= ~ETH_REGS_CHANGE;
                                pegasus->flags |= ETH_REGS_CHANGED;
@@ -110,9 +110,9 @@ static void ctrl_callback( urb_t *urb )
                                return;
                        }
                        break;
-               case USB_ST_URB_PENDING:
+               case -EINPROGRESS:
                        return;
-               case USB_ST_URB_KILLED:
+               case -ENOENT:
                        break;
                default:
                        warn( __FUNCTION__ " status %d", urb->status);
@@ -526,9 +526,9 @@ static void read_bulk_callback( struct urb *urb )
        pegasus->flags |= PEGASUS_RX_BUSY;
 
        switch ( urb->status ) {
-               case USB_ST_NOERROR:
+               case 0:
                        break;
-               case USB_ST_NORESPONSE:
+               case -ETIMEDOUT:
                        dbg( "reset MAC" );
                        pegasus->flags &= ~PEGASUS_RX_BUSY;
                        break;
@@ -607,9 +607,9 @@ static void intr_callback( struct urb *urb )
                return;
                
        switch ( urb->status ) {
-               case USB_ST_NOERROR:
+               case 0:
                        break;
-               case USB_ST_URB_KILLED:
+               case -ENOENT:
                        return;
                default:
                        info("intr status %d", urb->status);
@@ -713,10 +713,8 @@ static int pegasus_open(struct net_device *net)
        pegasus_t *pegasus = (pegasus_t *)net->priv;
        int     res;
 
-       MOD_INC_USE_COUNT;
        if ( (res = enable_net_traffic(net, pegasus->usb)) ) {
                err("can't enable_net_traffic() - %d", res);
-               MOD_DEC_USE_COUNT;
                return -EIO;
        }
        FILL_BULK_URB( &pegasus->rx_urb, pegasus->usb,
@@ -755,7 +753,6 @@ static int pegasus_close( struct net_device *net )
 #ifdef PEGASUS_USE_INTR
        usb_unlink_urb( &pegasus->intr_urb );
 #endif
-       MOD_DEC_USE_COUNT;
 
        return 0;
 }
@@ -867,6 +864,7 @@ static void * pegasus_probe( struct usb_device *dev, unsigned int ifnum,
        
        pegasus->usb = dev;
        pegasus->net = net;
+       SET_MODULE_OWNER(net);
        net->priv = pegasus;
        net->open = pegasus_open;
        net->stop = pegasus_close;
index 9ef3801f31a4c8f70d67c425764495a153298262..d76125cfa32e26296d56ca2175bfe6c83abfc7cb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 1999,2000 Petko Manolov - Petkan (petkan@dce.bg)
+ *  Copyright (c) 1999,2000 Petko Manolov - Petkan (pmanolov@lnxw.com)
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -138,6 +138,7 @@ struct usb_eth_dev {
 #define        VENDOR_DLINK            0x2001
 #define        VENDOR_ELSA             0x05cc
 #define        VENDOR_IODATA           0x04bb
+#define        VENDOR_KINGSTON         0x0951
 #define        VENDOR_LANEED           0x056e
 #define        VENDOR_LINKSYS          0x066b
 #define        VENDOR_MELCO            0x0411
@@ -210,6 +211,8 @@ PEGASUS_DEV( "Elsa Micolink USB2Ethernet", VENDOR_ELSA, 0x3000,
                DEFAULT_GPIO_RESET )
 PEGASUS_DEV( "IO DATA USB ET/TX", VENDOR_IODATA, 0x0904,
                DEFAULT_GPIO_RESET )
+PEGASUS_DEV( "Kingston KNU101TX Ethernet", VENDOR_KINGSTON, 0x000a,
+               DEFAULT_GPIO_RESET)
 PEGASUS_DEV( "LANEED USB Ethernet LD-USB/TX", VENDOR_LANEED, 0x4002,
                DEFAULT_GPIO_RESET )
 PEGASUS_DEV( "LANEED USB Ethernet LD-USB/TX", VENDOR_LANEED, 0x400b,
index 244674864c55e6cf4fc0b1a28cdcee1a0f2cd90d..96bb3a811e301a168c46248378cbe408e84181c9 100644 (file)
@@ -324,7 +324,7 @@ write_rio(struct file *file, const char *buffer,
                        dbg("write stats: result:%d thistime:%lu partial:%u",
                             result, thistime, partial);
 
-                       if (result == USB_ST_TIMEOUT) { /* NAK - so hold for a while */
+                       if (result == -ETIMEDOUT) {     /* NAK - so hold for a while */
                                if (!maxretry--) {
                                        errn = -ETIME;
                                        goto error;
@@ -403,7 +403,7 @@ read_rio(struct file *file, char *buffer, size_t count, loff_t * ppos)
 
                if (partial) {
                        count = this_read = partial;
-               } else if (result == USB_ST_TIMEOUT || result == 15) {  /* FIXME: 15 ??? */
+               } else if (result == -ETIMEDOUT || result == 15) {      /* FIXME: 15 ??? */
                        if (!maxretry--) {
                                up(&(rio->lock));
                                err("read_rio: maxretry timeout");
@@ -412,7 +412,7 @@ read_rio(struct file *file, char *buffer, size_t count, loff_t * ppos)
                        interruptible_sleep_on_timeout(&rio->wait_q,
                                                       NAK_TIMEOUT);
                        continue;
-               } else if (result != USB_ST_DATAUNDERRUN) {
+               } else if (result != -EREMOTEIO) {
                        up(&(rio->lock));
                        err("Read Whoops - result:%u partial:%u this_read:%u",
                             result, partial, this_read);
index ed98f11f4063b899863d9de0448ce76c6c055b0c..2e17eabd2d03b9803b2ce24d977fa6c5271a47a7 100644 (file)
  *    - Users are now notified to consult the Documentation/usb/scanner.txt
  *      for common error messages rather than the maintainer.
  *
+ * 0.4.7  11/28/2001
+ *    - Fixed typo in Documentation/scanner.txt.  Thanks to
+ *      Karel <karel.vervaeke@pandora.be> for pointing it out.
+ *    - Added ID's for a Memorex 6136u. Thanks to =C1lvaro Gaspar de
+ *      Valenzuela" <agaspard@utsi.edu>.
+ *    - Added ID's for Agfa e25.  Thanks to Heinrich 
+ *      Rust <Heinrich.Rust@gmx.de>.  Also reported to work with
+ *      Linux and SANE (?).
+ *    - Added Canon FB620U, D646U, and 1220U ID's.  Thanks to Paul
+ *      Rensing <Paul_Rensing@StanfordAlumni.org>.  For more info
+ *      on Linux support for these models, contact 
+ *      salvestrini@users.sourceforge.net.
+ *    - Added Plustek OpticPro UT12, OpticPro U24, KYE/Genius
+ *      ColorPage-HR6 V2 ID's in addition to many "Unknown" models
+ *      under those vendors.  Thanks to
+ *      Jaeger, Gerhard" <g.jaeger@earthling.net>.  These scanner are
+ *      apparently based upon the LM983x IC's.
+ *    - Applied Frank's patch that addressed some locking and module
+ *      referencing counts.  Thanks to both
+ *      Frank Zago <fzago@greshamstorage.com> and
+ *      Oliver Neukum <520047054719-0001@t-online.de> for reviewing/testing.
+ *
  * TODO
  *    - Performance
  *    - Select/poll methods
@@ -324,17 +346,16 @@ irq_scanner(struct urb *urb)
        struct scn_usb_data *scn;
        unsigned char *data;
        scn = urb->context;
-       down(&(scn->sem));
+
        data = &scn->button;
        data += 0;              /* Keep gcc from complaining about unused var */
 
        if (urb->status) {
-               up(&(scn->sem));
                return;
        }
 
        dbg("irq_scanner(%d): data:%x", scn->scn_minor, *data);
-       up(&(scn->sem));
+
        return;
 }
 
@@ -358,6 +379,7 @@ open_scanner(struct inode * inode, struct file * file)
 
        if (!p_scn_table[scn_minor]) {
                up(&scn_mutex);
+               MOD_DEC_USE_COUNT;
                err("open_scanner(%d): Unable to access minor data", scn_minor);
                return -ENODEV;
        }
@@ -606,7 +628,7 @@ read_scanner(struct file * file, char * buffer,
                        }
                        ret = result;
                        break;
-               } else if ((result < 0) && (result != USB_ST_DATAUNDERRUN)) {
+               } else if ((result < 0) && (result != -EREMOTEIO)) {
                        warn("read_scanner(%d): funky result:%d. Consult Documentation/usb/scanner.txt.", scn_minor, (int)result);
                        ret = -EIO;
                        break;
@@ -939,6 +961,7 @@ probe_scanner(struct usb_device *dev, unsigned int ifnum,
 /* Check to make sure that the last slot isn't already taken */
        if (p_scn_table[scn_minor]) {
                err("probe_scanner: No more minor devices remaining.");
+               up(&scn_mutex);
                return NULL;
        }
 
@@ -946,6 +969,7 @@ probe_scanner(struct usb_device *dev, unsigned int ifnum,
 
        if (!(scn = kmalloc (sizeof (struct scn_usb_data), GFP_KERNEL))) {
                err("probe_scanner: Out of memory.");
+               up(&scn_mutex);
                return NULL;
        }
        memset (scn, 0, sizeof(struct scn_usb_data));
@@ -1028,9 +1052,11 @@ probe_scanner(struct usb_device *dev, unsigned int ifnum,
        if (scn->devfs == NULL)
                dbg("scanner%d: device node registration failed", scn_minor);
 
+       p_scn_table[scn_minor] = scn;
+
        up(&scn_mutex);
 
-       return p_scn_table[scn_minor] = scn;
+       return scn;
 }
 
 static void
index ca10402fbb8179a57d32c45158305ff22b5f70be..2b03ce8f682d647f024832b60537bb0a6ad9d815 100644 (file)
@@ -86,12 +86,23 @@ static struct usb_device_id scanner_device_ids [] = {
        { USB_DEVICE(0x06bd, 0x2061) }, /* Another SnapScan 1212U (?)*/
        { USB_DEVICE(0x06bd, 0x0100) }, /* SnapScan Touch */
        { USB_DEVICE(0x06bd, 0x2091) }, /* SnapScan e20 */
+       { USB_DEVICE(0x06bd, 0x2095) }, /* SnapScan e25 */
        { USB_DEVICE(0x06bd, 0x2097) }, /* SnapScan e26 */
        { USB_DEVICE(0x06bd, 0x208d) }, /* Snapscan e40 */
+       /* Canon */
+       { USB_DEVICE(0x04a9, 0x2202) }, /* FB620U */
+       { USB_DEVICE(0x04a9, 0x220b) }, /* D646U */
+       { USB_DEVICE(0x04a9, 0x2207) }, /* 1220U */
        /* Colorado -- See Primax/Colorado below */
        /* Epson -- See Seiko/Epson below */
        /* Genius */
        { USB_DEVICE(0x0458, 0x2001) }, /* ColorPage-Vivid Pro */
+       { USB_DEVICE(0x0458, 0x2007) }, /* ColorPage HR6 V2 */
+       { USB_DEVICE(0x0458, 0x2008) }, /* Unknown */
+       { USB_DEVICE(0x0458, 0x2009) }, /* Unknown */
+       { USB_DEVICE(0x0458, 0x2013) }, /* Unknown */
+       { USB_DEVICE(0x0458, 0x2015) }, /* Unknown  */
+       { USB_DEVICE(0x0458, 0x2016) }, /* Unknown  */
        /* Hewlett Packard */
        { USB_DEVICE(0x03f0, 0x0205) }, /* 3300C */
        { USB_DEVICE(0x03f0, 0x0405) }, /* 3400C */
@@ -108,6 +119,8 @@ static struct usb_device_id scanner_device_ids [] = {
        { USB_DEVICE(0x0638, 0x0268) }, /* 1200U */
        /* Lifetec */
        { USB_DEVICE(0x05d8, 0x4002) }, /* Lifetec LT9385 */
+       /* Memorex */
+       { USB_DEVICE(0x0461, 0x0346) }, /* 6136u - repackaged Primax ? */
        /* Microtek -- No longer supported - Enable SCSI and USB Microtek in kernel config */
        //      { USB_DEVICE(0x05da, 0x0099) }, /* ScanMaker X6 - X6U */
        //      { USB_DEVICE(0x05da, 0x0094) }, /* Phantom 336CX - C3 */
@@ -128,6 +141,19 @@ static struct usb_device_id scanner_device_ids [] = {
        { USB_DEVICE(0x0400, 0x1001) }, /* BearPaw 2400 */
        { USB_DEVICE(0x055f, 0x0008) }, /* 1200 CU Plus */
        { USB_DEVICE(0x0ff5, 0x0010) }, /* BearPaw 1200F */
+       /* Plustek */
+       { USB_DEVICE(0x07b3, 0x0017) }, /* OpticPro UT12 */
+       { USB_DEVICE(0x07b3, 0x0011) }, /* OpticPro UT24 */
+       { USB_DEVICE(0x07b3, 0x0005) }, /* Unknown */
+       { USB_DEVICE(0x07b3, 0x0007) }, /* Unknown */
+       { USB_DEVICE(0x07b3, 0x000F) }, /* Unknown */
+       { USB_DEVICE(0x07b3, 0x0010) }, /* Unknown */
+       { USB_DEVICE(0x07b3, 0x0012) }, /* Unknown */
+       { USB_DEVICE(0x07b3, 0x0013) }, /* Unknown */
+       { USB_DEVICE(0x07b3, 0x0014) }, /* Unknown */
+       { USB_DEVICE(0x07b3, 0x0015) }, /* Unknown */
+       { USB_DEVICE(0x07b3, 0x0016) }, /* Unknown */
+       { USB_DEVICE(0x07b3, 0x0012) }, /* Unknown */
        /* Primax/Colorado */
        { USB_DEVICE(0x0461, 0x0300) }, /* G2-300 #1 */
        { USB_DEVICE(0x0461, 0x0380) }, /* G2-600 #1 */
index 9859afcb876783ffcae70a28da785eb2adca4303..126846933c94ff1ff367878b02b73d93b465158f 100644 (file)
@@ -211,9 +211,7 @@ static int  belkin_sa_open (struct usb_serial_port *port, struct file *filp)
        ++port->open_count;
        MOD_INC_USE_COUNT;
        
-       if (!port->active) {
-               port->active = 1;
-
+       if (port->open_count == 1) {
                /*Start reading from the device*/
                /* TODO: Look at possibility of submitting mulitple URBs to device to
                 *       enhance buffering.  Win trace shows 16 initial read URBs.
@@ -262,7 +260,7 @@ static void belkin_sa_close (struct usb_serial_port *port, struct file *filp)
                        usb_unlink_urb (port->read_urb);
                        usb_unlink_urb (port->interrupt_in_urb);
                }
-               port->active = 0;
+               port->open_count = 0;
        }
        
        up (&port->sem);
index ea16120a042d456259f6539fb1de1d3139c2704c..f74b72bb6b57f034eae42456956ad45bafda9aac 100644 (file)
@@ -156,8 +156,7 @@ static int  cyberjack_open (struct usb_serial_port *port, struct file *filp)
 
        ++port->open_count;
 
-       if (!port->active) {
-               port->active = 1;
+       if (port->open_count == 1) {
                /* force low_latency on so that our tty_push actually forces
                 * the data through, otherwise it is scheduled, and with high
                 * data rates (like with OHCI) data can get lost.
@@ -201,8 +200,6 @@ static void cyberjack_close (struct usb_serial_port *port, struct file *filp)
                        usb_unlink_urb (port->read_urb);
                        usb_unlink_urb (port->interrupt_in_urb);
                }
-
-               port->active = 0;
                port->open_count = 0;
        }
 
index 2f00a4d4d612a21faa051fe915004504c56441d6..74316472f873da2d64c3ec1890d6b85657291c43 100644 (file)
 *  Peter Berger (pberger@brimson.com)
 *  Al Borchers (borchers@steinerpoint.com)
 * 
+* (12/03/2001) gkh
+*      switched to using port->open_count instead of private version.
+*      Removed port->active
+*
 * (04/08/2001) gb
 *      Identify version on module load.
 *
@@ -429,7 +433,6 @@ typedef struct digi_port {
        int dp_write_urb_in_use;
        unsigned int dp_modem_signals;
        wait_queue_head_t dp_modem_change_wait;
-       int dp_open_count;                      /* inc on open, dec on close */
        int dp_transmit_idle;
        wait_queue_head_t dp_transmit_idle_wait;
        int dp_throttled;
@@ -1380,7 +1383,7 @@ dbg( "digi_write_bulk_callback: TOP, urb->status=%d", urb->status );
        /* try to send any buffered data on this port, if it is open */
        spin_lock( &priv->dp_port_lock );
        priv->dp_write_urb_in_use = 0;
-       if( priv->dp_open_count && port->write_urb->status != -EINPROGRESS
+       if( port->open_count && port->write_urb->status != -EINPROGRESS
        && priv->dp_out_buf_len > 0 ) {
 
                *((unsigned char *)(port->write_urb->transfer_buffer))
@@ -1474,7 +1477,7 @@ static int digi_open( struct usb_serial_port *port, struct file *filp )
        unsigned long flags = 0;
 
 
-dbg( "digi_open: TOP: port=%d, active=%d, open_count=%d", priv->dp_port_num, port->active, priv->dp_open_count );
+dbg( "digi_open: TOP: port=%d, open_count=%d", priv->dp_port_num, port->open_count );
 
        /* be sure the device is started up */
        if( digi_startup_device( port->serial ) != 0 )
@@ -1489,7 +1492,7 @@ dbg( "digi_open: TOP: port=%d, active=%d, open_count=%d", priv->dp_port_num, por
        }
 
        /* inc module use count before sleeping to wait for closes */
-       ++priv->dp_open_count;
+       ++port->open_count;
        MOD_INC_USE_COUNT;
 
        /* wait for a close in progress to finish */
@@ -1498,7 +1501,7 @@ dbg( "digi_open: TOP: port=%d, active=%d, open_count=%d", priv->dp_port_num, por
                        &priv->dp_close_wait, DIGI_RETRY_TIMEOUT,
                        &priv->dp_port_lock, flags );
                if( signal_pending(current) ) {
-                       --priv->dp_open_count;
+                       --port->open_count;
                        MOD_DEC_USE_COUNT;
                        return( -EINTR );
                }
@@ -1507,13 +1510,11 @@ dbg( "digi_open: TOP: port=%d, active=%d, open_count=%d", priv->dp_port_num, por
 
        /* if port is already open, just return */
        /* be sure exactly one open proceeds */
-       if( port->active ) {
+       if( port->open_count != 1)  {
                spin_unlock_irqrestore( &priv->dp_port_lock, flags );
                return( 0 );
        }
 
-       /* first open, mark port as active */
-       port->active = 1;
        spin_unlock_irqrestore( &priv->dp_port_lock, flags );
  
        /* read modem signals automatically whenever they change */
@@ -1554,17 +1555,17 @@ static void digi_close( struct usb_serial_port *port, struct file *filp )
        unsigned long flags = 0;
 
 
-dbg( "digi_close: TOP: port=%d, active=%d, open_count=%d", priv->dp_port_num, port->active, priv->dp_open_count );
+dbg( "digi_close: TOP: port=%d, open_count=%d", priv->dp_port_num, port->open_count );
 
 
        /* do cleanup only after final close on this port */
        spin_lock_irqsave( &priv->dp_port_lock, flags );
-       if( priv->dp_open_count > 1 ) {
-               --priv->dp_open_count;
+       if( port->open_count > 1 ) {
+               --port->open_count;
                MOD_DEC_USE_COUNT;
                spin_unlock_irqrestore( &priv->dp_port_lock, flags );
                return;
-       } else if( priv->dp_open_count <= 0 ) {
+       } else if( port->open_count <= 0 ) {
                spin_unlock_irqrestore( &priv->dp_port_lock, flags );
                return;
        }
@@ -1638,10 +1639,9 @@ dbg( "digi_close: TOP: port=%d, active=%d, open_count=%d", priv->dp_port_num, po
        tty->closing = 0;
 
        spin_lock_irqsave( &priv->dp_port_lock, flags );
-       port->active = 0;
        priv->dp_write_urb_in_use = 0;
        priv->dp_in_close = 0;
-       --priv->dp_open_count;
+       --port->open_count;
        MOD_DEC_USE_COUNT;
        wake_up_interruptible( &priv->dp_close_wait );
        spin_unlock_irqrestore( &priv->dp_port_lock, flags );
@@ -1710,8 +1710,6 @@ dbg( "digi_startup: TOP" );
        /* number of regular ports + 1 for the out-of-band port */
        for( i=0; i<serial->type->num_ports+1; i++ ) {
 
-               serial->port[i].active = 0;
-
                /* allocate port private structure */
                priv = serial->port[i].private =
                        (digi_port_t *)kmalloc( sizeof(digi_port_t),
@@ -1730,7 +1728,6 @@ dbg( "digi_startup: TOP" );
                priv->dp_write_urb_in_use = 0;
                priv->dp_modem_signals = 0;
                init_waitqueue_head( &priv->dp_modem_change_wait );
-               priv->dp_open_count = 0;
                priv->dp_transmit_idle = 0;
                init_waitqueue_head( &priv->dp_transmit_idle_wait );
                priv->dp_throttled = 0;
@@ -1789,9 +1786,9 @@ dbg( "digi_shutdown: TOP, in_interrupt()=%d", in_interrupt() );
        for( i=0; i<serial->type->num_ports; i++ ) {
                priv = serial->port[i].private;
                spin_lock_irqsave( &priv->dp_port_lock, flags );
-               while( priv->dp_open_count > 0 ) {
+               while( serial->port[i].open_count > 0 ) {
                        MOD_DEC_USE_COUNT;
-                       --priv->dp_open_count;
+                       --serial->port[i].open_count;
                }
                spin_unlock_irqrestore( &priv->dp_port_lock, flags );
        }
@@ -1883,7 +1880,7 @@ static int digi_read_inb_callback( struct urb *urb )
 
        /* do not process callbacks on closed ports */
        /* but do continue the read chain */
-       if( priv->dp_open_count == 0 )
+       if( port->open_count == 0 )
                return( 0 );
 
        /* short/multiple packet check */
@@ -2017,7 +2014,7 @@ opcode, line, status, val );
                        if( val & DIGI_READ_INPUT_SIGNALS_CTS ) {
                                priv->dp_modem_signals |= TIOCM_CTS;
                                /* port must be open to use tty struct */
-                               if( priv->dp_open_count
+                               if( port->open_count
                                && port->tty->termios->c_cflag & CRTSCTS ) {
                                        port->tty->hw_stopped = 0;
                                        digi_wakeup_write( port );
@@ -2025,7 +2022,7 @@ opcode, line, status, val );
                        } else {
                                priv->dp_modem_signals &= ~TIOCM_CTS;
                                /* port must be open to use tty struct */
-                               if( priv->dp_open_count
+                               if( port->open_count
                                && port->tty->termios->c_cflag & CRTSCTS ) {
                                        port->tty->hw_stopped = 1;
                                }
index cfae2c79b8cf7265840efd255e0d304a309e76e9..e935a248db3cc7f933701976bed8dfd00f5c738c 100644 (file)
@@ -161,12 +161,11 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp)
        ++port->open_count;
        MOD_INC_USE_COUNT;
 
-       if (!port->active) {
+       if (port->open_count == 1) {
 
                /* Force default termio settings */
                empeg_set_termios (port, NULL) ;
 
-               port->active = 1;
                bytes_in = 0;
                bytes_out = 0;
 
@@ -218,7 +217,6 @@ static void empeg_close (struct usb_serial_port *port, struct file * filp)
                        /* shutdown our bulk read */
                        usb_unlink_urb (port->read_urb);
                }
-               port->active = 0;
                port->open_count = 0;
        }
 
index 5ab508584ae4d3e6d25be93a9bca813713ba6b4f..8f634f74f5a147db25bd0f83861a2fcfc9ab17f6 100644 (file)
@@ -321,9 +321,7 @@ static int  ftdi_sio_open (struct usb_serial_port *port, struct file *filp)
        MOD_INC_USE_COUNT;
        ++port->open_count;
 
-       if (!port->active){
-               port->active = 1;
-
+       if (port->open_count == 1){
                /* This will push the characters through immediately rather 
                   than queue a task to deliver them */
                port->tty->low_latency = 1;
@@ -404,7 +402,6 @@ static void ftdi_sio_close (struct usb_serial_port *port, struct file *filp)
                        usb_unlink_urb (port->write_urb);
                        usb_unlink_urb (port->read_urb);
                }
-               port->active = 0;
                port->open_count = 0;
        } else {  
                /* Send a HUP if necessary */
index 4203f6fde67c09037f6b6d5acf8404b0c745d0fe..395ca62627e73ed121333e632949b3d4bb768f72 100644 (file)
@@ -987,9 +987,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
        ++port->open_count;
        MOD_INC_USE_COUNT;
        
-       if (!port->active) {
-               port->active = 1;
-
+       if (port->open_count == 1) {
                /* force low_latency on so that our tty_push actually forces the data through, 
                   otherwise it is scheduled, and with high data rates (like with OHCI) data
                   can get lost. */
@@ -1000,7 +998,6 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
                serial = port->serial;
                edge_serial = (struct edgeport_serial *)serial->private;
                if (edge_serial == NULL) {
-                       port->active = 0;
                        port->open_count = 0;
                        MOD_DEC_USE_COUNT;
                        return -ENODEV;
@@ -1064,7 +1061,6 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
                if (response < 0) {
                        err(__FUNCTION__" - error sending open port command");
                        edge_port->openPending = FALSE;
-                       port->active = 0;
                        port->open_count = 0;
                        MOD_DEC_USE_COUNT;
                        return -ENODEV;
@@ -1080,7 +1076,6 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
                        /* open timed out */
                        dbg(__FUNCTION__" - open timedout");
                        edge_port->openPending = FALSE;
-                       port->active = 0;
                        port->open_count = 0;
                        MOD_DEC_USE_COUNT;
                        return -ENODEV;
@@ -1285,7 +1280,6 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
                if (edge_port->txfifo.fifo) {
                        kfree(edge_port->txfifo.fifo);
                }
-               port->active = 0;
                port->open_count = 0;
        }
 
index 9fd18ce61a221c53029a714dce3ee28ed76a9ac5..ecec9b98339710ec81c0613acd5e9fd8dca20699 100644 (file)
@@ -206,9 +206,7 @@ static int ir_open (struct usb_serial_port *port, struct file *filp)
        ++port->open_count;
        MOD_INC_USE_COUNT;
        
-       if (!port->active) {
-               port->active = 1;
-
+       if (port->open_count == 1) {
                if (buffer_size) {
                        /* override the default buffer sizes */
                        buffer = kmalloc (buffer_size, GFP_KERNEL);
@@ -268,7 +266,6 @@ static void ir_close (struct usb_serial_port *port, struct file * filp)
                        /* shutdown our bulk read */
                        usb_unlink_urb (port->read_urb);
                }
-               port->active = 0;
                port->open_count = 0;
 
        }
index d5dd6ca6ce146b1d69762b432b77aa6a84863e00..80df4f4515a0393c7a80190d09eac14c8afcb644 100644 (file)
@@ -468,7 +468,7 @@ static void usa2x_outdat_callback(struct urb *urb)
        p_priv = (struct keyspan_port_private *)(port->private);
        dbg (__FUNCTION__ " urb %d\n", urb == p_priv->out_urbs[1]); 
 
-       if (port->active) {
+       if (port->open_count) {
                queue_task(&port->tqueue, &tq_immediate);
                mark_bh(IMMEDIATE_BH);
        }
@@ -880,9 +880,8 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp)
        MOD_INC_USE_COUNT;
 
        down (&port->sem);
+       already_active = port->open_count;
        ++port->open_count;
-       already_active = port->active;
-       port->active = 1;
        up (&port->sem);
 
        if (already_active)
@@ -948,18 +947,15 @@ static void keyspan_close(struct usb_serial_port *port, struct file *filp)
        down (&port->sem);
 
        if (--port->open_count <= 0) {
-               if (port->active) {
-                       if (serial->dev) {
-                               /* Stop reading/writing urbs */
-                               stop_urb(p_priv->inack_urb);
-                               stop_urb(p_priv->outcont_urb);
-                               for (i = 0; i < 2; i++) {
-                                       stop_urb(p_priv->in_urbs[i]);
-                                       stop_urb(p_priv->out_urbs[i]);
-                               }
+               if (serial->dev) {
+                       /* Stop reading/writing urbs */
+                       stop_urb(p_priv->inack_urb);
+                       stop_urb(p_priv->outcont_urb);
+                       for (i = 0; i < 2; i++) {
+                               stop_urb(p_priv->in_urbs[i]);
+                               stop_urb(p_priv->out_urbs[i]);
                        }
                }
-               port->active = 0;
                port->open_count = 0;
                port->tty = 0;
        }
index 7a2a9c25d0d4dfc6d0f1edb92dc9d0638758b787..c1a9864c930e782da99e86f60f025158604b886a 100644 (file)
@@ -675,9 +675,7 @@ static int keyspan_pda_open (struct usb_serial_port *port, struct file *filp)
        MOD_INC_USE_COUNT;
        ++port->open_count;
 
-       if (!port->active) {
-               port->active = 1;
+       if (port->open_count == 1) {
                /* find out how much room is in the Tx ring */
                rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
                                     6, /* write_room */
@@ -723,7 +721,6 @@ static int keyspan_pda_open (struct usb_serial_port *port, struct file *filp)
        return rc;
 error:
        --port->open_count;
-       port->active = 0;
        MOD_DEC_USE_COUNT;
        up (&port->sem);
        return rc;
@@ -748,7 +745,6 @@ static void keyspan_pda_close(struct usb_serial_port *port, struct file *filp)
                        usb_unlink_urb (port->write_urb);
                        usb_unlink_urb (port->interrupt_in_urb);
                }
-               port->active = 0;
                port->open_count = 0;
        }
 
index 0854402a688bab0cc62109346312ad07d246a167..f8b7f39f90d855a76430216378a913ccad8015a5 100644 (file)
@@ -27,6 +27,9 @@
  * 10-Nov-2001 Wolfgang Grandegger
  *   - Fixed an endianess problem with the baudrate selection for PowerPC.
  *
+ * 06-Dec-2001 Martin Hamilton <martinh@gnu.org>
+ *     Added support for the Belkin F5U109 DB9 adaptor
+ *
  * 30-May-2001 Greg Kroah-Hartman
  *     switched from using spinlock to a semaphore, which fixes lots of problems.
  *
@@ -133,6 +136,7 @@ static __devinitdata struct usb_device_id id_table_combined [] = {
        { USB_DEVICE(MCT_U232_VID, MCT_U232_PID) },
        { USB_DEVICE(MCT_U232_VID, MCT_U232_SITECOM_PID) },
        { USB_DEVICE(MCT_U232_VID, MCT_U232_DU_H3SP_PID) },
+       { USB_DEVICE(MCT_U232_BELKIN_F5U109_VID, MCT_U232_BELKIN_F5U109_PID) },
        { }             /* Terminating entry */
 };
 
@@ -175,7 +179,8 @@ struct mct_u232_private {
 #define WDR_TIMEOUT (HZ * 5 ) /* default urb timeout */
 
 static int mct_u232_calculate_baud_rate(struct usb_serial *serial, int value) {
-       if (serial->dev->descriptor.idProduct == MCT_U232_SITECOM_PID) {
+       if (serial->dev->descriptor.idProduct == MCT_U232_SITECOM_PID
+         || serial->dev->descriptor.idProduct == MCT_U232_BELKIN_F5U109_PID) {
                switch (value) {
                        case    300: return 0x01;
                        case    600: return 0x02; /* this one not tested */
@@ -340,9 +345,7 @@ static int  mct_u232_open (struct usb_serial_port *port, struct file *filp)
        ++port->open_count;
        MOD_INC_USE_COUNT;
 
-       if (!port->active) {
-               port->active = 1;
-
+       if (port->open_count == 1) {
                /* Compensate for a hardware bug: although the Sitecom U232-P25
                 * device reports a maximum output packet size of 32 bytes,
                 * it seems to be able to accept only 16 bytes (and that's what
@@ -416,7 +419,7 @@ static void mct_u232_close (struct usb_serial_port *port, struct file *filp)
                        usb_unlink_urb (port->read_urb);
                        usb_unlink_urb (port->interrupt_in_urb);
                }
-               port->active = 0;
+               port->open_count = 0;
        }
        
        up (&port->sem);
index 84e79ddc610d80df959708d94b1b86b16f14a4a0..06ca30b801dd1b17734425931e940b561afe4fbd 100644 (file)
 #define MCT_U232_SITECOM_PID           0x0230  /* Sitecom Product Id */
 
 /* DU-H3SP USB BAY hub */
-
 #define MCT_U232_DU_H3SP_PID           0x0200  /* D-Link DU-H3SP USB BAY */
 
+/* Belkin badge the MCT U232-P9 as the F5U109 */
+#define MCT_U232_BELKIN_F5U109_VID     0x050d  /* Vendor Id */
+#define MCT_U232_BELKIN_F5U109_PID     0x0109  /* Product Id */
+
 /*
  * Vendor Request Interface
  */
  *       bmAttributes        =   03 (Interrupt)
  *       wMaxPacketSize      = 0002
  *       bInterval           =   02
+ *
+ *
+ * Hardware details (added by Martin Hamilton, 2001/12/06)
+ * -----------------------------------------------------------------
+ *
+ * This info was gleaned from opening a Belkin F5U109 DB9 USB serial
+ * adaptor, which turns out to simply be a re-badged U232-P9.  We
+ * know this because there is a sticky label on the circuit board
+ * which says "U232-P9" ;-)
+ * 
+ * The circuit board inside the adaptor contains a Philips PDIUSBD12
+ * USB endpoint chip and a Phillips P87C52UBAA microcontroller with
+ * embedded UART.  Exhaustive documentation for these is available at:
+ *
+ *   http://www.semiconductors.philips.com/pip/p87c52ubaa
+ *   http://www.semiconductors.philips.com/pip/pdiusbd12
+ *
+ * Thanks to Julian Highfield for the pointer to the Philips database.
+ * 
  */
 
 #endif /* __LINUX_USB_SERIAL_MCT_U232_H */
index 946fe4e8d25681d8e9e0560f49ae60dbb2b6f020..ff8e75733e6f9a394e9d2a024ac2ce23183a94ee 100644 (file)
@@ -161,14 +161,11 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp)
        MOD_INC_USE_COUNT;
        ++port->open_count;
 
-       if (!port->active) {
-               port->active = 1;
-
+       if (port->open_count == 1) {
                od = kmalloc( sizeof(struct omninet_data), GFP_KERNEL );
                if( !od ) {
                        err(__FUNCTION__"- kmalloc(%Zd) failed.", sizeof(struct omninet_data));
-                       --port->open_count;
-                       port->active = 0;
+                       port->open_count = 0;
                        up (&port->sem);
                        MOD_DEC_USE_COUNT;
                        return -ENOMEM;
@@ -219,7 +216,6 @@ static void omninet_close (struct usb_serial_port *port, struct file * filp)
                        usb_unlink_urb (port->read_urb);
                }
 
-               port->active = 0;
                port->open_count = 0;
                od = (struct omninet_data *)port->private;
                if (od)
index cc2db352980a9cafc491af70aaab251ac14f25ce..07ff1da9cf44ff42724bedc77a4c0dc0cb4a207c 100644 (file)
@@ -371,9 +371,7 @@ static int pl2303_open (struct usb_serial_port *port, struct file *filp)
        ++port->open_count;
        MOD_INC_USE_COUNT;
 
-       if (!port->active) {
-               port->active = 1;
-
+       if (port->open_count == 1) {
 #define FISH(a,b,c,d)                                                                  \
                result=usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev,0),     \
                                       b, a, c, d, buf, 1, 100);                        \
@@ -478,8 +476,6 @@ static void pl2303_close (struct usb_serial_port *port, struct file *filp)
                                     "(interrupt_in_urb) failed with reason: %d",
                                     result);
                }
-
-               port->active = 0;
                port->open_count = 0;
        }
 
@@ -648,7 +644,7 @@ static void pl2303_read_bulk_callback (struct urb *urb)
 
        if (urb->status) {
                dbg (__FUNCTION__ " - urb->status = %d", urb->status);
-               if (!port->active) {
+               if (!port->open_count) {
                        dbg (__FUNCTION__ " - port is closed, exiting.");
                        return;
                }
@@ -680,7 +676,7 @@ static void pl2303_read_bulk_callback (struct urb *urb)
        }
 
        /* Schedule the next read _if_ we are still open */
-       if (port->active) {
+       if (port->open_count) {
                urb->dev = serial->dev;
                result = usb_submit_urb(urb);
                if (result)
index cf55d0228a553eefc2c547d635f212c1543354fc..db1f4ff4f818cff6b6b806cc5357be9f4ccbbe1d 100644 (file)
  *
  * See Documentation/usb/usb-serial.txt for more information on using this driver
  *
+ * (12/03/2001) gkh
+ *     removed active from the port structure.
+ *     added documentation to the usb_serial_device_type structure
+ *
  * (10/10/2001) gkh
  *     added vendor and product to serial structure.  Needed to determine device
  *     owner when the device is disconnected.
@@ -65,7 +69,6 @@ struct usb_serial_port {
        struct usb_serial       *serial;        /* pointer back to the owner of this port */
        struct tty_struct *     tty;            /* the coresponding tty for this port */
        unsigned char           number;
-       char                    active;         /* someone has this device open */
 
        unsigned char *         interrupt_in_buffer;
        struct urb *            interrupt_in_urb;
@@ -111,21 +114,40 @@ struct usb_serial {
 #define NUM_DONT_CARE  (-1)
 
 
-/* This structure defines the individual serial converter. */
+/**
+ * usb_serial_device_type - a structure that defines a usb serial device
+ * @name: pointer to a string that describes this device.  This string used
+ *     in the syslog messages when a device is inserted or removed.
+ * @id_table: pointer to a list of usb_device_id structures that define all
+ *     of the devices this structure can support.
+ * @num_interrupt_in: the number of interrupt in endpoints this device will
+ *     have.
+ * @num_bulk_in: the number of bulk in endpoints this device will have.
+ * @num_bulk_out: the number of bulk out endpoints this device will have.
+ * @num_ports: the number of different ports this device will have.
+ * @startup: pointer to the driver's startup function.  This will be called
+ *     when the driver is inserted into the system.  Return 0 to continue
+ *     on with the initialization sequence.  Anything else will abort it.
+ * @shutdown: pointer to the driver's shutdown function.  This will be
+ *     called when the device is removed from the system.
+ *
+ * This structure is defines a USB Serial device.  It provides all of
+ * the information that the USB serial core code needs.  If the function
+ * pointers are defined, then the USB serial core code will call them when
+ * the corresponding tty port functions are called.  If they are not
+ * called, the generic serial function will be used instead.
+ */
 struct usb_serial_device_type {
        char    *name;
        const struct usb_device_id *id_table;
        char    num_interrupt_in;
        char    num_bulk_in;
        char    num_bulk_out;
-       char    num_ports;              /* number of serial ports this device has */
+       char    num_ports;
 
        struct list_head        driver_list;
        
-       /* function call to make before accepting driver */
-       /* return 0 to continue initialization, anything else to abort */
        int (*startup) (struct usb_serial *serial);
-       
        void (*shutdown) (struct usb_serial *serial);
 
        /* serial function calls */
index 4d17c25e4f99066b42d713db6ba5a09b433d64ab..fdd07e6c7d825b79aa2b798593a0a0e5aaf52234 100644 (file)
@@ -545,7 +545,7 @@ static void serial_close(struct tty_struct *tty, struct file * filp)
 
        dbg(__FUNCTION__ " - port %d", port->number);
        
-       if (!port->active) {
+       if (!port->open_count) {
                dbg (__FUNCTION__ " - port not opened");
                return;
        }
@@ -570,7 +570,7 @@ static int serial_write (struct tty_struct * tty, int from_user, const unsigned
        
        dbg(__FUNCTION__ " - port %d, %d byte(s)", port->number, count);
 
-       if (!port->active) {
+       if (!port->open_count) {
                dbg (__FUNCTION__ " - port not opened");
                return -EINVAL;
        }
@@ -595,7 +595,7 @@ static int serial_write_room (struct tty_struct *tty)
 
        dbg(__FUNCTION__ " - port %d", port->number);
        
-       if (!port->active) {
+       if (!port->open_count) {
                dbg (__FUNCTION__ " - port not open");
                return -EINVAL;
        }
@@ -618,7 +618,7 @@ static int serial_chars_in_buffer (struct tty_struct *tty)
                return -ENODEV;
        }
 
-       if (!port->active) {
+       if (!port->open_count) {
                dbg (__FUNCTION__ " - port not open");
                return -EINVAL;
        }
@@ -643,7 +643,7 @@ static void serial_throttle (struct tty_struct * tty)
 
        dbg(__FUNCTION__ " - port %d", port->number);
 
-       if (!port->active) {
+       if (!port->open_count) {
                dbg (__FUNCTION__ " - port not open");
                return;
        }
@@ -668,7 +668,7 @@ static void serial_unthrottle (struct tty_struct * tty)
 
        dbg(__FUNCTION__ " - port %d", port->number);
 
-       if (!port->active) {
+       if (!port->open_count) {
                dbg (__FUNCTION__ " - port not open");
                return;
        }
@@ -693,7 +693,7 @@ static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned in
 
        dbg(__FUNCTION__ " - port %d, cmd 0x%.4x", port->number, cmd);
 
-       if (!port->active) {
+       if (!port->open_count) {
                dbg (__FUNCTION__ " - port not open");
                return -ENODEV;
        }
@@ -718,7 +718,7 @@ static void serial_set_termios (struct tty_struct *tty, struct termios * old)
 
        dbg(__FUNCTION__ " - port %d", port->number);
 
-       if (!port->active) {
+       if (!port->open_count) {
                dbg (__FUNCTION__ " - port not open");
                return;
        }
@@ -743,7 +743,7 @@ static void serial_break (struct tty_struct *tty, int break_state)
 
        dbg(__FUNCTION__ " - port %d", port->number);
 
-       if (!port->active) {
+       if (!port->open_count) {
                dbg (__FUNCTION__ " - port not open");
                return;
        }
@@ -787,9 +787,7 @@ static int generic_open (struct usb_serial_port *port, struct file *filp)
        
        ++port->open_count;
        
-       if (!port->active) {
-               port->active = 1;
-
+       if (port->open_count == 1) {
                /* force low_latency on so that our tty_push actually forces the data through, 
                   otherwise it is scheduled, and with high data rates (like with OHCI) data
                   can get lost. */
@@ -798,13 +796,14 @@ static int generic_open (struct usb_serial_port *port, struct file *filp)
                /* if we have a bulk interrupt, start reading from it */
                if (serial->num_bulk_in) {
                        /* Start reading from the device */
-                       FILL_BULK_URB(port->read_urb, serial->dev, 
-                                     usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress),
-                                     port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length,
-                                     ((serial->type->read_bulk_callback) ?
-                                      serial->type->read_bulk_callback :
-                                      generic_read_bulk_callback), 
-                                     port);
+                       usb_fill_bulk_urb (port->read_urb, serial->dev,
+                                          usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress),
+                                          port->read_urb->transfer_buffer,
+                                          port->read_urb->transfer_buffer_length,
+                                          ((serial->type->read_bulk_callback) ?
+                                            serial->type->read_bulk_callback :
+                                            generic_read_bulk_callback),
+                                          port);
                        result = usb_submit_urb(port->read_urb);
                        if (result)
                                err(__FUNCTION__ " - failed resubmitting read urb, error %d", result);
@@ -835,8 +834,6 @@ static void generic_close (struct usb_serial_port *port, struct file * filp)
                        if (serial->num_bulk_in)
                                usb_unlink_urb (port->read_urb);
                }
-               
-               port->active = 0;
                port->open_count = 0;
        }
 
@@ -879,13 +876,13 @@ static int generic_write (struct usb_serial_port *port, int from_user, const uns
                usb_serial_debug_data (__FILE__, __FUNCTION__, count, port->write_urb->transfer_buffer);
 
                /* set up our urb */
-               FILL_BULK_URB(port->write_urb, serial->dev, 
-                             usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress),
-                             port->write_urb->transfer_buffer, count,
-                             ((serial->type->write_bulk_callback) ? 
-                              serial->type->write_bulk_callback : 
-                              generic_write_bulk_callback), 
-                             port);
+               usb_fill_bulk_urb (port->write_urb, serial->dev,
+                                  usb_sndbulkpipe (serial->dev,
+                                                   port->bulk_out_endpointAddress),
+                                  port->write_urb->transfer_buffer, count,
+                                  ((serial->type->write_bulk_callback) ? 
+                                    serial->type->write_bulk_callback :
+                                    generic_write_bulk_callback), port);
 
                /* send the data out the bulk port */
                result = usb_submit_urb(port->write_urb);
@@ -973,13 +970,14 @@ static void generic_read_bulk_callback (struct urb *urb)
        }
 
        /* Continue trying to always read  */
-       FILL_BULK_URB(port->read_urb, serial->dev, 
-                     usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress),
-                     port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length,
-                     ((serial->type->read_bulk_callback) ?
-                      serial->type->read_bulk_callback :
-                      generic_read_bulk_callback), 
-                     port);
+       usb_fill_bulk_urb (port->read_urb, serial->dev,
+                          usb_rcvbulkpipe (serial->dev,
+                                           port->bulk_in_endpointAddress),
+                          port->read_urb->transfer_buffer,
+                          port->read_urb->transfer_buffer_length,
+                          ((serial->type->read_bulk_callback) ? 
+                            serial->type->read_bulk_callback : 
+                            generic_read_bulk_callback), port);
        result = usb_submit_urb(port->read_urb);
        if (result)
                err(__FUNCTION__ " - failed resubmitting read urb, error %d", result);
@@ -1203,13 +1201,14 @@ static void * usb_serial_probe(struct usb_device *dev, unsigned int ifnum,
                        err("Couldn't allocate bulk_in_buffer");
                        goto probe_error;
                }
-               FILL_BULK_URB(port->read_urb, dev, 
-                             usb_rcvbulkpipe(dev, endpoint->bEndpointAddress),
-                             port->bulk_in_buffer, buffer_size, 
-                             ((serial->type->read_bulk_callback) ?
-                              serial->type->read_bulk_callback :
-                              generic_read_bulk_callback), 
-                             port);
+               usb_fill_bulk_urb (port->read_urb, dev,
+                                  usb_rcvbulkpipe (dev,
+                                                   endpoint->bEndpointAddress),
+                                  port->bulk_in_buffer, buffer_size,
+                                  ((serial->type->read_bulk_callback) ? 
+                                    serial->type->read_bulk_callback : 
+                                    generic_read_bulk_callback),
+                                  port);
        }
 
        for (i = 0; i < num_bulk_out; ++i) {
@@ -1228,13 +1227,14 @@ static void * usb_serial_probe(struct usb_device *dev, unsigned int ifnum,
                        err("Couldn't allocate bulk_out_buffer");
                        goto probe_error;
                }
-               FILL_BULK_URB(port->write_urb, dev, 
-                             usb_sndbulkpipe(dev, endpoint->bEndpointAddress),
-                             port->bulk_out_buffer, buffer_size,
-                             ((serial->type->write_bulk_callback) ? 
-                              serial->type->write_bulk_callback : 
-                              generic_write_bulk_callback), 
-                             port);
+               usb_fill_bulk_urb (port->write_urb, dev,
+                                  usb_sndbulkpipe (dev,
+                                                   endpoint->bEndpointAddress),
+                                  port->bulk_out_buffer, buffer_size, 
+                                  ((serial->type->write_bulk_callback) ? 
+                                    serial->type->write_bulk_callback : 
+                                    generic_write_bulk_callback),
+                                  port);
        }
 
        for (i = 0; i < num_interrupt_in; ++i) {
@@ -1252,12 +1252,12 @@ static void * usb_serial_probe(struct usb_device *dev, unsigned int ifnum,
                        err("Couldn't allocate interrupt_in_buffer");
                        goto probe_error;
                }
-               FILL_INT_URB(port->interrupt_in_urb, dev, 
-                            usb_rcvintpipe(dev, endpoint->bEndpointAddress),
-                            port->interrupt_in_buffer, buffer_size, 
-                            serial->type->read_int_callback,
-                            port, 
-                            endpoint->bInterval);
+               usb_fill_int_urb (port->interrupt_in_urb, dev, 
+                                 usb_rcvintpipe (dev,
+                                                 endpoint->bEndpointAddress),
+                                 port->interrupt_in_buffer, buffer_size, 
+                                 serial->type->read_int_callback, port, 
+                                 endpoint->bInterval);
        }
 
        /* initialize some parts of the port structures */
@@ -1335,7 +1335,7 @@ static void usb_serial_disconnect(struct usb_device *dev, void *ptr)
                serial_shutdown (serial);
 
                for (i = 0; i < serial->num_ports; ++i)
-                       serial->port[i].active = 0;
+                       serial->port[i].open_count = 0;
 
                for (i = 0; i < serial->num_bulk_in; ++i) {
                        port = &serial->port[i];
index fcadd7b126d939314e9d2c8d01ecffa3f2123c53..292101a812e03377ded7bfa64c35a95e6b79c0d3 100644 (file)
 /*
  * Version Information
  */
-#define DRIVER_VERSION "v1.6"
+#define DRIVER_VERSION "v1.7"
 #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>"
 #define DRIVER_DESC "USB HandSpring Visor, Palm m50x, Sony Clié driver"
 
@@ -251,8 +251,7 @@ static int visor_open (struct usb_serial_port *port, struct file *filp)
        ++port->open_count;
        MOD_INC_USE_COUNT;
        
-       if (!port->active) {
-               port->active = 1;
+       if (port->open_count == 1) {
                bytes_in = 0;
                bytes_out = 0;
 
@@ -262,10 +261,12 @@ static int visor_open (struct usb_serial_port *port, struct file *filp)
                port->tty->low_latency = 1;
                
                /* Start reading from the device */
-               FILL_BULK_URB(port->read_urb, serial->dev, 
-                             usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress),
-                             port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length,
-                             visor_read_bulk_callback, port);
+               usb_fill_bulk_urb (port->read_urb, serial->dev,
+                                  usb_rcvbulkpipe (serial->dev, 
+                                                   port->bulk_in_endpointAddress),
+                                  port->read_urb->transfer_buffer,
+                                  port->read_urb->transfer_buffer_length,
+                                  visor_read_bulk_callback, port);
                result = usb_submit_urb(port->read_urb);
                if (result)
                        err(__FUNCTION__ " - failed submitting read urb, error %d", result);
@@ -314,7 +315,6 @@ static void visor_close (struct usb_serial_port *port, struct file * filp)
                        /* shutdown our bulk read */
                        usb_unlink_urb (port->read_urb);
                }
-               port->active = 0;
                port->open_count = 0;
        }
        up (&port->sem);
@@ -375,8 +375,11 @@ static int visor_write (struct usb_serial_port *port, int from_user, const unsig
                usb_serial_debug_data (__FILE__, __FUNCTION__, transfer_size, urb->transfer_buffer);
 
                /* build up our urb */
-               FILL_BULK_URB (urb, serial->dev, usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress), 
-                               urb->transfer_buffer, transfer_size, visor_write_bulk_callback, port);
+               usb_fill_bulk_urb (urb, serial->dev,
+                                  usb_sndbulkpipe (serial->dev,
+                                                   port->bulk_out_endpointAddress),
+                                  urb->transfer_buffer, transfer_size, 
+                                  visor_write_bulk_callback, port);
                urb->transfer_flags |= USB_QUEUE_BULK;
 
                /* send it down the pipe */
@@ -506,10 +509,12 @@ static void visor_read_bulk_callback (struct urb *urb)
        }
 
        /* Continue trying to always read  */
-       FILL_BULK_URB(port->read_urb, serial->dev, 
-                     usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress),
-                     port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length,
-                     visor_read_bulk_callback, port);
+       usb_fill_bulk_urb (port->read_urb, serial->dev,
+                          usb_rcvbulkpipe (serial->dev,
+                                           port->bulk_in_endpointAddress),
+                          port->read_urb->transfer_buffer,
+                          port->read_urb->transfer_buffer_length,
+                          visor_read_bulk_callback, port);
        result = usb_submit_urb(port->read_urb);
        if (result)
                err(__FUNCTION__ " - failed resubmitting read urb, error %d", result);
@@ -647,11 +652,8 @@ static void visor_shutdown (struct usb_serial *serial)
        dbg (__FUNCTION__);
 
        /* stop reads and writes on all ports */
-       for (i=0; i < serial->num_ports; ++i) {
-               while (serial->port[i].open_count > 0) {
-                       visor_close (&serial->port[i], NULL);
-               }
-       }
+       for (i=0; i < serial->num_ports; ++i)
+               serial->port[i].open_count = 0;
 }
 
 
index 8ceb2cedffccca0c0b06f1d99ac1c55c38456aa0..e07b797e88d66071a2583cb9b93d43d7470c3599 100644 (file)
@@ -309,9 +309,7 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp)
        ++port->open_count;
        MOD_INC_USE_COUNT;
        
-       if (!port->active) {
-               port->active = 1;
-
+       if (port->open_count == 1) {
                /* set up some stuff for our command port */
                command_port = &port->serial->port[COMMAND_PORT];
                if (command_port->private == NULL) {
@@ -391,7 +389,7 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp)
                /* shutdown our bulk reads and writes */
                usb_unlink_urb (port->write_urb);
                usb_unlink_urb (port->read_urb);
-               port->active = 0;
+               port->open_count = 0;
        }
        MOD_DEC_USE_COUNT;
        up (&port->sem);
index 96787e4a39726dea7e98a787b6577a4076450a6c..6a62a015d0622d4e3966a409f7b1fd2b2394d5fc 100644 (file)
@@ -485,7 +485,7 @@ static int sohci_return_urb (struct ohci *hc, urb_t * urb)
 
                        /* implicitly requeued */
                        urb->actual_length = 0;
-                       urb->status = USB_ST_URB_PENDING;
+                       urb->status = -EINPROGRESS;
                        if (urb_priv->state != URB_DEL)
                                td_submit_urb (urb);
                        break;
@@ -502,7 +502,7 @@ static int sohci_return_urb (struct ohci *hc, urb_t * urb)
                                urb->complete (urb);
                                spin_lock_irqsave (&usb_ed_lock, flags);
                                urb->actual_length = 0;
-                               urb->status = USB_ST_URB_PENDING;
+                               urb->status = -EINPROGRESS;
                                urb->start_frame = urb_priv->ed->last_iso + 1;
                                if (urb_priv->state != URB_DEL) {
                                        for (i = 0; i < urb->number_of_packets; i++) {
@@ -673,7 +673,7 @@ static int sohci_submit_urb (urb_t * urb)
 
        urb->actual_length = 0;
        urb->hcpriv = urb_priv;
-       urb->status = USB_ST_URB_PENDING;
+       urb->status = -EINPROGRESS;
 
        /* link the ed into a chain if is not already */
        if (ed->state != ED_OPER)
@@ -737,7 +737,7 @@ static int sohci_unlink_urb (urb_t * urb)
        if (usb_pipedevice (urb->pipe) == ohci->rh.devnum)
                return rh_unlink_urb (urb);
 
-       if (urb->hcpriv && (urb->status == USB_ST_URB_PENDING)) { 
+       if (urb->hcpriv && (urb->status == -EINPROGRESS)) { 
                if (!ohci->disabled) {
                        urb_priv_t  * urb_priv;
 
@@ -777,11 +777,11 @@ static int sohci_unlink_urb (urb_t * urb)
 
                                /* wait until all TDs are deleted */
                                set_current_state(TASK_UNINTERRUPTIBLE);
-                               while (timeout && (urb->status == USB_ST_URB_PENDING))
+                               while (timeout && (urb->status == -EINPROGRESS))
                                        timeout = schedule_timeout (timeout);
                                set_current_state(TASK_RUNNING);
                                remove_wait_queue (&unlink_wakeup, &wait); 
-                               if (urb->status == USB_ST_URB_PENDING) {
+                               if (urb->status == -EINPROGRESS) {
                                        err ("unlink URB timeout");
                                        return -ETIMEDOUT;
                                }
index e38fc015af499c0cd353bf86cb12aa42e8b51763..ba9758e2ddf52d41b03b0be710fc62d20b8c4e57 100644 (file)
 static int cc_to_error[16] = { 
 
 /* mapping of the OHCI CC status to error codes */ 
-       /* No  Error  */               USB_ST_NOERROR,
-       /* CRC Error  */               USB_ST_CRC,
-       /* Bit Stuff  */               USB_ST_BITSTUFF,
-       /* Data Togg  */               USB_ST_CRC,
-       /* Stall      */               USB_ST_STALL,
-       /* DevNotResp */               USB_ST_NORESPONSE,
-       /* PIDCheck   */               USB_ST_BITSTUFF,
-       /* UnExpPID   */               USB_ST_BITSTUFF,
-       /* DataOver   */               USB_ST_DATAOVERRUN,
-       /* DataUnder  */               USB_ST_DATAUNDERRUN,
-       /* reservd    */               USB_ST_NORESPONSE,
-       /* reservd    */               USB_ST_NORESPONSE,
-       /* BufferOver */               USB_ST_BUFFEROVERRUN,
-       /* BuffUnder  */               USB_ST_BUFFERUNDERRUN,
-       /* Not Access */               USB_ST_NORESPONSE,
-       /* Not Access */               USB_ST_NORESPONSE 
+       /* No  Error  */        0,
+       /* CRC Error  */        -EILSEQ,
+       /* Bit Stuff  */        -EPROTO,
+       /* Data Togg  */        -EILSEQ,
+       /* Stall      */        -EPIPE,
+       /* DevNotResp */        -ETIMEDOUT,
+       /* PIDCheck   */        -EPROTO,
+       /* UnExpPID   */        -EPROTO,
+       /* DataOver   */        -EOVERFLOW,
+       /* DataUnder  */        -EREMOTEIO,
+       /* reservd    */        -ETIMEDOUT,
+       /* reservd    */        -ETIMEDOUT,
+       /* BufferOver */        -ECOMM,
+       /* BuffUnder  */        -ENOSR,
+       /* Not Access */        -ETIMEDOUT,
+       /* Not Access */        -ETIMEDOUT 
 };
 
 #include <linux/config.h>
index 6928f52a95ab9a39c157e419bd48ba507d8dcb70..1003eaf5212fa6e4de17ed68c3e0b35d6fcc1181 100644 (file)
@@ -106,8 +106,8 @@ int usb_register(struct usb_driver *new_driver)
  *     Goes through all unclaimed USB interfaces, and offers them to all
  *     registered USB drivers through the 'probe' function.
  *     This will automatically be called after usb_register is called.
- *     It is called by some of the USB subsystems after one of their subdrivers
- *     are registered.
+ *     It is called by some of the subsystems layered over USB
+ *     after one of their subdrivers are registered.
  */
 void usb_scan_devices(void)
 {
@@ -292,7 +292,7 @@ static long usb_calc_bus_time (int low_speed, int input_dir, int isoc, int bytec
  * bustime is from calc_bus_time(), but converted to microseconds.
  *
  * returns <bustime in us> if successful,
- * or USB_ST_BANDWIDTH_ERROR if bandwidth request fails.
+ * or -ENOSPC if bandwidth request fails.
  *
  * FIXME:
  * This initial implementation does not use Endpoint.bInterval
@@ -333,7 +333,7 @@ int usb_check_bandwidth (struct usb_device *dev, struct urb *urb)
 
        if (!usb_bandwidth_option)      /* don't enforce it */
                return (bustime);
-       return (new_alloc <= FRAME_TIME_MAX_USECS_ALLOC) ? bustime : USB_ST_BANDWIDTH_ERROR;
+       return (new_alloc <= FRAME_TIME_MAX_USECS_ALLOC) ? bustime : -ENOSPC;
 }
 
 void usb_claim_bandwidth (struct usb_device *dev, struct urb *urb, int bustime, int isoc)
@@ -1121,7 +1121,10 @@ void usb_free_urb(urb_t* urb)
  * any transfer flags.
  *
  * Successful submissions return 0; otherwise this routine returns a
- * negative error number.
+ * negative error number.  If the submission is successful, the complete
+ * fuction of the urb will be called when the USB host driver is
+ * finished with the urb (either a successful transmission, or some
+ * error case.)
  *
  * Unreserved Bandwidth Transfers:
  *
@@ -1198,12 +1201,14 @@ int usb_unlink_urb(urb_t *urb)
                return -ENODEV;
 }
 /*-------------------------------------------------------------------*
- *                     COMPLETION HANDLERS                           *
+ *                         SYNCHRONOUS CALLS                         *
  *-------------------------------------------------------------------*/
 
-/*-------------------------------------------------------------------*
- * completion handler for compatibility wrappers (sync control/bulk) *
- *-------------------------------------------------------------------*/
+struct usb_api_data {
+       wait_queue_head_t wqh;
+       int done;
+};
+
 static void usb_api_blocking_completion(urb_t *urb)
 {
        struct usb_api_data *awd = (struct usb_api_data *)urb->context;
@@ -1213,10 +1218,6 @@ static void usb_api_blocking_completion(urb_t *urb)
        wake_up(&awd->wqh);
 }
 
-/*-------------------------------------------------------------------*
- *                         SYNCHRONOUS CALLS                         *
- *-------------------------------------------------------------------*/
-
 // Starts urb and waits for completion or timeout
 static int usb_start_wait_urb(urb_t *urb, int timeout, int* actual_length)
 { 
@@ -1723,7 +1724,8 @@ int usb_parse_configuration(struct usb_config_descriptor *config, char *buffer)
        return size;
 }
 
-// usbcore-internal:  enumeration/hub only!!
+// hub-only!! ... and only exported for reset/reinit path.
+// otherwise used internally on disconnect/destroy path
 void usb_destroy_configuration(struct usb_device *dev)
 {
        int c, i, j, k;
@@ -1955,18 +1957,14 @@ void usb_connect(struct usb_device *dev)
  * These are the actual routines to send
  * and receive control messages.
  */
-#ifdef CONFIG_USB_LONG_TIMEOUT
-#define GET_TIMEOUT 4
-#else
-#define GET_TIMEOUT 3
-#endif
-#define SET_TIMEOUT 3
 
-// hub driver only!!! for enumeration
+// hub-only!! ... and only exported for reset/reinit path.
+// otherwise used internally, for usb_new_device()
 int usb_set_address(struct usb_device *dev)
 {
        return usb_control_msg(dev, usb_snddefctrl(dev), USB_REQ_SET_ADDRESS,
-               0, dev->devnum, 0, NULL, 0, HZ * GET_TIMEOUT);
+               // FIXME USB_CTRL_SET_TIMEOUT
+               0, dev->devnum, 0, NULL, 0, HZ * USB_CTRL_GET_TIMEOUT);
 }
 
 /**
@@ -1984,7 +1982,7 @@ int usb_set_address(struct usb_device *dev)
  * Configuration descriptors (USB_DT_CONFIG) are part of the device
  * structure, at least for the current configuration.
  * In addition to a number of USB-standard descriptors, some
- * devices also use vendor-specific descriptors.
+ * devices also use class-specific or vendor-specific descriptors.
  *
  * This call is synchronous, and may not be used in an interrupt context.
  *
@@ -1999,24 +1997,17 @@ int usb_get_descriptor(struct usb_device *dev, unsigned char type, unsigned char
        memset(buf,0,size);     // Make sure we parse really received data
 
        while (i--) {
+               /* retries if the returned length was 0; flakey device */
                if ((result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
-                       USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,
-                       (type << 8) + index, 0, buf, size, HZ * GET_TIMEOUT)) > 0 ||
-                    result == -EPIPE)
-                       break;  /* retry if the returned length was 0; flaky device */
+                                   USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,
+                                   (type << 8) + index, 0, buf, size,
+                                   HZ * USB_CTRL_GET_TIMEOUT)) > 0
+                               || result == -EPIPE)
+                       break;
        }
        return result;
 }
 
-// FIXME  Doesn't use USB_DT_CLASS ... but hid-core.c expects it this way
-int usb_get_class_descriptor(struct usb_device *dev, int ifnum,
-               unsigned char type, unsigned char id, void *buf, int size)
-{
-       return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
-               USB_REQ_GET_DESCRIPTOR, USB_RECIP_INTERFACE | USB_DIR_IN,
-               (type << 8) + id, ifnum, buf, size, HZ * GET_TIMEOUT);
-}
-
 /**
  * usb_get_string - gets a string descriptor
  * @dev: the device whose string descriptor is being retrieved
@@ -2042,7 +2033,8 @@ int usb_get_string(struct usb_device *dev, unsigned short langid, unsigned char
 {
        return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
                USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,
-               (USB_DT_STRING << 8) + index, langid, buf, size, HZ * GET_TIMEOUT);
+               (USB_DT_STRING << 8) + index, langid, buf, size,
+               HZ * USB_CTRL_GET_TIMEOUT);
 }
 
 /**
@@ -2100,40 +2092,13 @@ int usb_get_device_descriptor(struct usb_device *dev)
 int usb_get_status(struct usb_device *dev, int type, int target, void *data)
 {
        return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
-               USB_REQ_GET_STATUS, USB_DIR_IN | type, 0, target, data, 2, HZ * GET_TIMEOUT);
+               USB_REQ_GET_STATUS, USB_DIR_IN | type, 0, target, data, 2,
+               HZ * USB_CTRL_GET_TIMEOUT);
 }
 
-// FIXME hid-specific !!  DOES NOT BELONG HERE
-int usb_get_protocol(struct usb_device *dev, int ifnum)
-{
-       unsigned char type;
-       int ret;
-
-       if ((ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
-           USB_REQ_GET_PROTOCOL, USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
-           0, ifnum, &type, 1, HZ * GET_TIMEOUT)) < 0)
-               return ret;
 
-       return type;
-}
-
-// FIXME hid-specific !!  DOES NOT BELONG HERE
-int usb_set_protocol(struct usb_device *dev, int ifnum, int protocol)
-{
-       return usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
-               USB_REQ_SET_PROTOCOL, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
-               protocol, ifnum, NULL, 0, HZ * SET_TIMEOUT);
-}
-
-// FIXME hid-specific !!  DOES NOT BELONG HERE
-int usb_set_idle(struct usb_device *dev, int ifnum, int duration, int report_id)
-{
-       return usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
-               USB_REQ_SET_IDLE, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
-               (duration << 8) | report_id, ifnum, NULL, 0, HZ * SET_TIMEOUT);
-}
-
-// hub-only!!
+// hub-only!! ... and only exported for reset/reinit path.
+// otherwise used internally, for config/altsetting reconfig.
 void usb_set_maxpacket(struct usb_device *dev)
 {
        int i, b;
@@ -2197,7 +2162,8 @@ int usb_clear_halt(struct usb_device *dev, int pipe)
 */
 
        result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
-               USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, 0, endp, NULL, 0, HZ * SET_TIMEOUT);
+               USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, 0, endp, NULL, 0,
+               HZ * USB_CTRL_SET_TIMEOUT);
 
        /* don't clear if failed */
        if (result < 0)
@@ -2211,7 +2177,8 @@ int usb_clear_halt(struct usb_device *dev, int pipe)
 
        result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
                USB_REQ_GET_STATUS, USB_DIR_IN | USB_RECIP_ENDPOINT, 0, endp,
-               buffer, sizeof(status), HZ * SET_TIMEOUT);
+               // FIXME USB_CTRL_GET_TIMEOUT, yes?  why not usb_get_status() ?
+               buffer, sizeof(status), HZ * USB_CTRL_SET_TIMEOUT);
 
        memcpy(&status, buffer, sizeof(status));
        kfree(buffer);
@@ -2327,7 +2294,8 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
        }
 
        if ((ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
-           USB_REQ_SET_CONFIGURATION, 0, configuration, 0, NULL, 0, HZ * SET_TIMEOUT)) < 0)
+                       USB_REQ_SET_CONFIGURATION, 0, configuration, 0,
+                       NULL, 0, HZ * USB_CTRL_SET_TIMEOUT)) < 0)
                return ret;
 
        dev->actconfig = cp;
@@ -2338,23 +2306,8 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
        return 0;
 }
 
-// FIXME hid-specific !!  DOES NOT BELONG HERE
-int usb_get_report(struct usb_device *dev, int ifnum, unsigned char type, unsigned char id, void *buf, int size)
-{
-       return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
-               USB_REQ_GET_REPORT, USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
-               (type << 8) + id, ifnum, buf, size, HZ * GET_TIMEOUT);
-}
-
-// FIXME hid-specific !!  DOES NOT BELONG HERE
-int usb_set_report(struct usb_device *dev, int ifnum, unsigned char type, unsigned char id, void *buf, int size)
-{
-       return usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
-               USB_REQ_SET_REPORT, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
-               (type << 8) + id, ifnum, buf, size, HZ);
-}
-
-// hub driver only !!
+// hub-only!! ... and only in reset path, or usb_new_device()
+// (used by real hubs and virtual root hubs)
 int usb_get_configuration(struct usb_device *dev)
 {
        int result;
@@ -2761,33 +2714,28 @@ EXPORT_SYMBOL(usb_check_bandwidth);
 EXPORT_SYMBOL(usb_claim_bandwidth);
 EXPORT_SYMBOL(usb_release_bandwidth);
 
-EXPORT_SYMBOL(usb_set_address);
-EXPORT_SYMBOL(usb_get_descriptor);
-EXPORT_SYMBOL(usb_get_class_descriptor);
 EXPORT_SYMBOL(__usb_get_extra_descriptor);
-EXPORT_SYMBOL(usb_get_device_descriptor);
-EXPORT_SYMBOL(usb_get_string);
-EXPORT_SYMBOL(usb_string);
-EXPORT_SYMBOL(usb_get_protocol);
-EXPORT_SYMBOL(usb_set_protocol);
-EXPORT_SYMBOL(usb_get_report);
-EXPORT_SYMBOL(usb_set_report);
-EXPORT_SYMBOL(usb_set_idle);
-EXPORT_SYMBOL(usb_clear_halt);
-EXPORT_SYMBOL(usb_set_interface);
-EXPORT_SYMBOL(usb_get_configuration);
-EXPORT_SYMBOL(usb_set_configuration);
-EXPORT_SYMBOL(usb_get_status);
 
 EXPORT_SYMBOL(usb_get_current_frame_number);
 
+// asynchronous request completion model
 EXPORT_SYMBOL(usb_alloc_urb);
 EXPORT_SYMBOL(usb_free_urb);
 EXPORT_SYMBOL(usb_submit_urb);
 EXPORT_SYMBOL(usb_unlink_urb);
 
+// synchronous request completion model
 EXPORT_SYMBOL(usb_control_msg);
 EXPORT_SYMBOL(usb_bulk_msg);
+// synchronous control message convenience routines
+EXPORT_SYMBOL(usb_get_descriptor);
+EXPORT_SYMBOL(usb_get_device_descriptor);
+EXPORT_SYMBOL(usb_get_status);
+EXPORT_SYMBOL(usb_get_string);
+EXPORT_SYMBOL(usb_string);
+EXPORT_SYMBOL(usb_clear_halt);
+EXPORT_SYMBOL(usb_set_configuration);
+EXPORT_SYMBOL(usb_set_interface);
 
 EXPORT_SYMBOL(usb_devfs_handle);
 MODULE_LICENSE("GPL");
index c2c742d4b1578a047fd8dd1e31d52717d5007c89..365adb3bb0f4ab86dbd141be358f4936517307fb 100644 (file)
@@ -35,6 +35,9 @@
 #include <linux/init.h>
 #include <linux/usb.h>
 
+#define        _HID_BOOT_PROTOCOL
+#include "hid.h"
+
 /*
  * Version Information
  */
@@ -192,8 +195,8 @@ static void *usb_kbd_probe(struct usb_device *dev, unsigned int ifnum,
        pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
        maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
 
-       usb_set_protocol(dev, interface->bInterfaceNumber, 0);
-       usb_set_idle(dev, interface->bInterfaceNumber, 0, 0);
+       hid_set_protocol(dev, interface->bInterfaceNumber, 0);
+       hid_set_idle(dev, interface->bInterfaceNumber, 0, 0);
 
        if (!(kbd = kmalloc(sizeof(struct usb_kbd), GFP_KERNEL))) return NULL;
        memset(kbd, 0, sizeof(struct usb_kbd));
@@ -216,7 +219,7 @@ static void *usb_kbd_probe(struct usb_device *dev, unsigned int ifnum,
                usb_kbd_irq, kbd, endpoint->bInterval);
 
        kbd->dr.requesttype = USB_TYPE_CLASS | USB_RECIP_INTERFACE;
-       kbd->dr.request = USB_REQ_SET_REPORT;
+       kbd->dr.request = HID_REQ_SET_REPORT;
        kbd->dr.value = 0x200;
        kbd->dr.index = interface->bInterfaceNumber;
        kbd->dr.length = 1;
index 9eb4fb275b07b39b170ec2197e9d58cd1a8b84b2..ff4ee6676420025ae660c222e1cfccba16fa2605 100644 (file)
@@ -35,6 +35,9 @@
 #include <linux/init.h>
 #include <linux/usb.h>
 
+#define        _HID_BOOT_PROTOCOL
+#include "hid.h"
+
 /*
  * Version Information
  */
@@ -118,7 +121,7 @@ static void *usb_mouse_probe(struct usb_device *dev, unsigned int ifnum,
        pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
        maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
 
-       usb_set_idle(dev, interface->bInterfaceNumber, 0, 0);
+       hid_set_idle(dev, interface->bInterfaceNumber, 0, 0);
 
        if (!(mouse = kmalloc(sizeof(struct usb_mouse), GFP_KERNEL))) return NULL;
        memset(mouse, 0, sizeof(struct usb_mouse));
index 96608c0d91068b2f74038ec2589e3616ba0e0312..033ad12eb0bc16d36f9bd4adc1f44469ba87f349 100644 (file)
@@ -1535,7 +1535,7 @@ static void tx_complete (struct urb *urb)
        struct skb_data         *entry = (struct skb_data *) skb->cb;
        struct usbnet           *dev = entry->dev;
 
-       if (urb->status == USB_ST_STALL) {
+       if (urb->status == -EPIPE) {
                if (dev->ctrl_task.sync == 0) {
                        dev->ctrl_task.routine = tx_clear_halt;
                        dev->ctrl_task.data = dev;
@@ -1870,6 +1870,11 @@ static const struct usb_device_id        products [] = {
        USB_DEVICE (0x0547, 0x2720),    // AnchorChips defaults
        driver_info:    (unsigned long) &an2720_info,
 },
+
+{
+       USB_DEVICE (0x0547, 0x2727),    // Xircom PGUNET
+       driver_info:    (unsigned long) &an2720_info,
+},
 #endif
 
 #ifdef CONFIG_USB_BELKIN
index 98067c8666548825601cc394e19800110a115356..ebf8e985bcecef890200d099fd95d201b5cee2b3 100644 (file)
@@ -193,7 +193,7 @@ static int uss720_irq(int usbstatus, void *buffer, int len, void *dev_id)
        struct parport *pp = (struct parport *)dev_id;
        struct parport_uss720_private *priv = pp->private_data; 
 
-       if (usbstatus != USB_ST_NOERROR || len < 4 || !buffer)
+       if (usbstatus != 0 || len < 4 || !buffer)
                return 1;
        memcpy(priv->reg, buffer, 4);
        /* if nAck interrupts are enabled and we have an interrupt, call the interrupt procedure */
index 76539b360ad731400397bcd2151bcc08bce054c7..9ce3025daf55e6c291aeb92cca849c2e875e5a92 100644 (file)
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -47,7 +47,6 @@ static unsigned int bio_pool_free;
 struct biovec_pool {
        int bp_size;
        kmem_cache_t *bp_cachep;
-       wait_queue_head_t bp_wait;
 };
 
 static struct biovec_pool bvec_list[BIOVEC_NR_POOLS];
@@ -161,32 +160,22 @@ static inline struct bio_vec *bvec_alloc(int gfp_mask, int nr, int *idx)
        if ((bvl = kmem_cache_alloc(bp->bp_cachep, gfp_mask)))
                goto out_gotit;
 
-       /*
-        * we need slab reservations for this to be completely
-        * deadlock free...
-        */
-       if (BIO_CAN_WAIT(gfp_mask)) {
-               DECLARE_WAITQUEUE(wait, current);
+       if (!BIO_CAN_WAIT(gfp_mask))
+               return NULL;
 
-               add_wait_queue_exclusive(&bp->bp_wait, &wait);
-               for (;;) {
-                       set_current_state(TASK_UNINTERRUPTIBLE);
-                       bvl = kmem_cache_alloc(bp->bp_cachep, gfp_mask);
-                       if (bvl)
-                               goto out_gotit;
+       do {
+               bvl = kmem_cache_alloc(bp->bp_cachep, gfp_mask);
+               if (bvl)
+                       break;
 
-                       run_task_queue(&tq_disk);
-                       schedule();
-               }
-               remove_wait_queue(&bp->bp_wait, &wait);
+               run_task_queue(&tq_disk);
                __set_current_state(TASK_RUNNING);
-       }
+               current->policy |= SCHED_YIELD;
+               schedule();
+       } while (1);
 
-       if (bvl) {
 out_gotit:
-               memset(bvl, 0, bp->bp_size);
-       }
-
+       memset(bvl, 0, bp->bp_size);
        return bvl;
 }
 
@@ -202,10 +191,8 @@ void bio_destructor(struct bio *bio)
        /*
         * cloned bio doesn't own the veclist
         */
-       if (!(bio->bi_flags & (1 << BIO_CLONED))) {
+       if (!(bio->bi_flags & (1 << BIO_CLONED)))
                kmem_cache_free(bp->bp_cachep, bio->bi_io_vec);
-               wake_up_nr(&bp->bp_wait, 1);
-       }
 
        bio_pool_put(bio);
 }
@@ -326,31 +313,46 @@ void bio_put(struct bio *bio)
 }
 
 /**
- *     bio_clone       -       duplicate a bio
- *     @bio: bio to clone
- *     @gfp_mask: allocation priority
+ *     __bio_clone     -       clone a bio
+ *     @bio: destination bio
+ *     @bio_src: bio to clone
  *
- *     Duplicate a &bio. Caller will own the returned bio, but not
+ *     Clone a &bio. Caller will own the returned bio, but not
  *     the actual data it points to. Reference count of returned
  *     bio will be one.
  */
-struct bio *bio_clone(struct bio *bio, int gfp_mask)
+inline void __bio_clone(struct bio *bio, struct bio *bio_src)
 {
-       struct bio *b = bio_alloc(gfp_mask, 0);
+       bio->bi_io_vec = bio_src->bi_io_vec;
 
-       if (b) {
-               b->bi_io_vec = bio->bi_io_vec;
+       bio->bi_sector = bio_src->bi_sector;
+       bio->bi_dev = bio_src->bi_dev;
+       bio->bi_flags |= 1 << BIO_CLONED;
+       bio->bi_rw = bio_src->bi_rw;
 
-               b->bi_sector = bio->bi_sector;
-               b->bi_dev = bio->bi_dev;
-               b->bi_flags |= 1 << BIO_CLONED;
-               b->bi_rw = bio->bi_rw;
+       /*
+        * notes -- maybe just leave bi_idx alone. bi_max has no used
+        * on a cloned bio
+        */
+       bio->bi_vcnt = bio_src->bi_vcnt;
+       bio->bi_idx = bio_src->bi_idx;
+       bio->bi_size = bio_src->bi_size;
+       bio->bi_max = bio_src->bi_max;
+}
 
-               b->bi_vcnt = bio->bi_vcnt;
-               b->bi_idx = bio->bi_idx;
-               b->bi_size = bio->bi_size;
-               b->bi_max = bio->bi_max;
-       }
+/**
+ *     bio_clone       -       clone a bio
+ *     @bio: bio to clone
+ *     @gfp_mask: allocation priority
+ *
+ *     Like __bio_clone, only also allocates the returned bio
+ */
+struct bio *bio_clone(struct bio *bio, int gfp_mask)
+{
+       struct bio *b = bio_alloc(gfp_mask, 0);
+
+       if (b)
+               __bio_clone(b, bio);
 
        return b;
 }
@@ -667,7 +669,6 @@ static void __init biovec_init_pool(void)
                        panic("biovec: can't init slab pools\n");
 
                bp->bp_size = size;
-               init_waitqueue_head(&bp->bp_wait);
        }
 }
 
@@ -696,4 +697,5 @@ EXPORT_SYMBOL(ll_rw_kio);
 EXPORT_SYMBOL(bio_endio);
 EXPORT_SYMBOL(bio_init);
 EXPORT_SYMBOL(bio_copy);
+EXPORT_SYMBOL(__bio_clone);
 EXPORT_SYMBOL(bio_clone);
index 3aed4d13827c5dc45f1f5fa1a9acecdc50efd74d..f8bc9ac9cfd059f6090a215d63c57e92c6f048df 100644 (file)
@@ -67,18 +67,6 @@ do {                                                                         \
 
 #define PAGE_BUG(page) BUG()
 
-#define BUG_ON(condition)                      \
-       do {                                    \
-               if (unlikely((long)(condition)))\
-                       BUG();                  \
-       } while (0)
-
-#define BUG_ON(condition)                      \
-       do {                                    \
-               if (unlikely((int)(condition))) \
-                       BUG();                  \
-       } while (0)
-
 /* Pure 2^n version of get_order */
 extern __inline__ int get_order(unsigned long size)
 {
index ac78341f54023959a2a4492e9bac8fb15412769c..1bdb4c4b641c3f0bfc917056f10989b6d45b5998 100644 (file)
@@ -101,12 +101,6 @@ extern void do_BUG(const char *file, int line);
        BUG(); \
 } while (0)
 
-#define BUG_ON(condition)                      \
-       do {                                    \
-               if (unlikely((int)(condition))) \
-                       BUG();                  \
-       } while (0)
-
 /* Pure 2^n version of get_order */
 static __inline__ int get_order(unsigned long size)
 {
index 85e518c1c1e6e6512e4410c4d14b942ed21446c2..09819839310ddc36a987e4ebd2e0a5b393907708 100644 (file)
@@ -168,6 +168,7 @@ extern void bio_put(struct bio *);
 
 extern int bio_endio(struct bio *, int, int);
 
+extern inline void __bio_clone(struct bio *, struct bio *);
 extern struct bio *bio_clone(struct bio *, int);
 extern struct bio *bio_copy(struct bio *, int, int);
 
index e54f03ebbf0283ab7c9a0df2374314fa1ecf658c..e3155fcaaf47ca4ed8c32159e69f92ccf2a4c1d5 100644 (file)
@@ -77,12 +77,21 @@ extern inline struct request *elv_next_request(request_queue_t *q)
        return rq;
 }
 
-extern inline void elv_add_request(request_queue_t *q, struct request *rq)
-{
-       blk_plug_device(q);
-       q->elevator.elevator_add_req_fn(q, rq, q->queue_head.prev);
-}
-
+#define __elv_add_request_core(q, rq, where, plug)                     \
+       do {                                                            \
+               if ((plug))                                             \
+                       blk_plug_device((q));                           \
+               (q)->elevator.elevator_add_req_fn((q), (rq), (where));  \
+       } while (0)
+
+#define __elv_add_request(q, rq, back, p)                                    \
+       if ((back))                                                           \
+               __elv_add_request_core((q), (rq), (q)->queue_head.prev, (p)); \
+       else                                                                  \
+               __elv_add_request_core((q), (rq), &(q)->queue_head, 0);       \
+
+#define elv_add_request(q, rq, back) __elv_add_request((q), (rq), (back), 1)
+       
 #if defined(MAJOR_NR) || defined(IDE_DRIVER)
 
 #undef DEVICE_ON
index ce4aef9e56662fa4d0fb61852e2e37257a321a06..523e38822f65840b5bae7711465d2e2ca02b96dc 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/linkage.h>
 #include <linux/stddef.h>
 #include <linux/types.h>
+#include <linux/compiler.h>
 
 /* Optimization barrier */
 /* The "volatile" is due to gcc bugs */
@@ -176,4 +177,5 @@ struct sysinfo {
        char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
 };
 
+#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
 #endif
index b70220e801b1e93f98bb38c9fe61280a1f98ffcf..7af47915e3839b214e7f4fc7235dc30cf20694da 100644 (file)
 #define USB_CLASS_COMM                 2
 #define USB_CLASS_HID                  3
 #define USB_CLASS_PHYSICAL             5
+#define USB_CLASS_STILL_IMAGE          6
 #define USB_CLASS_PRINTER              7
 #define USB_CLASS_MASS_STORAGE         8
 #define USB_CLASS_HUB                  9
-#define USB_CLASS_DATA                 10
+#define USB_CLASS_CDC_DATA             0x0a
+#define USB_CLASS_CSCID                0x0b /* chip+ smart card */
+#define USB_CLASS_CONTENT_SEC          0x0d /* content security */
 #define USB_CLASS_APP_SPEC             0xfe
 #define USB_CLASS_VENDOR_SPEC          0xff
 
 #define USB_DIR_OUT                    0
 #define USB_DIR_IN                     0x80
 
-/*
- * Descriptor types
- */
-#define USB_DT_DEVICE                  0x01
-#define USB_DT_CONFIG                  0x02
-#define USB_DT_STRING                  0x03
-#define USB_DT_INTERFACE               0x04
-#define USB_DT_ENDPOINT                        0x05
-
-#define USB_DT_HID                     (USB_TYPE_CLASS | 0x01)
-#define USB_DT_REPORT                  (USB_TYPE_CLASS | 0x02)
-#define USB_DT_PHYSICAL                        (USB_TYPE_CLASS | 0x03)
-#define USB_DT_HUB                     (USB_TYPE_CLASS | 0x09)
-
-/*
- * Descriptor sizes per descriptor type
- */
-#define USB_DT_DEVICE_SIZE             18
-#define USB_DT_CONFIG_SIZE             9
-#define USB_DT_INTERFACE_SIZE          9
-#define USB_DT_ENDPOINT_SIZE           7
-#define USB_DT_ENDPOINT_AUDIO_SIZE     9       /* Audio extension */
-#define USB_DT_HUB_NONVAR_SIZE         7
-#define USB_DT_HID_SIZE                        9
-
 /*
  * Endpoints
  */
 #define USB_REQ_SET_INTERFACE          0x0B
 #define USB_REQ_SYNCH_FRAME            0x0C
 
-/*
- * HID requests
- */
-#define USB_REQ_GET_REPORT             0x01
-#define USB_REQ_GET_IDLE               0x02
-#define USB_REQ_GET_PROTOCOL           0x03
-#define USB_REQ_SET_REPORT             0x09
-#define USB_REQ_SET_IDLE               0x0A
-#define USB_REQ_SET_PROTOCOL           0x0B
-
 
 #ifdef __KERNEL__
 
@@ -157,32 +125,6 @@ typedef struct {
        __u16 length;
 } devrequest __attribute__ ((packed));
 
-/*
- * USB-status codes:
- * USB_ST* maps to -E* and should go away in the future
- */
-
-#define USB_ST_NOERROR         0
-#define USB_ST_CRC             (-EILSEQ)
-#define USB_ST_BITSTUFF                (-EPROTO)
-#define USB_ST_NORESPONSE      (-ETIMEDOUT)                    /* device not responding/handshaking */
-#define USB_ST_DATAOVERRUN     (-EOVERFLOW)
-#define USB_ST_DATAUNDERRUN    (-EREMOTEIO)
-#define USB_ST_BUFFEROVERRUN   (-ECOMM)
-#define USB_ST_BUFFERUNDERRUN  (-ENOSR)
-#define USB_ST_INTERNALERROR   (-EPROTO)                       /* unknown error */
-#define USB_ST_SHORT_PACKET            (-EREMOTEIO)
-#define USB_ST_PARTIAL_ERROR   (-EXDEV)                        /* ISO transfer only partially completed */
-#define USB_ST_URB_KILLED      (-ENOENT)                       /* URB canceled by user */
-#define USB_ST_URB_PENDING       (-EINPROGRESS)
-#define USB_ST_REMOVED         (-ENODEV)                       /* device not existing or removed */
-#define USB_ST_TIMEOUT         (-ETIMEDOUT)                    /* communication timed out, also in urb->status**/
-#define USB_ST_NOTSUPPORTED    (-ENOSYS)                       
-#define USB_ST_BANDWIDTH_ERROR (-ENOSPC)                       /* too much bandwidth used */
-#define USB_ST_URB_INVALID_ERROR  (-EINVAL)                    /* invalid value/transfer type */
-#define USB_ST_URB_REQUEST_ERROR  (-ENXIO)                     /* invalid endpoint */
-#define USB_ST_STALL           (-EPIPE)                        /* pipe stalled, also in urb->status*/
-
 /*
  * USB device number allocation bitmap. There's one bitmap
  * per USB tree.
@@ -197,18 +139,46 @@ struct usb_busmap {
        unsigned long busmap[USB_MAXBUS / (8*sizeof(unsigned long))];
 };
 
+struct usb_device;
+
+/*-------------------------------------------------------------------------*/
+
 /*
- * This is a USB device descriptor.
- *
- * USB device information
+ * Standard USB Descriptor support.
+ * Devices may also have class-specific or vendor-specific descriptors.
  */
 
-/* Everything but the endpoint maximums are aribtrary */
+/*
+ * Descriptor types ... USB 2.0 spec table 9.5
+ */
+#define USB_DT_DEVICE                  0x01
+#define USB_DT_CONFIG                  0x02
+#define USB_DT_STRING                  0x03
+#define USB_DT_INTERFACE               0x04
+#define USB_DT_ENDPOINT                        0x05
+#define USB_DT_DEVICE_QUALIFIER                0x06
+#define USB_DT_OTHER_SPEED_CONFIG      0x07
+#define USB_DT_INTERFACE_POWER         0x08
+
+// FIXME should be internal to hub driver
+#define USB_DT_HUB                     (USB_TYPE_CLASS | 0x09)
+#define USB_DT_HUB_NONVAR_SIZE         7
+
+/*
+ * Descriptor sizes per descriptor type
+ */
+#define USB_DT_DEVICE_SIZE             18
+#define USB_DT_CONFIG_SIZE             9
+#define USB_DT_INTERFACE_SIZE          9
+#define USB_DT_ENDPOINT_SIZE           7
+#define USB_DT_ENDPOINT_AUDIO_SIZE     9       /* Audio extension */
+
+/* most of these maximums are arbitrary */
 #define USB_MAXCONFIG          8
 #define USB_ALTSETTINGALLOC     4
 #define USB_MAXALTSETTING      128  /* Hard limit */
 #define USB_MAXINTERFACES      32
-#define USB_MAXENDPOINTS       32
+#define USB_MAXENDPOINTS       32   /* Hard limit */
 
 /* All standard descriptors have these 2 fields in common */
 struct usb_descriptor_header {
@@ -216,7 +186,7 @@ struct usb_descriptor_header {
        __u8  bDescriptorType;
 } __attribute__ ((packed));
 
-/* Device descriptor */
+/* USB_DT_DEVICE: Device descriptor */
 struct usb_device_descriptor {
        __u8  bLength;
        __u8  bDescriptorType;
@@ -234,7 +204,7 @@ struct usb_device_descriptor {
        __u8  bNumConfigurations;
 } __attribute__ ((packed));
 
-/* Endpoint descriptor */
+/* USB_DT_ENDPOINT: Endpoint descriptor */
 struct usb_endpoint_descriptor {
        __u8  bLength           __attribute__ ((packed));
        __u8  bDescriptorType   __attribute__ ((packed));
@@ -245,11 +215,12 @@ struct usb_endpoint_descriptor {
        __u8  bRefresh          __attribute__ ((packed));
        __u8  bSynchAddress     __attribute__ ((packed));
 
+       /* the rest is internal to the Linux implementation */
        unsigned char *extra;   /* Extra descriptors */
        int extralen;
 };
 
-/* Interface descriptor */
+/* USB_DT_INTERFACE: Interface descriptor */
 struct usb_interface_descriptor {
        __u8  bLength           __attribute__ ((packed));
        __u8  bDescriptorType   __attribute__ ((packed));
@@ -261,6 +232,7 @@ struct usb_interface_descriptor {
        __u8  bInterfaceProtocol __attribute__ ((packed));
        __u8  iInterface        __attribute__ ((packed));
 
+       /* the rest is internal to the Linux implementation */
        struct usb_endpoint_descriptor *endpoint;
 
        unsigned char *extra;   /* Extra descriptors */
@@ -278,7 +250,13 @@ struct usb_interface {
        void *private_data;
 };
 
-/* Configuration descriptor information.. */
+/* USB_DT_CONFIG: Configuration descriptor information.
+ *
+ * USB_DT_OTHER_SPEED_CONFIG is the same descriptor, except that the
+ * descriptor type is different.  Highspeed-capable devices can look
+ * different depending on what speed they're currently running.  Only
+ * devices with a USB_DT_DEVICE_QUALIFIER have an OTHER_SPEED_CONFIG.
+ */
 struct usb_config_descriptor {
        __u8  bLength           __attribute__ ((packed));
        __u8  bDescriptorType   __attribute__ ((packed));
@@ -289,20 +267,46 @@ struct usb_config_descriptor {
        __u8  bmAttributes      __attribute__ ((packed));
        __u8  MaxPower          __attribute__ ((packed));
 
+       /* the rest is internal to the Linux implementation */
        struct usb_interface *interface;
 
        unsigned char *extra;   /* Extra descriptors */
        int extralen;
 };
 
-/* String descriptor */
+/* USB_DT_STRING: String descriptor */
 struct usb_string_descriptor {
        __u8  bLength;
        __u8  bDescriptorType;
-       __u16 wData[1];
+       __u16 wData[1];         /* UTF-16LE encoded */
 } __attribute__ ((packed));
 
-struct usb_device;
+/* USB_DT_DEVICE_QUALIFIER: Device Qualifier descriptor */
+struct usb_qualifier_descriptor {
+       __u8  bLength;
+       __u8  bDescriptorType;
+       __u16 bcdUSB;
+       __u8  bDeviceClass;
+       __u8  bDeviceSubClass;
+       __u8  bDeviceProtocol;
+       __u8  bMaxPacketSize0;
+       __u8  bNumConfigurations;
+       __u8  bRESERVED;
+} __attribute__ ((packed));
+
+/* helpers for driver access to descriptors */
+extern struct usb_interface *
+       usb_ifnum_to_if(struct usb_device *dev, unsigned ifnum);
+extern struct usb_endpoint_descriptor *
+       usb_epnum_to_ep_desc(struct usb_device *dev, unsigned epnum);
+
+int __usb_get_extra_descriptor(char *buffer, unsigned size,
+       unsigned char type, void **ptr);
+#define usb_get_extra_descriptor(ifpoint,type,ptr)\
+       __usb_get_extra_descriptor((ifpoint)->extra,(ifpoint)->extralen,\
+               type,(void**)ptr)
+
+/*-------------------------------------------------------------------------*/
 
 /*
  * Device table entry for "new style" table-driven USB drivers.
@@ -316,34 +320,6 @@ struct usb_device;
  * Terminate the driver's table with an all-zeroes entry.
  * Use the flag values to control which fields are compared.
  */
-#define USB_DEVICE_ID_MATCH_VENDOR             0x0001
-#define USB_DEVICE_ID_MATCH_PRODUCT            0x0002
-#define USB_DEVICE_ID_MATCH_DEV_LO             0x0004
-#define USB_DEVICE_ID_MATCH_DEV_HI             0x0008
-#define USB_DEVICE_ID_MATCH_DEV_CLASS          0x0010
-#define USB_DEVICE_ID_MATCH_DEV_SUBCLASS       0x0020
-#define USB_DEVICE_ID_MATCH_DEV_PROTOCOL       0x0040
-#define USB_DEVICE_ID_MATCH_INT_CLASS          0x0080
-#define USB_DEVICE_ID_MATCH_INT_SUBCLASS       0x0100
-#define USB_DEVICE_ID_MATCH_INT_PROTOCOL       0x0200
-
-#define USB_DEVICE_ID_MATCH_DEVICE             (USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT)
-#define USB_DEVICE_ID_MATCH_DEV_RANGE          (USB_DEVICE_ID_MATCH_DEV_LO | USB_DEVICE_ID_MATCH_DEV_HI)
-#define USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION (USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_DEV_RANGE)
-#define USB_DEVICE_ID_MATCH_DEV_INFO \
-       (USB_DEVICE_ID_MATCH_DEV_CLASS | USB_DEVICE_ID_MATCH_DEV_SUBCLASS | USB_DEVICE_ID_MATCH_DEV_PROTOCOL)
-#define USB_DEVICE_ID_MATCH_INT_INFO \
-       (USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS | USB_DEVICE_ID_MATCH_INT_PROTOCOL)
-
-/* Some useful macros */
-#define USB_DEVICE(vend,prod) \
-       match_flags: USB_DEVICE_ID_MATCH_DEVICE, idVendor: (vend), idProduct: (prod)
-#define USB_DEVICE_VER(vend,prod,lo,hi) \
-       match_flags: USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION, idVendor: (vend), idProduct: (prod), bcdDevice_lo: (lo), bcdDevice_hi: (hi)
-#define USB_DEVICE_INFO(cl,sc,pr) \
-       match_flags: USB_DEVICE_ID_MATCH_DEV_INFO, bDeviceClass: (cl), bDeviceSubClass: (sc), bDeviceProtocol: (pr)
-#define USB_INTERFACE_INFO(cl,sc,pr) \
-       match_flags: USB_DEVICE_ID_MATCH_INT_INFO, bInterfaceClass: (cl), bInterfaceSubClass: (sc), bInterfaceProtocol: (pr)
 
 /**
  * struct usb_device_id - identifies USB devices for probing and hotplugging
@@ -377,7 +353,7 @@ struct usb_device;
  *     device flags.
  *
  * In most cases, drivers will create a table of device IDs by using
- * the USB_DEVICE() macros designed for that purpose.
+ * USB_DEVICE(), or similar macros designed for that purpose.
  * They will then export it to userspace using MODULE_DEVICE_TABLE(),
  * and provide it to the USB core through their usb_driver structure.
  *
@@ -413,6 +389,75 @@ struct usb_device_id {
        unsigned long   driver_info;
 };
 
+/* Some useful macros to use to create struct usb_device_id */
+#define USB_DEVICE_ID_MATCH_VENDOR             0x0001
+#define USB_DEVICE_ID_MATCH_PRODUCT            0x0002
+#define USB_DEVICE_ID_MATCH_DEV_LO             0x0004
+#define USB_DEVICE_ID_MATCH_DEV_HI             0x0008
+#define USB_DEVICE_ID_MATCH_DEV_CLASS          0x0010
+#define USB_DEVICE_ID_MATCH_DEV_SUBCLASS       0x0020
+#define USB_DEVICE_ID_MATCH_DEV_PROTOCOL       0x0040
+#define USB_DEVICE_ID_MATCH_INT_CLASS          0x0080
+#define USB_DEVICE_ID_MATCH_INT_SUBCLASS       0x0100
+#define USB_DEVICE_ID_MATCH_INT_PROTOCOL       0x0200
+
+#define USB_DEVICE_ID_MATCH_DEVICE             (USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT)
+#define USB_DEVICE_ID_MATCH_DEV_RANGE          (USB_DEVICE_ID_MATCH_DEV_LO | USB_DEVICE_ID_MATCH_DEV_HI)
+#define USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION (USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_DEV_RANGE)
+#define USB_DEVICE_ID_MATCH_DEV_INFO \
+       (USB_DEVICE_ID_MATCH_DEV_CLASS | USB_DEVICE_ID_MATCH_DEV_SUBCLASS | USB_DEVICE_ID_MATCH_DEV_PROTOCOL)
+#define USB_DEVICE_ID_MATCH_INT_INFO \
+       (USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS | USB_DEVICE_ID_MATCH_INT_PROTOCOL)
+
+/**
+ * USB_DEVICE - macro used to describe a specific usb device
+ * @vend: the 16 bit USB Vendor ID
+ * @prod: the 16 bit USB Product ID
+ *
+ * This macro is used to create a struct usb_device_id that matches a
+ * specific device.
+ */
+#define USB_DEVICE(vend,prod) \
+       match_flags: USB_DEVICE_ID_MATCH_DEVICE, idVendor: (vend), idProduct: (prod)
+/**
+ * USB_DEVICE_VER - macro used to describe a specific usb device with a version range
+ * @vend: the 16 bit USB Vendor ID
+ * @prod: the 16 bit USB Product ID
+ * @lo: the bcdDevice_lo value
+ * @hi: the bcdDevice_hi value
+ *
+ * This macro is used to create a struct usb_device_id that matches a
+ * specific device, with a version range.
+ */
+#define USB_DEVICE_VER(vend,prod,lo,hi) \
+       match_flags: USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION, idVendor: (vend), idProduct: (prod), bcdDevice_lo: (lo), bcdDevice_hi: (hi)
+
+/**
+ * USB_DEVICE_INFO - macro used to describe a class of usb devices
+ * @cl: bDeviceClass value
+ * @sc: bDeviceSubClass value
+ * @pr: bDeviceProtocol value
+ *
+ * This macro is used to create a struct usb_device_id that matches a
+ * specific class of devices.
+ */
+#define USB_DEVICE_INFO(cl,sc,pr) \
+       match_flags: USB_DEVICE_ID_MATCH_DEV_INFO, bDeviceClass: (cl), bDeviceSubClass: (sc), bDeviceProtocol: (pr)
+
+/**
+ * USB_INTERFACE_INFO - macro used to describe a class of usb interfaces 
+ * @cl: bInterfaceClass value
+ * @sc: bInterfaceSubClass value
+ * @pr: bInterfaceProtocol value
+ *
+ * This macro is used to create a struct usb_device_id that matches a
+ * specific class of interfaces.
+ */
+#define USB_INTERFACE_INFO(cl,sc,pr) \
+       match_flags: USB_DEVICE_ID_MATCH_INT_INFO, bInterfaceClass: (cl), bInterfaceSubClass: (sc), bInterfaceProtocol: (pr)
+
+/* -------------------------------------------------------------------------- */
+
 /**
  * struct usb_driver - identifies USB driver to usbcore
  * @name: The driver name should be unique among USB drivers
@@ -439,6 +484,8 @@ struct usb_device_id {
  *     expose information to user space regardless of where they
  *     do (or don't) show up otherwise in the filesystem.
  * @id_table: USB drivers use ID table to support hotplugging.
+ *     Export this with MODULE_DEVICE_TABLE(usb,...), or use NULL to
+ *     say that probe() should be called for any unclaimed interfce.
  *
  * USB drivers should provide a name, probe() and disconnect() methods,
  * and an id_table.  Other driver fields are optional.
@@ -482,13 +529,22 @@ struct usb_driver {
 
        /* suspend before the bus suspends;
         * disconnect or resume when the bus resumes */
-       // void (*suspend)(struct usb_device *dev);
-       // void (*resume)(struct usb_device *dev);
+       /* void (*suspend)(struct usb_device *dev); */
+       /* void (*resume)(struct usb_device *dev); */
 };
-       
-/*----------------------------------------------------------------------------* 
- * New USB Structures                                                         *
- *----------------------------------------------------------------------------*/
+
+/*
+ * use these in module_init()/module_exit()
+ * and don't forget MODULE_DEVICE_TABLE(usb, ...)
+ */
+extern int usb_register(struct usb_driver *);
+extern void usb_deregister(struct usb_driver *);
+
+/* -------------------------------------------------------------------------- */
+
+/*
+ * URB support, for asynchronous request completions
+ */
 
 /*
  * urb->transfer_flags:
@@ -500,18 +556,21 @@ struct usb_driver {
 #define USB_ASYNC_UNLINK        0x0008
 #define USB_QUEUE_BULK          0x0010
 #define USB_NO_FSBR            0x0020
-#define USB_ZERO_PACKET         0x0040  // Finish bulk OUTs always with zero length packet
-#define USB_TIMEOUT_KILLED     0x1000  // only set by HCD!
+#define USB_ZERO_PACKET         0x0040  /* Finish bulk OUTs with short packet */
+#define URB_NO_INTERRUPT       0x0080  /* HINT: no non-error interrupt needed */
+                                       /* ... less overhead for QUEUE_BULK */
+#define USB_TIMEOUT_KILLED     0x1000  /* only set by HCD! */
 
 typedef struct
 {
        unsigned int offset;
-       unsigned int length;            // expected length
+       unsigned int length;            /* expected length */
        unsigned int actual_length;
        unsigned int status;
 } iso_packet_descriptor_t, *piso_packet_descriptor_t;
 
 struct urb;
+
 typedef void (*usb_complete_t)(struct urb *);
 
 /**
@@ -601,6 +660,8 @@ typedef void (*usb_complete_t)(struct urb *);
  * to poll for transfers.  After the URB has been submitted, the interval
  * and start_frame fields reflect how the transfer was actually scheduled.
  * The polling interval may be more frequent than requested.
+ * For example, some controllers have a maximum interval of 32 microseconds,
+ * while others support intervals of up to 1024 microseconds.
  *
  * Isochronous URBs normally use the USB_ISO_ASAP transfer flag, telling
  * the host controller to schedule the transfer as soon as bandwidth
@@ -634,7 +695,7 @@ typedef void (*usb_complete_t)(struct urb *);
  * When completion callback is invoked for non-isochronous URBs, the
  * actual_length field tells how many bytes were transferred.
  *
- * For interrupt and isochronous URBs, the URB provided to the calllback
+ * For interrupt and isochronous URBs, the URB provided to the callback
  * function is still "owned" by the USB core subsystem unless the status
  * indicates that the URB has been unlinked.  Completion handlers should
  * not modify such URBs until they have been unlinked.
@@ -681,8 +742,9 @@ typedef struct urb urb_t, *purb_t;
  * @COMPLETE: pointer to the usb_complete_t function
  * @CONTEXT: what to set the urb context to.
  *
- * Initializes a control urb with the proper information needed to submit it to
- * a device.
+ * Initializes a control urb with the proper information needed to submit
+ * it to a device.  This macro is depreciated, the usb_fill_control_urb()
+ * function should be used instead.
  */
 #define FILL_CONTROL_URB(URB,DEV,PIPE,SETUP_PACKET,TRANSFER_BUFFER,BUFFER_LENGTH,COMPLETE,CONTEXT) \
     do {\
@@ -706,8 +768,9 @@ typedef struct urb urb_t, *purb_t;
  * @COMPLETE: pointer to the usb_complete_t function
  * @CONTEXT: what to set the urb context to.
  *
- * Initializes a bulk urb with the proper information needed to submit it to
- * a device.
+ * Initializes a bulk urb with the proper information needed to submit it
+ * to a device.  This macro is depreciated, the usb_fill_bulk_urb()
+ * function should be used instead.
  */
 #define FILL_BULK_URB(URB,DEV,PIPE,TRANSFER_BUFFER,BUFFER_LENGTH,COMPLETE,CONTEXT) \
     do {\
@@ -731,8 +794,9 @@ typedef struct urb urb_t, *purb_t;
  * @CONTEXT: what to set the urb context to.
  * @INTERVAL: what to set the urb interval to.
  *
- * Initializes a interrupt urb with the proper information needed to submit it to
- * a device.
+ * Initializes a interrupt urb with the proper information needed to submit
+ * it to a device.  This macro is depreciated, the usb_fill_int_urb()
+ * function should be used instead.
  */
 #define FILL_INT_URB(URB,DEV,PIPE,TRANSFER_BUFFER,BUFFER_LENGTH,COMPLETE,CONTEXT,INTERVAL) \
     do {\
@@ -747,51 +811,150 @@ typedef struct urb urb_t, *purb_t;
        (URB)->start_frame=-1;\
     } while (0)
 
-#define FILL_CONTROL_URB_TO(a,aa,b,c,d,e,f,g,h) \
-    do {\
-       spin_lock_init(&(a)->lock);\
-       (a)->dev=aa;\
-       (a)->pipe=b;\
-       (a)->setup_packet=c;\
-       (a)->transfer_buffer=d;\
-       (a)->transfer_buffer_length=e;\
-       (a)->complete=f;\
-       (a)->context=g;\
-       (a)->timeout=h;\
-    } while (0)
+/**
+ * usb_fill_control_urb - initializes a control urb
+ * @urb: pointer to the urb to initialize.
+ * @dev: pointer to the struct usb_device for this urb.
+ * @pipe: the endpoint pipe
+ * @setup_packet: pointer to the setup_packet buffer
+ * @transfer_buffer: pointer to the transfer buffer
+ * @buffer_length: length of the transfer buffer
+ * @complete: pointer to the usb_complete_t function
+ * @context: what to set the urb context to.
+ *
+ * Initializes a control urb with the proper information needed to submit
+ * it to a device.
+ */
+static inline void usb_fill_control_urb (struct urb *urb,
+                                        struct usb_device *dev,
+                                        unsigned int pipe,
+                                        unsigned char *setup_packet,
+                                        void *transfer_buffer,
+                                        int buffer_length,
+                                        usb_complete_t complete,
+                                        void *context)
+{
+       spin_lock_init(&urb->lock);
+       urb->dev = dev;
+       urb->pipe = pipe;
+       urb->setup_packet = setup_packet;
+       urb->transfer_buffer = transfer_buffer;
+       urb->transfer_buffer_length = buffer_length;
+       urb->complete = complete;
+       urb->context = context;
+}
 
-#define FILL_BULK_URB_TO(a,aa,b,c,d,e,f,g) \
-    do {\
-       spin_lock_init(&(a)->lock);\
-       (a)->dev=aa;\
-       (a)->pipe=b;\
-       (a)->transfer_buffer=c;\
-       (a)->transfer_buffer_length=d;\
-       (a)->complete=e;\
-       (a)->context=f;\
-       (a)->timeout=g;\
-    } while (0)
+/**
+ * usb_fill_bulk_urb - macro to help initialize a bulk urb
+ * @urb: pointer to the urb to initialize.
+ * @dev: pointer to the struct usb_device for this urb.
+ * @pipe: the endpoint pipe
+ * @transfer_buffer: pointer to the transfer buffer
+ * @buffer_length: length of the transfer buffer
+ * @complete: pointer to the usb_complete_t function
+ * @context: what to set the urb context to.
+ *
+ * Initializes a bulk urb with the proper information needed to submit it
+ * to a device.
+ */
+static inline void usb_fill_bulk_urb (struct urb *urb,
+                                     struct usb_device *dev,
+                                     unsigned int pipe,
+                                     void *transfer_buffer,
+                                     int buffer_length,
+                                     usb_complete_t complete,
+                                     void *context)
+                                     
+{
+       spin_lock_init(&urb->lock);
+       urb->dev = dev;
+       urb->pipe = pipe;
+       urb->transfer_buffer = transfer_buffer;
+       urb->transfer_buffer_length = buffer_length;
+       urb->complete = complete;
+       urb->context = context;
+}
     
-purb_t usb_alloc_urb(int iso_packets);
-void usb_free_urb (purb_t purb);
-int usb_submit_urb(purb_t purb);
-int usb_unlink_urb(purb_t purb);
-int usb_internal_control_msg(struct usb_device *usb_dev, unsigned int pipe, devrequest *cmd,  void *data, int len, int timeout);
-int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe, void *data, int len, int *actual_length, int timeout);
+/**
+ * usb_fill_int_urb - macro to help initialize a interrupt urb
+ * @urb: pointer to the urb to initialize.
+ * @dev: pointer to the struct usb_device for this urb.
+ * @pipe: the endpoint pipe
+ * @transfer_buffer: pointer to the transfer buffer
+ * @buffer_length: length of the transfer buffer
+ * @complete: pointer to the usb_complete_t function
+ * @context: what to set the urb context to.
+ * @interval: what to set the urb interval to.
+ *
+ * Initializes a interrupt urb with the proper information needed to submit
+ * it to a device.
+ */
+static inline void usb_fill_int_urb (struct urb *urb,
+                                    struct usb_device *dev,
+                                    unsigned int pipe,
+                                    void *transfer_buffer,
+                                    int buffer_length,
+                                    usb_complete_t complete,
+                                    void *context,
+                                    int interval)
+{
+       spin_lock_init(&urb->lock);
+       urb->dev = dev;
+       urb->pipe = pipe;
+       urb->transfer_buffer = transfer_buffer;
+       urb->transfer_buffer_length = buffer_length;
+       urb->complete = complete;
+       urb->context = context;
+       urb->interval = interval;
+       urb->start_frame = -1;
+}
+    
+extern struct urb *usb_alloc_urb(int iso_packets);
+extern void usb_free_urb(struct urb *purb);
+extern int usb_submit_urb(struct urb *purb);
+extern int usb_unlink_urb(struct urb *purb);
 
 /*-------------------------------------------------------------------*
  *                         SYNCHRONOUS CALL SUPPORT                  *
  *-------------------------------------------------------------------*/
 
-struct usb_api_data
-{
-       wait_queue_head_t wqh;
-       int done;
-       /* void* stuff; */      /* Possible extension later. */
-};
+extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
+       __u8 request, __u8 requesttype, __u16 value, __u16 index,
+       void *data, __u16 size, int timeout);
+extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
+       void *data, int len, int *actual_length,
+       int timeout);
+
+/* wrappers around usb_control_msg() for the most common standard requests */
+extern int usb_clear_halt(struct usb_device *dev, int pipe);
+extern int usb_get_descriptor(struct usb_device *dev, unsigned char desctype,
+       unsigned char descindex, void *buf, int size);
+extern int usb_get_device_descriptor(struct usb_device *dev);
+extern int usb_get_status(struct usb_device *dev,
+       int type, int target, void *data);
+extern int usb_get_string(struct usb_device *dev,
+       unsigned short langid, unsigned char index, void *buf, int size);
+extern int usb_string(struct usb_device *dev, int index,
+       char *buf, size_t size);
+extern int usb_set_configuration(struct usb_device *dev, int configuration);
+extern int usb_set_interface(struct usb_device *dev, int ifnum, int alternate);
+
+/*
+ * timeouts, in seconds, used for sending/receiving control messages
+ * they typically complete within a few frames (msec) after they're issued
+ */
+#ifdef CONFIG_USB_LONG_TIMEOUT
+#define USB_CTRL_GET_TIMEOUT 4
+#else
+#define USB_CTRL_GET_TIMEOUT 3
+#endif
+
+#define USB_CTRL_SET_TIMEOUT 3
 
 /* -------------------------------------------------------------------------- */
 
+/* Host Controller Driver (HCD) support */
+
 struct usb_operations {
        int (*allocate)(struct usb_device *);
        int (*deallocate)(struct usb_device *);
@@ -832,6 +995,60 @@ struct usb_bus {
        atomic_t refcnt;
 };
 
+extern struct usb_bus *usb_alloc_bus(struct usb_operations *);
+extern void usb_free_bus(struct usb_bus *);
+extern void usb_register_bus(struct usb_bus *);
+extern void usb_deregister_bus(struct usb_bus *);
+
+extern int usb_check_bandwidth (struct usb_device *dev, struct urb *urb);
+extern void usb_claim_bandwidth (struct usb_device *dev, struct urb *urb,
+               int bustime, int isoc);
+extern void usb_release_bandwidth(struct usb_device *dev, struct urb *urb,
+               int isoc);
+extern int usb_root_hub_string(int id, int serial,
+               char *type, __u8 *data, int len);
+
+/*
+ * Some USB 1.1 bandwidth allocation constants.
+ */
+#define BW_HOST_DELAY  1000L           /* nanoseconds */
+#define BW_HUB_LS_SETUP        333L            /* nanoseconds */
+                        /* 4 full-speed bit times (est.) */
+
+#define FRAME_TIME_BITS         12000L         /* frame = 1 millisecond */
+#define FRAME_TIME_MAX_BITS_ALLOC      (90L * FRAME_TIME_BITS / 100L)
+#define FRAME_TIME_USECS       1000L
+#define FRAME_TIME_MAX_USECS_ALLOC     (90L * FRAME_TIME_USECS / 100L)
+
+#define BitTime(bytecount)  (7 * 8 * bytecount / 6)  /* with integer truncation */
+               /* Trying not to use worst-case bit-stuffing
+                   of (7/6 * 8 * bytecount) = 9.33 * bytecount */
+               /* bytecount = data payload byte count */
+
+#define NS_TO_US(ns)   ((ns + 500L) / 1000L)
+                       /* convert & round nanoseconds to microseconds */
+
+
+/* -------------------------------------------------------------------------- */
+
+/* Enumeration is only for the hub driver, or HCD virtual root hubs */
+extern struct usb_device *usb_alloc_dev(struct usb_device *parent,
+       struct usb_bus *);
+extern void usb_free_dev(struct usb_device *);
+extern int usb_new_device(struct usb_device *dev);
+extern void usb_connect(struct usb_device *dev);
+extern void usb_disconnect(struct usb_device **);
+
+#ifndef _LINUX_HUB_H
+/* exported to hub driver ONLY to support usb_reset_device () */
+extern int usb_get_configuration(struct usb_device *dev);
+extern void usb_set_maxpacket(struct usb_device *dev);
+extern void usb_destroy_configuration(struct usb_device *dev);
+extern int usb_set_address(struct usb_device *dev);
+#endif /* _LINUX_HUB_H */
+
+/* -------------------------------------------------------------------------- */
+
 /* This is arbitrary.
  * From USB 2.0 spec Table 11-13, offset 7, a hub can
  * have up to 255 ports. The most yet reported is 10.
@@ -889,44 +1106,30 @@ struct usb_device {
        struct usb_device *children[USB_MAXCHILDREN];
 };
 
-extern struct usb_interface *usb_ifnum_to_if(struct usb_device *dev, unsigned ifnum);
-extern struct usb_endpoint_descriptor *usb_epnum_to_ep_desc(struct usb_device *dev, unsigned epnum);
-
-extern int usb_register(struct usb_driver *);
-extern void usb_deregister(struct usb_driver *);
+/* for when layers above USB add new non-USB drivers */
 extern void usb_scan_devices(void);
 
-/* used these for multi-interface device registration */
-extern void usb_driver_claim_interface(struct usb_driver *driver, struct usb_interface *iface, void* priv);
-extern int usb_interface_claimed(struct usb_interface *iface);
-extern void usb_driver_release_interface(struct usb_driver *driver, struct usb_interface *iface);
-const struct usb_device_id *usb_match_id(struct usb_device *dev,
-                                        struct usb_interface *interface,
-                                        const struct usb_device_id *id);
+/* mostly for devices emulating SCSI over USB */
+extern int usb_reset_device(struct usb_device *dev);
 
-extern struct usb_bus *usb_alloc_bus(struct usb_operations *);
-extern void usb_free_bus(struct usb_bus *);
-extern void usb_register_bus(struct usb_bus *);
-extern void usb_deregister_bus(struct usb_bus *);
+/* for drivers using iso endpoints */
+extern int usb_get_current_frame_number (struct usb_device *usb_dev);
 
-extern struct usb_device *usb_alloc_dev(struct usb_device *parent, struct usb_bus *);
-extern void usb_free_dev(struct usb_device *);
+/* drivers must track when they bind to a device's interfaces */
 extern void usb_inc_dev_use(struct usb_device *);
 #define usb_dec_dev_use usb_free_dev
 
-extern int usb_check_bandwidth (struct usb_device *dev, struct urb *urb);
-extern void usb_claim_bandwidth (struct usb_device *dev, struct urb *urb, int bustime, int isoc);
-extern void usb_release_bandwidth(struct usb_device *dev, struct urb *urb, int isoc);
-
-extern int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u8 requesttype, __u16 value, __u16 index, void *data, __u16 size, int timeout);
-
-extern int usb_root_hub_string(int id, int serial, char *type, __u8 *data, int len);
-extern void usb_connect(struct usb_device *dev);
-extern void usb_disconnect(struct usb_device **);
-
-extern void usb_destroy_configuration(struct usb_device *dev);
+/* used these for multi-interface device registration */
+extern void usb_driver_claim_interface(struct usb_driver *driver,
+                       struct usb_interface *iface, void* priv);
+extern int usb_interface_claimed(struct usb_interface *iface);
+extern void usb_driver_release_interface(struct usb_driver *driver,
+                       struct usb_interface *iface);
+const struct usb_device_id *usb_match_id(struct usb_device *dev,
+                                        struct usb_interface *interface,
+                                        const struct usb_device_id *id);
 
-int usb_get_current_frame_number (struct usb_device *usb_dev);
+/* -------------------------------------------------------------------------- */
 
 /*
  * Calling this entity a "pipe" is glorifying it. A USB pipe
@@ -934,7 +1137,7 @@ int usb_get_current_frame_number (struct usb_device *usb_dev);
  * of the following information:
  *  - device number (7 bits)
  *  - endpoint number (4 bits)
- *  - current Data0/1 state (1 bit)
+ *  - current Data0/1 state (1 bit) [Historical; now gone]
  *  - direction (1 bit)
  *  - speed (1 bit)
  *  - max packet size (2 bits: 8, 16, 32 or 64) [Historical; now gone.]
@@ -951,7 +1154,7 @@ int usb_get_current_frame_number (struct usb_device *usb_dev);
  *  - direction:       bit 7           (0 = Host-to-Device [Out], 1 = Device-to-Host [In])
  *  - device:          bits 8-14
  *  - endpoint:                bits 15-18
- *  - Data0/1:         bit 19
+ *  - Data0/1:         bit 19          [Historical; now gone. ]
  *  - speed:           bit 26          (0 = Full, 1 = Low Speed)
  *  - pipe type:       bits 30-31      (00 = isochronous, 01 = interrupt, 10 = control, 11 = bulk)
  *
@@ -964,6 +1167,8 @@ int usb_get_current_frame_number (struct usb_device *usb_dev);
  * like full speed devices.
  */
 
+// FIXME 2.5 get rid of usb_pipeslow(), just use dev->speed
+
 #define PIPE_ISOCHRONOUS               0
 #define PIPE_INTERRUPT                 1
 #define PIPE_CONTROL                   2
@@ -979,7 +1184,6 @@ int usb_get_current_frame_number (struct usb_device *usb_dev);
 #define usb_pipedevice(pipe)   (((pipe) >> 8) & 0x7f)
 #define usb_pipe_endpdev(pipe) (((pipe) >> 8) & 0x7ff)
 #define usb_pipeendpoint(pipe) (((pipe) >> 15) & 0xf)
-#define usb_pipedata(pipe)     (((pipe) >> 19) & 1)
 #define usb_pipeslow(pipe)     (((pipe) >> 26) & 1)
 #define usb_pipetype(pipe)     (((pipe) >> 30) & 3)
 #define usb_pipeisoc(pipe)     (usb_pipetype((pipe)) == PIPE_ISOCHRONOUS)
@@ -1023,58 +1227,10 @@ static inline unsigned int __default_pipe(struct usb_device *dev)
 #define usb_snddefctrl(dev)            ((PIPE_CONTROL << 30) | __default_pipe(dev))
 #define usb_rcvdefctrl(dev)            ((PIPE_CONTROL << 30) | __default_pipe(dev) | USB_DIR_IN)
 
-/*
- * Send and receive control messages..
- */
-int usb_new_device(struct usb_device *dev);
-int usb_reset_device(struct usb_device *dev);
-int usb_set_address(struct usb_device *dev);
-int usb_get_descriptor(struct usb_device *dev, unsigned char desctype,
-       unsigned char descindex, void *buf, int size);
-int usb_get_class_descriptor(struct usb_device *dev, int ifnum, unsigned char desctype,
-       unsigned char descindex, void *buf, int size);
-int usb_get_device_descriptor(struct usb_device *dev);
-int __usb_get_extra_descriptor(char *buffer, unsigned size, unsigned char type, void **ptr);
-int usb_get_status(struct usb_device *dev, int type, int target, void *data);
-int usb_get_configuration(struct usb_device *dev);
-int usb_get_protocol(struct usb_device *dev, int ifnum);
-int usb_set_protocol(struct usb_device *dev, int ifnum, int protocol);
-int usb_set_interface(struct usb_device *dev, int ifnum, int alternate);
-int usb_set_idle(struct usb_device *dev, int ifnum, int duration, int report_id);
-int usb_set_configuration(struct usb_device *dev, int configuration);
-int usb_get_report(struct usb_device *dev, int ifnum, unsigned char type,
-       unsigned char id, void *buf, int size);
-int usb_set_report(struct usb_device *dev, int ifnum, unsigned char type,
-       unsigned char id, void *buf, int size);
-int usb_string(struct usb_device *dev, int index, char *buf, size_t size);
-int usb_clear_halt(struct usb_device *dev, int pipe);
-void usb_set_maxpacket(struct usb_device *dev);
-
-#define usb_get_extra_descriptor(ifpoint,type,ptr)\
-       __usb_get_extra_descriptor((ifpoint)->extra,(ifpoint)->extralen,type,(void**)ptr)
-
-/*
- * Some USB bandwidth allocation constants.
- */
-#define BW_HOST_DELAY  1000L           /* nanoseconds */
-#define BW_HUB_LS_SETUP        333L            /* nanoseconds */
-                        /* 4 full-speed bit times (est.) */
-
-#define FRAME_TIME_BITS         12000L         /* frame = 1 millisecond */
-#define FRAME_TIME_MAX_BITS_ALLOC      (90L * FRAME_TIME_BITS / 100L)
-#define FRAME_TIME_USECS       1000L
-#define FRAME_TIME_MAX_USECS_ALLOC     (90L * FRAME_TIME_USECS / 100L)
-
-#define BitTime(bytecount)  (7 * 8 * bytecount / 6)  /* with integer truncation */
-               /* Trying not to use worst-case bit-stuffing
-                   of (7/6 * 8 * bytecount) = 9.33 * bytecount */
-               /* bytecount = data payload byte count */
-
-#define NS_TO_US(ns)   ((ns + 500L) / 1000L)
-                       /* convert & round nanoseconds to microseconds */
+/* -------------------------------------------------------------------------- */
 
 /*
- * Debugging helpers..
+ * Debugging and troubleshooting/diagnostic helpers.
  */
 void usb_show_device_descriptor(struct usb_device_descriptor *);
 void usb_show_config_descriptor(struct usb_config_descriptor *);
@@ -1088,13 +1244,17 @@ void usb_show_string(struct usb_device *dev, char *id, int index);
 #else
 #define dbg(format, arg...) do {} while (0)
 #endif
+
 #define err(format, arg...) printk(KERN_ERR __FILE__ ": " format "\n" , ## arg)
 #define info(format, arg...) printk(KERN_INFO __FILE__ ": " format "\n" , ## arg)
 #define warn(format, arg...) printk(KERN_WARNING __FILE__ ": " format "\n" , ## arg)
 
 
+/* -------------------------------------------------------------------------- */
+
 /*
  * bus and driver list
+ * exported only for usbdevfs (not visible outside usbcore)
  */
 
 extern struct list_head usb_driver_list;
index 8d16e3face51ef34d1e471b0e0c58f896be3ca89..01439aadba8172a247b1fdc221af05e62d83e912 100644 (file)
@@ -351,7 +351,8 @@ skip_nfs:
                mount("devfs", ".", "devfs", 0, NULL);
 retry:
        for (p = fs_names; *p; p += strlen(p)+1) {
-               err = mount(name,"/root",p,root_mountflags,root_mount_data);
+               int err;
+               err = sys_mount(name,"/root",p,root_mountflags,root_mount_data);
                switch (err) {
                        case 0:
                                goto done;
index fb2ba9d0ba8bfa3fd41f93ec7c885962aea1b33a..25b3ae86eff4f2f2555f042ed1fcc1eb9cf79364 100644 (file)
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -569,6 +569,7 @@ asmlinkage long sys_shmat (int shmid, char *shmaddr, int shmflg, ulong *raddr)
 {
        struct shmid_kernel *shp;
        unsigned long addr;
+       unsigned long size;
        struct file * file;
        int    err;
        unsigned long flags;
@@ -588,8 +589,12 @@ asmlinkage long sys_shmat (int shmid, char *shmaddr, int shmflg, ulong *raddr)
                                return -EINVAL;
                }
                flags = MAP_SHARED | MAP_FIXED;
-       } else
+       } else {
+               if ((shmflg & SHM_REMAP))
+                       return -EINVAL;
+
                flags = MAP_SHARED;
+       }
 
        if (shmflg & SHM_RDONLY) {
                prot = PROT_READ;
@@ -603,7 +608,7 @@ asmlinkage long sys_shmat (int shmid, char *shmaddr, int shmflg, ulong *raddr)
 
        /*
         * We cannot rely on the fs check since SYSV IPC does have an
-        * aditional creator id...
+        * additional creator id...
         */
        shp = shm_lock(shmid);
        if(shp == NULL)
@@ -618,11 +623,27 @@ asmlinkage long sys_shmat (int shmid, char *shmaddr, int shmflg, ulong *raddr)
                return -EACCES;
        }
        file = shp->shm_file;
+       size = file->f_dentry->d_inode->i_size;
        shp->shm_nattch++;
        shm_unlock(shmid);
 
        down_write(&current->mm->mmap_sem);
-       user_addr = (void *) do_mmap (file, addr, file->f_dentry->d_inode->i_size, prot, flags, 0);
+       if (addr && !(shmflg & SHM_REMAP)) {
+               user_addr = ERR_PTR(-EINVAL);
+               if (find_vma_intersection(current->mm, addr, addr + size))
+                       goto invalid;
+               /*
+                * If shm segment goes below stack, make sure there is some
+                * space left for the stack to grow (at least 4 pages).
+                */
+               if (addr < current->mm->start_stack &&
+                   addr > current->mm->start_stack - size - PAGE_SIZE * 5)
+                       goto invalid;
+       }
+               
+       user_addr = (void*) do_mmap (file, addr, size, prot, flags, 0);
+
+invalid:
        up_write(&current->mm->mmap_sem);
 
        down (&shm_ids.sem);
index 4d248a59c314a6e39de44f6de7d678920d3a8d7e..f88f1d30f3035b6ff79d572da1f7c24cef90c9cd 100644 (file)
@@ -387,9 +387,9 @@ void create_bounce(unsigned long pfn, struct bio **bio_orig)
                        char *vto, *vfrom;
 
                        vto = page_address(to->bv_page) + to->bv_offset;
-                       vfrom = kmap(from->bv_page);
-                       memcpy(vto, vfrom + from->bv_offset, to->bv_len);
-                       kunmap(to->bv_page);
+                       vfrom = kmap(from->bv_page) + from->bv_offset;
+                       memcpy(vto, vfrom, to->bv_len);
+                       kunmap(from->bv_page);
                }
        }