From c025114993d79023b137babafbc76553688767e4 Mon Sep 17 00:00:00 2001 From: "minyard@acm.org" Date: Mon, 18 Apr 2005 21:57:30 -0700 Subject: [PATCH] --- yaml --- r: 303 b: refs/heads/master c: 5c11c52046eb0f7252574bad161db53d0345ea50 h: refs/heads/master i: 301: a4b25ce4263c8d9280c7ae2c87c75bec2c53f08a 299: bec5e7ab60a2778fc01747c4088d1ddf128dbab1 295: bc9322129a3ead6b8284d599bb0fed102189f3af 287: feef0a3c13d283909c629b4bd143a6ed12d610c9 v: v3 --- [refs] | 2 +- trunk/Documentation/aoe/mkdevs.sh | 1 - trunk/Documentation/aoe/mkshelf.sh | 1 - trunk/Documentation/aoe/todo.txt | 14 -- trunk/Documentation/aoe/udev-install.sh | 6 +- trunk/Documentation/kref.txt | 211 ++++++++++++++++++++ trunk/drivers/block/aoe/aoe.h | 23 +-- trunk/drivers/block/aoe/aoeblk.c | 5 +- trunk/drivers/block/aoe/aoecmd.c | 108 +++++----- trunk/drivers/block/aoe/aoedev.c | 8 +- trunk/drivers/block/aoe/aoenet.c | 8 +- trunk/drivers/i2c/chips/it87.c | 2 +- trunk/drivers/i2c/chips/via686a.c | 5 +- trunk/drivers/net/irda/stir4200.c | 4 +- trunk/drivers/usb/class/audio.c | 48 +++-- trunk/drivers/usb/class/bluetty.c | 4 +- trunk/drivers/usb/core/config.c | 3 +- trunk/drivers/usb/core/devices.c | 8 +- trunk/drivers/usb/core/devio.c | 72 ++++--- trunk/drivers/usb/core/file.c | 2 - trunk/drivers/usb/core/hcd-pci.c | 151 ++++++-------- trunk/drivers/usb/core/hcd.h | 4 +- trunk/drivers/usb/core/hub.c | 24 ++- trunk/drivers/usb/core/inode.c | 1 - trunk/drivers/usb/core/message.c | 25 ++- trunk/drivers/usb/core/urb.c | 16 +- trunk/drivers/usb/core/usb.c | 13 +- trunk/drivers/usb/core/usb.h | 8 - trunk/drivers/usb/gadget/ether.c | 56 +++--- trunk/drivers/usb/gadget/omap_udc.c | 12 +- trunk/drivers/usb/gadget/rndis.c | 40 ++-- trunk/drivers/usb/gadget/rndis.h | 3 +- trunk/drivers/usb/gadget/serial.c | 5 +- trunk/drivers/usb/host/ehci-dbg.c | 2 +- trunk/drivers/usb/host/ehci-hcd.c | 4 +- trunk/drivers/usb/host/ehci-mem.c | 3 +- trunk/drivers/usb/host/ehci-sched.c | 4 +- trunk/drivers/usb/host/ehci.h | 2 +- trunk/drivers/usb/host/ohci-omap.c | 4 +- trunk/drivers/usb/host/ohci-pci.c | 21 +- trunk/drivers/usb/host/ohci-pxa27x.c | 4 +- trunk/drivers/usb/host/ohci-q.c | 13 +- trunk/drivers/usb/host/ohci.h | 1 - trunk/drivers/usb/host/uhci-hcd.c | 9 +- trunk/drivers/usb/input/aiptek.c | 1 - trunk/drivers/usb/input/hid-core.c | 9 +- trunk/drivers/usb/media/dabusb.c | 3 +- trunk/drivers/usb/media/ov511.c | 12 +- trunk/drivers/usb/media/se401.c | 15 +- trunk/drivers/usb/media/usbvideo.c | 6 +- trunk/drivers/usb/media/w9968cf.c | 6 +- trunk/drivers/usb/misc/auerswald.c | 26 ++- trunk/drivers/usb/misc/sisusbvga/sisusb.c | 3 +- trunk/drivers/usb/net/pegasus.c | 22 +- trunk/drivers/usb/net/usbnet.c | 31 +-- trunk/drivers/usb/net/zd1201.c | 3 +- trunk/drivers/usb/serial/belkin_sa.c | 3 +- trunk/drivers/usb/serial/cypress_m8.c | 5 +- trunk/drivers/usb/serial/digi_acceleport.c | 10 +- trunk/drivers/usb/serial/empeg.c | 6 +- trunk/drivers/usb/serial/ftdi_sio.c | 10 +- trunk/drivers/usb/serial/io_edgeport.c | 24 ++- trunk/drivers/usb/serial/io_ti.c | 5 +- trunk/drivers/usb/serial/kl5kusb105.c | 3 +- trunk/drivers/usb/serial/omninet.c | 5 +- trunk/drivers/usb/serial/pl2303.c | 55 ++--- trunk/drivers/usb/serial/pl2303.h | 3 - trunk/drivers/usb/serial/ti_usb_3410_5052.c | 3 +- trunk/drivers/usb/serial/visor.c | 6 - trunk/drivers/usb/serial/visor.h | 4 - trunk/drivers/usb/storage/sddr55.c | 24 ++- trunk/drivers/usb/storage/transport.c | 2 +- trunk/drivers/usb/storage/unusual_devs.h | 13 -- trunk/drivers/w1/w1.c | 9 +- trunk/drivers/w1/w1_smem.c | 4 +- trunk/include/linux/usb.h | 4 +- trunk/include/linux/usb_cdc.h | 2 +- 77 files changed, 709 insertions(+), 588 deletions(-) delete mode 100644 trunk/Documentation/aoe/todo.txt create mode 100644 trunk/Documentation/kref.txt diff --git a/[refs] b/[refs] index c57c03c105ab..cf9de0aec35b 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: c3c661932cd53582c5b03692b99649300977248a +refs/heads/master: 5c11c52046eb0f7252574bad161db53d0345ea50 diff --git a/trunk/Documentation/aoe/mkdevs.sh b/trunk/Documentation/aoe/mkdevs.sh index ec5a6de1cd7b..6ce70703eb47 100644 --- a/trunk/Documentation/aoe/mkdevs.sh +++ b/trunk/Documentation/aoe/mkdevs.sh @@ -5,7 +5,6 @@ n_partitions=${n_partitions:-16} if test "$#" != "1"; then echo "Usage: sh `basename $0` {dir}" 1>&2 - echo " n_partitions=16 sh `basename $0` {dir}" 1>&2 exit 1 fi dir=$1 diff --git a/trunk/Documentation/aoe/mkshelf.sh b/trunk/Documentation/aoe/mkshelf.sh index 8bacf9f2c7cc..40932836bb80 100644 --- a/trunk/Documentation/aoe/mkshelf.sh +++ b/trunk/Documentation/aoe/mkshelf.sh @@ -2,7 +2,6 @@ if test "$#" != "2"; then echo "Usage: sh `basename $0` {dir} {shelfaddress}" 1>&2 - echo " n_partitions=16 sh `basename $0` {dir} {shelfaddress}" 1>&2 exit 1 fi n_partitions=${n_partitions:-16} diff --git a/trunk/Documentation/aoe/todo.txt b/trunk/Documentation/aoe/todo.txt deleted file mode 100644 index 7fee1e1165bc..000000000000 --- a/trunk/Documentation/aoe/todo.txt +++ /dev/null @@ -1,14 +0,0 @@ -There is a potential for deadlock when allocating a struct sk_buff for -data that needs to be written out to aoe storage. If the data is -being written from a dirty page in order to free that page, and if -there are no other pages available, then deadlock may occur when a -free page is needed for the sk_buff allocation. This situation has -not been observed, but it would be nice to eliminate any potential for -deadlock under memory pressure. - -Because ATA over Ethernet is not fragmented by the kernel's IP code, -the destructore member of the struct sk_buff is available to the aoe -driver. By using a mempool for allocating all but the first few -sk_buffs, and by registering a destructor, we should be able to -efficiently allocate sk_buffs without introducing any potential for -deadlock. diff --git a/trunk/Documentation/aoe/udev-install.sh b/trunk/Documentation/aoe/udev-install.sh index 6449911c6a71..861a27f98771 100644 --- a/trunk/Documentation/aoe/udev-install.sh +++ b/trunk/Documentation/aoe/udev-install.sh @@ -23,8 +23,4 @@ fi # /etc/udev/rules.d # rules_d="`sed -n '/^udev_rules=/{ s!udev_rules=!!; s!\"!!g; p; }' $conf`" -if test -z "$rules_d" || test ! -d "$rules_d"; then - echo "$me Error: cannot find udev rules directory" 1>&2 - exit 1 -fi -sh -xc "cp `dirname $0`/udev.txt $rules_d/60-aoe.rules" +test "$rules_d" && sh -xc "cp `dirname $0`/udev.txt $rules_d/60-aoe.rules" diff --git a/trunk/Documentation/kref.txt b/trunk/Documentation/kref.txt new file mode 100644 index 000000000000..96d8f5666afe --- /dev/null +++ b/trunk/Documentation/kref.txt @@ -0,0 +1,211 @@ + +krefs allow you to add reference counters to your objects. If you +have objects that are used in multiple places and passed around, and +you don't have refcounts, your code is almost certainly broken. If +you want refcounts, krefs are the way to go. + +To use a kref, add one to your data structures like: + +struct my_data +{ + . + . + struct kref refcount; + . + . +}; + +The kref can occur anywhere within the data structure. + +You must initialize the kref after you allocate it. To do this, call +kref_init as so: + + struct my_data *data; + + data = kmalloc(sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + kref_init(&data->refcount); + +This sets the refcount in the kref to 1. + +Once you have an initialized kref, you must follow the following +rules: + +1) If you make a non-temporary copy of a pointer, especially if + it can be passed to another thread of execution, you must + increment the refcount with kref_get() before passing it off: + kref_get(&data->refcount); + If you already have a valid pointer to a kref-ed structure (the + refcount cannot go to zero) you may do this without a lock. + +2) When you are done with a pointer, you must call kref_put(): + kref_put(&data->refcount, data_release); + If this is the last reference to the pointer, the release + routine will be called. If the code never tries to get + a valid pointer to a kref-ed structure without already + holding a valid pointer, it is safe to do this without + a lock. + +3) If the code attempts to gain a reference to a kref-ed structure + without already holding a valid pointer, it must serialize access + where a kref_put() cannot occur during the kref_get(), and the + structure must remain valid during the kref_get(). + +For example, if you allocate some data and then pass it to another +thread to process: + +void data_release(struct kref *ref) +{ + struct my_data *data = container_of(ref, struct my_data, refcount); + kfree(data); +} + +void more_data_handling(void *cb_data) +{ + struct my_data *data = cb_data; + . + . do stuff with data here + . + kref_put(data, data_release); +} + +int my_data_handler(void) +{ + int rv = 0; + struct my_data *data; + struct task_struct *task; + data = kmalloc(sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + kref_init(&data->refcount); + + kref_get(&data->refcount); + task = kthread_run(more_data_handling, data, "more_data_handling"); + if (task == ERR_PTR(-ENOMEM)) { + rv = -ENOMEM; + kref_put(&data->refcount, data_release); + goto out; + } + + . + . do stuff with data here + . + out: + kref_put(&data->refcount, data_release); + return rv; +} + +This way, it doesn't matter what order the two threads handle the +data, the kref_put() handles knowing when the data is not referenced +any more and releasing it. The kref_get() does not require a lock, +since we already have a valid pointer that we own a refcount for. The +put needs no lock because nothing tries to get the data without +already holding a pointer. + +Note that the "before" in rule 1 is very important. You should never +do something like: + + task = kthread_run(more_data_handling, data, "more_data_handling"); + if (task == ERR_PTR(-ENOMEM)) { + rv = -ENOMEM; + goto out; + } else + /* BAD BAD BAD - get is after the handoff */ + kref_get(&data->refcount); + +Don't assume you know what you are doing and use the above construct. +First of all, you may not know what you are doing. Second, you may +know what you are doing (there are some situations where locking is +involved where the above may be legal) but someone else who doesn't +know what they are doing may change the code or copy the code. It's +bad style. Don't do it. + +There are some situations where you can optimize the gets and puts. +For instance, if you are done with an object and enqueuing it for +something else or passing it off to something else, there is no reason +to do a get then a put: + + /* Silly extra get and put */ + kref_get(&obj->ref); + enqueue(obj); + kref_put(&obj->ref, obj_cleanup); + +Just do the enqueue. A comment about this is always welcome: + + enqueue(obj); + /* We are done with obj, so we pass our refcount off + to the queue. DON'T TOUCH obj AFTER HERE! */ + +The last rule (rule 3) is the nastiest one to handle. Say, for +instance, you have a list of items that are each kref-ed, and you wish +to get the first one. You can't just pull the first item off the list +and kref_get() it. That violates rule 3 because you are not already +holding a valid pointer. You must add locks or semaphores. For +instance: + +static DECLARE_MUTEX(sem); +static LIST_HEAD(q); +struct my_data +{ + struct kref refcount; + struct list_head link; +}; + +static struct my_data *get_entry() +{ + struct my_data *entry = NULL; + down(&sem); + if (!list_empty(&q)) { + entry = container_of(q.next, struct my_q_entry, link); + kref_get(&entry->refcount); + } + up(&sem); + return entry; +} + +static void release_entry(struct kref *ref) +{ + struct my_data *entry = container_of(ref, struct my_data, refcount); + + list_del(&entry->link); + kfree(entry); +} + +static void put_entry(struct my_data *entry) +{ + down(&sem); + kref_put(&entry->refcount, release_entry); + up(&sem); +} + +The kref_put() return value is useful if you do not want to hold the +lock during the whole release operation. Say you didn't want to call +kfree() with the lock held in the example above (since it is kind of +pointless to do so). You could use kref_put() as follows: + +static void release_entry(struct kref *ref) +{ + /* All work is done after the return from kref_put(). */ +} + +static void put_entry(struct my_data *entry) +{ + down(&sem); + if (kref_put(&entry->refcount, release_entry)) { + list_del(&entry->link); + up(&sem); + kfree(entry); + } else + up(&sem); +} + +This is really more useful if you have to call other routines as part +of the free operations that could take a long time or might claim the +same lock. Note that doing everything in the release routine is still +preferred as it is a little neater. + + +Corey Minyard + +A lot of this was lifted from Greg KH's OLS presentation on krefs. diff --git a/trunk/drivers/block/aoe/aoe.h b/trunk/drivers/block/aoe/aoe.h index aa8b547ffafa..db78f826d40c 100644 --- a/trunk/drivers/block/aoe/aoe.h +++ b/trunk/drivers/block/aoe/aoe.h @@ -1,15 +1,10 @@ /* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ -#define VERSION "6" +#define VERSION "5" #define AOE_MAJOR 152 #define DEVICE_NAME "aoe" - -/* set AOE_PARTITIONS to 1 to use whole-disks only - * default is 16, which is 15 partitions plus the whole disk - */ #ifndef AOE_PARTITIONS #define AOE_PARTITIONS 16 #endif - #define SYSMINOR(aoemajor, aoeminor) ((aoemajor) * 10 + (aoeminor)) #define AOEMAJOR(sysminor) ((sysminor) / 10) #define AOEMINOR(sysminor) ((sysminor) % 10) @@ -39,13 +34,13 @@ enum { struct aoe_hdr { unsigned char dst[6]; unsigned char src[6]; - __be16 type; + unsigned char type[2]; unsigned char verfl; unsigned char err; - __be16 major; + unsigned char major[2]; unsigned char minor; unsigned char cmd; - __be32 tag; + unsigned char tag[4]; }; struct aoe_atahdr { @@ -63,8 +58,8 @@ struct aoe_atahdr { }; struct aoe_cfghdr { - __be16 bufcnt; - __be16 fwver; + unsigned char bufcnt[2]; + unsigned char fwver[2]; unsigned char res; unsigned char aoeccmd; unsigned char cslen[2]; @@ -90,7 +85,6 @@ enum { struct buf { struct list_head bufs; - ulong start_time; /* for disk stats */ ulong flags; ulong nframesout; char *bufaddr; @@ -131,8 +125,7 @@ struct aoedev { struct timer_list timer; spinlock_t lock; struct net_device *ifp; /* interface ed is attached to */ - struct sk_buff *sendq_hd; /* packets needing to be sent, list head */ - struct sk_buff *sendq_tl; + struct sk_buff *skblist;/* packets needing to be sent */ mempool_t *bufpool; /* for deadlock-free Buf allocation */ struct list_head bufq; /* queue of bios to work on */ struct buf *inprocess; /* the one we're currently working on */ @@ -158,7 +151,7 @@ void aoecmd_cfg_rsp(struct sk_buff *); int aoedev_init(void); void aoedev_exit(void); -struct aoedev *aoedev_by_aoeaddr(int maj, int min); +struct aoedev *aoedev_bymac(unsigned char *); void aoedev_downdev(struct aoedev *d); struct aoedev *aoedev_set(ulong, unsigned char *, struct net_device *, ulong); int aoedev_busy(void); diff --git a/trunk/drivers/block/aoe/aoeblk.c b/trunk/drivers/block/aoe/aoeblk.c index 4780f7926d42..63561b280bc5 100644 --- a/trunk/drivers/block/aoe/aoeblk.c +++ b/trunk/drivers/block/aoe/aoeblk.c @@ -125,7 +125,6 @@ aoeblk_make_request(request_queue_t *q, struct bio *bio) } memset(buf, 0, sizeof(*buf)); INIT_LIST_HEAD(&buf->bufs); - buf->start_time = jiffies; buf->bio = bio; buf->resid = bio->bi_size; buf->sector = bio->bi_sector; @@ -147,8 +146,8 @@ aoeblk_make_request(request_queue_t *q, struct bio *bio) list_add_tail(&buf->bufs, &d->bufq); aoecmd_work(d); - sl = d->sendq_hd; - d->sendq_hd = d->sendq_tl = NULL; + sl = d->skblist; + d->skblist = NULL; spin_unlock_irqrestore(&d->lock, flags); diff --git a/trunk/drivers/block/aoe/aoecmd.c b/trunk/drivers/block/aoe/aoecmd.c index b5be4b7d7b5b..fb6d942a4565 100644 --- a/trunk/drivers/block/aoe/aoecmd.c +++ b/trunk/drivers/block/aoe/aoecmd.c @@ -90,16 +90,19 @@ newtag(struct aoedev *d) static int aoehdr_atainit(struct aoedev *d, struct aoe_hdr *h) { + u16 type = __constant_cpu_to_be16(ETH_P_AOE); + u16 aoemajor = __cpu_to_be16(d->aoemajor); u32 host_tag = newtag(d); + u32 tag = __cpu_to_be32(host_tag); memcpy(h->src, d->ifp->dev_addr, sizeof h->src); memcpy(h->dst, d->addr, sizeof h->dst); - h->type = __constant_cpu_to_be16(ETH_P_AOE); + memcpy(h->type, &type, sizeof type); h->verfl = AOE_HVER; - h->major = cpu_to_be16(d->aoemajor); + memcpy(h->major, &aoemajor, sizeof aoemajor); h->minor = d->aoeminor; h->cmd = AOECMD_ATA; - h->tag = cpu_to_be32(host_tag); + memcpy(h->tag, &tag, sizeof tag); return host_tag; } @@ -178,12 +181,8 @@ aoecmd_ata_rw(struct aoedev *d, struct frame *f) skb = skb_prepare(d, f); if (skb) { - skb->next = NULL; - if (d->sendq_hd) - d->sendq_tl->next = skb; - else - d->sendq_hd = skb; - d->sendq_tl = skb; + skb->next = d->skblist; + d->skblist = skb; } } @@ -216,6 +215,7 @@ rexmit(struct aoedev *d, struct frame *f) struct aoe_hdr *h; char buf[128]; u32 n; + u32 net_tag; n = newtag(d); @@ -227,16 +227,13 @@ rexmit(struct aoedev *d, struct frame *f) h = (struct aoe_hdr *) f->data; f->tag = n; - h->tag = cpu_to_be32(n); + net_tag = __cpu_to_be32(n); + memcpy(h->tag, &net_tag, sizeof net_tag); skb = skb_prepare(d, f); if (skb) { - skb->next = NULL; - if (d->sendq_hd) - d->sendq_tl->next = skb; - else - d->sendq_hd = skb; - d->sendq_tl = skb; + skb->next = d->skblist; + d->skblist = skb; } } @@ -288,8 +285,8 @@ tdie: spin_unlock_irqrestore(&d->lock, flags); } } - sl = d->sendq_hd; - d->sendq_hd = d->sendq_tl = NULL; + sl = d->skblist; + d->skblist = NULL; if (sl) { n = d->rttavg <<= 1; if (n > MAXTIMER) @@ -311,16 +308,16 @@ ataid_complete(struct aoedev *d, unsigned char *id) u16 n; /* word 83: command set supported */ - n = le16_to_cpup((__le16 *) &id[83<<1]); + n = __le16_to_cpu(*((u16 *) &id[83<<1])); /* word 86: command set/feature enabled */ - n |= le16_to_cpup((__le16 *) &id[86<<1]); + n |= __le16_to_cpu(*((u16 *) &id[86<<1])); if (n & (1<<10)) { /* bit 10: LBA 48 */ d->flags |= DEVFL_EXT; /* word 100: number lba48 sectors */ - ssize = le64_to_cpup((__le64 *) &id[100<<1]); + ssize = __le64_to_cpu(*((u64 *) &id[100<<1])); /* set as in ide-disk.c:init_idedisk_capacity */ d->geo.cylinders = ssize; @@ -331,12 +328,12 @@ ataid_complete(struct aoedev *d, unsigned char *id) d->flags &= ~DEVFL_EXT; /* number lba28 sectors */ - ssize = le32_to_cpup((__le32 *) &id[60<<1]); + ssize = __le32_to_cpu(*((u32 *) &id[60<<1])); /* NOTE: obsolete in ATA 6 */ - d->geo.cylinders = le16_to_cpup((__le16 *) &id[54<<1]); - d->geo.heads = le16_to_cpup((__le16 *) &id[55<<1]); - d->geo.sectors = le16_to_cpup((__le16 *) &id[56<<1]); + d->geo.cylinders = __le16_to_cpu(*((u16 *) &id[54<<1])); + d->geo.heads = __le16_to_cpu(*((u16 *) &id[55<<1])); + d->geo.sectors = __le16_to_cpu(*((u16 *) &id[56<<1])); } d->ssize = ssize; d->geo.start = 0; @@ -383,30 +380,29 @@ aoecmd_ata_rsp(struct sk_buff *skb) register long n; ulong flags; char ebuf[128]; - u16 aoemajor; - + hin = (struct aoe_hdr *) skb->mac.raw; - aoemajor = be16_to_cpu(hin->major); - d = aoedev_by_aoeaddr(aoemajor, hin->minor); + d = aoedev_bymac(hin->src); if (d == NULL) { snprintf(ebuf, sizeof ebuf, "aoecmd_ata_rsp: ata response " "for unknown device %d.%d\n", - aoemajor, hin->minor); + __be16_to_cpu(*((u16 *) hin->major)), + hin->minor); aoechr_error(ebuf); return; } spin_lock_irqsave(&d->lock, flags); - f = getframe(d, be32_to_cpu(hin->tag)); + f = getframe(d, __be32_to_cpu(*((u32 *) hin->tag))); if (f == NULL) { spin_unlock_irqrestore(&d->lock, flags); snprintf(ebuf, sizeof ebuf, "%15s e%d.%d tag=%08x@%08lx\n", "unexpected rsp", - be16_to_cpu(hin->major), + __be16_to_cpu(*((u16 *) hin->major)), hin->minor, - be32_to_cpu(hin->tag), + __be32_to_cpu(*((u32 *) hin->tag)), jiffies); aoechr_error(ebuf); return; @@ -456,7 +452,7 @@ aoecmd_ata_rsp(struct sk_buff *skb) printk(KERN_INFO "aoe: aoecmd_ata_rsp: unrecognized " "outbound ata command %2.2Xh for %d.%d\n", ahout->cmdstat, - be16_to_cpu(hin->major), + __be16_to_cpu(*((u16 *) hin->major)), hin->minor); } } @@ -464,20 +460,6 @@ aoecmd_ata_rsp(struct sk_buff *skb) if (buf) { buf->nframesout -= 1; if (buf->nframesout == 0 && buf->resid == 0) { - unsigned long duration = jiffies - buf->start_time; - unsigned long n_sect = buf->bio->bi_size >> 9; - struct gendisk *disk = d->gd; - - if (bio_data_dir(buf->bio) == WRITE) { - disk_stat_inc(disk, writes); - disk_stat_add(disk, write_ticks, duration); - disk_stat_add(disk, write_sectors, n_sect); - } else { - disk_stat_inc(disk, reads); - disk_stat_add(disk, read_ticks, duration); - disk_stat_add(disk, read_sectors, n_sect); - } - disk_stat_add(disk, io_ticks, duration); n = (buf->flags & BUFFL_FAIL) ? -EIO : 0; bio_endio(buf->bio, buf->bio->bi_size, n); mempool_free(buf, d->bufpool); @@ -489,8 +471,8 @@ aoecmd_ata_rsp(struct sk_buff *skb) aoecmd_work(d); - sl = d->sendq_hd; - d->sendq_hd = d->sendq_tl = NULL; + sl = d->skblist; + d->skblist = NULL; spin_unlock_irqrestore(&d->lock, flags); @@ -504,6 +486,8 @@ aoecmd_cfg(ushort aoemajor, unsigned char aoeminor) struct aoe_cfghdr *ch; struct sk_buff *skb, *sl; struct net_device *ifp; + u16 aoe_type = __constant_cpu_to_be16(ETH_P_AOE); + u16 net_aoemajor = __cpu_to_be16(aoemajor); sl = NULL; @@ -523,9 +507,9 @@ aoecmd_cfg(ushort aoemajor, unsigned char aoeminor) memset(h->dst, 0xff, sizeof h->dst); memcpy(h->src, ifp->dev_addr, sizeof h->src); - h->type = __constant_cpu_to_be16(ETH_P_AOE); + memcpy(h->type, &aoe_type, sizeof aoe_type); h->verfl = AOE_HVER; - h->major = cpu_to_be16(aoemajor); + memcpy(h->major, &net_aoemajor, sizeof net_aoemajor); h->minor = aoeminor; h->cmd = AOECMD_CFG; @@ -539,7 +523,7 @@ aoecmd_cfg(ushort aoemajor, unsigned char aoeminor) /* * Since we only call this in one place (and it only prepares one frame) - * we just return the skb. Usually we'd chain it up to the aoedev sendq. + * we just return the skb. Usually we'd chain it up to the d->skblist. */ static struct sk_buff * aoecmd_ata_id(struct aoedev *d) @@ -591,10 +575,9 @@ aoecmd_cfg_rsp(struct sk_buff *skb) struct aoedev *d; struct aoe_hdr *h; struct aoe_cfghdr *ch; - ulong flags, sysminor, aoemajor; - u16 bufcnt; + ulong flags, bufcnt, sysminor, aoemajor; struct sk_buff *sl; - enum { MAXFRAMES = 8 }; + enum { MAXFRAMES = 8, MAXSYSMINOR = 255 }; h = (struct aoe_hdr *) skb->mac.raw; ch = (struct aoe_cfghdr *) (h+1); @@ -603,7 +586,7 @@ aoecmd_cfg_rsp(struct sk_buff *skb) * Enough people have their dip switches set backwards to * warrant a loud message for this special case. */ - aoemajor = be16_to_cpu(h->major); + aoemajor = __be16_to_cpu(*((u16 *) h->major)); if (aoemajor == 0xfff) { printk(KERN_CRIT "aoe: aoecmd_cfg_rsp: Warning: shelf " "address is all ones. Check shelf dip switches\n"); @@ -611,14 +594,13 @@ aoecmd_cfg_rsp(struct sk_buff *skb) } sysminor = SYSMINOR(aoemajor, h->minor); - if (sysminor * AOE_PARTITIONS + AOE_PARTITIONS > MINORMASK) { - printk(KERN_INFO - "aoe: e%ld.%d: minor number too large\n", - aoemajor, (int) h->minor); + if (sysminor > MAXSYSMINOR) { + printk(KERN_INFO "aoe: aoecmd_cfg_rsp: sysminor %ld too " + "large\n", sysminor); return; } - bufcnt = be16_to_cpu(ch->bufcnt); + bufcnt = __be16_to_cpu(*((u16 *) ch->bufcnt)); if (bufcnt > MAXFRAMES) /* keep it reasonable */ bufcnt = MAXFRAMES; @@ -635,7 +617,7 @@ aoecmd_cfg_rsp(struct sk_buff *skb) return; } - d->fw_ver = be16_to_cpu(ch->fwver); + d->fw_ver = __be16_to_cpu(*((u16 *) ch->fwver)); /* we get here only if the device is new */ sl = aoecmd_ata_id(d); diff --git a/trunk/drivers/block/aoe/aoedev.c b/trunk/drivers/block/aoe/aoedev.c index ec16c64dd114..240abaec159b 100644 --- a/trunk/drivers/block/aoe/aoedev.c +++ b/trunk/drivers/block/aoe/aoedev.c @@ -13,7 +13,7 @@ static struct aoedev *devlist; static spinlock_t devlist_lock; struct aoedev * -aoedev_by_aoeaddr(int maj, int min) +aoedev_bymac(unsigned char *macaddr) { struct aoedev *d; ulong flags; @@ -21,7 +21,7 @@ aoedev_by_aoeaddr(int maj, int min) spin_lock_irqsave(&devlist_lock, flags); for (d=devlist; d; d=d->next) - if (d->aoemajor == maj && d->aoeminor == min) + if (!memcmp(d->addr, macaddr, 6)) break; spin_unlock_irqrestore(&devlist_lock, flags); @@ -125,6 +125,7 @@ aoedev_set(ulong sysminor, unsigned char *addr, struct net_device *ifp, ulong bu d->ifp = ifp; if (d->sysminor != sysminor + || memcmp(d->addr, addr, sizeof d->addr) || (d->flags & DEVFL_UP) == 0) { aoedev_downdev(d); /* flushes outstanding frames */ memcpy(d->addr, addr, sizeof d->addr); @@ -146,8 +147,7 @@ aoedev_freedev(struct aoedev *d) put_disk(d->gd); } kfree(d->frames); - if (d->bufpool) - mempool_destroy(d->bufpool); + mempool_destroy(d->bufpool); kfree(d); } diff --git a/trunk/drivers/block/aoe/aoenet.c b/trunk/drivers/block/aoe/aoenet.c index bc92aacb6dad..cc1945b8d52b 100644 --- a/trunk/drivers/block/aoe/aoenet.c +++ b/trunk/drivers/block/aoe/aoenet.c @@ -69,7 +69,7 @@ set_aoe_iflist(const char __user *user_str, size_t size) u64 mac_addr(char addr[6]) { - __be64 n = 0; + u64 n = 0; char *p = (char *) &n; memcpy(p + 2, addr, 6); /* (sizeof addr != 6) */ @@ -108,7 +108,7 @@ static int aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt) { struct aoe_hdr *h; - u32 n; + ulong n; skb = skb_check(skb); if (!skb) @@ -121,7 +121,7 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt) skb_push(skb, ETH_HLEN); /* (1) */ h = (struct aoe_hdr *) skb->mac.raw; - n = be32_to_cpu(h->tag); + n = __be32_to_cpu(*((u32 *) h->tag)); if ((h->verfl & AOEFL_RSP) == 0 || (n & 1<<31)) goto exit; @@ -132,7 +132,7 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt) if (net_ratelimit()) printk(KERN_ERR "aoe: aoenet_rcv: error packet from %d.%d; " "ecode=%d '%s'\n", - be16_to_cpu(h->major), h->minor, + __be16_to_cpu(*((u16 *) h->major)), h->minor, h->err, aoe_errlist[n]); goto exit; } diff --git a/trunk/drivers/i2c/chips/it87.c b/trunk/drivers/i2c/chips/it87.c index cf7e6898754f..3d484a7aff12 100644 --- a/trunk/drivers/i2c/chips/it87.c +++ b/trunk/drivers/i2c/chips/it87.c @@ -668,7 +668,7 @@ static ssize_t show_alarms(struct device *dev, char *buf) struct it87_data *data = it87_update_device(dev); return sprintf(buf,"%d\n", ALARMS_FROM_REG(data->alarms)); } -static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); +static DEVICE_ATTR(alarms, S_IRUGO | S_IWUSR, show_alarms, NULL); static ssize_t show_vrm_reg(struct device *dev, char *buf) diff --git a/trunk/drivers/i2c/chips/via686a.c b/trunk/drivers/i2c/chips/via686a.c index 6614a59cecd4..9b948f4531f5 100644 --- a/trunk/drivers/i2c/chips/via686a.c +++ b/trunk/drivers/i2c/chips/via686a.c @@ -574,7 +574,7 @@ static ssize_t show_alarms(struct device *dev, char *buf) { struct via686a_data *data = via686a_update_device(dev); return sprintf(buf,"%d\n", ALARMS_FROM_REG(data->alarms)); } -static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); +static DEVICE_ATTR(alarms, S_IRUGO | S_IWUSR, show_alarms, NULL); /* The driver. I choose to use type i2c_driver, as at is identical to both smbus_driver and isa_driver, and clients could be of either kind */ @@ -651,9 +651,10 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) new_client->adapter = adapter; new_client->driver = &via686a_driver; new_client->flags = 0; + new_client->dev.parent = &adapter->dev; /* Fill in the remaining client fields and put into the global list */ - strlcpy(new_client->name, client_name, I2C_NAME_SIZE); + snprintf(new_client->name, I2C_NAME_SIZE, client_name); data->valid = 0; init_MUTEX(&data->update_lock); diff --git a/trunk/drivers/net/irda/stir4200.c b/trunk/drivers/net/irda/stir4200.c index 66f488c13717..83c605e8824c 100644 --- a/trunk/drivers/net/irda/stir4200.c +++ b/trunk/drivers/net/irda/stir4200.c @@ -1128,8 +1128,8 @@ static void stir_disconnect(struct usb_interface *intf) } #ifdef CONFIG_PM -/* USB suspend, so power off the transmitter/receiver */ -static int stir_suspend(struct usb_interface *intf, pm_message_t message) +/* Power management suspend, so power off the transmitter/receiver */ +static int stir_suspend(struct usb_interface *intf, u32 state) { struct stir_cb *stir = usb_get_intfdata(intf); diff --git a/trunk/drivers/usb/class/audio.c b/trunk/drivers/usb/class/audio.c index f8f21567cc22..f432b7d5b235 100644 --- a/trunk/drivers/usb/class/audio.c +++ b/trunk/drivers/usb/class/audio.c @@ -649,10 +649,14 @@ static void usbin_stop(struct usb_audiodev *as) } } set_current_state(TASK_RUNNING); - kfree(u->durb[0].urb->transfer_buffer); - kfree(u->durb[1].urb->transfer_buffer); - kfree(u->surb[0].urb->transfer_buffer); - kfree(u->surb[1].urb->transfer_buffer); + if (u->durb[0].urb->transfer_buffer) + kfree(u->durb[0].urb->transfer_buffer); + if (u->durb[1].urb->transfer_buffer) + kfree(u->durb[1].urb->transfer_buffer); + if (u->surb[0].urb->transfer_buffer) + kfree(u->surb[0].urb->transfer_buffer); + if (u->surb[1].urb->transfer_buffer) + kfree(u->surb[1].urb->transfer_buffer); u->durb[0].urb->transfer_buffer = u->durb[1].urb->transfer_buffer = u->surb[0].urb->transfer_buffer = u->surb[1].urb->transfer_buffer = NULL; } @@ -1005,17 +1009,21 @@ static int usbin_start(struct usb_audiodev *as) u->phase = 0; maxsze = (u->freqmax + 0x3fff) >> (14 - AFMT_BYTESSHIFT(u->format)); bufsz = DESCFRAMES * maxsze; - kfree(u->durb[0].urb->transfer_buffer); + if (u->durb[0].urb->transfer_buffer) + kfree(u->durb[0].urb->transfer_buffer); u->durb[0].urb->transfer_buffer = kmalloc(bufsz, GFP_KERNEL); u->durb[0].urb->transfer_buffer_length = bufsz; - kfree(u->durb[1].urb->transfer_buffer); + if (u->durb[1].urb->transfer_buffer) + kfree(u->durb[1].urb->transfer_buffer); u->durb[1].urb->transfer_buffer = kmalloc(bufsz, GFP_KERNEL); u->durb[1].urb->transfer_buffer_length = bufsz; if (u->syncpipe) { - kfree(u->surb[0].urb->transfer_buffer); + if (u->surb[0].urb->transfer_buffer) + kfree(u->surb[0].urb->transfer_buffer); u->surb[0].urb->transfer_buffer = kmalloc(3*SYNCFRAMES, GFP_KERNEL); u->surb[0].urb->transfer_buffer_length = 3*SYNCFRAMES; - kfree(u->surb[1].urb->transfer_buffer); + if (u->surb[1].urb->transfer_buffer) + kfree(u->surb[1].urb->transfer_buffer); u->surb[1].urb->transfer_buffer = kmalloc(3*SYNCFRAMES, GFP_KERNEL); u->surb[1].urb->transfer_buffer_length = 3*SYNCFRAMES; } @@ -1120,10 +1128,14 @@ static void usbout_stop(struct usb_audiodev *as) } } set_current_state(TASK_RUNNING); - kfree(u->durb[0].urb->transfer_buffer); - kfree(u->durb[1].urb->transfer_buffer); - kfree(u->surb[0].urb->transfer_buffer); - kfree(u->surb[1].urb->transfer_buffer); + if (u->durb[0].urb->transfer_buffer) + kfree(u->durb[0].urb->transfer_buffer); + if (u->durb[1].urb->transfer_buffer) + kfree(u->durb[1].urb->transfer_buffer); + if (u->surb[0].urb->transfer_buffer) + kfree(u->surb[0].urb->transfer_buffer); + if (u->surb[1].urb->transfer_buffer) + kfree(u->surb[1].urb->transfer_buffer); u->durb[0].urb->transfer_buffer = u->durb[1].urb->transfer_buffer = u->surb[0].urb->transfer_buffer = u->surb[1].urb->transfer_buffer = NULL; } @@ -1364,17 +1376,21 @@ static int usbout_start(struct usb_audiodev *as) u->phase = 0; maxsze = (u->freqmax + 0x3fff) >> (14 - AFMT_BYTESSHIFT(u->format)); bufsz = DESCFRAMES * maxsze; - kfree(u->durb[0].urb->transfer_buffer); + if (u->durb[0].urb->transfer_buffer) + kfree(u->durb[0].urb->transfer_buffer); u->durb[0].urb->transfer_buffer = kmalloc(bufsz, GFP_KERNEL); u->durb[0].urb->transfer_buffer_length = bufsz; - kfree(u->durb[1].urb->transfer_buffer); + if (u->durb[1].urb->transfer_buffer) + kfree(u->durb[1].urb->transfer_buffer); u->durb[1].urb->transfer_buffer = kmalloc(bufsz, GFP_KERNEL); u->durb[1].urb->transfer_buffer_length = bufsz; if (u->syncpipe) { - kfree(u->surb[0].urb->transfer_buffer); + if (u->surb[0].urb->transfer_buffer) + kfree(u->surb[0].urb->transfer_buffer); u->surb[0].urb->transfer_buffer = kmalloc(3*SYNCFRAMES, GFP_KERNEL); u->surb[0].urb->transfer_buffer_length = 3*SYNCFRAMES; - kfree(u->surb[1].urb->transfer_buffer); + if (u->surb[1].urb->transfer_buffer) + kfree(u->surb[1].urb->transfer_buffer); u->surb[1].urb->transfer_buffer = kmalloc(3*SYNCFRAMES, GFP_KERNEL); u->surb[1].urb->transfer_buffer_length = 3*SYNCFRAMES; } diff --git a/trunk/drivers/usb/class/bluetty.c b/trunk/drivers/usb/class/bluetty.c index 524023327c49..6bac65e0ade7 100644 --- a/trunk/drivers/usb/class/bluetty.c +++ b/trunk/drivers/usb/class/bluetty.c @@ -309,7 +309,7 @@ static int bluetooth_ctrl_msg (struct usb_bluetooth *bluetooth, int request, int } } if (urb->transfer_buffer_length < len) { - kfree(urb->transfer_buffer); + kfree (urb->transfer_buffer); urb->transfer_buffer = kmalloc (len, GFP_KERNEL); if (urb->transfer_buffer == NULL) { err ("%s - out of memory", __FUNCTION__); @@ -535,7 +535,7 @@ static int bluetooth_write (struct tty_struct * tty, const unsigned char *buf, i } exit: - kfree(temp_buffer); + kfree (temp_buffer); return retval; } diff --git a/trunk/drivers/usb/core/config.c b/trunk/drivers/usb/core/config.c index 99595e07b653..0b092bdf98f3 100644 --- a/trunk/drivers/usb/core/config.c +++ b/trunk/drivers/usb/core/config.c @@ -10,8 +10,7 @@ #include #include #include -#include "usb.h" -#include "hcd.h" + #define USB_MAXALTSETTING 128 /* Hard limit */ #define USB_MAXENDPOINTS 30 /* Hard limit */ diff --git a/trunk/drivers/usb/core/devices.c b/trunk/drivers/usb/core/devices.c index ef0b35731ff0..8b61bcd742ca 100644 --- a/trunk/drivers/usb/core/devices.c +++ b/trunk/drivers/usb/core/devices.c @@ -59,7 +59,6 @@ #include #include -#include "usb.h" #include "hcd.h" #define MAX_TOPO_LEVEL 6 @@ -637,8 +636,11 @@ static int usb_device_open(struct inode *inode, struct file *file) static int usb_device_release(struct inode *inode, struct file *file) { - kfree(file->private_data); - file->private_data = NULL; + if (file->private_data) { + kfree(file->private_data); + file->private_data = NULL; + } + return 0; } diff --git a/trunk/drivers/usb/core/devio.c b/trunk/drivers/usb/core/devio.c index 6bfab4bcaa9e..a047bc392983 100644 --- a/trunk/drivers/usb/core/devio.c +++ b/trunk/drivers/usb/core/devio.c @@ -213,10 +213,12 @@ static struct async *alloc_async(unsigned int numisoframes) static void free_async(struct async *as) { - kfree(as->urb->transfer_buffer); - kfree(as->urb->setup_packet); + if (as->urb->transfer_buffer) + kfree(as->urb->transfer_buffer); + if (as->urb->setup_packet) + kfree(as->urb->setup_packet); usb_free_urb(as->urb); - kfree(as); + kfree(as); } static inline void async_newpending(struct async *as) @@ -936,13 +938,17 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, return -EINVAL; } if (!(as = alloc_async(uurb->number_of_packets))) { - kfree(isopkt); - kfree(dr); + if (isopkt) + kfree(isopkt); + if (dr) + kfree(dr); return -ENOMEM; } if (!(as->urb->transfer_buffer = kmalloc(uurb->buffer_length, GFP_KERNEL))) { - kfree(isopkt); - kfree(dr); + if (isopkt) + kfree(isopkt); + if (dr) + kfree(dr); free_async(as); return -ENOMEM; } @@ -961,7 +967,8 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, as->urb->iso_frame_desc[u].length = isopkt[u].length; totlen += isopkt[u].length; } - kfree(isopkt); + if (isopkt) + kfree(isopkt); as->ps = ps; as->userurb = arg; if (uurb->endpoint & USB_DIR_IN) @@ -1025,15 +1032,15 @@ static int processcompl(struct async *as, void __user * __user *arg) if (put_user(urb->error_count, &userurb->error_count)) return -EFAULT; - if (usb_pipeisoc(urb->pipe)) { - for (i = 0; i < urb->number_of_packets; i++) { - if (put_user(urb->iso_frame_desc[i].actual_length, - &userurb->iso_frame_desc[i].actual_length)) - return -EFAULT; - if (put_user(urb->iso_frame_desc[i].status, - &userurb->iso_frame_desc[i].status)) - return -EFAULT; - } + if (!(usb_pipeisoc(urb->pipe))) + return 0; + for (i = 0; i < urb->number_of_packets; i++) { + if (put_user(urb->iso_frame_desc[i].actual_length, + &userurb->iso_frame_desc[i].actual_length)) + return -EFAULT; + if (put_user(urb->iso_frame_desc[i].status, + &userurb->iso_frame_desc[i].status)) + return -EFAULT; } free_async(as); @@ -1119,7 +1126,7 @@ static int proc_submiturb_compat(struct dev_state *ps, void __user *arg) if (get_urb32(&uurb,(struct usbdevfs_urb32 *)arg)) return -EFAULT; - return proc_do_submiturb(ps, &uurb, ((struct usbdevfs_urb32 __user *)arg)->iso_frame_desc, arg); + return proc_do_submiturb(ps, &uurb, ((struct usbdevfs_urb __user *)arg)->iso_frame_desc, arg); } static int processcompl_compat(struct async *as, void __user * __user *arg) @@ -1139,15 +1146,15 @@ static int processcompl_compat(struct async *as, void __user * __user *arg) if (put_user(urb->error_count, &userurb->error_count)) return -EFAULT; - if (usb_pipeisoc(urb->pipe)) { - for (i = 0; i < urb->number_of_packets; i++) { - if (put_user(urb->iso_frame_desc[i].actual_length, - &userurb->iso_frame_desc[i].actual_length)) - return -EFAULT; - if (put_user(urb->iso_frame_desc[i].status, - &userurb->iso_frame_desc[i].status)) - return -EFAULT; - } + if (!(usb_pipeisoc(urb->pipe))) + return 0; + for (i = 0; i < urb->number_of_packets; i++) { + if (put_user(urb->iso_frame_desc[i].actual_length, + &userurb->iso_frame_desc[i].actual_length)) + return -EFAULT; + if (put_user(urb->iso_frame_desc[i].status, + &userurb->iso_frame_desc[i].status)) + return -EFAULT; } free_async(as); @@ -1170,8 +1177,10 @@ static int proc_reapurbnonblock_compat(struct dev_state *ps, void __user *arg) { struct async *as; + printk("reapurbnblock\n"); if (!(as = async_getcompleted(ps))) return -EAGAIN; + printk("reap got as %p\n", as); return processcompl_compat(as, (void __user * __user *)arg); } @@ -1230,7 +1239,7 @@ static int proc_ioctl (struct dev_state *ps, void __user *arg) return -ENOMEM; if ((_IOC_DIR(ctrl.ioctl_code) & _IOC_WRITE)) { if (copy_from_user (buf, ctrl.data, size)) { - kfree(buf); + kfree (buf); return -EFAULT; } } else { @@ -1239,7 +1248,8 @@ static int proc_ioctl (struct dev_state *ps, void __user *arg) } if (!connected(ps->dev)) { - kfree(buf); + if (buf) + kfree(buf); return -ENODEV; } @@ -1301,8 +1311,8 @@ static int proc_ioctl (struct dev_state *ps, void __user *arg) && size > 0 && copy_to_user (ctrl.data, buf, size) != 0) retval = -EFAULT; - - kfree(buf); + if (buf != NULL) + kfree (buf); return retval; } diff --git a/trunk/drivers/usb/core/file.c b/trunk/drivers/usb/core/file.c index 38ed2220c9fc..80ce9644d0ee 100644 --- a/trunk/drivers/usb/core/file.c +++ b/trunk/drivers/usb/core/file.c @@ -28,8 +28,6 @@ #endif #include -#include "usb.h" - #define MAX_USB_MINORS 256 static struct file_operations *usb_minors[MAX_USB_MINORS]; static DEFINE_SPINLOCK(minor_lock); diff --git a/trunk/drivers/usb/core/hcd-pci.c b/trunk/drivers/usb/core/hcd-pci.c index 71b4a8d66318..b9a3dae07036 100644 --- a/trunk/drivers/usb/core/hcd-pci.c +++ b/trunk/drivers/usb/core/hcd-pci.c @@ -33,7 +33,7 @@ #include "hcd.h" -/* PCI-based HCs are common, but plenty of non-PCI HCs are used too */ +/* PCI-based HCs are normal, but custom bus glue should be ok */ /*-------------------------------------------------------------------------*/ @@ -67,8 +67,8 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id) if (pci_enable_device (dev) < 0) return -ENODEV; - dev->current_state = PCI_D0; - dev->dev.power.power_state = PMSG_ON; + dev->current_state = 0; + dev->dev.power.power_state = 0; if (!dev->irq) { dev_err (&dev->dev, @@ -186,14 +186,26 @@ EXPORT_SYMBOL (usb_hcd_pci_remove); #ifdef CONFIG_PM +static char __attribute_used__ *pci_state(u32 state) +{ + switch (state) { + case 0: return "D0"; + case 1: return "D1"; + case 2: return "D2"; + case 3: return "D3hot"; + case 4: return "D3cold"; + } + return NULL; +} + /** * usb_hcd_pci_suspend - power management suspend of a PCI-based HCD * @dev: USB Host Controller being suspended - * @message: semantics in flux + * @state: state that the controller is going into * * Store this function in the HCD's struct pci_driver as suspend(). */ -int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message) +int usb_hcd_pci_suspend (struct pci_dev *dev, u32 state) { struct usb_hcd *hcd; int retval = 0; @@ -201,23 +213,13 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message) hcd = pci_get_drvdata(dev); - /* FIXME until the generic PM interfaces change a lot more, this - * can't use PCI D1 and D2 states. For example, the confusion - * between messages and states will need to vanish, and messages - * will need to provide a target system state again. - * - * It'll be important to learn characteristics of the target state, - * especially on embedded hardware where the HCD will often be in - * charge of an external VBUS power supply and one or more clocks. - * Some target system states will leave them active; others won't. - * (With PCI, that's often handled by platform BIOS code.) - */ - /* even when the PCI layer rejects some of the PCI calls * below, HCs can try global suspend and reduce DMA traffic. * PM-sensitive HCDs may already have done this. */ has_pci_pm = pci_find_capability(dev, PCI_CAP_ID_PM); + if (state > 4) + state = 4; switch (hcd->state) { @@ -226,7 +228,7 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message) */ case HC_STATE_RUNNING: hcd->state = HC_STATE_QUIESCING; - retval = hcd->driver->suspend (hcd, message); + retval = hcd->driver->suspend (hcd, state); if (retval) { dev_dbg (hcd->self.controller, "suspend fail, retval %d\n", @@ -244,11 +246,14 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message) * have been called, otherwise root hub timers still run ... */ case HC_STATE_SUSPENDED: - /* no DMA or IRQs except when HC is active */ - if (dev->current_state == PCI_D0) { - free_irq (hcd->irq, hcd); + if (state <= dev->current_state) + break; + + /* no DMA or IRQs except in D0 */ + if (!dev->current_state) { pci_save_state (dev); pci_disable_device (dev); + free_irq (hcd->irq, hcd); } if (!has_pci_pm) { @@ -256,19 +261,25 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message) break; } - /* NOTE: dev->current_state becomes nonzero only here, and - * only for devices that support PCI PM. Also, exiting - * PCI_D3 (but not PCI_D1 or PCI_D2) is allowed to reset - * some device state (e.g. as part of clock reinit). + /* POLICY: ignore D1/D2/D3hot differences; + * we know D3hot will always work. */ - retval = pci_set_power_state (dev, PCI_D3hot); + retval = pci_set_power_state (dev, state); + if (retval < 0 && state < 3) { + retval = pci_set_power_state (dev, 3); + if (retval == 0) + state = 3; + } if (retval == 0) { - dev_dbg (hcd->self.controller, "--> PCI D3\n"); - pci_enable_wake (dev, PCI_D3hot, hcd->remote_wakeup); - pci_enable_wake (dev, PCI_D3cold, hcd->remote_wakeup); + dev_dbg (hcd->self.controller, "--> PCI %s\n", + pci_state(dev->current_state)); +#ifdef CONFIG_USB_SUSPEND + pci_enable_wake (dev, state, hcd->remote_wakeup); + pci_enable_wake (dev, 4, hcd->remote_wakeup); +#endif } else if (retval < 0) { - dev_dbg (&dev->dev, "PCI D3 suspend fail, %d\n", - retval); + dev_dbg (&dev->dev, "PCI %s suspend fail, %d\n", + pci_state(state), retval); (void) usb_hcd_pci_resume (dev); break; } @@ -276,14 +287,13 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message) default: dev_dbg (hcd->self.controller, "hcd state %d; not suspended\n", hcd->state); - WARN_ON(1); retval = -EINVAL; break; } /* update power_state **ONLY** to make sysfs happier */ if (retval == 0) - dev->dev.power.power_state = message; + dev->dev.power.power_state = state; return retval; } EXPORT_SYMBOL (usb_hcd_pci_suspend); @@ -298,6 +308,7 @@ int usb_hcd_pci_resume (struct pci_dev *dev) { struct usb_hcd *hcd; int retval; + int has_pci_pm; hcd = pci_get_drvdata(dev); if (hcd->state != HC_STATE_SUSPENDED) { @@ -305,73 +316,31 @@ int usb_hcd_pci_resume (struct pci_dev *dev) "can't resume, not suspended!\n"); return 0; } + has_pci_pm = pci_find_capability(dev, PCI_CAP_ID_PM); - /* NOTE: chip docs cover clean "real suspend" cases (what Linux - * calls "standby", "suspend to RAM", and so on). There are also - * dirty cases when swsusp fakes a suspend in "shutdown" mode. - */ - if (dev->current_state != PCI_D0) { -#ifdef DEBUG - int pci_pm; - u16 pmcr; - - pci_pm = pci_find_capability(dev, PCI_CAP_ID_PM); - pci_read_config_word(dev, pci_pm + PCI_PM_CTRL, &pmcr); - pmcr &= PCI_PM_CTRL_STATE_MASK; - if (pmcr) { - /* Clean case: power to USB and to HC registers was - * maintained; remote wakeup is easy. - */ - dev_dbg(hcd->self.controller, "resume from PCI D%d\n", - pmcr); - } else { - /* Clean: HC lost Vcc power, D0 uninitialized - * + Vaux may have preserved port and transceiver - * state ... for remote wakeup from D3cold - * + or not; HCD must reinit + re-enumerate - * - * Dirty: D0 semi-initialized cases with swsusp - * + after BIOS init - * + after Linux init (HCD statically linked) - */ - dev_dbg(hcd->self.controller, - "PCI D0, from previous PCI D%d\n", - dev->current_state); - } -#endif - pci_enable_wake (dev, dev->current_state, 0); - pci_enable_wake (dev, PCI_D3cold, 0); - } else { - /* Same basic cases: clean (powered/not), dirty */ - dev_dbg(hcd->self.controller, "PCI legacy resume\n"); - } - - /* NOTE: the PCI API itself is asymmetric here. We don't need to - * pci_set_power_state(PCI_D0) since that's part of re-enabling; - * but that won't re-enable bus mastering. Yet pci_disable_device() - * explicitly disables bus mastering... - */ - retval = pci_enable_device (dev); - if (retval < 0) { - dev_err (hcd->self.controller, - "can't re-enable after resume, %d!\n", retval); - return retval; - } - pci_set_master (dev); - pci_restore_state (dev); - - dev->dev.power.power_state = PMSG_ON; + /* D3cold resume isn't usually reported this way... */ + dev_dbg(hcd->self.controller, "resume from PCI %s%s\n", + pci_state(dev->current_state), + has_pci_pm ? "" : " (legacy)"); hcd->state = HC_STATE_RESUMING; - hcd->saw_irq = 0; + + if (has_pci_pm) + pci_set_power_state (dev, 0); + dev->dev.power.power_state = 0; retval = request_irq (dev->irq, usb_hcd_irq, SA_SHIRQ, - hcd->irq_descr, hcd); + hcd->driver->description, hcd); if (retval < 0) { dev_err (hcd->self.controller, "can't restore IRQ after resume!\n"); - usb_hc_died (hcd); return retval; } + hcd->saw_irq = 0; + pci_restore_state (dev); +#ifdef CONFIG_USB_SUSPEND + pci_enable_wake (dev, dev->current_state, 0); + pci_enable_wake (dev, 4, 0); +#endif retval = hcd->driver->resume (hcd); if (!HC_IS_RUNNING (hcd->state)) { diff --git a/trunk/drivers/usb/core/hcd.h b/trunk/drivers/usb/core/hcd.h index f67cf1e634fc..6c625b35fa0c 100644 --- a/trunk/drivers/usb/core/hcd.h +++ b/trunk/drivers/usb/core/hcd.h @@ -177,7 +177,7 @@ struct hc_driver { * a whole, not just the root hub; they're for bus glue. */ /* called after all devices were suspended */ - int (*suspend) (struct usb_hcd *hcd, pm_message_t message); + int (*suspend) (struct usb_hcd *hcd, u32 state); /* called before any devices get resumed */ int (*resume) (struct usb_hcd *hcd); @@ -226,7 +226,7 @@ extern int usb_hcd_pci_probe (struct pci_dev *dev, extern void usb_hcd_pci_remove (struct pci_dev *dev); #ifdef CONFIG_PM -extern int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t state); +extern int usb_hcd_pci_suspend (struct pci_dev *dev, u32 state); extern int usb_hcd_pci_resume (struct pci_dev *dev); #endif /* CONFIG_PM */ diff --git a/trunk/drivers/usb/core/hub.c b/trunk/drivers/usb/core/hub.c index d2d648ee8640..fa0dc4f6de47 100644 --- a/trunk/drivers/usb/core/hub.c +++ b/trunk/drivers/usb/core/hub.c @@ -381,7 +381,7 @@ static void hub_tt_kevent (void *arg) dev_err (&hdev->dev, "clear tt %d (%04x) error %d\n", clear->tt, clear->devinfo, status); - kfree(clear); + kfree (clear); } spin_unlock_irqrestore (&hub->tt.lock, flags); } @@ -728,11 +728,15 @@ static void hub_disconnect(struct usb_interface *intf) list_del_init(&hub->event_list); spin_unlock_irq(&hub_event_lock); - kfree(hub->descriptor); - hub->descriptor = NULL; + if (hub->descriptor) { + kfree(hub->descriptor); + hub->descriptor = NULL; + } - kfree(hub->status); - hub->status = NULL; + if (hub->status) { + kfree(hub->status); + hub->status = NULL; + } if (hub->buffer) { usb_buffer_free(hdev, sizeof(*hub->buffer), hub->buffer, @@ -1452,7 +1456,7 @@ static void hub_port_logical_disconnect(struct usb_hub *hub, int port1) /* FIXME let caller ask to power down the port: * - some devices won't enumerate without a VBUS power cycle * - SRP saves power that way - * - usb_suspend_device(dev, PMSG_SUSPEND) + * - usb_suspend_device(dev,PM_SUSPEND_DISK) * That's easy if this hub can switch power per-port, and * khubd reactivates the port later (timer, SRP, etc). * Powerdown must be optional, because of reset/DFU. @@ -1527,7 +1531,7 @@ static int hub_port_suspend(struct usb_hub *hub, int port1, /* * Devices on USB hub ports have only one "suspend" state, corresponding - * to ACPI D2, "may cause the device to lose some context". + * to ACPI D2 (PM_SUSPEND_MEM), "may cause the device to lose some context". * State transitions include: * * - suspend, resume ... when the VBUS power link stays live @@ -1727,7 +1731,7 @@ static int finish_port_resume(struct usb_device *udev) struct usb_driver *driver; intf = udev->actconfig->interface[i]; - if (intf->dev.power.power_state == PMSG_SUSPEND) + if (intf->dev.power.power_state == PM_SUSPEND_ON) continue; if (!intf->dev.driver) { /* FIXME maybe force to alt 0 */ @@ -1741,7 +1745,7 @@ static int finish_port_resume(struct usb_device *udev) /* can we do better than just logging errors? */ status = driver->resume(intf); - if (intf->dev.power.power_state != PMSG_ON + if (intf->dev.power.power_state != PM_SUSPEND_ON || status) dev_dbg(&intf->dev, "resume fail, state %d code %d\n", @@ -2350,7 +2354,7 @@ check_highspeed (struct usb_hub *hub, struct usb_device *udev, int port1) schedule_work (&hub->leds); } } - kfree(qual); + kfree (qual); } static unsigned diff --git a/trunk/drivers/usb/core/inode.c b/trunk/drivers/usb/core/inode.c index f9f9561c6bad..d913407bcdc1 100644 --- a/trunk/drivers/usb/core/inode.c +++ b/trunk/drivers/usb/core/inode.c @@ -41,7 +41,6 @@ #include #include #include "usb.h" -#include "hcd.h" static struct super_operations usbfs_ops; static struct file_operations default_file_operations; diff --git a/trunk/drivers/usb/core/message.c b/trunk/drivers/usb/core/message.c index e12c5be1e0a3..40bdb38e7bcb 100644 --- a/trunk/drivers/usb/core/message.c +++ b/trunk/drivers/usb/core/message.c @@ -1133,10 +1133,29 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) /* prevent submissions using previous endpoint settings */ usb_disable_interface(dev, iface); + /* 9.1.1.5 says: + * + * Configuring a device or changing an alternate setting + * causes all of the status and configuration values + * associated with endpoints in the affected interfaces to + * be set to their default values. This includes setting + * the data toggle of any endpoint using data toggles to + * the value DATA0. + * + * Some devices take this too literally and don't reset the data + * toggles if the new altsetting is the same as the old one (the + * command isn't "changing" an alternate setting). We will manually + * reset the toggles when the new and old altsettings are the same. + * Most devices won't need this, but fortunately it doesn't happen + * often. + */ + if (iface->cur_altsetting == alt) + manual = 1; iface->cur_altsetting = alt; /* If the interface only has one altsetting and the device didn't - * accept the request, we attempt to carry out the equivalent action + * accept the request (or whenever the old altsetting is the same + * as the new one), we attempt to carry out the equivalent action * by manually clearing the HALT feature for each endpoint in the * new altsetting. */ @@ -1183,9 +1202,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) * * Because this affects multiple interfaces, avoid using this with composite * (multi-interface) devices. Instead, the driver for each interface may - * use usb_set_interface() on the interfaces it claims. Be careful though; - * some devices don't support the SET_INTERFACE request, and others won't - * reset all the interface state (notably data toggles). Resetting the whole + * use usb_set_interface() on the interfaces it claims. Resetting the whole * configuration would affect other drivers' interfaces. * * The caller must own the device lock. diff --git a/trunk/drivers/usb/core/urb.c b/trunk/drivers/usb/core/urb.c index 16972159a57a..dc838f81742c 100644 --- a/trunk/drivers/usb/core/urb.c +++ b/trunk/drivers/usb/core/urb.c @@ -420,16 +420,12 @@ int usb_submit_urb(struct urb *urb, int mem_flags) * * Host Controller Drivers (HCDs) place all the URBs for a particular * endpoint in a queue. Normally the queue advances as the controller - * hardware processes each request. But when an URB terminates with an - * error its queue stops, at least until that URB's completion routine - * returns. It is guaranteed that the queue will not restart until all - * its unlinked URBs have been fully retired, with their completion - * routines run, even if that's not until some time after the original - * completion handler returns. Normally the same behavior and guarantees - * apply when an URB terminates because it was unlinked; however if an - * URB is unlinked before the hardware has started to execute it, then - * its queue is not guaranteed to stop until all the preceding URBs have - * completed. + * hardware processes each request. But when an URB terminates with any + * fault (such as an error, or being unlinked) its queue stops, at least + * until that URB's completion routine returns. It is guaranteed that + * the queue will not restart until all its unlinked URBs have been fully + * retired, with their completion routines run, even if that's not until + * some time after the original completion handler returns. * * This means that USB device drivers can safely build deep queues for * large or complex transfers, and clean them up reliably after any sort diff --git a/trunk/drivers/usb/core/usb.c b/trunk/drivers/usb/core/usb.c index c231b4bef314..f0534ee06490 100644 --- a/trunk/drivers/usb/core/usb.c +++ b/trunk/drivers/usb/core/usb.c @@ -50,6 +50,13 @@ #include "hcd.h" #include "usb.h" +extern int usb_hub_init(void); +extern void usb_hub_cleanup(void); +extern int usb_major_init(void); +extern void usb_major_cleanup(void); +extern int usb_host_init(void); +extern void usb_host_cleanup(void); + const char *usbcore_name = "usbcore"; @@ -1375,13 +1382,13 @@ void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe, usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); } -static int usb_generic_suspend(struct device *dev, pm_message_t message) +static int usb_generic_suspend(struct device *dev, u32 state) { struct usb_interface *intf; struct usb_driver *driver; if (dev->driver == &usb_generic_driver) - return usb_suspend_device (to_usb_device(dev), message); + return usb_suspend_device (to_usb_device(dev), state); if ((dev->driver == NULL) || (dev->driver_data == &usb_generic_driver_data)) @@ -1395,7 +1402,7 @@ static int usb_generic_suspend(struct device *dev, pm_message_t message) return 0; if (driver->suspend) - return driver->suspend(intf, message); + return driver->suspend(intf, state); return 0; } diff --git a/trunk/drivers/usb/core/usb.h b/trunk/drivers/usb/core/usb.h index 2c690f6d4c18..4c33eee52001 100644 --- a/trunk/drivers/usb/core/usb.h +++ b/trunk/drivers/usb/core/usb.h @@ -21,13 +21,6 @@ extern void usb_unlock_all_devices(void); extern void usb_kick_khubd(struct usb_device *dev); extern void usb_resume_root_hub(struct usb_device *dev); -extern int usb_hub_init(void); -extern void usb_hub_cleanup(void); -extern int usb_major_init(void); -extern void usb_major_cleanup(void); -extern int usb_host_init(void); -extern void usb_host_cleanup(void); - /* for labeling diagnostics */ extern const char *usbcore_name; @@ -37,7 +30,6 @@ extern struct file_operations usbfs_devices_fops; extern struct file_operations usbfs_device_file_operations; extern void usbfs_conn_disc_event(void); - struct dev_state { struct list_head list; /* state list */ struct usb_device *dev; diff --git a/trunk/drivers/usb/gadget/ether.c b/trunk/drivers/usb/gadget/ether.c index 3993156c2e82..cff9fb0b73cc 100644 --- a/trunk/drivers/usb/gadget/ether.c +++ b/trunk/drivers/usb/gadget/ether.c @@ -100,8 +100,6 @@ static const char driver_desc [] = DRIVER_DESC; /* CDC and RNDIS support the same host-chosen outgoing packet filters. */ #define DEFAULT_FILTER (USB_CDC_PACKET_TYPE_BROADCAST \ - |USB_CDC_PACKET_TYPE_ALL_MULTICAST \ - |USB_CDC_PACKET_TYPE_PROMISCUOUS \ |USB_CDC_PACKET_TYPE_DIRECTED) @@ -324,18 +322,12 @@ module_param (qmult, uint, S_IRUGO|S_IWUSR); /* also defer IRQs on highspeed TX */ #define TX_DELAY qmult -static inline int BITRATE(struct usb_gadget *g) -{ - return (g->speed == USB_SPEED_HIGH) ? HS_BPS : FS_BPS; -} +#define BITRATE(g) (((g)->speed == USB_SPEED_HIGH) ? HS_BPS : FS_BPS) #else /* full speed (low speed doesn't do bulk) */ #define qlen(gadget) DEFAULT_QLEN -static inline int BITRATE(struct usb_gadget *g) -{ - return FS_BPS; -} +#define BITRATE(g) FS_BPS #endif @@ -1175,7 +1167,7 @@ eth_set_config (struct eth_dev *dev, unsigned number, int gfp_flags) eth_reset_config (dev); /* default: pass all packets, no multicast filtering */ - dev->cdc_filter = DEFAULT_FILTER; + dev->cdc_filter = 0x000f; switch (number) { case DEV_CONFIG_VALUE: @@ -1351,9 +1343,9 @@ eth_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) struct eth_dev *dev = get_gadget_data (gadget); struct usb_request *req = dev->req; int value = -EOPNOTSUPP; - u16 wIndex = (__force u16) ctrl->wIndex; - u16 wValue = (__force u16) ctrl->wValue; - u16 wLength = (__force u16) ctrl->wLength; + u16 wIndex = ctrl->wIndex; + u16 wValue = ctrl->wValue; + u16 wLength = ctrl->wLength; /* descriptors just go into the pre-allocated ep0 buffer, * while config change events may enable network traffic. @@ -1701,7 +1693,7 @@ rx_submit (struct eth_dev *dev, struct usb_request *req, int gfp_flags) /* Some platforms perform better when IP packets are aligned, * but on at least one, checksumming fails otherwise. Note: - * RNDIS headers involve variable numbers of LE32 values. + * this doesn't account for variable-sized RNDIS headers. */ skb_reserve(skb, NET_IP_ALIGN); @@ -1738,11 +1730,9 @@ static void rx_complete (struct usb_ep *ep, struct usb_request *req) #ifdef CONFIG_USB_ETH_RNDIS /* we know MaxPacketsPerTransfer == 1 here */ if (dev->rndis) - status = rndis_rm_hdr (skb); + rndis_rm_hdr (req->buf, &(skb->len)); #endif - if (status < 0 - || ETH_HLEN > skb->len - || skb->len > ETH_FRAME_LEN) { + if (ETH_HLEN > skb->len || skb->len > ETH_FRAME_LEN) { dev->stats.rx_errors++; dev->stats.rx_length_errors++; DEBUG (dev, "rx length %d\n", skb->len); @@ -2057,20 +2047,38 @@ rndis_control_ack_complete (struct usb_ep *ep, struct usb_request *req) DEBUG ((struct eth_dev *) ep->driver_data, "rndis control ack complete --> %d, %d/%d\n", req->status, req->actual, req->length); + + usb_ep_free_buffer(ep, req->buf, req->dma, 8); + usb_ep_free_request(ep, req); } static int rndis_control_ack (struct net_device *net) { struct eth_dev *dev = netdev_priv(net); u32 length; - struct usb_request *resp = dev->stat_req; + struct usb_request *resp; /* in case RNDIS calls this after disconnect */ - if (!dev->status) { + if (!dev->status_ep) { DEBUG (dev, "status ENODEV\n"); return -ENODEV; } + /* Allocate memory for notification ie. ACK */ + resp = usb_ep_alloc_request (dev->status_ep, GFP_ATOMIC); + if (!resp) { + DEBUG (dev, "status ENOMEM\n"); + return -ENOMEM; + } + + resp->buf = usb_ep_alloc_buffer (dev->status_ep, 8, + &resp->dma, GFP_ATOMIC); + if (!resp->buf) { + DEBUG (dev, "status buf ENOMEM\n"); + usb_ep_free_request (dev->status_ep, resp); + return -ENOMEM; + } + /* Send RNDIS RESPONSE_AVAILABLE notification; * USB_CDC_NOTIFY_RESPONSE_AVAILABLE should work too */ @@ -2105,7 +2113,7 @@ static void eth_start (struct eth_dev *dev, int gfp_flags) if (dev->rndis) { rndis_set_param_medium (dev->rndis_config, NDIS_MEDIUM_802_3, - BITRATE(dev->gadget)/100); + BITRATE(dev->gadget)); rndis_send_media_state (dev, 1); } #endif @@ -2299,8 +2307,8 @@ eth_bind (struct usb_gadget *gadget) device_desc.bcdDevice = __constant_cpu_to_le16 (0x0210); } else if (gadget_is_pxa27x(gadget)) { device_desc.bcdDevice = __constant_cpu_to_le16 (0x0211); - } else if (gadget_is_s3c2410(gadget)) { - device_desc.bcdDevice = __constant_cpu_to_le16 (0x0212); + } else if (gadget_is_s3c2410(gadget)) { + device_desc.bcdDevice = __constant_cpu_to_le16 (0x0212); } else if (gadget_is_at91(gadget)) { device_desc.bcdDevice = __constant_cpu_to_le16 (0x0213); } else { diff --git a/trunk/drivers/usb/gadget/omap_udc.c b/trunk/drivers/usb/gadget/omap_udc.c index 98cbcbc16cc1..b66ea5a6ed79 100644 --- a/trunk/drivers/usb/gadget/omap_udc.c +++ b/trunk/drivers/usb/gadget/omap_udc.c @@ -2809,15 +2809,17 @@ static int __exit omap_udc_remove(struct device *dev) return 0; } -static int omap_udc_suspend(struct device *dev, pm_message_t state, u32 level) +/* suspend/resume/wakeup from sysfs (echo > power/state) */ + +static int omap_udc_suspend(struct device *dev, u32 state, u32 level) { if (level != 0) return 0; DBG("suspend, state %d\n", state); omap_pullup(&udc->gadget, 0); - udc->gadget.dev.power.power_state = PMSG_SUSPEND; - udc->gadget.dev.parent->power.power_state = PMSG_SUSPEND; + udc->gadget.dev.power.power_state = 3; + udc->gadget.dev.parent->power.power_state = 3; return 0; } @@ -2827,8 +2829,8 @@ static int omap_udc_resume(struct device *dev, u32 level) return 0; DBG("resume + wakeup/SRP\n"); - udc->gadget.dev.parent->power.power_state = PMSG_ON; - udc->gadget.dev.power.power_state = PMSG_ON; + udc->gadget.dev.parent->power.power_state = 0; + udc->gadget.dev.power.power_state = 0; omap_pullup(&udc->gadget, 1); /* maybe the host would enumerate us if we nudged it */ diff --git a/trunk/drivers/usb/gadget/rndis.c b/trunk/drivers/usb/gadget/rndis.c index 7457268d5f28..6c5197850edc 100644 --- a/trunk/drivers/usb/gadget/rndis.c +++ b/trunk/drivers/usb/gadget/rndis.c @@ -37,7 +37,6 @@ #include #include #include -#include #undef RNDIS_PM @@ -166,7 +165,7 @@ static int gen_ndis_query_resp (int configNr, u32 OID, rndis_resp_t *r) /* mandatory */ case OID_GEN_LINK_SPEED: -// DEBUG("%s: OID_GEN_LINK_SPEED\n", __FUNCTION__); + DEBUG("%s: OID_GEN_LINK_SPEED\n", __FUNCTION__); length = 4; if (rndis_per_dev_params [configNr].media_state == NDIS_MEDIA_STATE_DISCONNECTED) @@ -730,7 +729,7 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len, retval = 0; /* FIXME use these NDIS_PACKET_TYPE_* bitflags to - * set the cdc_filter; it's not RNDIS-specific + * filter packets in hard_start_xmit() * NDIS_PACKET_TYPE_x == USB_CDC_PACKET_TYPE_x for x in: * PROMISCUOUS, DIRECTED, * MULTICAST, ALL_MULTICAST, BROADCAST @@ -1195,10 +1194,10 @@ void rndis_add_hdr (struct sk_buff *skb) return; header = (void *) skb_push (skb, sizeof *header); memset (header, 0, sizeof *header); - header->MessageType = __constant_cpu_to_le32(REMOTE_NDIS_PACKET_MSG); + header->MessageType = __constant_cpu_to_le32 (1); header->MessageLength = cpu_to_le32(skb->len); header->DataOffset = __constant_cpu_to_le32 (36); - header->DataLength = cpu_to_le32(skb->len - sizeof *header); + header->OOBDataOffset = cpu_to_le32(skb->len - 44); } void rndis_free_response (int configNr, u8 *buf) @@ -1254,23 +1253,26 @@ static rndis_resp_t *rndis_add_response (int configNr, u32 length) return r; } -int rndis_rm_hdr(struct sk_buff *skb) +int rndis_rm_hdr (u8 *buf, u32 *length) { - /* tmp points to a struct rndis_packet_msg_type */ - __le32 *tmp = (void *) skb->data; - - /* MessageType, MessageLength */ - if (__constant_cpu_to_le32(REMOTE_NDIS_PACKET_MSG) - != get_unaligned(tmp++)) - return -EINVAL; - tmp++; + u32 i, messageLen, dataOffset; + __le32 *tmp; + + tmp = (__le32 *) buf; - /* DataOffset, DataLength */ - if (!skb_pull(skb, le32_to_cpu(get_unaligned(tmp++)) - + 8 /* offset of DataOffset */)) - return -EOVERFLOW; - skb_trim(skb, le32_to_cpu(get_unaligned(tmp++))); + if (!buf || !length) return -1; + if (le32_to_cpup(tmp++) != 1) return -1; + + messageLen = le32_to_cpup(tmp++); + dataOffset = le32_to_cpup(tmp++) + 8; + if (messageLen < dataOffset || messageLen > *length) return -1; + + for (i = dataOffset; i < messageLen; i++) + buf [i - dataOffset] = buf [i]; + + *length = messageLen - dataOffset; + return 0; } diff --git a/trunk/drivers/usb/gadget/rndis.h b/trunk/drivers/usb/gadget/rndis.h index 2b5b55df3cfd..822501852c50 100644 --- a/trunk/drivers/usb/gadget/rndis.h +++ b/trunk/drivers/usb/gadget/rndis.h @@ -38,7 +38,6 @@ */ /* Message Set for Connectionless (802.3) Devices */ -#define REMOTE_NDIS_PACKET_MSG 0x00000001U #define REMOTE_NDIS_INITIALIZE_MSG 0x00000002U /* Initialize device */ #define REMOTE_NDIS_HALT_MSG 0x00000003U #define REMOTE_NDIS_QUERY_MSG 0x00000004U @@ -334,7 +333,7 @@ int rndis_set_param_vendor (u8 configNr, u32 vendorID, const char *vendorDescr); int rndis_set_param_medium (u8 configNr, u32 medium, u32 speed); void rndis_add_hdr (struct sk_buff *skb); -int rndis_rm_hdr (struct sk_buff *skb); +int rndis_rm_hdr (u8 *buf, u32 *length); u8 *rndis_get_next_response (int configNr, u32 *length); void rndis_free_response (int configNr, u8 *buf); diff --git a/trunk/drivers/usb/gadget/serial.c b/trunk/drivers/usb/gadget/serial.c index f1762ed6db63..2af3f785d5a1 100644 --- a/trunk/drivers/usb/gadget/serial.c +++ b/trunk/drivers/usb/gadget/serial.c @@ -2312,8 +2312,9 @@ static struct gs_buf *gs_buf_alloc(unsigned int size, int kmalloc_flags) */ void gs_buf_free(struct gs_buf *gb) { - if (gb) { - kfree(gb->buf_buf); + if (gb != NULL) { + if (gb->buf_buf != NULL) + kfree(gb->buf_buf); kfree(gb); } } diff --git a/trunk/drivers/usb/host/ehci-dbg.c b/trunk/drivers/usb/host/ehci-dbg.c index 9b347d765383..495e2a3ef6f1 100644 --- a/trunk/drivers/usb/host/ehci-dbg.c +++ b/trunk/drivers/usb/host/ehci-dbg.c @@ -394,7 +394,7 @@ static void qh_lines ( mark = ' '; if (hw_curr == td->qtd_dma) mark = '*'; - else if (qh->hw_qtd_next == cpu_to_le32(td->qtd_dma)) + else if (qh->hw_qtd_next == td->qtd_dma) mark = '+'; else if (QTD_LENGTH (scratch)) { if (td->hw_alt_next == ehci->async->hw_alt_next) diff --git a/trunk/drivers/usb/host/ehci-hcd.c b/trunk/drivers/usb/host/ehci-hcd.c index 84d2b93aca37..a63bb792e2c7 100644 --- a/trunk/drivers/usb/host/ehci-hcd.c +++ b/trunk/drivers/usb/host/ehci-hcd.c @@ -721,7 +721,7 @@ static int ehci_get_frame (struct usb_hcd *hcd) * the right sort of wakeup. */ -static int ehci_suspend (struct usb_hcd *hcd, pm_message_t message) +static int ehci_suspend (struct usb_hcd *hcd, u32 state) { struct ehci_hcd *ehci = hcd_to_ehci (hcd); @@ -729,7 +729,7 @@ static int ehci_suspend (struct usb_hcd *hcd, pm_message_t message) msleep (100); #ifdef CONFIG_USB_SUSPEND - (void) usb_suspend_device (hcd->self.root_hub, message); + (void) usb_suspend_device (hcd->self.root_hub, state); #else usb_lock_device (hcd->self.root_hub); (void) ehci_hub_suspend (hcd); diff --git a/trunk/drivers/usb/host/ehci-mem.c b/trunk/drivers/usb/host/ehci-mem.c index 5c38ad869485..9938697ff361 100644 --- a/trunk/drivers/usb/host/ehci-mem.c +++ b/trunk/drivers/usb/host/ehci-mem.c @@ -156,7 +156,8 @@ static void ehci_mem_cleanup (struct ehci_hcd *ehci) ehci->periodic = NULL; /* shadow periodic table */ - kfree(ehci->pshadow); + if (ehci->pshadow) + kfree (ehci->pshadow); ehci->pshadow = NULL; } diff --git a/trunk/drivers/usb/host/ehci-sched.c b/trunk/drivers/usb/host/ehci-sched.c index 2fa1ffee5ff3..f6c86354e304 100644 --- a/trunk/drivers/usb/host/ehci-sched.c +++ b/trunk/drivers/usb/host/ehci-sched.c @@ -310,9 +310,9 @@ static int qh_link_periodic (struct ehci_hcd *ehci, struct ehci_qh *qh) for (i = qh->start; i < ehci->periodic_size; i += period) { union ehci_shadow *prev = &ehci->pshadow [i]; - __le32 *hw_p = &ehci->periodic [i]; + u32 *hw_p = &ehci->periodic [i]; union ehci_shadow here = *prev; - __le32 type = 0; + u32 type = 0; /* skip the iso nodes at list head */ while (here.ptr) { diff --git a/trunk/drivers/usb/host/ehci.h b/trunk/drivers/usb/host/ehci.h index e763a8399a75..67988dba9eb7 100644 --- a/trunk/drivers/usb/host/ehci.h +++ b/trunk/drivers/usb/host/ehci.h @@ -364,7 +364,7 @@ union ehci_shadow { struct ehci_itd *itd; /* Q_TYPE_ITD */ struct ehci_sitd *sitd; /* Q_TYPE_SITD */ struct ehci_fstn *fstn; /* Q_TYPE_FSTN */ - __le32 *hw_next; /* (all types) */ + u32 *hw_next; /* (all types) */ void *ptr; }; diff --git a/trunk/drivers/usb/host/ohci-omap.c b/trunk/drivers/usb/host/ohci-omap.c index 8aab5907afe9..90285f180f87 100644 --- a/trunk/drivers/usb/host/ohci-omap.c +++ b/trunk/drivers/usb/host/ohci-omap.c @@ -458,11 +458,9 @@ static int ohci_hcd_omap_drv_remove(struct device *dev) /* states match PCI usage, always suspending the root hub except that * 4 ~= D3cold (ACPI D3) with clock off (resume sees reset). - * - * FIXME: above comment is not right, and code is wrong, too :-(. */ -static int ohci_omap_suspend(struct device *dev, pm_message_t state, u32 level) +static int ohci_omap_suspend(struct device *dev, u32 state, u32 level) { struct ohci_hcd *ohci = hcd_to_ohci(dev_get_drvdata(dev)); int status = -EINVAL; diff --git a/trunk/drivers/usb/host/ohci-pci.c b/trunk/drivers/usb/host/ohci-pci.c index 57fd07d00549..b611582e6bcf 100644 --- a/trunk/drivers/usb/host/ohci-pci.c +++ b/trunk/drivers/usb/host/ohci-pci.c @@ -54,7 +54,7 @@ ohci_pci_start (struct usb_hcd *hcd) if (pdev->vendor == PCI_VENDOR_ID_AMD && pdev->device == 0x740c) { ohci->flags = OHCI_QUIRK_AMD756; - ohci_dbg (ohci, "AMD756 erratum 4 workaround\n"); + ohci_info (ohci, "AMD756 erratum 4 workaround\n"); // also somewhat erratum 10 (suspend/resume issues) } @@ -68,7 +68,7 @@ ohci_pci_start (struct usb_hcd *hcd) */ else if (pdev->vendor == PCI_VENDOR_ID_OPTI && pdev->device == 0xc861) { - ohci_dbg (ohci, + ohci_info (ohci, "WARNING: OPTi workarounds unavailable\n"); } @@ -84,20 +84,9 @@ ohci_pci_start (struct usb_hcd *hcd) if (b && b->device == PCI_DEVICE_ID_NS_87560_LIO && b->vendor == PCI_VENDOR_ID_NS) { ohci->flags |= OHCI_QUIRK_SUPERIO; - ohci_dbg (ohci, "Using NSC SuperIO setup\n"); + ohci_info (ohci, "Using NSC SuperIO setup\n"); } } - - /* Check for Compaq's ZFMicro chipset, which needs short - * delays before control or bulk queues get re-activated - * in finish_unlinks() - */ - else if (pdev->vendor == PCI_VENDOR_ID_COMPAQ - && pdev->device == 0xa0f8) { - ohci->flags |= OHCI_QUIRK_ZFMICRO; - ohci_dbg (ohci, - "enabled Compaq ZFMicro chipset quirk\n"); - } } /* NOTE: there may have already been a first reset, to @@ -113,7 +102,7 @@ ohci_pci_start (struct usb_hcd *hcd) #ifdef CONFIG_PM -static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message) +static int ohci_pci_suspend (struct usb_hcd *hcd, u32 state) { struct ohci_hcd *ohci = hcd_to_ohci (hcd); @@ -122,7 +111,7 @@ static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message) msleep (100); #ifdef CONFIG_USB_SUSPEND - (void) usb_suspend_device (hcd->self.root_hub, message); + (void) usb_suspend_device (hcd->self.root_hub, state); #else usb_lock_device (hcd->self.root_hub); (void) ohci_hub_suspend (hcd); diff --git a/trunk/drivers/usb/host/ohci-pxa27x.c b/trunk/drivers/usb/host/ohci-pxa27x.c index e5bc1789d18a..6f3464a95779 100644 --- a/trunk/drivers/usb/host/ohci-pxa27x.c +++ b/trunk/drivers/usb/host/ohci-pxa27x.c @@ -337,7 +337,7 @@ static int ohci_hcd_pxa27x_drv_remove(struct device *dev) return 0; } -static int ohci_hcd_pxa27x_drv_suspend(struct device *dev, pm_message_t state, u32 level) +static int ohci_hcd_pxa27x_drv_suspend(struct device *dev, u32 state, u32 level) { // struct platform_device *pdev = to_platform_device(dev); // struct usb_hcd *hcd = dev_get_drvdata(dev); @@ -346,7 +346,7 @@ static int ohci_hcd_pxa27x_drv_suspend(struct device *dev, pm_message_t state, u return 0; } -static int ohci_hcd_pxa27x_drv_resume(struct device *dev, u32 level) +static int ohci_hcd_pxa27x_drv_resume(struct device *dev, u32 state) { // struct platform_device *pdev = to_platform_device(dev); // struct usb_hcd *hcd = dev_get_drvdata(dev); diff --git a/trunk/drivers/usb/host/ohci-q.c b/trunk/drivers/usb/host/ohci-q.c index e372306ed0da..c90114a77277 100644 --- a/trunk/drivers/usb/host/ohci-q.c +++ b/trunk/drivers/usb/host/ohci-q.c @@ -1021,8 +1021,6 @@ finish_unlinks (struct ohci_hcd *ohci, u16 tick, struct pt_regs *regs) if (ohci->ed_controltail) { command |= OHCI_CLF; - if (ohci->flags & OHCI_QUIRK_ZFMICRO) - mdelay(1); if (!(ohci->hc_control & OHCI_CTRL_CLE)) { control |= OHCI_CTRL_CLE; ohci_writel (ohci, 0, @@ -1031,8 +1029,6 @@ finish_unlinks (struct ohci_hcd *ohci, u16 tick, struct pt_regs *regs) } if (ohci->ed_bulktail) { command |= OHCI_BLF; - if (ohci->flags & OHCI_QUIRK_ZFMICRO) - mdelay(1); if (!(ohci->hc_control & OHCI_CTRL_BLE)) { control |= OHCI_CTRL_BLE; ohci_writel (ohci, 0, @@ -1043,17 +1039,12 @@ finish_unlinks (struct ohci_hcd *ohci, u16 tick, struct pt_regs *regs) /* CLE/BLE to enable, CLF/BLF to (maybe) kickstart */ if (control) { ohci->hc_control |= control; - if (ohci->flags & OHCI_QUIRK_ZFMICRO) - mdelay(1); ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); } - if (command) { - if (ohci->flags & OHCI_QUIRK_ZFMICRO) - mdelay(1); + if (command) ohci_writel (ohci, command, &ohci->regs->cmdstatus); - } - } + } } diff --git a/trunk/drivers/usb/host/ohci.h b/trunk/drivers/usb/host/ohci.h index 22e1ac138ac0..2ba6e2b0210c 100644 --- a/trunk/drivers/usb/host/ohci.h +++ b/trunk/drivers/usb/host/ohci.h @@ -396,7 +396,6 @@ struct ohci_hcd { #define OHCI_QUIRK_SUPERIO 0x02 /* natsemi */ #define OHCI_QUIRK_INITRESET 0x04 /* SiS, OPTi, ... */ #define OHCI_BIG_ENDIAN 0x08 /* big endian HC */ -#define OHCI_QUIRK_ZFMICRO 0x10 /* Compaq ZFMicro chipset*/ // there are also chip quirks/bugs in init logic }; diff --git a/trunk/drivers/usb/host/uhci-hcd.c b/trunk/drivers/usb/host/uhci-hcd.c index 49bd83ee0c75..324a1a9bbdb2 100644 --- a/trunk/drivers/usb/host/uhci-hcd.c +++ b/trunk/drivers/usb/host/uhci-hcd.c @@ -716,7 +716,7 @@ static void uhci_stop(struct usb_hcd *hcd) } #ifdef CONFIG_PM -static int uhci_suspend(struct usb_hcd *hcd, pm_message_t message) +static int uhci_suspend(struct usb_hcd *hcd, u32 state) { struct uhci_hcd *uhci = hcd_to_uhci(hcd); @@ -890,7 +890,8 @@ static int __init uhci_hcd_init(void) debugfs_remove(uhci_debugfs_root); debug_failed: - kfree(errbuf); + if (errbuf) + kfree(errbuf); errbuf_failed: @@ -905,7 +906,9 @@ static void __exit uhci_hcd_cleanup(void) warn("not all urb_priv's were freed!"); debugfs_remove(uhci_debugfs_root); - kfree(errbuf); + + if (errbuf) + kfree(errbuf); } module_init(uhci_hcd_init); diff --git a/trunk/drivers/usb/input/aiptek.c b/trunk/drivers/usb/input/aiptek.c index 2d76be62f4e0..d7fea9ea301b 100644 --- a/trunk/drivers/usb/input/aiptek.c +++ b/trunk/drivers/usb/input/aiptek.c @@ -2138,7 +2138,6 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) aiptek->inputdev.id.vendor = le16_to_cpu(usbdev->descriptor.idVendor); aiptek->inputdev.id.product = le16_to_cpu(usbdev->descriptor.idProduct); aiptek->inputdev.id.version = le16_to_cpu(usbdev->descriptor.bcdDevice); - aiptek->inputdev.dev = &intf->dev; aiptek->usbdev = usbdev; aiptek->ifnum = intf->altsetting[0].desc.bInterfaceNumber; diff --git a/trunk/drivers/usb/input/hid-core.c b/trunk/drivers/usb/input/hid-core.c index 869ff73690ac..7662cf4e2621 100644 --- a/trunk/drivers/usb/input/hid-core.c +++ b/trunk/drivers/usb/input/hid-core.c @@ -558,7 +558,8 @@ static void hid_free_device(struct hid_device *device) } } - kfree(device->rdesc); + if (device->rdesc) + kfree(device->rdesc); kfree(device); } @@ -1789,12 +1790,12 @@ static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id) return 0; } -static int hid_suspend(struct usb_interface *intf, pm_message_t message) +static int hid_suspend(struct usb_interface *intf, u32 state) { struct hid_device *hid = usb_get_intfdata (intf); usb_kill_urb(hid->urbin); - intf->dev.power.power_state = PMSG_SUSPEND; + intf->dev.power.power_state = state; dev_dbg(&intf->dev, "suspend\n"); return 0; } @@ -1804,7 +1805,7 @@ static int hid_resume(struct usb_interface *intf) struct hid_device *hid = usb_get_intfdata (intf); int status; - intf->dev.power.power_state = PMSG_ON; + intf->dev.power.power_state = PM_SUSPEND_ON; if (hid->open) status = usb_submit_urb(hid->urbin, GFP_NOIO); else diff --git a/trunk/drivers/usb/media/dabusb.c b/trunk/drivers/usb/media/dabusb.c index 6ca2fae99d2d..8823297d2191 100644 --- a/trunk/drivers/usb/media/dabusb.c +++ b/trunk/drivers/usb/media/dabusb.c @@ -138,7 +138,8 @@ static int dabusb_free_queue (struct list_head *q) #ifdef DEBUG dump_urb(b->purb); #endif - kfree(b->purb->transfer_buffer); + if (b->purb->transfer_buffer) + kfree (b->purb->transfer_buffer); usb_free_urb(b->purb); tmp = p->next; list_del (p); diff --git a/trunk/drivers/usb/media/ov511.c b/trunk/drivers/usb/media/ov511.c index d6051822416e..0fd7ffed3a98 100644 --- a/trunk/drivers/usb/media/ov511.c +++ b/trunk/drivers/usb/media/ov511.c @@ -3915,8 +3915,10 @@ ov51x_do_dealloc(struct usb_ov511 *ov) ov->tempfbuf = NULL; for (i = 0; i < OV511_NUMSBUF; i++) { - kfree(ov->sbuf[i].data); - ov->sbuf[i].data = NULL; + if (ov->sbuf[i].data) { + kfree(ov->sbuf[i].data); + ov->sbuf[i].data = NULL; + } } for (i = 0; i < OV511_NUMFRAMES; i++) { @@ -5952,8 +5954,10 @@ ov51x_probe(struct usb_interface *intf, const struct usb_device_id *id) up(&ov->cbuf_lock); } - kfree(ov); - ov = NULL; + if (ov) { + kfree(ov); + ov = NULL; + } error_out: err("Camera initialization failed"); diff --git a/trunk/drivers/usb/media/se401.c b/trunk/drivers/usb/media/se401.c index f69e443cd1bc..685bdae5cb62 100644 --- a/trunk/drivers/usb/media/se401.c +++ b/trunk/drivers/usb/media/se401.c @@ -868,14 +868,13 @@ static void usb_se401_remove_disconnected (struct usb_se401 *se401) se401->dev = NULL; - for (i=0; iurb[i]) { - usb_kill_urb(se401->urb[i]); - usb_free_urb(se401->urb[i]); - se401->urb[i] = NULL; - kfree(se401->sbuf[i].data); - } - for (i=0; iurb[i]) { + usb_kill_urb(se401->urb[i]); + usb_free_urb(se401->urb[i]); + se401->urb[i] = NULL; + kfree(se401->sbuf[i].data); + } + for (i=0; iscratch[i].data) { kfree(se401->scratch[i].data); } if (se401->inturb) { diff --git a/trunk/drivers/usb/media/usbvideo.c b/trunk/drivers/usb/media/usbvideo.c index 24efb21969c6..298484aa27d2 100644 --- a/trunk/drivers/usb/media/usbvideo.c +++ b/trunk/drivers/usb/media/usbvideo.c @@ -1169,8 +1169,10 @@ static int usbvideo_v4l_open(struct inode *inode, struct file *file) } RingQueue_Free(&uvd->dp); for (i=0; i < USBVIDEO_NUMSBUF; i++) { - kfree(uvd->sbuf[i].data); - uvd->sbuf[i].data = NULL; + if (uvd->sbuf[i].data != NULL) { + kfree (uvd->sbuf[i].data); + uvd->sbuf[i].data = NULL; + } } } } diff --git a/trunk/drivers/usb/media/w9968cf.c b/trunk/drivers/usb/media/w9968cf.c index ca9f3a30634f..689e79e4bcee 100644 --- a/trunk/drivers/usb/media/w9968cf.c +++ b/trunk/drivers/usb/media/w9968cf.c @@ -3624,8 +3624,10 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) return 0; fail: /* Free unused memory */ - kfree(cam->control_buffer); - kfree(cam->data_buffer); + if (cam->control_buffer) + kfree(cam->control_buffer); + if (cam->data_buffer) + kfree(cam->data_buffer); if (cam->v4ldev) video_device_release(cam->v4ldev); up(&cam->dev_sem); diff --git a/trunk/drivers/usb/misc/auerswald.c b/trunk/drivers/usb/misc/auerswald.c index 6f7994f5a714..a530bb976e43 100644 --- a/trunk/drivers/usb/misc/auerswald.c +++ b/trunk/drivers/usb/misc/auerswald.c @@ -705,12 +705,16 @@ static int auerchain_control_msg (pauerchain_t acp, struct usb_device *dev, unsi /* free a single auerbuf */ static void auerbuf_free (pauerbuf_t bp) { - kfree(bp->bufp); - kfree(bp->dr); + if (bp->bufp) { + kfree (bp->bufp); + } + if (bp->dr) { + kfree (bp->dr); + } if (bp->urbp) { - usb_free_urb(bp->urbp); + usb_free_urb (bp->urbp); } - kfree(bp); + kfree (bp); } /* free the buffers from an auerbuf list */ @@ -1089,12 +1093,14 @@ static void auerswald_int_complete (struct urb * urb, struct pt_regs *regs) */ static void auerswald_int_free (pauerswald_t cp) { - if (cp->inturbp) { - usb_free_urb(cp->inturbp); - cp->inturbp = NULL; - } - kfree(cp->intbufp); - cp->intbufp = NULL; + if (cp->inturbp) { + usb_free_urb (cp->inturbp); + cp->inturbp = NULL; + } + if (cp->intbufp) { + kfree (cp->intbufp); + cp->intbufp = NULL; + } } /* This function is called to activate the interrupt diff --git a/trunk/drivers/usb/misc/sisusbvga/sisusb.c b/trunk/drivers/usb/misc/sisusbvga/sisusb.c index 57b82d53a940..be163b330167 100644 --- a/trunk/drivers/usb/misc/sisusbvga/sisusb.c +++ b/trunk/drivers/usb/misc/sisusbvga/sisusb.c @@ -3104,7 +3104,6 @@ static void sisusb_disconnect(struct usb_interface *intf) static struct usb_device_id sisusb_table [] = { { USB_DEVICE(0x0711, 0x0900) }, - { USB_DEVICE(0x182d, 0x021c) }, { } }; @@ -3115,7 +3114,7 @@ static struct usb_driver sisusb_driver = { .name = "sisusb", .probe = sisusb_probe, .disconnect = sisusb_disconnect, - .id_table = sisusb_table, + .id_table = sisusb_table }; static int __init usb_sisusb_init(void) diff --git a/trunk/drivers/usb/net/pegasus.c b/trunk/drivers/usb/net/pegasus.c index a02be795d63e..f6c19d73b7da 100644 --- a/trunk/drivers/usb/net/pegasus.c +++ b/trunk/drivers/usb/net/pegasus.c @@ -1364,18 +1364,11 @@ static void pegasus_disconnect(struct usb_interface *intf) free_netdev(pegasus->net); } -static int pegasus_suspend (struct usb_interface *intf, pm_message_t message) +static int pegasus_suspend (struct usb_interface *intf, pm_message_t state) { struct pegasus *pegasus = usb_get_intfdata(intf); netif_device_detach (pegasus->net); - if (netif_running(pegasus->net)) { - cancel_delayed_work(&pegasus->carrier_check); - - usb_kill_urb(pegasus->rx_urb); - usb_kill_urb(pegasus->intr_urb); - } - intf->dev.power.power_state = PMSG_SUSPEND; return 0; } @@ -1383,20 +1376,7 @@ static int pegasus_resume (struct usb_interface *intf) { struct pegasus *pegasus = usb_get_intfdata(intf); - intf->dev.power.power_state = PMSG_ON; netif_device_attach (pegasus->net); - if (netif_running(pegasus->net)) { - pegasus->rx_urb->status = 0; - pegasus->rx_urb->actual_length = 0; - read_bulk_callback(pegasus->rx_urb, 0); - - pegasus->intr_urb->status = 0; - pegasus->intr_urb->actual_length = 0; - intr_callback(pegasus->intr_urb, 0); - - queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check, - CARRIER_CHECK_DELAY); - } return 0; } diff --git a/trunk/drivers/usb/net/usbnet.c b/trunk/drivers/usb/net/usbnet.c index bbaef047d532..dd8b4456ea35 100644 --- a/trunk/drivers/usb/net/usbnet.c +++ b/trunk/drivers/usb/net/usbnet.c @@ -426,7 +426,7 @@ static void skb_return (struct usbnet *dev, struct sk_buff *skb) dev->stats.rx_bytes += skb->len; if (netif_msg_rx_status (dev)) - devdbg (dev, "< rx, len %zd, type 0x%x", + devdbg (dev, "< rx, len %d, type 0x%x", skb->len + sizeof (struct ethhdr), skb->protocol); memset (skb->cb, 0, sizeof (struct skb_data)); status = netif_rx (skb); @@ -3732,17 +3732,11 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) #ifdef CONFIG_PM -static int usbnet_suspend (struct usb_interface *intf, pm_message_t message) +static int usbnet_suspend (struct usb_interface *intf, u32 state) { struct usbnet *dev = usb_get_intfdata(intf); - /* accelerate emptying of the rx and queues, to avoid - * having everything error out. - */ netif_device_detach (dev->net); - (void) unlink_urbs (dev, &dev->rxq); - (void) unlink_urbs (dev, &dev->txq); - intf->dev.power.power_state = PMSG_SUSPEND; return 0; } @@ -3750,9 +3744,7 @@ static int usbnet_resume (struct usb_interface *intf) { struct usbnet *dev = usb_get_intfdata(intf); - intf->dev.power.power_state = PMSG_ON; netif_device_attach (dev->net); - tasklet_schedule (&dev->bh); return 0; } @@ -4017,23 +4009,10 @@ static const struct usb_device_id products [] = { .idProduct = 0x9050, /* C-860 */ ZAURUS_MASTER_INTERFACE, .driver_info = ZAURUS_PXA_INFO, -}, - #ifdef CONFIG_USB_ZAURUS - /* at least some (reports vary) PXA units have very different - * lies about their standards support: they claim to be cell - * phones giving direct radio access (which they aren't). + /* at least some (reports vary) C-860 units have very different + * lies about their standards support. */ -{ - .match_flags = USB_DEVICE_ID_MATCH_INT_INFO - | USB_DEVICE_ID_MATCH_DEVICE, - .idVendor = 0x04DD, - /* Sharp ROM v1.32 */ - .idProduct = 0x8006, /* SL-5600 */ - .bInterfaceClass = USB_CLASS_COMM, - .bInterfaceSubClass = USB_CDC_SUBCLASS_MDLM, - .bInterfaceProtocol = USB_CDC_PROTO_NONE, - .driver_info = (unsigned long) &zaurus_pxa_mdlm_info, }, { .match_flags = USB_DEVICE_ID_MATCH_INT_INFO | USB_DEVICE_ID_MATCH_DEVICE, @@ -4044,8 +4023,8 @@ static const struct usb_device_id products [] = { .bInterfaceSubClass = USB_CDC_SUBCLASS_MDLM, .bInterfaceProtocol = USB_CDC_PROTO_NONE, .driver_info = (unsigned long) &zaurus_pxa_mdlm_info, -}, #endif +}, /* Olympus has some models with a Zaurus-compatible option. * R-1000 uses a FreeScale i.MXL cpu (ARMv4T) diff --git a/trunk/drivers/usb/net/zd1201.c b/trunk/drivers/usb/net/zd1201.c index c81cd0a619bf..938025e2c646 100644 --- a/trunk/drivers/usb/net/zd1201.c +++ b/trunk/drivers/usb/net/zd1201.c @@ -106,7 +106,8 @@ int zd1201_fw_upload(struct usb_device *dev, int apfw) err = 0; exit: - kfree(buf); + if (buf) + kfree(buf); release_firmware(fw_entry); return err; } diff --git a/trunk/drivers/usb/serial/belkin_sa.c b/trunk/drivers/usb/serial/belkin_sa.c index abb1b2c543bb..86994d117c44 100644 --- a/trunk/drivers/usb/serial/belkin_sa.c +++ b/trunk/drivers/usb/serial/belkin_sa.c @@ -202,7 +202,8 @@ static void belkin_sa_shutdown (struct usb_serial *serial) for (i=0; i < serial->num_ports; ++i) { /* My special items, the standard routines free my urbs */ priv = usb_get_serial_port_data(serial->port[i]); - kfree(priv); + if (priv) + kfree(priv); } } diff --git a/trunk/drivers/usb/serial/cypress_m8.c b/trunk/drivers/usb/serial/cypress_m8.c index d165f42d560d..db8f472d9e3f 100644 --- a/trunk/drivers/usb/serial/cypress_m8.c +++ b/trunk/drivers/usb/serial/cypress_m8.c @@ -1340,8 +1340,9 @@ static struct cypress_buf *cypress_buf_alloc(unsigned int size) static void cypress_buf_free(struct cypress_buf *cb) { - if (cb) { - kfree(cb->buf_buf); + if (cb != NULL) { + if (cb->buf_buf != NULL) + kfree(cb->buf_buf); kfree(cb); } } diff --git a/trunk/drivers/usb/serial/digi_acceleport.c b/trunk/drivers/usb/serial/digi_acceleport.c index a19a47f6cf12..25f92788a6d4 100644 --- a/trunk/drivers/usb/serial/digi_acceleport.c +++ b/trunk/drivers/usb/serial/digi_acceleport.c @@ -568,9 +568,6 @@ static struct usb_serial_device_type digi_acceleport_4_device = { * and the sleep. In other words, spin_unlock_irqrestore and * interruptible_sleep_on_timeout are "atomic" with respect to * wake ups. This is used to implement condition variables. -* -* interruptible_sleep_on_timeout is deprecated and has been replaced -* with the equivalent code. */ static inline long cond_wait_interruptible_timeout_irqrestore( @@ -579,12 +576,13 @@ static inline long cond_wait_interruptible_timeout_irqrestore( { DEFINE_WAIT(wait); - prepare_to_wait(q, &wait, TASK_INTERRUPTIBLE); + prepare_to_wait(q, &wait, TASK_UNINTERRUPTIBLE); spin_unlock_irqrestore(lock, flags); timeout = schedule_timeout(timeout); finish_wait(q, &wait); return timeout; + } @@ -1598,7 +1596,7 @@ dbg( "digi_close: TOP: port=%d, open_count=%d", priv->dp_port_num, port->open_co dbg( "digi_close: write oob failed, ret=%d", ret ); /* wait for final commands on oob port to complete */ - prepare_to_wait(&priv->dp_flush_wait, &wait, TASK_INTERRUPTIBLE); + prepare_to_wait(&priv->dp_flush_wait, &wait, TASK_UNINTERRUPTIBLE); schedule_timeout(DIGI_CLOSE_TIMEOUT); finish_wait(&priv->dp_flush_wait, &wait); @@ -1997,7 +1995,7 @@ opcode, line, status, val ); } else if( opcode == DIGI_CMD_IFLUSH_FIFO ) { - wake_up_interruptible( &priv->dp_flush_wait ); + wake_up( &priv->dp_flush_wait ); } diff --git a/trunk/drivers/usb/serial/empeg.c b/trunk/drivers/usb/serial/empeg.c index 8d562ab454a8..4d46394f351b 100644 --- a/trunk/drivers/usb/serial/empeg.c +++ b/trunk/drivers/usb/serial/empeg.c @@ -550,7 +550,8 @@ static int __init empeg_init (void) failed_usb_serial_register: for (i = 0; i < NUM_URBS; ++i) { if (write_urb_pool[i]) { - kfree(write_urb_pool[i]->transfer_buffer); + if (write_urb_pool[i]->transfer_buffer) + kfree(write_urb_pool[i]->transfer_buffer); usb_free_urb(write_urb_pool[i]); } } @@ -574,7 +575,8 @@ static void __exit empeg_exit (void) * the host controllers get fixed to set urb->dev = NULL after * the urb is finished. Otherwise this call oopses. */ /* usb_kill_urb(write_urb_pool[i]); */ - kfree(write_urb_pool[i]->transfer_buffer); + if (write_urb_pool[i]->transfer_buffer) + kfree(write_urb_pool[i]->transfer_buffer); usb_free_urb (write_urb_pool[i]); } } diff --git a/trunk/drivers/usb/serial/ftdi_sio.c b/trunk/drivers/usb/serial/ftdi_sio.c index 4c788c767a97..4afd905fe2fe 100644 --- a/trunk/drivers/usb/serial/ftdi_sio.c +++ b/trunk/drivers/usb/serial/ftdi_sio.c @@ -1347,7 +1347,9 @@ static int ftdi_common_startup (struct usb_serial *serial) priv->flags = ASYNC_LOW_LATENCY; /* Increase the size of read buffers */ - kfree(port->bulk_in_buffer); + if (port->bulk_in_buffer) { + kfree (port->bulk_in_buffer); + } port->bulk_in_buffer = kmalloc (BUFSZ, GFP_KERNEL); if (!port->bulk_in_buffer) { kfree (priv); @@ -1363,8 +1365,10 @@ static int ftdi_common_startup (struct usb_serial *serial) usb_free_urb (port->write_urb); port->write_urb = NULL; } - kfree(port->bulk_out_buffer); - port->bulk_out_buffer = NULL; + if (port->bulk_out_buffer) { + kfree (port->bulk_out_buffer); + port->bulk_out_buffer = NULL; + } usb_set_serial_port_data(serial->port[0], priv); diff --git a/trunk/drivers/usb/serial/io_edgeport.c b/trunk/drivers/usb/serial/io_edgeport.c index 04bfe279d763..e35b5adcd5fe 100644 --- a/trunk/drivers/usb/serial/io_edgeport.c +++ b/trunk/drivers/usb/serial/io_edgeport.c @@ -951,7 +951,9 @@ static void edge_bulk_out_cmd_callback (struct urb *urb, struct pt_regs *regs) /* clean up the transfer buffer */ - kfree(urb->transfer_buffer); + if (urb->transfer_buffer != NULL) { + kfree(urb->transfer_buffer); + } /* Free the command urb */ usb_free_urb (urb); @@ -1264,12 +1266,16 @@ static void edge_close (struct usb_serial_port *port, struct file * filp) if (edge_port->write_urb) { /* if this urb had a transfer buffer already (old transfer) free it */ - kfree(edge_port->write_urb->transfer_buffer); - usb_free_urb(edge_port->write_urb); + if (edge_port->write_urb->transfer_buffer != NULL) { + kfree(edge_port->write_urb->transfer_buffer); + } + usb_free_urb (edge_port->write_urb); edge_port->write_urb = NULL; } - kfree(edge_port->txfifo.fifo); - edge_port->txfifo.fifo = NULL; + if (edge_port->txfifo.fifo) { + kfree(edge_port->txfifo.fifo); + edge_port->txfifo.fifo = NULL; + } dbg("%s exited", __FUNCTION__); } @@ -1413,9 +1419,11 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge // get a pointer to the write_urb urb = edge_port->write_urb; - /* make sure transfer buffer is freed */ - kfree(urb->transfer_buffer); - urb->transfer_buffer = NULL; + /* if this urb had a transfer buffer already (old transfer) free it */ + if (urb->transfer_buffer != NULL) { + kfree(urb->transfer_buffer); + urb->transfer_buffer = NULL; + } /* build the data header for the buffer and port that we are about to send out */ count = fifo->count; diff --git a/trunk/drivers/usb/serial/io_ti.c b/trunk/drivers/usb/serial/io_ti.c index ebf9967f7c86..6c96fdaec36e 100644 --- a/trunk/drivers/usb/serial/io_ti.c +++ b/trunk/drivers/usb/serial/io_ti.c @@ -2845,8 +2845,9 @@ static struct edge_buf *edge_buf_alloc(unsigned int size) void edge_buf_free(struct edge_buf *eb) { - if (eb) { - kfree(eb->buf_buf); + if (eb != NULL) { + if (eb->buf_buf != NULL) + kfree(eb->buf_buf); kfree(eb); } } diff --git a/trunk/drivers/usb/serial/kl5kusb105.c b/trunk/drivers/usb/serial/kl5kusb105.c index a11e829e38c8..49c602a0b4df 100644 --- a/trunk/drivers/usb/serial/kl5kusb105.c +++ b/trunk/drivers/usb/serial/kl5kusb105.c @@ -341,7 +341,8 @@ static void klsi_105_shutdown (struct usb_serial *serial) * finished. Otherwise this call * oopses. */ /* usb_kill_urb(write_urbs[j]); */ - kfree(write_urbs[j]->transfer_buffer); + if (write_urbs[j]->transfer_buffer) + kfree(write_urbs[j]->transfer_buffer); usb_free_urb (write_urbs[j]); } } diff --git a/trunk/drivers/usb/serial/omninet.c b/trunk/drivers/usb/serial/omninet.c index b5f2c06d4f3e..a1cba4b5fa23 100644 --- a/trunk/drivers/usb/serial/omninet.c +++ b/trunk/drivers/usb/serial/omninet.c @@ -178,6 +178,7 @@ static void omninet_close (struct usb_serial_port *port, struct file * filp) { struct usb_serial *serial = port->serial; struct usb_serial_port *wport; + struct omninet_data *od; dbg("%s - port %d", __FUNCTION__, port->number); @@ -185,7 +186,9 @@ static void omninet_close (struct usb_serial_port *port, struct file * filp) usb_kill_urb(wport->write_urb); usb_kill_urb(port->read_urb); - kfree(usb_get_serial_port_data(port)); + od = usb_get_serial_port_data(port); + if (od) + kfree(od); } diff --git a/trunk/drivers/usb/serial/pl2303.c b/trunk/drivers/usb/serial/pl2303.c index 7eab5d4cf3a8..3368d2b0412d 100644 --- a/trunk/drivers/usb/serial/pl2303.c +++ b/trunk/drivers/usb/serial/pl2303.c @@ -94,7 +94,6 @@ static struct usb_device_id id_table [] = { { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_ID) }, { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_ID) }, { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_X65) }, - { USB_DEVICE(SYNTECH_VENDOR_ID, SYNTECH_PRODUCT_ID) }, { } /* Terminating entry */ }; @@ -678,9 +677,6 @@ static int pl2303_tiocmset (struct usb_serial_port *port, struct file *file, unsigned long flags; u8 control; - if (!usb_get_intfdata(port->serial->interface)) - return -ENODEV; - spin_lock_irqsave (&priv->lock, flags); if (set & TIOCM_RTS) priv->line_control |= CONTROL_RTS; @@ -706,9 +702,6 @@ static int pl2303_tiocmget (struct usb_serial_port *port, struct file *file) dbg("%s (%d)", __FUNCTION__, port->number); - if (!usb_get_intfdata(port->serial->interface)) - return -ENODEV; - spin_lock_irqsave (&priv->lock, flags); mcr = priv->line_control; status = priv->line_status; @@ -818,40 +811,15 @@ static void pl2303_shutdown (struct usb_serial *serial) } } -static void pl2303_update_line_status(struct usb_serial_port *port, - unsigned char *data, - unsigned int actual_length) -{ - - struct pl2303_private *priv = usb_get_serial_port_data(port); - unsigned long flags; - u8 status_idx = UART_STATE; - u8 length = UART_STATE; - - if ((le16_to_cpu(port->serial->dev->descriptor.idVendor) == SIEMENS_VENDOR_ID) && - (le16_to_cpu(port->serial->dev->descriptor.idProduct) == SIEMENS_PRODUCT_ID_X65)) { - length = 1; - status_idx = 0; - } - - if (actual_length < length) - goto exit; - - /* Save off the uart status for others to look at */ - spin_lock_irqsave(&priv->lock, flags); - priv->line_status = data[status_idx]; - spin_unlock_irqrestore(&priv->lock, flags); - -exit: - return; -} static void pl2303_read_int_callback (struct urb *urb, struct pt_regs *regs) { struct usb_serial_port *port = (struct usb_serial_port *) urb->context; + struct pl2303_private *priv = usb_get_serial_port_data(port); unsigned char *data = urb->transfer_buffer; - unsigned int actual_length = urb->actual_length; + unsigned long flags; int status; + u8 uart_state; dbg("%s (%d)", __FUNCTION__, port->number); @@ -870,9 +838,19 @@ static void pl2303_read_int_callback (struct urb *urb, struct pt_regs *regs) goto exit; } + usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, urb->transfer_buffer); - pl2303_update_line_status(port, data, actual_length); + if (urb->actual_length < UART_STATE) + goto exit; + + /* Save off the uart status for others to look at */ + uart_state = data[UART_STATE]; + spin_lock_irqsave(&priv->lock, flags); + uart_state |= (priv->line_status & UART_STATE_TRANSIENT_MASK); + priv->line_status = uart_state; + spin_unlock_irqrestore(&priv->lock, flags); + exit: status = usb_submit_urb (urb, GFP_ATOMIC); if (status) @@ -1044,8 +1022,9 @@ static struct pl2303_buf *pl2303_buf_alloc(unsigned int size) static void pl2303_buf_free(struct pl2303_buf *pb) { - if (pb) { - kfree(pb->buf_buf); + if (pb != NULL) { + if (pb->buf_buf != NULL) + kfree(pb->buf_buf); kfree(pb); } } diff --git a/trunk/drivers/usb/serial/pl2303.h b/trunk/drivers/usb/serial/pl2303.h index b734c4003c5a..6c1b4712dc2f 100644 --- a/trunk/drivers/usb/serial/pl2303.h +++ b/trunk/drivers/usb/serial/pl2303.h @@ -55,6 +55,3 @@ #define SIEMENS_VENDOR_ID 0x11f5 #define SIEMENS_PRODUCT_ID_X65 0x0003 - -#define SYNTECH_VENDOR_ID 0x0745 -#define SYNTECH_PRODUCT_ID 0x0001 diff --git a/trunk/drivers/usb/serial/ti_usb_3410_5052.c b/trunk/drivers/usb/serial/ti_usb_3410_5052.c index 59c88de3e7ae..98054876cca2 100644 --- a/trunk/drivers/usb/serial/ti_usb_3410_5052.c +++ b/trunk/drivers/usb/serial/ti_usb_3410_5052.c @@ -517,7 +517,8 @@ static void ti_shutdown(struct usb_serial *serial) } } - kfree(tdev); + if (tdev) + kfree(tdev); usb_set_serial_data(serial, NULL); } diff --git a/trunk/drivers/usb/serial/visor.c b/trunk/drivers/usb/serial/visor.c index 31c57adcb623..69d313e98fad 100644 --- a/trunk/drivers/usb/serial/visor.c +++ b/trunk/drivers/usb/serial/visor.c @@ -215,8 +215,6 @@ static struct usb_device_id id_table [] = { .driver_info = (kernel_ulong_t)&palm_os_4_probe }, { USB_DEVICE(PALM_VENDOR_ID, PALM_TUNGSTEN_T_ID), .driver_info = (kernel_ulong_t)&palm_os_4_probe }, - { USB_DEVICE(PALM_VENDOR_ID, PALM_TREO_650), - .driver_info = (kernel_ulong_t)&palm_os_4_probe }, { USB_DEVICE(PALM_VENDOR_ID, PALM_TUNGSTEN_Z_ID), .driver_info = (kernel_ulong_t)&palm_os_4_probe }, { USB_DEVICE(PALM_VENDOR_ID, PALM_ZIRE31_ID), @@ -239,8 +237,6 @@ static struct usb_device_id id_table [] = { .driver_info = (kernel_ulong_t)&palm_os_4_probe }, { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SPH_I500_ID), .driver_info = (kernel_ulong_t)&palm_os_4_probe }, - { USB_DEVICE(TAPWAVE_VENDOR_ID, TAPWAVE_ZODIAC_ID), - .driver_info = (kernel_ulong_t)&palm_os_4_probe }, { USB_DEVICE(GARMIN_VENDOR_ID, GARMIN_IQUE_3600_ID), .driver_info = (kernel_ulong_t)&palm_os_4_probe }, { USB_DEVICE(ACEECA_VENDOR_ID, ACEECA_MEZ1000_ID), @@ -277,7 +273,6 @@ static struct usb_device_id id_table_combined [] = { { USB_DEVICE(PALM_VENDOR_ID, PALM_M125_ID) }, { USB_DEVICE(PALM_VENDOR_ID, PALM_M130_ID) }, { USB_DEVICE(PALM_VENDOR_ID, PALM_TUNGSTEN_T_ID) }, - { USB_DEVICE(PALM_VENDOR_ID, PALM_TREO_650) }, { USB_DEVICE(PALM_VENDOR_ID, PALM_TUNGSTEN_Z_ID) }, { USB_DEVICE(PALM_VENDOR_ID, PALM_ZIRE31_ID) }, { USB_DEVICE(PALM_VENDOR_ID, PALM_ZIRE_ID) }, @@ -291,7 +286,6 @@ static struct usb_device_id id_table_combined [] = { { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_TJ25_ID) }, { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID) }, { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SPH_I500_ID) }, - { USB_DEVICE(TAPWAVE_VENDOR_ID, TAPWAVE_ZODIAC_ID) }, { USB_DEVICE(GARMIN_VENDOR_ID, GARMIN_IQUE_3600_ID) }, { USB_DEVICE(ACEECA_VENDOR_ID, ACEECA_MEZ1000_ID) }, { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_7135_ID) }, diff --git a/trunk/drivers/usb/serial/visor.h b/trunk/drivers/usb/serial/visor.h index b84d1cb4c693..a2fa2c61a009 100644 --- a/trunk/drivers/usb/serial/visor.h +++ b/trunk/drivers/usb/serial/visor.h @@ -30,7 +30,6 @@ #define PALM_M125_ID 0x0040 #define PALM_M130_ID 0x0050 #define PALM_TUNGSTEN_T_ID 0x0060 -#define PALM_TREO_650 0x0061 #define PALM_TUNGSTEN_Z_ID 0x0031 #define PALM_ZIRE31_ID 0x0061 #define PALM_ZIRE_ID 0x0070 @@ -50,9 +49,6 @@ #define SAMSUNG_SCH_I330_ID 0x8001 #define SAMSUNG_SPH_I500_ID 0x6601 -#define TAPWAVE_VENDOR_ID 0x12EF -#define TAPWAVE_ZODIAC_ID 0x0100 - #define GARMIN_VENDOR_ID 0x091E #define GARMIN_IQUE_3600_ID 0x0004 diff --git a/trunk/drivers/usb/storage/sddr55.c b/trunk/drivers/usb/storage/sddr55.c index 8451779f4269..229ca181716b 100644 --- a/trunk/drivers/usb/storage/sddr55.c +++ b/trunk/drivers/usb/storage/sddr55.c @@ -119,8 +119,10 @@ static int sddr55_status(struct us_data *us) /* expect to get short transfer if no card fitted */ if (result == USB_STOR_XFER_SHORT || result == USB_STOR_XFER_STALLED) { /* had a short transfer, no card inserted, free map memory */ - kfree(info->lba_to_pba); - kfree(info->pba_to_lba); + if (info->lba_to_pba) + kfree(info->lba_to_pba); + if (info->pba_to_lba) + kfree(info->pba_to_lba); info->lba_to_pba = NULL; info->pba_to_lba = NULL; @@ -647,14 +649,18 @@ static int sddr55_read_map(struct us_data *us) { return -1; } - kfree(info->lba_to_pba); - kfree(info->pba_to_lba); + if (info->lba_to_pba) + kfree(info->lba_to_pba); + if (info->pba_to_lba) + kfree(info->pba_to_lba); info->lba_to_pba = kmalloc(numblocks*sizeof(int), GFP_NOIO); info->pba_to_lba = kmalloc(numblocks*sizeof(int), GFP_NOIO); if (info->lba_to_pba == NULL || info->pba_to_lba == NULL) { - kfree(info->lba_to_pba); - kfree(info->pba_to_lba); + if (info->lba_to_pba != NULL) + kfree(info->lba_to_pba); + if (info->pba_to_lba != NULL) + kfree(info->pba_to_lba); info->lba_to_pba = NULL; info->pba_to_lba = NULL; kfree(buffer); @@ -722,8 +728,10 @@ static void sddr55_card_info_destructor(void *extra) { if (!extra) return; - kfree(info->lba_to_pba); - kfree(info->pba_to_lba); + if (info->lba_to_pba) + kfree(info->lba_to_pba); + if (info->pba_to_lba) + kfree(info->pba_to_lba); } diff --git a/trunk/drivers/usb/storage/transport.c b/trunk/drivers/usb/storage/transport.c index 9743e289cd3b..d2c3d2fa082e 100644 --- a/trunk/drivers/usb/storage/transport.c +++ b/trunk/drivers/usb/storage/transport.c @@ -996,7 +996,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) * command phase and the data phase. Some devices need a little * more than that, probably because of clock rate inaccuracies. */ if (unlikely(us->flags & US_FL_GO_SLOW)) - udelay(125); + udelay(110); if (transfer_length) { unsigned int pipe = srb->sc_data_direction == DMA_FROM_DEVICE ? diff --git a/trunk/drivers/usb/storage/unusual_devs.h b/trunk/drivers/usb/storage/unusual_devs.h index fa68dea6bc6f..d53f777c4f50 100644 --- a/trunk/drivers/usb/storage/unusual_devs.h +++ b/trunk/drivers/usb/storage/unusual_devs.h @@ -763,19 +763,6 @@ UNUSUAL_DEV( 0x07c4, 0xa109, 0x0000, 0xffff, US_FL_SINGLE_LUN ), #endif -#ifdef CONFIG_USB_STORAGE_DATAFAB -/* Reported by Felix Moeller - * in Germany this is sold by Hama with the productnumber 46952 - * as "DualSlot CompactFlash(TM) & MStick Drive USB" - */ -UNUSUAL_DEV( 0x07c4, 0xa10b, 0x0000, 0xffff, - "DataFab Systems Inc.", - "USB CF+MS", - US_SC_SCSI, US_PR_DATAFAB, NULL, - 0 ), - -#endif - /* Datafab KECF-USB / Sagatek DCS-CF / Simpletech Flashlink UCF-100 * Only revision 1.13 tested (same for all of the above devices, * based on the Datafab DF-UG-07 chip). Needed for US_FL_FIX_INQUIRY. diff --git a/trunk/drivers/w1/w1.c b/trunk/drivers/w1/w1.c index 8d7821899cc1..fd630cec0e79 100644 --- a/trunk/drivers/w1/w1.c +++ b/trunk/drivers/w1/w1.c @@ -522,11 +522,10 @@ void w1_slave_found(unsigned long data, u64 rn) slave_count++; } - rn = cpu_to_le64(rn); - - if (slave_count == dev->slave_count && - rn && ((le64_to_cpu(rn) >> 56) & 0xff) == w1_calc_crc8((u8 *)&rn, 7)) { - w1_attach_slave_device(dev, tmp); + if (slave_count == dev->slave_count && rn ) { + tmp = cpu_to_le64(rn); + if(((rn >> 56) & 0xff) == w1_calc_crc8((u8 *)&tmp, 7)) + w1_attach_slave_device(dev, (struct w1_reg_num *) &rn); } atomic_dec(&dev->refcnt); diff --git a/trunk/drivers/w1/w1_smem.c b/trunk/drivers/w1/w1_smem.c index a54e425217a0..ab82eb7ed74f 100644 --- a/trunk/drivers/w1/w1_smem.c +++ b/trunk/drivers/w1/w1_smem.c @@ -60,7 +60,7 @@ static ssize_t w1_smem_read_val(struct device *dev, char *buf) int i; ssize_t count = 0; - for (i = 0; i < 8; ++i) + for (i = 0; i < 9; ++i) count += sprintf(buf + count, "%02x ", ((u8 *)&sl->reg_num)[i]); count += sprintf(buf + count, "\n"); @@ -87,7 +87,7 @@ static ssize_t w1_smem_read_bin(struct kobject *kobj, char *buf, loff_t off, siz count = 0; goto out; } - for (i = 0; i < 8; ++i) + for (i = 0; i < 9; ++i) count += sprintf(buf + count, "%02x ", ((u8 *)&sl->reg_num)[i]); count += sprintf(buf + count, "\n"); diff --git a/trunk/include/linux/usb.h b/trunk/include/linux/usb.h index 41d1a644c9d4..c96728435935 100644 --- a/trunk/include/linux/usb.h +++ b/trunk/include/linux/usb.h @@ -558,7 +558,7 @@ struct usb_driver { int (*ioctl) (struct usb_interface *intf, unsigned int code, void *buf); - int (*suspend) (struct usb_interface *intf, pm_message_t message); + int (*suspend) (struct usb_interface *intf, u32 state); int (*resume) (struct usb_interface *intf); const struct usb_device_id *id_table; @@ -977,7 +977,7 @@ extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe, int timeout); /* selective suspend/resume */ -extern int usb_suspend_device(struct usb_device *dev, pm_message_t message); +extern int usb_suspend_device(struct usb_device *dev, u32 state); extern int usb_resume_device(struct usb_device *dev); diff --git a/trunk/include/linux/usb_cdc.h b/trunk/include/linux/usb_cdc.h index f22d6beecc73..1b68c122279a 100644 --- a/trunk/include/linux/usb_cdc.h +++ b/trunk/include/linux/usb_cdc.h @@ -114,7 +114,7 @@ struct usb_cdc_mdlm_detail_desc { /* type is associated with mdlm_desc.bGUID */ __u8 bGuidDescriptorType; - __u8 bDetailData[0]; + __u8 bDetailData[]; } __attribute__ ((packed)); /*-------------------------------------------------------------------------*/