Alan Stern wrote: >>Are there any plans to backport usb-storage changes to kernel 2.4? >> >> >One URL is > http://www.geocrawler.com/lists/3/SourceForge/2571/475/9524582/ > >
Here is an updated version of this patch for the case somebody else whants it. Yuri diff -u usb-2.5/drivers/usb/storage/Makefile usb-2.4/drivers/usb/storage/Makefile --- usb-2.5/drivers/usb/storage/Makefile Fri Sep 27 11:11:13 2002 +++ usb-2.4/drivers/usb/storage/Makefile Mon Sep 30 10:19:56 2002 @@ -5,8 +5,11 @@ # Rewritten to use lists instead of if-statements. # +O_TARGET := storage.o EXTRA_CFLAGS := -I../../scsi/ +list-multi := usb-storage.o + obj-$(CONFIG_USB_STORAGE) += usb-storage.o usb-storage-obj-$(CONFIG_USB_STORAGE_DEBUG) += debug.o @@ -20,6 +23,9 @@ usb-storage-obj-$(CONFIG_USB_STORAGE_JUMPSHOT) += jumpshot.o raw_bulk.o usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \ - initializers.o $(usb-storage-obj-y) + initializers.o $(sort $(usb-storage-obj-y)) include $(TOPDIR)/Rules.make + +usb-storage.o: $(usb-storage-objs) + $(LD) -r -o $@ $(usb-storage-objs) diff -u usb-2.5/drivers/usb/storage/debug.c usb-2.4/drivers/usb/storage/debug.c --- usb-2.5/drivers/usb/storage/debug.c Fri Sep 27 11:11:13 2002 +++ usb-2.4/drivers/usb/storage/debug.c Mon Sep 30 10:20:09 2002 @@ -218,17 +218,157 @@ unsigned char asc, unsigned char ascq) { - const char *what, *keystr; + char *keys[] = { + "No Sense", + "Recovered Error", + "Not Ready", + "Medium Error", + "Hardware Error", + "Illegal Request", + "Unit Attention", + "Data Protect", + "Blank Check", + "Vendor Specific", + "Copy Aborted", + "Aborted Command", + "(Obsolete)", + "Volume Overflow", + "Miscompare" + }; - keystr = scsi_sense_key_string(key); - what = scsi_extd_sense_format(asc, ascq); + unsigned short qual = asc; - if (keystr == NULL) + char *what = 0; + char *keystr = 0; + + qual <<= 8; + qual |= ascq; + + if (key>0x0E) keystr = "(Unknown Key)"; - if (what == NULL) + else + keystr = keys[key]; + + switch (qual) { + + case 0x0000: what="no additional sense information"; break; + case 0x0001: what="filemark detected"; break; + case 0x0002: what="end of partition/medium detected"; break; + case 0x0003: what="setmark detected"; break; + case 0x0004: what="beginning of partition/medium detected"; break; + case 0x0005: what="end of data detected"; break; + case 0x0006: what="I/O process terminated"; break; + case 0x0011: what="audio play operation in progress"; break; + case 0x0012: what="audio play operation paused"; break; + case 0x0013: what="audio play operation stopped due to error"; break; + case 0x0014: what="audio play operation successfully completed"; break; + case 0x0015: what="no current audio status to return"; break; + case 0x0016: what="operation in progress"; break; + case 0x0017: what="cleaning requested"; break; + case 0x0100: what="no index/sector signal"; break; + case 0x0200: what="no seek complete"; break; + case 0x0300: what="peripheral device write fault"; break; + case 0x0301: what="no write current"; break; + case 0x0302: what="excessive write errors"; break; + case 0x0400: what="LUN not ready, cause not reportable"; break; + case 0x0401: what="LUN in process of becoming ready"; break; + case 0x0402: what="LUN not ready, initializing cmd. required"; break; + case 0x0403: what="LUN not ready, manual intervention required"; break; + case 0x0404: what="LUN not ready, format in progress"; break; + case 0x0405: what="LUN not ready, rebuild in progress"; break; + case 0x0406: what="LUN not ready, recalculation in progress"; break; + case 0x0407: what="LUN not ready, operation in progress"; break; + case 0x0408: what="LUN not ready, long write in progress"; break; + case 0x0500: what="LUN doesn't respond to selection"; break; + case 0x0A00: what="error log overflow"; break; + case 0x0C04: what="compression check miscompare error"; break; + case 0x0C05: what="data expansion occurred during compression"; break; + case 0x0C06: what="block not compressible"; break; + case 0x1102: what="error too long to correct"; break; + case 0x1106: what="CIRC unrecovered error"; break; + case 0x1107: what="data resynchronization error"; break; + case 0x110D: what="decompression CRC error"; break; + case 0x110E: what="can't decompress using declared algorithm"; break; + case 0x110F: what="error reading UPC/EAN number"; break; + case 0x1110: what="error reading ISRC number"; break; + case 0x1200: what="address mark not found for ID field"; break; + case 0x1300: what="address mark not found for data field"; break; + case 0x1403: what="end of data not found"; break; + case 0x1404: what="block sequence error"; break; + case 0x1600: what="data sync mark error"; break; + case 0x1601: what="data sync error: data rewritten"; break; + case 0x1602: what="data sync error: recommend rewrite"; break; + case 0x1603: what="data sync error: data auto-reallocated"; break; + case 0x1604: what="data sync error: recommend reassignment"; break; + case 0x1900: what="defect list error"; break; + case 0x1901: what="defect list not available"; break; + case 0x1902: what="defect list error in primary list"; break; + case 0x1903: what="defect list error in grown list"; break; + case 0x1C00: what="defect list not found"; break; + case 0x2000: what="invalid command operation code"; break; + case 0x2400: what="invalid field in CDB"; break; + case 0x2703: what="associated write protect"; break; + case 0x2800: what="not ready to ready transition"; break; + case 0x2900: what="device reset occurred"; break; + case 0x2903: what="bus device reset function occurred"; break; + case 0x2904: what="device internal reset"; break; + case 0x2B00: what="copy can't execute / host can't disconnect"; break; + case 0x2C00: what="command sequence error"; break; + case 0x2C03: what="current program area is not empty"; break; + case 0x2C04: what="current program area is empty"; break; + case 0x2F00: what="commands cleared by another initiator"; break; + case 0x3001: what="can't read medium: unknown format"; break; + case 0x3002: what="can't read medium: incompatible format"; break; + case 0x3003: what="cleaning cartridge installed"; break; + case 0x3004: what="can't write medium: unknown format"; break; + case 0x3005: what="can't write medium: incompatible format"; break; + case 0x3006: what="can't format medium: incompatible medium"; break; + case 0x3007: what="cleaning failure"; break; + case 0x3008: what="can't write: application code mismatch"; break; + case 0x3009: what="current session not fixated for append"; break; + case 0x3201: what="defect list update failure"; break; + case 0x3400: what="enclosure failure"; break; + case 0x3500: what="enclosure services failure"; break; + case 0x3502: what="enclosure services unavailable"; break; + case 0x3503: what="enclosure services transfer failure"; break; + case 0x3504: what="enclosure services transfer refused"; break; + case 0x3A00: what="media not present"; break; + case 0x3B0F: what="end of medium reached"; break; + case 0x3F02: what="changed operating definition"; break; + case 0x4100: what="data path failure (should use 40 NN)"; break; + case 0x4A00: what="command phase error"; break; + case 0x4B00: what="data phase error"; break; + case 0x5100: what="erase failure"; break; + case 0x5200: what="cartridge fault"; break; + case 0x6300: what="end of user area encountered on this track"; break; + case 0x6600: what="automatic document feeder cover up"; break; + case 0x6601: what="automatic document feeder lift up"; break; + case 0x6602: what="document jam in auto doc feeder"; break; + case 0x6603: what="document miss feed auto in doc feeder"; break; + case 0x6700: what="configuration failure"; break; + case 0x6701: what="configuration of incapable LUN's failed"; break; + case 0x6702: what="add logical unit failed"; break; + case 0x6706: what="attachment of logical unit failed"; break; + case 0x6707: what="creation of logical unit failed"; break; + case 0x6900: what="data loss on logical unit"; break; + case 0x6E00: what="command to logical unit failed"; break; + case 0x7100: what="decompression exception long algorithm ID"; break; + case 0x7204: what="empty or partially written reserved track"; break; + case 0x7300: what="CD control error"; break; + + default: + if (asc==0x40) { + US_DEBUGP("%s: diagnostic failure on component" + " %02X\n", keystr, ascq); + return; + } + if (asc==0x70) { + US_DEBUGP("%s: decompression exception short" + " algorithm ID of %02X\n", keystr, ascq); + return; + } what = "(unknown ASC/ASCQ)"; + } - US_DEBUGP("%s: ", keystr); - US_DEBUGPX(what, ascq); - US_DEBUGPX("\n"); + US_DEBUGP("%s: %s\n", keystr, what); } diff -u usb-2.5/drivers/usb/storage/isd200.c usb-2.4/drivers/usb/storage/isd200.c --- usb-2.5/drivers/usb/storage/isd200.c Fri Sep 27 11:11:13 2002 +++ usb-2.4/drivers/usb/storage/isd200.c Mon Sep 30 10:20:18 2002 @@ -49,7 +49,7 @@ #include "scsiglue.h" #include "isd200.h" -#include <linux/jiffies.h> +#include <linux/sched.h> #include <linux/errno.h> #include <linux/slab.h> #include <linux/hdreg.h> diff -u usb-2.5/drivers/usb/storage/scsiglue.c usb-2.4/drivers/usb/storage/scsiglue.c --- usb-2.5/drivers/usb/storage/scsiglue.c Fri Sep 27 17:59:47 2002 +++ usb-2.4/drivers/usb/storage/scsiglue.c Mon Sep 30 10:20:23 2002 @@ -117,7 +117,6 @@ * notification that it has exited. */ US_DEBUGP("-- sending exit command to thread\n"); - BUG_ON(atomic_read(&us->sm_state) != US_STATE_IDLE); us->srb = NULL; up(&(us->sema)); wait_for_completion(&(us->notify)); @@ -147,8 +146,6 @@ srb->host_scribble = (unsigned char *)us; /* enqueue the command */ - BUG_ON(atomic_read(&us->sm_state) != US_STATE_IDLE); - BUG_ON(us->srb != NULL); srb->scsi_done = done; us->srb = srb; @@ -189,7 +186,6 @@ int result; US_DEBUGP("device_reset() called\n" ); - BUG_ON(atomic_read(&us->sm_state) != US_STATE_IDLE); /* set the state and release the lock */ atomic_set(&us->sm_state, US_STATE_RESETTING); @@ -252,6 +248,7 @@ for (i = 0; i < pusb_dev_save->actconfig->bNumInterfaces; i++) { struct usb_interface *intf = &pusb_dev_save->actconfig->interface[i]; + const struct usb_device_id *id; /* if this is an unclaimed interface, skip it */ if (!intf->driver) { @@ -262,8 +259,11 @@ /* simulate a disconnect and reconnect for all interfaces */ US_DEBUGPX("simulating disconnect/reconnect.\n"); - usb_device_remove (&intf->dev); - usb_device_probe (&intf->dev); + down(&intf->driver->serialize); + intf->driver->disconnect(pusb_dev_save, intf->private_data); + id = usb_match_id(pusb_dev_save, intf, intf->driver->id_table); + intf->driver->probe(pusb_dev_save, i, id); + up(&intf->driver->serialize); } US_DEBUGP("bus_reset() complete\n"); scsi_lock(srb->host); @@ -373,6 +373,7 @@ .present = 0, .unchecked_isa_dma = FALSE, .use_clustering = TRUE, + .use_new_eh_code = TRUE, .emulated = TRUE }; diff -u usb-2.5/drivers/usb/storage/sddr55.c usb-2.4/drivers/usb/storage/sddr55.c --- usb-2.5/drivers/usb/storage/sddr55.c Sat Sep 28 10:20:41 2002 +++ usb-2.4/drivers/usb/storage/sddr55.c Sat Sep 28 12:30:01 2002 @@ -31,7 +31,7 @@ #include "debug.h" #include "sddr55.h" -#include <linux/jiffies.h> +#include <linux/sched.h> #include <linux/errno.h> #include <linux/slab.h> diff -u usb-2.5/drivers/usb/storage/transport.c usb-2.4/drivers/usb/storage/transport.c --- usb-2.5/drivers/usb/storage/transport.c Sat Sep 28 10:20:41 2002 +++ usb-2.4/drivers/usb/storage/transport.c Mon Sep 30 10:20:33 2002 @@ -429,7 +429,7 @@ us->current_urb->transfer_flags = USB_ASYNC_UNLINK; /* submit the URB */ - status = usb_submit_urb(us->current_urb, GFP_NOIO); + status = usb_submit_urb(us->current_urb); if (status) { /* something went wrong */ return status; @@ -860,14 +860,12 @@ void usb_stor_abort_transport(struct us_data *us) { struct Scsi_Host *host; - int state = atomic_read(&us->sm_state); US_DEBUGP("usb_stor_abort_transport called\n"); /* Normally the current state is RUNNING. If the control thread * hasn't even started processing this command, the state will be * IDLE. Anything else is a bug. */ - BUG_ON((state != US_STATE_RUNNING && state != US_STATE_IDLE)); /* set state to abort and release the lock */ atomic_set(&us->sm_state, US_STATE_ABORTING); diff -u usb-2.5/drivers/usb/storage/usb.c usb-2.4/drivers/usb/storage/usb.c --- usb-2.5/drivers/usb/storage/usb.c Fri Sep 27 17:32:41 2002 +++ usb-2.4/drivers/usb/storage/usb.c Mon Sep 30 10:20:39 2002 @@ -103,10 +103,10 @@ struct us_data *us_list; struct semaphore us_list_semaphore; -static int storage_probe(struct usb_interface *iface, - const struct usb_device_id *id); +static void * storage_probe(struct usb_device *dev, unsigned int ifnum, + const struct usb_device_id *id); -static void storage_disconnect(struct usb_interface *iface); +static void storage_disconnect(struct usb_device *dev, void *ptr); /* The entries in this table, except for final ones here * (USB_MASS_STORAGE_CLASS and the empty entry), correspond, @@ -313,9 +313,8 @@ /* avoid getting signals */ spin_lock_irq(¤t->sigmask_lock); flush_signals(current); - current->flags |= PF_IOTHREAD; sigfillset(¤t->blocked); - recalc_sigpending(); + recalc_sigpending(current); spin_unlock_irq(¤t->sigmask_lock); /* set our name for identification purposes */ @@ -535,7 +534,7 @@ /* allocate the URB we're going to use */ US_DEBUGP("Allocating URB\n"); - ss->current_urb = usb_alloc_urb(0, GFP_KERNEL); + ss->current_urb = usb_alloc_urb(0); if (!ss->current_urb) { US_DEBUGP("allocation failed\n"); return 2; @@ -549,7 +548,7 @@ down(&(ss->irq_urb_sem)); /* allocate the URB */ - ss->irq_urb = usb_alloc_urb(0, GFP_KERNEL); + ss->irq_urb = usb_alloc_urb(0); if (!ss->irq_urb) { up(&(ss->irq_urb_sem)); US_DEBUGP("couldn't allocate interrupt URB"); @@ -568,7 +567,7 @@ maxp, usb_stor_CBI_irq, ss, ss->ep_int->bInterval); /* submit the URB for processing */ - result = usb_submit_urb(ss->irq_urb, GFP_KERNEL); + result = usb_submit_urb(ss->irq_urb); US_DEBUGP("usb_submit_urb() returns %d\n", result); if (result) { up(&(ss->irq_urb_sem)); @@ -618,16 +617,14 @@ /* mark the device as gone */ ss->flags &= ~ US_FL_DEV_ATTACHED; - usb_put_dev(ss->pusb_dev); + usb_dec_dev_use(ss->pusb_dev); ss->pusb_dev = NULL; } /* Probe to see if a new device is actually a SCSI device */ -static int storage_probe(struct usb_interface *intf, - const struct usb_device_id *id) +static void * storage_probe(struct usb_device *dev, unsigned int ifnum, + const struct usb_device_id *id) { - struct usb_device *dev = interface_to_usbdev(intf); - int ifnum = intf->altsetting->bInterfaceNumber; int i; const int id_index = id - storage_usb_ids; char mf[USB_STOR_STRING_LEN]; /* manufacturer */ @@ -652,6 +649,7 @@ /* the altsetting on the interface we're probing that matched our * usb_match_id table */ + struct usb_interface *intf = dev->actconfig->interface; struct usb_interface_descriptor *altsetting = intf[ifnum].altsetting + intf[ifnum].act_altsetting; US_DEBUGP("act_altsetting is %d\n", intf[ifnum].act_altsetting); @@ -681,7 +679,7 @@ US_DEBUGP("Product: %s\n", unusual_dev->productName); } else /* no, we can't support it */ - return -EIO; + return NULL; /* At this point, we know we've got a live one */ US_DEBUGP("USB Mass Storage device detected\n"); @@ -729,7 +727,7 @@ } else if (result != 0) { /* it's not a stall, but another error -- time to bail */ US_DEBUGP("-- Unknown error. Rejecting device\n"); - return -EIO; + return NULL; } } #endif @@ -737,11 +735,11 @@ /* Do some basic sanity checks, and bail if we find a problem */ if (!ep_in || !ep_out || (protocol == US_PR_CBI && !ep_int)) { US_DEBUGP("Endpoint sanity check failed! Rejecting dev.\n"); - return -EIO; + return NULL; } /* At this point, we've decided to try to use the device */ - usb_get_dev(dev); + usb_inc_dev_use(dev); /* clear the GUID and fetch the strings */ GUID_CLEAR(guid); @@ -815,8 +813,8 @@ if ((ss = (struct us_data *)kmalloc(sizeof(struct us_data), GFP_KERNEL)) == NULL) { printk(KERN_WARNING USB_STORAGE "Out of memory\n"); - usb_put_dev(dev); - return -ENOMEM; + usb_dec_dev_use(dev); + return NULL; } memset(ss, 0, sizeof(struct us_data)); new_device = 1; @@ -1061,7 +1059,7 @@ /* now register - our detect function will be called */ ss->htmplt.module = THIS_MODULE; - result = scsi_register_host(&(ss->htmplt)); + result = scsi_register_module(MODULE_SCSI_HA, &(ss->htmplt)); if (result) { printk(KERN_WARNING USB_STORAGE "Unable to register the scsi host\n"); @@ -1092,9 +1090,8 @@ printk(KERN_DEBUG "USB Mass Storage device found at %d\n", dev->devnum); - /* save a pointer to our structure */ - dev_set_drvdata (&intf->dev, ss); - return 0; + /* return a pointer for the disconnect function */ + return ss; /* we come here if there are any problems */ /* ss->dev_semaphore must be locked */ @@ -1104,18 +1101,16 @@ up(&ss->dev_semaphore); if (new_device) kfree(ss); - return -EIO; + return NULL; } /* Handle a disconnect event from the USB core */ -static void storage_disconnect(struct usb_interface *intf) +static void storage_disconnect(struct usb_device *dev, void *ptr) { - struct us_data *ss = dev_get_drvdata (&intf->dev); + struct us_data *ss = ptr; US_DEBUGP("storage_disconnect() called\n"); - dev_set_drvdata (&intf->dev, NULL); - /* this is the odd case -- we disconnected but weren't using it */ if (!ss) { US_DEBUGP("-- device was not in use\n"); @@ -1168,7 +1163,7 @@ */ for (next = us_list; next; next = next->next) { US_DEBUGP("-- calling scsi_unregister_host()\n"); - scsi_unregister_host(&(next->htmplt)); + scsi_unregister_module(MODULE_SCSI_HA, &(next->htmplt)); } /* While there are still structures, free them. Note that we are diff -u usb-2.5/drivers/usb/storage/usb.h usb-2.4/drivers/usb/storage/usb.h --- usb-2.5/drivers/usb/storage/usb.h Fri Sep 27 11:11:13 2002 +++ usb-2.4/drivers/usb/storage/usb.h Mon Sep 30 10:20:40 2002 @@ -204,8 +204,8 @@ /* The scsi_lock() and scsi_unlock() macros protect the sm_state and the * single queue element srb for write access */ -#define scsi_unlock(host) spin_unlock_irq(host->host_lock) -#define scsi_lock(host) spin_lock_irq(host->host_lock) -#define sg_address(psg) (page_address((psg).page) + (psg).offset) +#define scsi_unlock(host) spin_unlock_irq(&io_request_lock) +#define scsi_lock(host) spin_lock_irq(&io_request_lock) +#define sg_address(sg) ((sg).address) #endif ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel