diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2006-01-05 10:35:39 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-01-05 10:35:39 -0800 |
commit | 5758ac5a57c079fa516d792c9f4d65229c83f135 (patch) | |
tree | 68f361d0d13b8802a9290d6abcd1cac7c193804d /usb | |
parent | 3c5bdf48c8d492dfdcbb3ac3a7c1242bd1a6e6e1 (diff) | |
download | patches-5758ac5a57c079fa516d792c9f4d65229c83f135.tar.gz |
removed some usb patches in 2.6.15-git1
Diffstat (limited to 'usb')
25 files changed, 0 insertions, 4836 deletions
diff --git a/usb/usb-small-cleanups.patch b/usb/usb-small-cleanups.patch deleted file mode 100644 index 153dbc4072794..0000000000000 --- a/usb/usb-small-cleanups.patch +++ /dev/null @@ -1,53 +0,0 @@ -From bunk@stusta.de Mon Nov 21 13:09:07 2005 -Date: Sun, 20 Nov 2005 23:56:11 +0100 -From: Adrian Bunk <bunk@stusta.de> -To: <gregkh@suse.de> -Cc: <mdharm-usb@one-eyed-alien.net> -Subject: USB: small cleanups -Message-ID: <20051120225611.GA16060@stusta.de> -Content-Disposition: inline - -This patch contains the following cleanups: -- make needlessly global functions static -- every file should #include the headers containing the prototypes for - it's global functions - - -Signed-off-by: Adrian Bunk <bunk@stusta.de> -Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> - ---- - drivers/usb/atm/usbatm.c | 4 ++-- - drivers/usb/serial/io_ti.c | 2 +- - 2 files changed, 3 insertions(+), 3 deletions(-) - ---- gregkh-2.6.orig/drivers/usb/atm/usbatm.c -+++ gregkh-2.6/drivers/usb/atm/usbatm.c -@@ -646,14 +646,14 @@ static void usbatm_destroy_instance(stru - kfree(instance); - } - --void usbatm_get_instance(struct usbatm_data *instance) -+static void usbatm_get_instance(struct usbatm_data *instance) - { - dbg("%s", __func__); - - kref_get(&instance->refcount); - } - --void usbatm_put_instance(struct usbatm_data *instance) -+static void usbatm_put_instance(struct usbatm_data *instance) - { - dbg("%s", __func__); - ---- gregkh-2.6.orig/drivers/usb/serial/io_ti.c -+++ gregkh-2.6/drivers/usb/serial/io_ti.c -@@ -2843,7 +2843,7 @@ static struct edge_buf *edge_buf_alloc(u - * Free the buffer and all associated memory. - */ - --void edge_buf_free(struct edge_buf *eb) -+static void edge_buf_free(struct edge_buf *eb) - { - if (eb) { - kfree(eb->buf_buf); diff --git a/usb/usb-storage-add-alauda-support.patch b/usb/usb-storage-add-alauda-support.patch deleted file mode 100644 index 0d7e2c25dabe8..0000000000000 --- a/usb/usb-storage-add-alauda-support.patch +++ /dev/null @@ -1,1361 +0,0 @@ -From mdharm@multivac.one-eyed-alien.net Sun Dec 4 22:07:07 2005 -Date: Sun, 4 Dec 2005 22:02:44 -0800 -From: Matthew Dharm <mdharm-usb@one-eyed-alien.net> -To: Greg KH <greg@kroah.com> -Subject: USB Storage: add alauda support -Message-ID: <20051205060244.GE15047@one-eyed-alien.net> -Content-Disposition: inline - -This patch adds another usb-storage subdriver, which supports two fairly -old dual-XD/SmartMedia reader-writers (USB1.1 devices). - -This driver was written by Daniel Drake <dsd@gentoo.org> -- he notes -that he wrote this driver without specs, however a vendor-supplied GPL -driver for the previous generation of products ("sma03") did prove to be -quite useful, as did the sddr09 driver which also has to deal with -low-level physical block layout on SmartMedia. - -The original patch has been reformed by me, as it clashed with the -libusual patches. - -We really need to consolidate some of this common SmartMedia code, and -get together with the MTD guys to share it with them as well. - -Signed-off-by: Daniel Drake <dsd@gentoo.org> -Signed-off-by: Matthew Dharm <mdharm-usb@one-eyed-alien.net> -Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> - - ---- - drivers/usb/storage/Kconfig | 9 - drivers/usb/storage/Makefile | 1 - drivers/usb/storage/alauda.c | 1119 +++++++++++++++++++++++++++++++++++++ - drivers/usb/storage/alauda.h | 100 +++ - drivers/usb/storage/unusual_devs.h | 14 - drivers/usb/storage/usb.c | 12 - include/linux/usb_usual.h | 3 - 7 files changed, 1258 insertions(+) - ---- /dev/null -+++ gregkh-2.6/drivers/usb/storage/alauda.c -@@ -0,0 +1,1119 @@ -+/* -+ * Driver for Alauda-based card readers -+ * -+ * Current development and maintenance by: -+ * (c) 2005 Daniel Drake <dsd@gentoo.org> -+ * -+ * The 'Alauda' is a chip manufacturered by RATOC for OEM use. -+ * -+ * Alauda implements a vendor-specific command set to access two media reader -+ * ports (XD, SmartMedia). This driver converts SCSI commands to the commands -+ * which are accepted by these devices. -+ * -+ * The driver was developed through reverse-engineering, with the help of the -+ * sddr09 driver which has many similarities, and with some help from the -+ * (very old) vendor-supplied GPL sma03 driver. -+ * -+ * For protocol info, see http://alauda.sourceforge.net -+ * -+ * This program is free software; you can redistribute it and/or modify it -+ * under the terms of the GNU General Public License as published by the -+ * Free Software Foundation; either version 2, or (at your option) any -+ * later version. -+ * -+ * This program is distributed in the hope that it will be useful, but -+ * WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License along -+ * with this program; if not, write to the Free Software Foundation, Inc., -+ * 675 Mass Ave, Cambridge, MA 02139, USA. -+ */ -+ -+#include <scsi/scsi.h> -+#include <scsi/scsi_cmnd.h> -+#include <scsi/scsi_device.h> -+ -+#include "usb.h" -+#include "transport.h" -+#include "protocol.h" -+#include "debug.h" -+#include "alauda.h" -+ -+#define short_pack(lsb,msb) ( ((u16)(lsb)) | ( ((u16)(msb))<<8 ) ) -+#define LSB_of(s) ((s)&0xFF) -+#define MSB_of(s) ((s)>>8) -+ -+#define MEDIA_PORT(us) us->srb->device->lun -+#define MEDIA_INFO(us) ((struct alauda_info *)us->extra)->port[MEDIA_PORT(us)] -+ -+#define PBA_LO(pba) ((pba & 0xF) << 5) -+#define PBA_HI(pba) (pba >> 3) -+#define PBA_ZONE(pba) (pba >> 11) -+ -+/* -+ * Media handling -+ */ -+ -+struct alauda_card_info { -+ unsigned char id; /* id byte */ -+ unsigned char chipshift; /* 1<<cs bytes total capacity */ -+ unsigned char pageshift; /* 1<<ps bytes in a page */ -+ unsigned char blockshift; /* 1<<bs pages per block */ -+ unsigned char zoneshift; /* 1<<zs blocks per zone */ -+}; -+ -+static struct alauda_card_info alauda_card_ids[] = { -+ /* NAND flash */ -+ { 0x6e, 20, 8, 4, 8}, /* 1 MB */ -+ { 0xe8, 20, 8, 4, 8}, /* 1 MB */ -+ { 0xec, 20, 8, 4, 8}, /* 1 MB */ -+ { 0x64, 21, 8, 4, 9}, /* 2 MB */ -+ { 0xea, 21, 8, 4, 9}, /* 2 MB */ -+ { 0x6b, 22, 9, 4, 9}, /* 4 MB */ -+ { 0xe3, 22, 9, 4, 9}, /* 4 MB */ -+ { 0xe5, 22, 9, 4, 9}, /* 4 MB */ -+ { 0xe6, 23, 9, 4, 10}, /* 8 MB */ -+ { 0x73, 24, 9, 5, 10}, /* 16 MB */ -+ { 0x75, 25, 9, 5, 10}, /* 32 MB */ -+ { 0x76, 26, 9, 5, 10}, /* 64 MB */ -+ { 0x79, 27, 9, 5, 10}, /* 128 MB */ -+ { 0x71, 28, 9, 5, 10}, /* 256 MB */ -+ -+ /* MASK ROM */ -+ { 0x5d, 21, 9, 4, 8}, /* 2 MB */ -+ { 0xd5, 22, 9, 4, 9}, /* 4 MB */ -+ { 0xd6, 23, 9, 4, 10}, /* 8 MB */ -+ { 0x57, 24, 9, 4, 11}, /* 16 MB */ -+ { 0x58, 25, 9, 4, 12}, /* 32 MB */ -+ { 0,} -+}; -+ -+static struct alauda_card_info *alauda_card_find_id(unsigned char id) { -+ int i; -+ -+ for (i = 0; alauda_card_ids[i].id != 0; i++) -+ if (alauda_card_ids[i].id == id) -+ return &(alauda_card_ids[i]); -+ return NULL; -+} -+ -+/* -+ * ECC computation. -+ */ -+ -+static unsigned char parity[256]; -+static unsigned char ecc2[256]; -+ -+static void nand_init_ecc(void) { -+ int i, j, a; -+ -+ parity[0] = 0; -+ for (i = 1; i < 256; i++) -+ parity[i] = (parity[i&(i-1)] ^ 1); -+ -+ for (i = 0; i < 256; i++) { -+ a = 0; -+ for (j = 0; j < 8; j++) { -+ if (i & (1<<j)) { -+ if ((j & 1) == 0) -+ a ^= 0x04; -+ if ((j & 2) == 0) -+ a ^= 0x10; -+ if ((j & 4) == 0) -+ a ^= 0x40; -+ } -+ } -+ ecc2[i] = ~(a ^ (a<<1) ^ (parity[i] ? 0xa8 : 0)); -+ } -+} -+ -+/* compute 3-byte ecc on 256 bytes */ -+static void nand_compute_ecc(unsigned char *data, unsigned char *ecc) { -+ int i, j, a; -+ unsigned char par, bit, bits[8]; -+ -+ par = 0; -+ for (j = 0; j < 8; j++) -+ bits[j] = 0; -+ -+ /* collect 16 checksum bits */ -+ for (i = 0; i < 256; i++) { -+ par ^= data[i]; -+ bit = parity[data[i]]; -+ for (j = 0; j < 8; j++) -+ if ((i & (1<<j)) == 0) -+ bits[j] ^= bit; -+ } -+ -+ /* put 4+4+4 = 12 bits in the ecc */ -+ a = (bits[3] << 6) + (bits[2] << 4) + (bits[1] << 2) + bits[0]; -+ ecc[0] = ~(a ^ (a<<1) ^ (parity[par] ? 0xaa : 0)); -+ -+ a = (bits[7] << 6) + (bits[6] << 4) + (bits[5] << 2) + bits[4]; -+ ecc[1] = ~(a ^ (a<<1) ^ (parity[par] ? 0xaa : 0)); -+ -+ ecc[2] = ecc2[par]; -+} -+ -+static int nand_compare_ecc(unsigned char *data, unsigned char *ecc) { -+ return (data[0] == ecc[0] && data[1] == ecc[1] && data[2] == ecc[2]); -+} -+ -+static void nand_store_ecc(unsigned char *data, unsigned char *ecc) { -+ memcpy(data, ecc, 3); -+} -+ -+/* -+ * Alauda driver -+ */ -+ -+/* -+ * Forget our PBA <---> LBA mappings for a particular port -+ */ -+static void alauda_free_maps (struct alauda_media_info *media_info) -+{ -+ unsigned int shift = media_info->zoneshift -+ + media_info->blockshift + media_info->pageshift; -+ unsigned int num_zones = media_info->capacity >> shift; -+ unsigned int i; -+ -+ if (media_info->lba_to_pba != NULL) -+ for (i = 0; i < num_zones; i++) { -+ kfree(media_info->lba_to_pba[i]); -+ media_info->lba_to_pba[i] = NULL; -+ } -+ -+ if (media_info->pba_to_lba != NULL) -+ for (i = 0; i < num_zones; i++) { -+ kfree(media_info->pba_to_lba[i]); -+ media_info->pba_to_lba[i] = NULL; -+ } -+} -+ -+/* -+ * Returns 2 bytes of status data -+ * The first byte describes media status, and second byte describes door status -+ */ -+static int alauda_get_media_status(struct us_data *us, unsigned char *data) -+{ -+ int rc; -+ unsigned char command; -+ -+ if (MEDIA_PORT(us) == ALAUDA_PORT_XD) -+ command = ALAUDA_GET_XD_MEDIA_STATUS; -+ else -+ command = ALAUDA_GET_SM_MEDIA_STATUS; -+ -+ rc = usb_stor_ctrl_transfer(us, us->recv_ctrl_pipe, -+ command, 0xc0, 0, 1, data, 2); -+ -+ US_DEBUGP("alauda_get_media_status: Media status %02X %02X\n", -+ data[0], data[1]); -+ -+ return rc; -+} -+ -+/* -+ * Clears the "media was changed" bit so that we know when it changes again -+ * in the future. -+ */ -+static int alauda_ack_media(struct us_data *us) -+{ -+ unsigned char command; -+ -+ if (MEDIA_PORT(us) == ALAUDA_PORT_XD) -+ command = ALAUDA_ACK_XD_MEDIA_CHANGE; -+ else -+ command = ALAUDA_ACK_SM_MEDIA_CHANGE; -+ -+ return usb_stor_ctrl_transfer(us, us->send_ctrl_pipe, -+ command, 0x40, 0, 1, NULL, 0); -+} -+ -+/* -+ * Retrieves a 4-byte media signature, which indicates manufacturer, capacity, -+ * and some other details. -+ */ -+static int alauda_get_media_signature(struct us_data *us, unsigned char *data) -+{ -+ unsigned char command; -+ -+ if (MEDIA_PORT(us) == ALAUDA_PORT_XD) -+ command = ALAUDA_GET_XD_MEDIA_SIG; -+ else -+ command = ALAUDA_GET_SM_MEDIA_SIG; -+ -+ return usb_stor_ctrl_transfer(us, us->recv_ctrl_pipe, -+ command, 0xc0, 0, 0, data, 4); -+} -+ -+/* -+ * Resets the media status (but not the whole device?) -+ */ -+static int alauda_reset_media(struct us_data *us) -+{ -+ unsigned char *command = us->iobuf; -+ -+ memset(command, 0, 9); -+ command[0] = ALAUDA_BULK_CMD; -+ command[1] = ALAUDA_BULK_RESET_MEDIA; -+ command[8] = MEDIA_PORT(us); -+ -+ return usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, -+ command, 9, NULL); -+} -+ -+/* -+ * Examines the media and deduces capacity, etc. -+ */ -+static int alauda_init_media(struct us_data *us) -+{ -+ unsigned char *data = us->iobuf; -+ int ready = 0; -+ struct alauda_card_info *media_info; -+ unsigned int num_zones; -+ -+ while (ready == 0) { -+ msleep(20); -+ -+ if (alauda_get_media_status(us, data) != USB_STOR_XFER_GOOD) -+ return USB_STOR_TRANSPORT_ERROR; -+ -+ if (data[0] & 0x10) -+ ready = 1; -+ } -+ -+ US_DEBUGP("alauda_init_media: We are ready for action!\n"); -+ -+ if (alauda_ack_media(us) != USB_STOR_XFER_GOOD) -+ return USB_STOR_TRANSPORT_ERROR; -+ -+ msleep(10); -+ -+ if (alauda_get_media_status(us, data) != USB_STOR_XFER_GOOD) -+ return USB_STOR_TRANSPORT_ERROR; -+ -+ if (data[0] != 0x14) { -+ US_DEBUGP("alauda_init_media: Media not ready after ack\n"); -+ return USB_STOR_TRANSPORT_ERROR; -+ } -+ -+ if (alauda_get_media_signature(us, data) != USB_STOR_XFER_GOOD) -+ return USB_STOR_TRANSPORT_ERROR; -+ -+ US_DEBUGP("alauda_init_media: Media signature: %02X %02X %02X %02X\n", -+ data[0], data[1], data[2], data[3]); -+ media_info = alauda_card_find_id(data[1]); -+ if (media_info == NULL) { -+ printk("alauda_init_media: Unrecognised media signature: " -+ "%02X %02X %02X %02X\n", -+ data[0], data[1], data[2], data[3]); -+ return USB_STOR_TRANSPORT_ERROR; -+ } -+ -+ MEDIA_INFO(us).capacity = 1 << media_info->chipshift; -+ US_DEBUGP("Found media with capacity: %ldMB\n", -+ MEDIA_INFO(us).capacity >> 20); -+ -+ MEDIA_INFO(us).pageshift = media_info->pageshift; -+ MEDIA_INFO(us).blockshift = media_info->blockshift; -+ MEDIA_INFO(us).zoneshift = media_info->zoneshift; -+ -+ MEDIA_INFO(us).pagesize = 1 << media_info->pageshift; -+ MEDIA_INFO(us).blocksize = 1 << media_info->blockshift; -+ MEDIA_INFO(us).zonesize = 1 << media_info->zoneshift; -+ -+ MEDIA_INFO(us).uzonesize = ((1 << media_info->zoneshift) / 128) * 125; -+ MEDIA_INFO(us).blockmask = MEDIA_INFO(us).blocksize - 1; -+ -+ num_zones = MEDIA_INFO(us).capacity >> (MEDIA_INFO(us).zoneshift -+ + MEDIA_INFO(us).blockshift + MEDIA_INFO(us).pageshift); -+ MEDIA_INFO(us).pba_to_lba = kcalloc(num_zones, sizeof(u16*), GFP_NOIO); -+ MEDIA_INFO(us).lba_to_pba = kcalloc(num_zones, sizeof(u16*), GFP_NOIO); -+ -+ if (alauda_reset_media(us) != USB_STOR_XFER_GOOD) -+ return USB_STOR_TRANSPORT_ERROR; -+ -+ return USB_STOR_TRANSPORT_GOOD; -+} -+ -+/* -+ * Examines the media status and does the right thing when the media has gone, -+ * appeared, or changed. -+ */ -+static int alauda_check_media(struct us_data *us) -+{ -+ struct alauda_info *info = (struct alauda_info *) us->extra; -+ unsigned char status[2]; -+ int rc; -+ -+ rc = alauda_get_media_status(us, status); -+ -+ /* Check for no media or door open */ -+ if ((status[0] & 0x80) || ((status[0] & 0x1F) == 0x10) -+ || ((status[1] & 0x01) == 0)) { -+ US_DEBUGP("alauda_check_media: No media, or door open\n"); -+ alauda_free_maps(&MEDIA_INFO(us)); -+ info->sense_key = 0x02; -+ info->sense_asc = 0x3A; -+ info->sense_ascq = 0x00; -+ return USB_STOR_TRANSPORT_FAILED; -+ } -+ -+ /* Check for media change */ -+ if (status[0] & 0x08) { -+ US_DEBUGP("alauda_check_media: Media change detected\n"); -+ alauda_free_maps(&MEDIA_INFO(us)); -+ alauda_init_media(us); -+ -+ info->sense_key = UNIT_ATTENTION; -+ info->sense_asc = 0x28; -+ info->sense_ascq = 0x00; -+ return USB_STOR_TRANSPORT_FAILED; -+ } -+ -+ return USB_STOR_TRANSPORT_GOOD; -+} -+ -+/* -+ * Checks the status from the 2nd status register -+ * Returns 3 bytes of status data, only the first is known -+ */ -+static int alauda_check_status2(struct us_data *us) -+{ -+ int rc; -+ unsigned char command[] = { -+ ALAUDA_BULK_CMD, ALAUDA_BULK_GET_STATUS2, -+ 0, 0, 0, 0, 3, 0, MEDIA_PORT(us) -+ }; -+ unsigned char data[3]; -+ -+ rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, -+ command, 9, NULL); -+ if (rc != USB_STOR_XFER_GOOD) -+ return rc; -+ -+ rc = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, -+ data, 3, NULL); -+ if (rc != USB_STOR_XFER_GOOD) -+ return rc; -+ -+ US_DEBUGP("alauda_check_status2: %02X %02X %02X\n", data[0], data[1], data[2]); -+ if (data[0] & ALAUDA_STATUS_ERROR) -+ return USB_STOR_XFER_ERROR; -+ -+ return USB_STOR_XFER_GOOD; -+} -+ -+/* -+ * Gets the redundancy data for the first page of a PBA -+ * Returns 16 bytes. -+ */ -+static int alauda_get_redu_data(struct us_data *us, u16 pba, unsigned char *data) -+{ -+ int rc; -+ unsigned char command[] = { -+ ALAUDA_BULK_CMD, ALAUDA_BULK_GET_REDU_DATA, -+ PBA_HI(pba), PBA_ZONE(pba), 0, PBA_LO(pba), 0, 0, MEDIA_PORT(us) -+ }; -+ -+ rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, -+ command, 9, NULL); -+ if (rc != USB_STOR_XFER_GOOD) -+ return rc; -+ -+ return usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, -+ data, 16, NULL); -+} -+ -+/* -+ * Finds the first unused PBA in a zone -+ * Returns the absolute PBA of an unused PBA, or 0 if none found. -+ */ -+static u16 alauda_find_unused_pba(struct alauda_media_info *info, -+ unsigned int zone) -+{ -+ u16 *pba_to_lba = info->pba_to_lba[zone]; -+ unsigned int i; -+ -+ for (i = 0; i < info->zonesize; i++) -+ if (pba_to_lba[i] == UNDEF) -+ return (zone << info->zoneshift) + i; -+ -+ return 0; -+} -+ -+/* -+ * Reads the redundancy data for all PBA's in a zone -+ * Produces lba <--> pba mappings -+ */ -+static int alauda_read_map(struct us_data *us, unsigned int zone) -+{ -+ unsigned char *data = us->iobuf; -+ int result; -+ int i, j; -+ unsigned int zonesize = MEDIA_INFO(us).zonesize; -+ unsigned int uzonesize = MEDIA_INFO(us).uzonesize; -+ unsigned int lba_offset, lba_real, blocknum; -+ unsigned int zone_base_lba = zone * uzonesize; -+ unsigned int zone_base_pba = zone * zonesize; -+ u16 *lba_to_pba = kcalloc(zonesize, sizeof(u16), GFP_NOIO); -+ u16 *pba_to_lba = kcalloc(zonesize, sizeof(u16), GFP_NOIO); -+ if (lba_to_pba == NULL || pba_to_lba == NULL) { -+ result = USB_STOR_TRANSPORT_ERROR; -+ goto error; -+ } -+ -+ US_DEBUGP("alauda_read_map: Mapping blocks for zone %d\n", zone); -+ -+ /* 1024 PBA's per zone */ -+ for (i = 0; i < zonesize; i++) -+ lba_to_pba[i] = pba_to_lba[i] = UNDEF; -+ -+ for (i = 0; i < zonesize; i++) { -+ blocknum = zone_base_pba + i; -+ -+ result = alauda_get_redu_data(us, blocknum, data); -+ if (result != USB_STOR_XFER_GOOD) { -+ result = USB_STOR_TRANSPORT_ERROR; -+ goto error; -+ } -+ -+ /* special PBAs have control field 0^16 */ -+ for (j = 0; j < 16; j++) -+ if (data[j] != 0) -+ goto nonz; -+ pba_to_lba[i] = UNUSABLE; -+ US_DEBUGP("alauda_read_map: PBA %d has no logical mapping\n", blocknum); -+ continue; -+ -+ nonz: -+ /* unwritten PBAs have control field FF^16 */ -+ for (j = 0; j < 16; j++) -+ if (data[j] != 0xff) -+ goto nonff; -+ continue; -+ -+ nonff: -+ /* normal PBAs start with six FFs */ -+ if (j < 6) { -+ US_DEBUGP("alauda_read_map: PBA %d has no logical mapping: " -+ "reserved area = %02X%02X%02X%02X " -+ "data status %02X block status %02X\n", -+ blocknum, data[0], data[1], data[2], data[3], -+ data[4], data[5]); -+ pba_to_lba[i] = UNUSABLE; -+ continue; -+ } -+ -+ if ((data[6] >> 4) != 0x01) { -+ US_DEBUGP("alauda_read_map: PBA %d has invalid address " -+ "field %02X%02X/%02X%02X\n", -+ blocknum, data[6], data[7], data[11], data[12]); -+ pba_to_lba[i] = UNUSABLE; -+ continue; -+ } -+ -+ /* check even parity */ -+ if (parity[data[6] ^ data[7]]) { -+ printk("alauda_read_map: Bad parity in LBA for block %d" -+ " (%02X %02X)\n", i, data[6], data[7]); -+ pba_to_lba[i] = UNUSABLE; -+ continue; -+ } -+ -+ lba_offset = short_pack(data[7], data[6]); -+ lba_offset = (lba_offset & 0x07FF) >> 1; -+ lba_real = lba_offset + zone_base_lba; -+ -+ /* -+ * Every 1024 physical blocks ("zone"), the LBA numbers -+ * go back to zero, but are within a higher block of LBA's. -+ * Also, there is a maximum of 1000 LBA's per zone. -+ * In other words, in PBA 1024-2047 you will find LBA 0-999 -+ * which are really LBA 1000-1999. This allows for 24 bad -+ * or special physical blocks per zone. -+ */ -+ -+ if (lba_offset >= uzonesize) { -+ printk("alauda_read_map: Bad low LBA %d for block %d\n", -+ lba_real, blocknum); -+ continue; -+ } -+ -+ if (lba_to_pba[lba_offset] != UNDEF) { -+ printk("alauda_read_map: LBA %d seen for PBA %d and %d\n", -+ lba_real, lba_to_pba[lba_offset], blocknum); -+ continue; -+ } -+ -+ pba_to_lba[i] = lba_real; -+ lba_to_pba[lba_offset] = blocknum; -+ continue; -+ } -+ -+ MEDIA_INFO(us).lba_to_pba[zone] = lba_to_pba; -+ MEDIA_INFO(us).pba_to_lba[zone] = pba_to_lba; -+ result = 0; -+ goto out; -+ -+error: -+ kfree(lba_to_pba); -+ kfree(pba_to_lba); -+out: -+ return result; -+} -+ -+/* -+ * Checks to see whether we have already mapped a certain zone -+ * If we haven't, the map is generated -+ */ -+static void alauda_ensure_map_for_zone(struct us_data *us, unsigned int zone) -+{ -+ if (MEDIA_INFO(us).lba_to_pba[zone] == NULL -+ || MEDIA_INFO(us).pba_to_lba[zone] == NULL) -+ alauda_read_map(us, zone); -+} -+ -+/* -+ * Erases an entire block -+ */ -+static int alauda_erase_block(struct us_data *us, u16 pba) -+{ -+ int rc; -+ unsigned char command[] = { -+ ALAUDA_BULK_CMD, ALAUDA_BULK_ERASE_BLOCK, PBA_HI(pba), -+ PBA_ZONE(pba), 0, PBA_LO(pba), 0x02, 0, MEDIA_PORT(us) -+ }; -+ unsigned char buf[2]; -+ -+ US_DEBUGP("alauda_erase_block: Erasing PBA %d\n", pba); -+ -+ rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, -+ command, 9, NULL); -+ if (rc != USB_STOR_XFER_GOOD) -+ return rc; -+ -+ rc = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, -+ buf, 2, NULL); -+ if (rc != USB_STOR_XFER_GOOD) -+ return rc; -+ -+ US_DEBUGP("alauda_erase_block: Erase result: %02X %02X\n", -+ buf[0], buf[1]); -+ return rc; -+} -+ -+/* -+ * Reads data from a certain offset page inside a PBA, including interleaved -+ * redundancy data. Returns (pagesize+64)*pages bytes in data. -+ */ -+static int alauda_read_block_raw(struct us_data *us, u16 pba, -+ unsigned int page, unsigned int pages, unsigned char *data) -+{ -+ int rc; -+ unsigned char command[] = { -+ ALAUDA_BULK_CMD, ALAUDA_BULK_READ_BLOCK, PBA_HI(pba), -+ PBA_ZONE(pba), 0, PBA_LO(pba) + page, pages, 0, MEDIA_PORT(us) -+ }; -+ -+ US_DEBUGP("alauda_read_block: pba %d page %d count %d\n", -+ pba, page, pages); -+ -+ rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, -+ command, 9, NULL); -+ if (rc != USB_STOR_XFER_GOOD) -+ return rc; -+ -+ return usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, -+ data, (MEDIA_INFO(us).pagesize + 64) * pages, NULL); -+} -+ -+/* -+ * Reads data from a certain offset page inside a PBA, excluding redundancy -+ * data. Returns pagesize*pages bytes in data. Note that data must be big enough -+ * to hold (pagesize+64)*pages bytes of data, but you can ignore those 'extra' -+ * trailing bytes outside this function. -+ */ -+static int alauda_read_block(struct us_data *us, u16 pba, -+ unsigned int page, unsigned int pages, unsigned char *data) -+{ -+ int i, rc; -+ unsigned int pagesize = MEDIA_INFO(us).pagesize; -+ -+ rc = alauda_read_block_raw(us, pba, page, pages, data); -+ if (rc != USB_STOR_XFER_GOOD) -+ return rc; -+ -+ /* Cut out the redundancy data */ -+ for (i = 0; i < pages; i++) { -+ int dest_offset = i * pagesize; -+ int src_offset = i * (pagesize + 64); -+ memmove(data + dest_offset, data + src_offset, pagesize); -+ } -+ -+ return rc; -+} -+ -+/* -+ * Writes an entire block of data and checks status after write. -+ * Redundancy data must be already included in data. Data should be -+ * (pagesize+64)*blocksize bytes in length. -+ */ -+static int alauda_write_block(struct us_data *us, u16 pba, unsigned char *data) -+{ -+ int rc; -+ struct alauda_info *info = (struct alauda_info *) us->extra; -+ unsigned char command[] = { -+ ALAUDA_BULK_CMD, ALAUDA_BULK_WRITE_BLOCK, PBA_HI(pba), -+ PBA_ZONE(pba), 0, PBA_LO(pba), 32, 0, MEDIA_PORT(us) -+ }; -+ -+ US_DEBUGP("alauda_write_block: pba %d\n", pba); -+ -+ rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, -+ command, 9, NULL); -+ if (rc != USB_STOR_XFER_GOOD) -+ return rc; -+ -+ rc = usb_stor_bulk_transfer_buf(us, info->wr_ep, data, -+ (MEDIA_INFO(us).pagesize + 64) * MEDIA_INFO(us).blocksize, -+ NULL); -+ if (rc != USB_STOR_XFER_GOOD) -+ return rc; -+ -+ return alauda_check_status2(us); -+} -+ -+/* -+ * Write some data to a specific LBA. -+ */ -+static int alauda_write_lba(struct us_data *us, u16 lba, -+ unsigned int page, unsigned int pages, -+ unsigned char *ptr, unsigned char *blockbuffer) -+{ -+ u16 pba, lbap, new_pba; -+ unsigned char *bptr, *cptr, *xptr; -+ unsigned char ecc[3]; -+ int i, result; -+ unsigned int uzonesize = MEDIA_INFO(us).uzonesize; -+ unsigned int zonesize = MEDIA_INFO(us).zonesize; -+ unsigned int pagesize = MEDIA_INFO(us).pagesize; -+ unsigned int blocksize = MEDIA_INFO(us).blocksize; -+ unsigned int lba_offset = lba % uzonesize; -+ unsigned int new_pba_offset; -+ unsigned int zone = lba / uzonesize; -+ -+ alauda_ensure_map_for_zone(us, zone); -+ -+ pba = MEDIA_INFO(us).lba_to_pba[zone][lba_offset]; -+ if (pba == 1) { -+ /* Maybe it is impossible to write to PBA 1. -+ Fake success, but don't do anything. */ -+ printk("alauda_write_lba: avoid writing to pba 1\n"); -+ return USB_STOR_TRANSPORT_GOOD; -+ } -+ -+ new_pba = alauda_find_unused_pba(&MEDIA_INFO(us), zone); -+ if (!new_pba) { -+ printk("alauda_write_lba: Out of unused blocks\n"); -+ return USB_STOR_TRANSPORT_ERROR; -+ } -+ -+ /* read old contents */ -+ if (pba != UNDEF) { -+ result = alauda_read_block_raw(us, pba, 0, -+ blocksize, blockbuffer); -+ if (result != USB_STOR_XFER_GOOD) -+ return result; -+ } else { -+ memset(blockbuffer, 0, blocksize * (pagesize + 64)); -+ } -+ -+ lbap = (lba_offset << 1) | 0x1000; -+ if (parity[MSB_of(lbap) ^ LSB_of(lbap)]) -+ lbap ^= 1; -+ -+ /* check old contents and fill lba */ -+ for (i = 0; i < blocksize; i++) { -+ bptr = blockbuffer + (i * (pagesize + 64)); -+ cptr = bptr + pagesize; -+ nand_compute_ecc(bptr, ecc); -+ if (!nand_compare_ecc(cptr+13, ecc)) { -+ US_DEBUGP("Warning: bad ecc in page %d- of pba %d\n", -+ i, pba); -+ nand_store_ecc(cptr+13, ecc); -+ } -+ nand_compute_ecc(bptr + (pagesize / 2), ecc); -+ if (!nand_compare_ecc(cptr+8, ecc)) { -+ US_DEBUGP("Warning: bad ecc in page %d+ of pba %d\n", -+ i, pba); -+ nand_store_ecc(cptr+8, ecc); -+ } -+ cptr[6] = cptr[11] = MSB_of(lbap); -+ cptr[7] = cptr[12] = LSB_of(lbap); -+ } -+ -+ /* copy in new stuff and compute ECC */ -+ xptr = ptr; -+ for (i = page; i < page+pages; i++) { -+ bptr = blockbuffer + (i * (pagesize + 64)); -+ cptr = bptr + pagesize; -+ memcpy(bptr, xptr, pagesize); -+ xptr += pagesize; -+ nand_compute_ecc(bptr, ecc); -+ nand_store_ecc(cptr+13, ecc); -+ nand_compute_ecc(bptr + (pagesize / 2), ecc); -+ nand_store_ecc(cptr+8, ecc); -+ } -+ -+ result = alauda_write_block(us, new_pba, blockbuffer); -+ if (result != USB_STOR_XFER_GOOD) -+ return result; -+ -+ new_pba_offset = new_pba - (zone * zonesize); -+ MEDIA_INFO(us).pba_to_lba[zone][new_pba_offset] = lba; -+ MEDIA_INFO(us).lba_to_pba[zone][lba_offset] = new_pba; -+ US_DEBUGP("alauda_write_lba: Remapped LBA %d to PBA %d\n", -+ lba, new_pba); -+ -+ if (pba != UNDEF) { -+ unsigned int pba_offset = pba - (zone * zonesize); -+ result = alauda_erase_block(us, pba); -+ if (result != USB_STOR_XFER_GOOD) -+ return result; -+ MEDIA_INFO(us).pba_to_lba[zone][pba_offset] = UNDEF; -+ } -+ -+ return USB_STOR_TRANSPORT_GOOD; -+} -+ -+/* -+ * Read data from a specific sector address -+ */ -+static int alauda_read_data(struct us_data *us, unsigned long address, -+ unsigned int sectors) -+{ -+ unsigned char *buffer; -+ u16 lba, max_lba; -+ unsigned int page, len, index, offset; -+ unsigned int blockshift = MEDIA_INFO(us).blockshift; -+ unsigned int pageshift = MEDIA_INFO(us).pageshift; -+ unsigned int blocksize = MEDIA_INFO(us).blocksize; -+ unsigned int pagesize = MEDIA_INFO(us).pagesize; -+ unsigned int uzonesize = MEDIA_INFO(us).uzonesize; -+ int result; -+ -+ /* -+ * Since we only read in one block at a time, we have to create -+ * a bounce buffer and move the data a piece at a time between the -+ * bounce buffer and the actual transfer buffer. -+ * We make this buffer big enough to hold temporary redundancy data, -+ * which we use when reading the data blocks. -+ */ -+ -+ len = min(sectors, blocksize) * (pagesize + 64); -+ buffer = kmalloc(len, GFP_NOIO); -+ if (buffer == NULL) { -+ printk("alauda_read_data: Out of memory\n"); -+ return USB_STOR_TRANSPORT_ERROR; -+ } -+ -+ /* Figure out the initial LBA and page */ -+ lba = address >> blockshift; -+ page = (address & MEDIA_INFO(us).blockmask); -+ max_lba = MEDIA_INFO(us).capacity >> (blockshift + pageshift); -+ -+ result = USB_STOR_TRANSPORT_GOOD; -+ index = offset = 0; -+ -+ while (sectors > 0) { -+ unsigned int zone = lba / uzonesize; /* integer division */ -+ unsigned int lba_offset = lba - (zone * uzonesize); -+ unsigned int pages; -+ u16 pba; -+ alauda_ensure_map_for_zone(us, zone); -+ -+ /* Not overflowing capacity? */ -+ if (lba >= max_lba) { -+ US_DEBUGP("Error: Requested lba %u exceeds " -+ "maximum %u\n", lba, max_lba); -+ result = USB_STOR_TRANSPORT_ERROR; -+ break; -+ } -+ -+ /* Find number of pages we can read in this block */ -+ pages = min(sectors, blocksize - page); -+ len = pages << pageshift; -+ -+ /* Find where this lba lives on disk */ -+ pba = MEDIA_INFO(us).lba_to_pba[zone][lba_offset]; -+ -+ if (pba == UNDEF) { /* this lba was never written */ -+ US_DEBUGP("Read %d zero pages (LBA %d) page %d\n", -+ pages, lba, page); -+ -+ /* This is not really an error. It just means -+ that the block has never been written. -+ Instead of returning USB_STOR_TRANSPORT_ERROR -+ it is better to return all zero data. */ -+ -+ memset(buffer, 0, len); -+ } else { -+ US_DEBUGP("Read %d pages, from PBA %d" -+ " (LBA %d) page %d\n", -+ pages, pba, lba, page); -+ -+ result = alauda_read_block(us, pba, page, pages, buffer); -+ if (result != USB_STOR_TRANSPORT_GOOD) -+ break; -+ } -+ -+ /* Store the data in the transfer buffer */ -+ usb_stor_access_xfer_buf(buffer, len, us->srb, -+ &index, &offset, TO_XFER_BUF); -+ -+ page = 0; -+ lba++; -+ sectors -= pages; -+ } -+ -+ kfree(buffer); -+ return result; -+} -+ -+/* -+ * Write data to a specific sector address -+ */ -+static int alauda_write_data(struct us_data *us, unsigned long address, -+ unsigned int sectors) -+{ -+ unsigned char *buffer, *blockbuffer; -+ unsigned int page, len, index, offset; -+ unsigned int blockshift = MEDIA_INFO(us).blockshift; -+ unsigned int pageshift = MEDIA_INFO(us).pageshift; -+ unsigned int blocksize = MEDIA_INFO(us).blocksize; -+ unsigned int pagesize = MEDIA_INFO(us).pagesize; -+ u16 lba, max_lba; -+ int result; -+ -+ /* -+ * Since we don't write the user data directly to the device, -+ * we have to create a bounce buffer and move the data a piece -+ * at a time between the bounce buffer and the actual transfer buffer. -+ */ -+ -+ len = min(sectors, blocksize) * pagesize; -+ buffer = kmalloc(len, GFP_NOIO); -+ if (buffer == NULL) { -+ printk("alauda_write_data: Out of memory\n"); -+ return USB_STOR_TRANSPORT_ERROR; -+ } -+ -+ /* -+ * We also need a temporary block buffer, where we read in the old data, -+ * overwrite parts with the new data, and manipulate the redundancy data -+ */ -+ blockbuffer = kmalloc((pagesize + 64) * blocksize, GFP_NOIO); -+ if (blockbuffer == NULL) { -+ printk("alauda_write_data: Out of memory\n"); -+ kfree(buffer); -+ return USB_STOR_TRANSPORT_ERROR; -+ } -+ -+ /* Figure out the initial LBA and page */ -+ lba = address >> blockshift; -+ page = (address & MEDIA_INFO(us).blockmask); -+ max_lba = MEDIA_INFO(us).capacity >> (pageshift + blockshift); -+ -+ result = USB_STOR_TRANSPORT_GOOD; -+ index = offset = 0; -+ -+ while (sectors > 0) { -+ /* Write as many sectors as possible in this block */ -+ unsigned int pages = min(sectors, blocksize - page); -+ len = pages << pageshift; -+ -+ /* Not overflowing capacity? */ -+ if (lba >= max_lba) { -+ US_DEBUGP("alauda_write_data: Requested lba %u exceeds " -+ "maximum %u\n", lba, max_lba); -+ result = USB_STOR_TRANSPORT_ERROR; -+ break; -+ } -+ -+ /* Get the data from the transfer buffer */ -+ usb_stor_access_xfer_buf(buffer, len, us->srb, -+ &index, &offset, FROM_XFER_BUF); -+ -+ result = alauda_write_lba(us, lba, page, pages, buffer, -+ blockbuffer); -+ if (result != USB_STOR_TRANSPORT_GOOD) -+ break; -+ -+ page = 0; -+ lba++; -+ sectors -= pages; -+ } -+ -+ kfree(buffer); -+ kfree(blockbuffer); -+ return result; -+} -+ -+/* -+ * Our interface with the rest of the world -+ */ -+ -+static void alauda_info_destructor(void *extra) -+{ -+ struct alauda_info *info = (struct alauda_info *) extra; -+ int port; -+ -+ if (!info) -+ return; -+ -+ for (port = 0; port < 2; port++) { -+ struct alauda_media_info *media_info = &info->port[port]; -+ -+ alauda_free_maps(media_info); -+ kfree(media_info->lba_to_pba); -+ kfree(media_info->pba_to_lba); -+ } -+} -+ -+/* -+ * Initialize alauda_info struct and find the data-write endpoint -+ */ -+int init_alauda(struct us_data *us) -+{ -+ struct alauda_info *info; -+ struct usb_host_interface *altsetting = us->pusb_intf->cur_altsetting; -+ nand_init_ecc(); -+ -+ us->extra = kzalloc(sizeof(struct alauda_info), GFP_NOIO); -+ if (!us->extra) { -+ US_DEBUGP("init_alauda: Gah! Can't allocate storage for" -+ "alauda info struct!\n"); -+ return USB_STOR_TRANSPORT_ERROR; -+ } -+ info = (struct alauda_info *) us->extra; -+ us->extra_destructor = alauda_info_destructor; -+ -+ info->wr_ep = usb_sndbulkpipe(us->pusb_dev, -+ altsetting->endpoint[0].desc.bEndpointAddress -+ & USB_ENDPOINT_NUMBER_MASK); -+ -+ return USB_STOR_TRANSPORT_GOOD; -+} -+ -+int alauda_transport(struct scsi_cmnd *srb, struct us_data *us) -+{ -+ int rc; -+ struct alauda_info *info = (struct alauda_info *) us->extra; -+ unsigned char *ptr = us->iobuf; -+ static unsigned char inquiry_response[36] = { -+ 0x00, 0x80, 0x00, 0x01, 0x1F, 0x00, 0x00, 0x00 -+ }; -+ -+ if (srb->cmnd[0] == INQUIRY) { -+ US_DEBUGP("alauda_transport: INQUIRY. " -+ "Returning bogus response.\n"); -+ memcpy(ptr, inquiry_response, sizeof(inquiry_response)); -+ fill_inquiry_response(us, ptr, 36); -+ return USB_STOR_TRANSPORT_GOOD; -+ } -+ -+ if (srb->cmnd[0] == TEST_UNIT_READY) { -+ US_DEBUGP("alauda_transport: TEST_UNIT_READY.\n"); -+ return alauda_check_media(us); -+ } -+ -+ if (srb->cmnd[0] == READ_CAPACITY) { -+ unsigned int num_zones; -+ unsigned long capacity; -+ -+ rc = alauda_check_media(us); -+ if (rc != USB_STOR_TRANSPORT_GOOD) -+ return rc; -+ -+ num_zones = MEDIA_INFO(us).capacity >> (MEDIA_INFO(us).zoneshift -+ + MEDIA_INFO(us).blockshift + MEDIA_INFO(us).pageshift); -+ -+ capacity = num_zones * MEDIA_INFO(us).uzonesize -+ * MEDIA_INFO(us).blocksize; -+ -+ /* Report capacity and page size */ -+ ((__be32 *) ptr)[0] = cpu_to_be32(capacity - 1); -+ ((__be32 *) ptr)[1] = cpu_to_be32(512); -+ -+ usb_stor_set_xfer_buf(ptr, 8, srb); -+ return USB_STOR_TRANSPORT_GOOD; -+ } -+ -+ if (srb->cmnd[0] == READ_10) { -+ unsigned int page, pages; -+ -+ rc = alauda_check_media(us); -+ if (rc != USB_STOR_TRANSPORT_GOOD) -+ return rc; -+ -+ page = short_pack(srb->cmnd[3], srb->cmnd[2]); -+ page <<= 16; -+ page |= short_pack(srb->cmnd[5], srb->cmnd[4]); -+ pages = short_pack(srb->cmnd[8], srb->cmnd[7]); -+ -+ US_DEBUGP("alauda_transport: READ_10: page %d pagect %d\n", -+ page, pages); -+ -+ return alauda_read_data(us, page, pages); -+ } -+ -+ if (srb->cmnd[0] == WRITE_10) { -+ unsigned int page, pages; -+ -+ rc = alauda_check_media(us); -+ if (rc != USB_STOR_TRANSPORT_GOOD) -+ return rc; -+ -+ page = short_pack(srb->cmnd[3], srb->cmnd[2]); -+ page <<= 16; -+ page |= short_pack(srb->cmnd[5], srb->cmnd[4]); -+ pages = short_pack(srb->cmnd[8], srb->cmnd[7]); -+ -+ US_DEBUGP("alauda_transport: WRITE_10: page %d pagect %d\n", -+ page, pages); -+ -+ return alauda_write_data(us, page, pages); -+ } -+ -+ if (srb->cmnd[0] == REQUEST_SENSE) { -+ US_DEBUGP("alauda_transport: REQUEST_SENSE.\n"); -+ -+ memset(ptr, 0, 18); -+ ptr[0] = 0xF0; -+ ptr[2] = info->sense_key; -+ ptr[7] = 11; -+ ptr[12] = info->sense_asc; -+ ptr[13] = info->sense_ascq; -+ usb_stor_set_xfer_buf(ptr, 18, srb); -+ -+ return USB_STOR_TRANSPORT_GOOD; -+ } -+ -+ if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) { -+ /* sure. whatever. not like we can stop the user from popping -+ the media out of the device (no locking doors, etc) */ -+ return USB_STOR_TRANSPORT_GOOD; -+ } -+ -+ US_DEBUGP("alauda_transport: Gah! Unknown command: %d (0x%x)\n", -+ srb->cmnd[0], srb->cmnd[0]); -+ info->sense_key = 0x05; -+ info->sense_asc = 0x20; -+ info->sense_ascq = 0x00; -+ return USB_STOR_TRANSPORT_FAILED; -+} -+ ---- /dev/null -+++ gregkh-2.6/drivers/usb/storage/alauda.h -@@ -0,0 +1,100 @@ -+/* -+ * Driver for Alauda-based card readers -+ * -+ * Current development and maintenance by: -+ * (c) 2005 Daniel Drake <dsd@gentoo.org> -+ * -+ * See alauda.c for more explanation. -+ * -+ * This program is free software; you can redistribute it and/or modify it -+ * under the terms of the GNU General Public License as published by the -+ * Free Software Foundation; either version 2, or (at your option) any -+ * later version. -+ * -+ * This program is distributed in the hope that it will be useful, but -+ * WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License along -+ * with this program; if not, write to the Free Software Foundation, Inc., -+ * 675 Mass Ave, Cambridge, MA 02139, USA. -+ */ -+ -+#ifndef _USB_ALAUDA_H -+#define _USB_ALAUDA_H -+ -+/* -+ * Status bytes -+ */ -+#define ALAUDA_STATUS_ERROR 0x01 -+#define ALAUDA_STATUS_READY 0x40 -+ -+/* -+ * Control opcodes (for request field) -+ */ -+#define ALAUDA_GET_XD_MEDIA_STATUS 0x08 -+#define ALAUDA_GET_SM_MEDIA_STATUS 0x98 -+#define ALAUDA_ACK_XD_MEDIA_CHANGE 0x0a -+#define ALAUDA_ACK_SM_MEDIA_CHANGE 0x9a -+#define ALAUDA_GET_XD_MEDIA_SIG 0x86 -+#define ALAUDA_GET_SM_MEDIA_SIG 0x96 -+ -+/* -+ * Bulk command identity (byte 0) -+ */ -+#define ALAUDA_BULK_CMD 0x40 -+ -+/* -+ * Bulk opcodes (byte 1) -+ */ -+#define ALAUDA_BULK_GET_REDU_DATA 0x85 -+#define ALAUDA_BULK_READ_BLOCK 0x94 -+#define ALAUDA_BULK_ERASE_BLOCK 0xa3 -+#define ALAUDA_BULK_WRITE_BLOCK 0xb4 -+#define ALAUDA_BULK_GET_STATUS2 0xb7 -+#define ALAUDA_BULK_RESET_MEDIA 0xe0 -+ -+/* -+ * Port to operate on (byte 8) -+ */ -+#define ALAUDA_PORT_XD 0x00 -+#define ALAUDA_PORT_SM 0x01 -+ -+/* -+ * LBA and PBA are unsigned ints. Special values. -+ */ -+#define UNDEF 0xffff -+#define SPARE 0xfffe -+#define UNUSABLE 0xfffd -+ -+int init_alauda(struct us_data *us); -+int alauda_transport(struct scsi_cmnd *srb, struct us_data *us); -+ -+struct alauda_media_info { -+ unsigned long capacity; /* total media size in bytes */ -+ unsigned int pagesize; /* page size in bytes */ -+ unsigned int blocksize; /* number of pages per block */ -+ unsigned int uzonesize; /* number of usable blocks per zone */ -+ unsigned int zonesize; /* number of blocks per zone */ -+ unsigned int blockmask; /* mask to get page from address */ -+ -+ unsigned char pageshift; -+ unsigned char blockshift; -+ unsigned char zoneshift; -+ -+ u16 **lba_to_pba; /* logical to physical block map */ -+ u16 **pba_to_lba; /* physical to logical block map */ -+}; -+ -+struct alauda_info { -+ struct alauda_media_info port[2]; -+ int wr_ep; /* endpoint to write data out of */ -+ -+ unsigned char sense_key; -+ unsigned long sense_asc; /* additional sense code */ -+ unsigned long sense_ascq; /* additional sense code qualifier */ -+}; -+ -+#endif -+ ---- gregkh-2.6.orig/drivers/usb/storage/Kconfig -+++ gregkh-2.6/drivers/usb/storage/Kconfig -@@ -112,6 +112,15 @@ config USB_STORAGE_JUMPSHOT - Say Y here to include additional code to support the Lexar Jumpshot - USB CompactFlash reader. - -+config USB_STORAGE_ALAUDA -+ bool "Olympus MAUSB-10/Fuji DPC-R1 support (EXPERIMENTAL)" -+ depends on USB_STORAGE && EXPERIMENTAL -+ help -+ Say Y here to include additional code to support the Olympus MAUSB-10 -+ and Fujifilm DPC-R1 USB Card reader/writer devices. -+ -+ These devices are based on the Alauda chip and support support both -+ XD and SmartMedia cards. - - config USB_STORAGE_ONETOUCH - bool "Support OneTouch Button on Maxtor Hard Drives (EXPERIMENTAL)" ---- gregkh-2.6.orig/drivers/usb/storage/Makefile -+++ gregkh-2.6/drivers/usb/storage/Makefile -@@ -18,6 +18,7 @@ usb-storage-obj-$(CONFIG_USB_STORAGE_DPC - usb-storage-obj-$(CONFIG_USB_STORAGE_ISD200) += isd200.o - usb-storage-obj-$(CONFIG_USB_STORAGE_DATAFAB) += datafab.o - usb-storage-obj-$(CONFIG_USB_STORAGE_JUMPSHOT) += jumpshot.o -+usb-storage-obj-$(CONFIG_USB_STORAGE_ALAUDA) += alauda.o - usb-storage-obj-$(CONFIG_USB_STORAGE_ONETOUCH) += onetouch.o - - usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \ ---- gregkh-2.6.orig/include/linux/usb_usual.h -+++ gregkh-2.6/include/linux/usb_usual.h -@@ -102,6 +102,9 @@ enum { US_DO_ALL_FLAGS }; - #ifdef CONFIG_USB_STORAGE_JUMPSHOT - #define US_PR_JUMPSHOT 0xf3 /* Lexar Jumpshot */ - #endif -+#ifdef CONFIG_USB_STORAGE_ALAUDA -+#define US_PR_ALAUDA 0xf4 /* Alauda chipsets */ -+#endif - - #define US_PR_DEVICE 0xff /* Use device's value */ - ---- gregkh-2.6.orig/drivers/usb/storage/unusual_devs.h -+++ gregkh-2.6/drivers/usb/storage/unusual_devs.h -@@ -535,6 +535,13 @@ UNUSUAL_DEV( 0x057b, 0x0022, 0x0000, 0x - "Silicon Media R/W", - US_SC_DEVICE, US_PR_DEVICE, NULL, 0), - -+#ifdef CONFIG_USB_STORAGE_ALAUDA -+UNUSUAL_DEV( 0x0584, 0x0008, 0x0102, 0x0102, -+ "Fujifilm", -+ "DPC-R1 (Alauda)", -+ US_SC_SCSI, US_PR_ALAUDA, init_alauda, 0 ), -+#endif -+ - /* Fabrizio Fellini <fello@libero.it> */ - UNUSUAL_DEV( 0x0595, 0x4343, 0x0000, 0x2210, - "Fujifilm", -@@ -784,6 +791,13 @@ UNUSUAL_DEV( 0x07af, 0x0006, 0x0100, 0x - US_SC_SCSI, US_PR_DPCM_USB, NULL, 0 ), - #endif - -+#ifdef CONFIG_USB_STORAGE_ALAUDA -+UNUSUAL_DEV( 0x07b4, 0x010a, 0x0102, 0x0102, -+ "Olympus", -+ "MAUSB-10 (Alauda)", -+ US_SC_SCSI, US_PR_ALAUDA, init_alauda, 0 ), -+#endif -+ - #ifdef CONFIG_USB_STORAGE_DATAFAB - UNUSUAL_DEV( 0x07c4, 0xa000, 0x0000, 0x0015, - "Datafab", ---- gregkh-2.6.orig/drivers/usb/storage/usb.c -+++ gregkh-2.6/drivers/usb/storage/usb.c -@@ -94,6 +94,9 @@ - #ifdef CONFIG_USB_STORAGE_ONETOUCH - #include "onetouch.h" - #endif -+#ifdef CONFIG_USB_STORAGE_ALAUDA -+#include "alauda.h" -+#endif - - /* Some informational data */ - MODULE_AUTHOR("Matthew Dharm <mdharm-usb@one-eyed-alien.net>"); -@@ -644,6 +647,15 @@ static int get_protocol(struct us_data * - break; - #endif - -+#ifdef CONFIG_USB_STORAGE_ALAUDA -+ case US_PR_ALAUDA: -+ us->transport_name = "Alauda Control/Bulk"; -+ us->transport = alauda_transport; -+ us->transport_reset = usb_stor_Bulk_reset; -+ us->max_lun = 1; -+ break; -+#endif -+ - default: - return -EIO; - } diff --git a/usb/usb-storage-add-debug-entry-for-report-luns.patch b/usb/usb-storage-add-debug-entry-for-report-luns.patch deleted file mode 100644 index a66523ad590d7..0000000000000 --- a/usb/usb-storage-add-debug-entry-for-report-luns.patch +++ /dev/null @@ -1,32 +0,0 @@ -From akpm@osdl.org Wed Nov 30 14:00:03 2005 -Message-Id: <200511302156.jAULuQ4M011629@shell0.pdx.osdl.net> -From: Paul Walmsley <paul@booyaka.com> -Subject: usb-storage: add debug entry for REPORT LUNS -Subject: + usb-storage-add-debug-entry-for-report-luns.patch added to -mm tree -To: paul@booyaka.com, greg@kroah.com, mdharm-usb@one-eyed-alien.net -Date: Wed, 30 Nov 2005 13:57:45 -0800 - -From: Paul Walmsley <paul@booyaka.com> - -Bugs involving the REPORT LUNS SCSI-3 command are much easier to track -down if usb-storage displays the command's name, rather than "(Unknown -command)". - -Signed-off-by: Paul Walmsley <paul@booyaka.com> -Cc: <mdharm-usb@one-eyed-alien.net> -Signed-off-by: Andrew Morton <akpm@osdl.org> -Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> ---- - drivers/usb/storage/debug.c | 1 + - 1 file changed, 1 insertion(+) - ---- gregkh-2.6.orig/drivers/usb/storage/debug.c -+++ gregkh-2.6/drivers/usb/storage/debug.c -@@ -132,6 +132,7 @@ void usb_stor_show_command(struct scsi_c - case 0x5C: what = "READ BUFFER CAPACITY"; break; - case 0x5D: what = "SEND CUE SHEET"; break; - case GPCMD_BLANK: what = "BLANK"; break; -+ case REPORT_LUNS: what = "REPORT LUNS"; break; - case MOVE_MEDIUM: what = "MOVE_MEDIUM or PLAY AUDIO (12)"; break; - case READ_12: what = "READ_12"; break; - case WRITE_12: what = "WRITE_12"; break; diff --git a/usb/usb-storage-add-unusual_devs-entry-for-nikon-coolpix-2000.patch b/usb/usb-storage-add-unusual_devs-entry-for-nikon-coolpix-2000.patch deleted file mode 100644 index 2a7296d801367..0000000000000 --- a/usb/usb-storage-add-unusual_devs-entry-for-nikon-coolpix-2000.patch +++ /dev/null @@ -1,49 +0,0 @@ -From phil@ipom.com Wed Nov 30 01:20:47 2005 -Message-ID: <438D6DD0.6050901@ipom.com> -Date: Wed, 30 Nov 2005 01:16:00 -0800 -From: fabien COSSE <fabien.cosse@wanadoo.fr> -To: Greg KH <greg@kroah.com> -Subject: USB Storage: add unusual_devs entry for NIKON Coolpix 2000 - -This patch adds an unusual_devs.h entry for NIKON Coolpix 2000 camera -wich cause error: "Not Ready: Medium not present" -Works fine with th patched kernel... - -Here are the informations in /proc/bus/usb/devices: - -T: Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=12 MxCh= 0 -D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1 -P: Vendor=04b0 ProdID=0301 Rev= 0.10 -S: Manufacturer=NIKON -S: Product=NIKON DSC E2000 -C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr= 0mA -I: If#= 0 Alt= 0 #EPs= 3 Cls=08(stor.) Sub=06 Prot=50 -Driver=usb-storage -E: Ad=01(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms -E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms -E: Ad=83(I) Atr=03(Int.) MxPS= 8 Ivl=16ms - -Signed-off-by: Fabien COSSE <fabien.cosse@wanadoo.fr> -Signed-off-by: Phil Dibowitz <phil@ipom.com> -Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> ---- - drivers/usb/storage/unusual_devs.h | 8 ++++++++ - 1 file changed, 8 insertions(+) - ---- gregkh-2.6.orig/drivers/usb/storage/unusual_devs.h -+++ gregkh-2.6/drivers/usb/storage/unusual_devs.h -@@ -187,6 +187,14 @@ UNUSUAL_DEV( 0x04b0, 0x0405, 0x0100, 0x - US_SC_DEVICE, US_PR_DEVICE, NULL, - US_FL_FIX_CAPACITY), - -+/* Patch for Nikon coolpix 2000 -+ * Submitted by Fabien Cosse <fabien.cosse@wanadoo.fr>*/ -+UNUSUAL_DEV( 0x04b0, 0x0301, 0x0010, 0x0010, -+ "NIKON", -+ "NIKON DSC E2000", -+ US_SC_DEVICE, US_PR_DEVICE,NULL, -+ US_FL_NOT_LOCKABLE ), -+ - /* BENQ DC5330 - * Reported by Manuel Fombuena <mfombuena@ya.com> and - * Frank Copeland <fjc@thingy.apana.org.au> */ diff --git a/usb/usb-storage-cleanups-of-sddr09.patch b/usb/usb-storage-cleanups-of-sddr09.patch deleted file mode 100644 index 63b9ae1152db9..0000000000000 --- a/usb/usb-storage-cleanups-of-sddr09.patch +++ /dev/null @@ -1,264 +0,0 @@ -From mdharm@multivac.one-eyed-alien.net Sun Dec 4 22:01:36 2005 -Date: Sun, 4 Dec 2005 21:57:51 -0800 -From: Matthew Dharm <mdharm-usb@one-eyed-alien.net> -To: Greg KH <greg@kroah.com> -Subject: USB Storage: cleanups of sddr09 -Message-ID: <20051205055751.GB15047@one-eyed-alien.net> -Content-Disposition: inline - -This is the first of three patches to prepare the sddr09 subdriver for -conversion to the Sim-SCSI framework. This patch (as594) straightens -out the initialization procedures and headers: - - Some ugly code from usb.c was moved into sddr09.c. - - Set-up of the private data structures was moved into the - initialization routine. - - The connection between the "dpcm" version and the standalone - version was clarified. - - A private declaration was moved from a header file into the - subdriver's .c file. - -Signed-off-by: Alan Stern <stern@rowland.harvard.edu> -Acked-by: Andries Brouwer <Andries.Brouwer@cwi.nl> -Signed-off-by: Matthew Dharm <mdharm-usb@one-eyed-alien.net> -Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> - ---- - drivers/usb/storage/initializers.h | 4 -- - drivers/usb/storage/sddr09.c | 74 ++++++++++++++++++++++++++++--------- - drivers/usb/storage/sddr09.h | 15 +------ - drivers/usb/storage/unusual_devs.h | 14 +++---- - drivers/usb/storage/usb.c | 22 ----------- - 5 files changed, 65 insertions(+), 64 deletions(-) - ---- gregkh-2.6.orig/drivers/usb/storage/unusual_devs.h -+++ gregkh-2.6/drivers/usb/storage/unusual_devs.h -@@ -284,14 +284,14 @@ UNUSUAL_DEV( 0x04e6, 0x0002, 0x0100, 0x - UNUSUAL_DEV( 0x04e6, 0x0003, 0x0000, 0x9999, - "Sandisk", - "ImageMate SDDR09", -- US_SC_SCSI, US_PR_EUSB_SDDR09, NULL, -- US_FL_SINGLE_LUN ), -+ US_SC_SCSI, US_PR_EUSB_SDDR09, usb_stor_sddr09_init, -+ 0), - - /* This entry is from Andries.Brouwer@cwi.nl */ - UNUSUAL_DEV( 0x04e6, 0x0005, 0x0100, 0x0208, - "SCM Microsystems", - "eUSB SmartMedia / CompactFlash Adapter", -- US_SC_SCSI, US_PR_DPCM_USB, sddr09_init, -+ US_SC_SCSI, US_PR_DPCM_USB, usb_stor_sddr09_dpcm_init, - 0), - #endif - -@@ -681,8 +681,8 @@ UNUSUAL_DEV( 0x0644, 0x0000, 0x0100, 0x - UNUSUAL_DEV( 0x066b, 0x0105, 0x0100, 0x0100, - "Olympus", - "Camedia MAUSB-2", -- US_SC_SCSI, US_PR_EUSB_SDDR09, NULL, -- US_FL_SINGLE_LUN ), -+ US_SC_SCSI, US_PR_EUSB_SDDR09, usb_stor_sddr09_init, -+ 0), - #endif - - /* Reported by Darsen Lu <darsen@micro.ee.nthu.edu.tw> */ -@@ -747,8 +747,8 @@ UNUSUAL_DEV( 0x0781, 0x0100, 0x0100, 0x - UNUSUAL_DEV( 0x0781, 0x0200, 0x0000, 0x9999, - "Sandisk", - "ImageMate SDDR-09", -- US_SC_SCSI, US_PR_EUSB_SDDR09, NULL, -- US_FL_SINGLE_LUN ), -+ US_SC_SCSI, US_PR_EUSB_SDDR09, usb_stor_sddr09_init, -+ 0), - #endif - - #ifdef CONFIG_USB_STORAGE_FREECOM ---- gregkh-2.6.orig/drivers/usb/storage/sddr09.c -+++ gregkh-2.6/drivers/usb/storage/sddr09.c -@@ -214,6 +214,20 @@ static void nand_store_ecc(unsigned char - * The actual driver starts here. - */ - -+struct sddr09_card_info { -+ unsigned long capacity; /* Size of card in bytes */ -+ int pagesize; /* Size of page in bytes */ -+ int pageshift; /* log2 of pagesize */ -+ int blocksize; /* Size of block in pages */ -+ int blockshift; /* log2 of blocksize */ -+ int blockmask; /* 2^blockshift - 1 */ -+ int *lba_to_pba; /* logical to physical map */ -+ int *pba_to_lba; /* physical to logical map */ -+ int lbact; /* number of available pages */ -+ int flags; -+#define SDDR09_WP 1 /* write protected */ -+}; -+ - /* - * On my 16MB card, control blocks have size 64 (16 real control bytes, - * and 48 junk bytes). In reality of course the card uses 16 control bytes, -@@ -1342,27 +1356,51 @@ sddr09_card_info_destructor(void *extra) - kfree(info->pba_to_lba); - } - --static void --sddr09_init_card_info(struct us_data *us) { -- if (!us->extra) { -- us->extra = kmalloc(sizeof(struct sddr09_card_info), GFP_NOIO); -- if (us->extra) { -- memset(us->extra, 0, sizeof(struct sddr09_card_info)); -- us->extra_destructor = sddr09_card_info_destructor; -- } -- } -+static int -+sddr09_common_init(struct us_data *us) { -+ int result; -+ -+ /* set the configuration -- STALL is an acceptable response here */ -+ if (us->pusb_dev->actconfig->desc.bConfigurationValue != 1) { -+ US_DEBUGP("active config #%d != 1 ??\n", us->pusb_dev -+ ->actconfig->desc.bConfigurationValue); -+ return -EINVAL; -+ } -+ -+ result = usb_reset_configuration(us->pusb_dev); -+ US_DEBUGP("Result of usb_reset_configuration is %d\n", result); -+ if (result == -EPIPE) { -+ US_DEBUGP("-- stall on control interface\n"); -+ } else if (result != 0) { -+ /* it's not a stall, but another error -- time to bail */ -+ US_DEBUGP("-- Unknown error. Rejecting device\n"); -+ return -EINVAL; -+ } -+ -+ us->extra = kzalloc(sizeof(struct sddr09_card_info), GFP_NOIO); -+ if (!us->extra) -+ return -ENOMEM; -+ us->extra_destructor = sddr09_card_info_destructor; -+ -+ nand_init_ecc(); -+ return 0; - } - -+ - /* - * This is needed at a very early stage. If this is not listed in the - * unusual devices list but called from here then LUN 0 of the combo reader - * is not recognized. But I do not know what precisely these calls do. - */ - int --sddr09_init(struct us_data *us) { -+usb_stor_sddr09_dpcm_init(struct us_data *us) { - int result; - unsigned char *data = us->iobuf; - -+ result = sddr09_common_init(us); -+ if (result) -+ return result; -+ - result = sddr09_send_command(us, 0x01, USB_DIR_IN, data, 2); - if (result != USB_STOR_TRANSPORT_GOOD) { - US_DEBUGP("sddr09_init: send_command fails\n"); -@@ -1398,7 +1436,7 @@ sddr09_init(struct us_data *us) { - - // test unit ready - -- return USB_STOR_TRANSPORT_GOOD; /* not result */ -+ return 0; /* not result */ - } - - /* -@@ -1427,13 +1465,6 @@ int sddr09_transport(struct scsi_cmnd *s - }; - - info = (struct sddr09_card_info *)us->extra; -- if (!info) { -- nand_init_ecc(); -- sddr09_init_card_info(us); -- info = (struct sddr09_card_info *)us->extra; -- if (!info) -- return USB_STOR_TRANSPORT_ERROR; -- } - - if (srb->cmnd[0] == REQUEST_SENSE && havefakesense) { - /* for a faked command, we have to follow with a faked sense */ -@@ -1606,3 +1637,10 @@ int sddr09_transport(struct scsi_cmnd *s - return USB_STOR_TRANSPORT_GOOD; - } - -+/* -+ * Initialization routine for the sddr09 subdriver -+ */ -+int -+usb_stor_sddr09_init(struct us_data *us) { -+ return sddr09_common_init(us); -+} ---- gregkh-2.6.orig/drivers/usb/storage/sddr09.h -+++ gregkh-2.6/drivers/usb/storage/sddr09.h -@@ -31,18 +31,7 @@ - - extern int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us); - --struct sddr09_card_info { -- unsigned long capacity; /* Size of card in bytes */ -- int pagesize; /* Size of page in bytes */ -- int pageshift; /* log2 of pagesize */ -- int blocksize; /* Size of block in pages */ -- int blockshift; /* log2 of blocksize */ -- int blockmask; /* 2^blockshift - 1 */ -- int *lba_to_pba; /* logical to physical map */ -- int *pba_to_lba; /* physical to logical map */ -- int lbact; /* number of available pages */ -- int flags; --#define SDDR09_WP 1 /* write protected */ --}; -+extern int usb_stor_sddr09_dpcm_init(struct us_data *us); -+extern int usb_stor_sddr09_init(struct us_data *us); - - #endif ---- gregkh-2.6.orig/drivers/usb/storage/usb.c -+++ gregkh-2.6/drivers/usb/storage/usb.c -@@ -919,28 +919,6 @@ static int storage_probe(struct usb_inte - */ - get_device_info(us, id); - --#ifdef CONFIG_USB_STORAGE_SDDR09 -- if (us->protocol == US_PR_EUSB_SDDR09 || -- us->protocol == US_PR_DPCM_USB) { -- /* set the configuration -- STALL is an acceptable response here */ -- if (us->pusb_dev->actconfig->desc.bConfigurationValue != 1) { -- US_DEBUGP("active config #%d != 1 ??\n", us->pusb_dev -- ->actconfig->desc.bConfigurationValue); -- goto BadDevice; -- } -- result = usb_reset_configuration(us->pusb_dev); -- -- US_DEBUGP("Result of usb_reset_configuration is %d\n", result); -- if (result == -EPIPE) { -- US_DEBUGP("-- stall on control interface\n"); -- } else if (result != 0) { -- /* it's not a stall, but another error -- time to bail */ -- US_DEBUGP("-- Unknown error. Rejecting device\n"); -- goto BadDevice; -- } -- } --#endif -- - /* Get the transport, protocol, and pipe settings */ - result = get_transport(us); - if (result) ---- gregkh-2.6.orig/drivers/usb/storage/initializers.h -+++ gregkh-2.6/drivers/usb/storage/initializers.h -@@ -45,10 +45,6 @@ - * mode */ - int usb_stor_euscsi_init(struct us_data *us); - --#ifdef CONFIG_USB_STORAGE_SDDR09 --int sddr09_init(struct us_data *us); --#endif -- - /* This function is required to activate all four slots on the UCR-61S2B - * flash reader */ - int usb_stor_ucr61s2b_init(struct us_data *us); diff --git a/usb/usb-storage-fix-unusual_devs.h-order.patch b/usb/usb-storage-fix-unusual_devs.h-order.patch deleted file mode 100644 index ace2f3beb8942..0000000000000 --- a/usb/usb-storage-fix-unusual_devs.h-order.patch +++ /dev/null @@ -1,47 +0,0 @@ -From phil@ipom.com Sun Dec 18 21:36:08 2005 -Message-ID: <43A6455A.9020406@ipom.com> -Date: Sun, 18 Dec 2005 21:30:02 -0800 -From: Phil Dibowitz <phil@ipom.com> -To: Greg KH <greg@kroah.com>, USB Storage list <usb-storage@lists.one-eyed-alien.net> -Subject: USB Storage: Fix unusual_devs.h order - -Alan Stern pointed out there was an ordering issue in unusual_devs.h, -and this patch fixes it. - -Signed-off-by: Phil Dibowitz <phil@ipom.com> -Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> - ---- - drivers/usb/storage/unusual_devs.h | 14 +++++++------- - 1 file changed, 7 insertions(+), 7 deletions(-) - ---- gregkh-2.6.orig/drivers/usb/storage/unusual_devs.h -+++ gregkh-2.6/drivers/usb/storage/unusual_devs.h -@@ -79,13 +79,6 @@ UNUSUAL_DEV( 0x03f0, 0x0307, 0x0001, 0x - US_SC_8070, US_PR_USBAT, init_usbat, 0), - #endif - --/* Patch submitted by Mihnea-Costin Grigore <mihnea@zulu.ro> */ --UNUSUAL_DEV( 0x040d, 0x6205, 0x0003, 0x0003, -- "VIA Technologies Inc.", -- "USB 2.0 Card Reader", -- US_SC_DEVICE, US_PR_DEVICE, NULL, -- US_FL_IGNORE_RESIDUE ), -- - /* Reported by Sebastian Kapfer <sebastian_kapfer@gmx.net> - * and Olaf Hering <olh@suse.de> (different bcd's, same vendor/product) - * for USB floppies that need the SINGLE_LUN enforcement. -@@ -96,6 +89,13 @@ UNUSUAL_DEV( 0x0409, 0x0040, 0x0000, 0x - US_SC_DEVICE, US_PR_DEVICE, NULL, - US_FL_SINGLE_LUN ), - -+/* Patch submitted by Mihnea-Costin Grigore <mihnea@zulu.ro> */ -+UNUSUAL_DEV( 0x040d, 0x6205, 0x0003, 0x0003, -+ "VIA Technologies Inc.", -+ "USB 2.0 Card Reader", -+ US_SC_DEVICE, US_PR_DEVICE, NULL, -+ US_FL_IGNORE_RESIDUE ), -+ - /* Deduced by Jonathan Woithe <jwoithe@physics.adelaide.edu.au> - * Entry needed for flags: US_FL_FIX_INQUIRY because initial inquiry message - * always fails and confuses drive. diff --git a/usb/usb-storage-make-onetouch-pm-aware.patch b/usb/usb-storage-make-onetouch-pm-aware.patch deleted file mode 100644 index a9ffc85dc576d..0000000000000 --- a/usb/usb-storage-make-onetouch-pm-aware.patch +++ /dev/null @@ -1,131 +0,0 @@ -From mdharm@multivac.one-eyed-alien.net Sun Dec 4 22:01:27 2005 -Date: Sun, 4 Dec 2005 21:56:51 -0800 -From: Matthew Dharm <mdharm-usb@one-eyed-alien.net> -To: Greg KH <greg@kroah.com> -Subject: USB Storage: make OneTouch PM-aware -Message-ID: <20051205055651.GA15047@one-eyed-alien.net> -Content-Disposition: inline - -The OneTouch subdriver submits its own interrupt URB for notifications -about button presses. Consequently it needs to know about suspend and -resume events, so it can cancel or restart the URB. - -This patch (as593) adds a hook to struct us_data, to be used for -notifying subdrivers about Power Management events, and it implements -the hook in the OneTouch driver. - -Signed-off-by: Alan Stern <stern@rowland.harvard.edu> -Signed-off-by: Nick Sillik <n.sillik@temple.edu> -Signed-off-by: Matthew Dharm <mdharm-usb@one-eyed-alien.net> -Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> - ---- - drivers/usb/storage/onetouch.c | 27 +++++++++++++++++++++++++++ - drivers/usb/storage/usb.c | 4 ++++ - drivers/usb/storage/usb.h | 9 ++++++++- - 3 files changed, 39 insertions(+), 1 deletion(-) - ---- gregkh-2.6.orig/drivers/usb/storage/usb.c -+++ gregkh-2.6/drivers/usb/storage/usb.c -@@ -188,6 +188,8 @@ static int storage_suspend(struct usb_in - down(&us->dev_semaphore); - - US_DEBUGP("%s\n", __FUNCTION__); -+ if (us->suspend_resume_hook) -+ (us->suspend_resume_hook)(us, US_SUSPEND); - iface->dev.power.power_state.event = message.event; - - /* When runtime PM is working, we'll set a flag to indicate -@@ -204,6 +206,8 @@ static int storage_resume(struct usb_int - down(&us->dev_semaphore); - - US_DEBUGP("%s\n", __FUNCTION__); -+ if (us->suspend_resume_hook) -+ (us->suspend_resume_hook)(us, US_RESUME); - iface->dev.power.power_state.event = PM_EVENT_ON; - - up(&us->dev_semaphore); ---- gregkh-2.6.orig/drivers/usb/storage/usb.h -+++ gregkh-2.6/drivers/usb/storage/usb.h -@@ -93,7 +93,11 @@ struct us_unusual_dev { - typedef int (*trans_cmnd)(struct scsi_cmnd *, struct us_data*); - typedef int (*trans_reset)(struct us_data*); - typedef void (*proto_cmnd)(struct scsi_cmnd*, struct us_data*); --typedef void (*extra_data_destructor)(void *); /* extra data destructor */ -+typedef void (*extra_data_destructor)(void *); /* extra data destructor */ -+typedef void (*pm_hook)(struct us_data *, int); /* power management hook */ -+ -+#define US_SUSPEND 0 -+#define US_RESUME 1 - - /* we allocate one of these for every device that we remember */ - struct us_data { -@@ -149,6 +153,9 @@ struct us_data { - /* subdriver information */ - void *extra; /* Any extra data */ - extra_data_destructor extra_destructor;/* extra data destructor */ -+#ifdef CONFIG_PM -+ pm_hook suspend_resume_hook; -+#endif - }; - - /* Convert between us_data and the corresponding Scsi_Host */ ---- gregkh-2.6.orig/drivers/usb/storage/onetouch.c -+++ gregkh-2.6/drivers/usb/storage/onetouch.c -@@ -52,6 +52,7 @@ struct usb_onetouch { - struct urb *irq; /* urb for interrupt in report */ - unsigned char *data; /* input data */ - dma_addr_t data_dma; -+ unsigned int is_open:1; - }; - - static void usb_onetouch_irq(struct urb *urb, struct pt_regs *regs) -@@ -89,6 +90,7 @@ static int usb_onetouch_open(struct inpu - { - struct usb_onetouch *onetouch = dev->private; - -+ onetouch->is_open = 1; - onetouch->irq->dev = onetouch->udev; - if (usb_submit_urb(onetouch->irq, GFP_KERNEL)) { - err("usb_submit_urb failed"); -@@ -103,8 +105,30 @@ static void usb_onetouch_close(struct in - struct usb_onetouch *onetouch = dev->private; - - usb_kill_urb(onetouch->irq); -+ onetouch->is_open = 0; - } - -+#ifdef CONFIG_PM -+static void usb_onetouch_pm_hook(struct us_data *us, int action) -+{ -+ struct usb_onetouch *onetouch = (struct usb_onetouch *) us->extra; -+ -+ if (onetouch->is_open) { -+ switch (action) { -+ case US_SUSPEND: -+ usb_kill_urb(onetouch->irq); -+ break; -+ case US_RESUME: -+ if (usb_submit_urb(onetouch->irq, GFP_KERNEL) != 0) -+ err("usb_submit_urb failed"); -+ break; -+ default: -+ break; -+ } -+ } -+} -+#endif /* CONFIG_PM */ -+ - int onetouch_connect_input(struct us_data *ss) - { - struct usb_device *udev = ss->pusb_dev; -@@ -185,6 +209,9 @@ int onetouch_connect_input(struct us_dat - - ss->extra_destructor = onetouch_release_input; - ss->extra = onetouch; -+#ifdef CONFIG_PM -+ ss->suspend_resume_hook = usb_onetouch_pm_hook; -+#endif - - input_register_device(onetouch->dev); - diff --git a/usb/usb-storage-more-sddr09-cleanups.patch b/usb/usb-storage-more-sddr09-cleanups.patch deleted file mode 100644 index fb4be50bd3e0b..0000000000000 --- a/usb/usb-storage-more-sddr09-cleanups.patch +++ /dev/null @@ -1,101 +0,0 @@ -From mdharm@multivac.one-eyed-alien.net Sun Dec 4 22:01:57 2005 -Date: Sun, 4 Dec 2005 21:59:45 -0800 -From: Matthew Dharm <mdharm-usb@one-eyed-alien.net> -To: Greg KH <greg@kroah.com> -Subject: USB Storage: more sddr09 cleanups -Message-ID: <20051205055945.GD15047@one-eyed-alien.net> -Content-Disposition: inline - -This is the third of three patches to prepare the sddr09 subdriver for -conversion to the Sim-SCSI framework. This patch (as596) moves the -computation of the LBA to the start of the read/write routines, so that -addresses completely beyond the end of the device can be detected and -reported differently from transfers that are partially within the -device's capacity. - -Signed-off-by: Alan Stern <stern@rowland.harvard.edu> -Acked-by: Andries Brouwer <Andries.Brouwer@cwi.nl> -Signed-off-by: Matthew Dharm <mdharm-usb@one-eyed-alien.net> -Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> - - ---- - drivers/usb/storage/sddr09.c | 33 +++++++++++++++++++++++---------- - 1 file changed, 23 insertions(+), 10 deletions(-) - ---- gregkh-2.6.orig/drivers/usb/storage/sddr09.c -+++ gregkh-2.6/drivers/usb/storage/sddr09.c -@@ -711,6 +711,13 @@ sddr09_read_data(struct us_data *us, - unsigned int len, index, offset; - int result; - -+ // Figure out the initial LBA and page -+ lba = address >> info->blockshift; -+ page = (address & info->blockmask); -+ maxlba = info->capacity >> (info->pageshift + info->blockshift); -+ if (lba >= maxlba) -+ return -EIO; -+ - // Since we only read in one block at a time, we have to create - // a bounce buffer and move the data a piece at a time between the - // bounce buffer and the actual transfer buffer. -@@ -722,11 +729,6 @@ sddr09_read_data(struct us_data *us, - return -ENOMEM; - } - -- // Figure out the initial LBA and page -- lba = address >> info->blockshift; -- page = (address & info->blockmask); -- maxlba = info->capacity >> (info->pageshift + info->blockshift); -- - // This could be made much more efficient by checking for - // contiguous LBA's. Another exercise left to the student. - -@@ -928,13 +930,20 @@ sddr09_write_data(struct us_data *us, - unsigned int sectors) { - - struct sddr09_card_info *info = (struct sddr09_card_info *) us->extra; -- unsigned int lba, page, pages; -+ unsigned int lba, maxlba, page, pages; - unsigned int pagelen, blocklen; - unsigned char *blockbuffer; - unsigned char *buffer; - unsigned int len, index, offset; - int result; - -+ // Figure out the initial LBA and page -+ lba = address >> info->blockshift; -+ page = (address & info->blockmask); -+ maxlba = info->capacity >> (info->pageshift + info->blockshift); -+ if (lba >= maxlba) -+ return -EIO; -+ - // blockbuffer is used for reading in the old data, overwriting - // with the new data, and performing ECC calculations - -@@ -961,10 +970,6 @@ sddr09_write_data(struct us_data *us, - return -ENOMEM; - } - -- // Figure out the initial LBA and page -- lba = address >> info->blockshift; -- page = (address & info->blockmask); -- - result = 0; - index = offset = 0; - -@@ -975,6 +980,14 @@ sddr09_write_data(struct us_data *us, - pages = min(sectors, info->blocksize - page); - len = (pages << info->pageshift); - -+ /* Not overflowing capacity? */ -+ if (lba >= maxlba) { -+ US_DEBUGP("Error: Requested lba %u exceeds " -+ "maximum %u\n", lba, maxlba); -+ result = -EIO; -+ break; -+ } -+ - // Get the data from the transfer buffer - usb_stor_access_xfer_buf(buffer, len, us->srb, - &index, &offset, FROM_XFER_BUF); diff --git a/usb/usb-storage-sddr09-cleanups.patch b/usb/usb-storage-sddr09-cleanups.patch deleted file mode 100644 index ebdd7a55b8219..0000000000000 --- a/usb/usb-storage-sddr09-cleanups.patch +++ /dev/null @@ -1,395 +0,0 @@ -From mdharm@multivac.one-eyed-alien.net Sun Dec 4 22:01:52 2005 -Date: Sun, 4 Dec 2005 21:58:52 -0800 -From: Matthew Dharm <mdharm-usb@one-eyed-alien.net> -To: Greg KH <greg@kroah.com> -Subject: USB Storage: sddr09 cleanups -Message-ID: <20051205055852.GC15047@one-eyed-alien.net> -Content-Disposition: inline - -This is the second of three patches to prepare the sddr09 subdriver for -conversion to the Sim-SCSI framework. This patch (as595) updates the -code to use standard error values for return codes instead of our -special-purpose USB_STOR_TRANSPORT_... codes. The reverse update is -then needed in the transport routine, but with the Sim-SCSI framework -that routine will go away. - -Signed-off-by: Alan Stern <stern@rowland.harvard.edu> -Acked-by: Andries Brouwer <Andries.Brouwer@cwi.nl> -Signed-off-by: Matthew Dharm <mdharm-usb@one-eyed-alien.net> -Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> - ---- - drivers/usb/storage/sddr09.c | 103 ++++++++++++++++++++----------------------- - 1 file changed, 50 insertions(+), 53 deletions(-) - ---- gregkh-2.6.orig/drivers/usb/storage/sddr09.c -+++ gregkh-2.6/drivers/usb/storage/sddr09.c -@@ -274,8 +274,11 @@ sddr09_send_command(struct us_data *us, - - rc = usb_stor_ctrl_transfer(us, pipe, request, requesttype, - 0, 0, xfer_data, xfer_len); -- return (rc == USB_STOR_XFER_GOOD ? USB_STOR_TRANSPORT_GOOD : -- USB_STOR_TRANSPORT_ERROR); -+ switch (rc) { -+ case USB_STOR_XFER_GOOD: return 0; -+ case USB_STOR_XFER_STALLED: return -EPIPE; -+ default: return -EIO; -+ } - } - - static int -@@ -322,20 +325,12 @@ sddr09_request_sense(struct us_data *us, - command[4] = buflen; - - result = sddr09_send_scsi_command(us, command, 12); -- if (result != USB_STOR_TRANSPORT_GOOD) { -- US_DEBUGP("request sense failed\n"); -+ if (result) - return result; -- } - - result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, - sensebuf, buflen, NULL); -- if (result != USB_STOR_XFER_GOOD) { -- US_DEBUGP("request sense bulk in failed\n"); -- return USB_STOR_TRANSPORT_ERROR; -- } else { -- US_DEBUGP("request sense worked\n"); -- return USB_STOR_TRANSPORT_GOOD; -- } -+ return (result == USB_STOR_XFER_GOOD ? 0 : -EIO); - } - - /* -@@ -383,7 +378,7 @@ sddr09_readX(struct us_data *us, int x, - - result = sddr09_send_scsi_command(us, command, 12); - -- if (result != USB_STOR_TRANSPORT_GOOD) { -+ if (result) { - US_DEBUGP("Result for send_control in sddr09_read2%d %d\n", - x, result); - return result; -@@ -395,9 +390,9 @@ sddr09_readX(struct us_data *us, int x, - if (result != USB_STOR_XFER_GOOD) { - US_DEBUGP("Result for bulk_transfer in sddr09_read2%d %d\n", - x, result); -- return USB_STOR_TRANSPORT_ERROR; -+ return -EIO; - } -- return USB_STOR_TRANSPORT_GOOD; -+ return 0; - } - - /* -@@ -511,7 +506,7 @@ sddr09_erase(struct us_data *us, unsigne - - result = sddr09_send_scsi_command(us, command, 12); - -- if (result != USB_STOR_TRANSPORT_GOOD) -+ if (result) - US_DEBUGP("Result for send_control in sddr09_erase %d\n", - result); - -@@ -569,7 +564,7 @@ sddr09_writeX(struct us_data *us, - - result = sddr09_send_scsi_command(us, command, 12); - -- if (result != USB_STOR_TRANSPORT_GOOD) { -+ if (result) { - US_DEBUGP("Result for send_control in sddr09_writeX %d\n", - result); - return result; -@@ -581,9 +576,9 @@ sddr09_writeX(struct us_data *us, - if (result != USB_STOR_XFER_GOOD) { - US_DEBUGP("Result for bulk_transfer in sddr09_writeX %d\n", - result); -- return USB_STOR_TRANSPORT_ERROR; -+ return -EIO; - } -- return USB_STOR_TRANSPORT_GOOD; -+ return 0; - } - - /* erase address, write same address */ -@@ -647,7 +642,7 @@ sddr09_read_sg_test_only(struct us_data - - result = sddr09_send_scsi_command(us, command, 4*nsg+3); - -- if (result != USB_STOR_TRANSPORT_GOOD) { -+ if (result) { - US_DEBUGP("Result for send_control in sddr09_read_sg %d\n", - result); - return result; -@@ -655,7 +650,7 @@ sddr09_read_sg_test_only(struct us_data - - buf = (unsigned char *) kmalloc(bulklen, GFP_NOIO); - if (!buf) -- return USB_STOR_TRANSPORT_ERROR; -+ return -ENOMEM; - - result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, - buf, bulklen, NULL); -@@ -663,10 +658,10 @@ sddr09_read_sg_test_only(struct us_data - if (result != USB_STOR_XFER_GOOD) { - US_DEBUGP("Result for bulk_transfer in sddr09_read_sg %d\n", - result); -- return USB_STOR_TRANSPORT_ERROR; -+ return -EIO; - } - -- return USB_STOR_TRANSPORT_GOOD; -+ return 0; - } - #endif - -@@ -695,14 +690,13 @@ sddr09_read_status(struct us_data *us, u - command[1] = LUNBITS; - - result = sddr09_send_scsi_command(us, command, 12); -- if (result != USB_STOR_TRANSPORT_GOOD) -+ if (result) - return result; - - result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, - data, 64, NULL); - *status = data[0]; -- return (result == USB_STOR_XFER_GOOD ? -- USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR); -+ return (result == USB_STOR_XFER_GOOD ? 0 : -EIO); - } - - static int -@@ -725,7 +719,7 @@ sddr09_read_data(struct us_data *us, - buffer = kmalloc(len, GFP_NOIO); - if (buffer == NULL) { - printk("sddr09_read_data: Out of memory\n"); -- return USB_STOR_TRANSPORT_ERROR; -+ return -ENOMEM; - } - - // Figure out the initial LBA and page -@@ -736,7 +730,7 @@ sddr09_read_data(struct us_data *us, - // This could be made much more efficient by checking for - // contiguous LBA's. Another exercise left to the student. - -- result = USB_STOR_TRANSPORT_GOOD; -+ result = 0; - index = offset = 0; - - while (sectors > 0) { -@@ -749,7 +743,7 @@ sddr09_read_data(struct us_data *us, - if (lba >= maxlba) { - US_DEBUGP("Error: Requested lba %u exceeds " - "maximum %u\n", lba, maxlba); -- result = USB_STOR_TRANSPORT_ERROR; -+ result = -EIO; - break; - } - -@@ -763,7 +757,7 @@ sddr09_read_data(struct us_data *us, - - /* This is not really an error. It just means - that the block has never been written. -- Instead of returning USB_STOR_TRANSPORT_ERROR -+ Instead of returning an error - it is better to return all zero data. */ - - memset(buffer, 0, len); -@@ -778,7 +772,7 @@ sddr09_read_data(struct us_data *us, - - result = sddr09_read20(us, address>>1, - pages, info->pageshift, buffer, 0); -- if (result != USB_STOR_TRANSPORT_GOOD) -+ if (result) - break; - } - -@@ -844,7 +838,7 @@ sddr09_write_lba(struct us_data *us, uns - pba = sddr09_find_unused_pba(info, lba); - if (!pba) { - printk("sddr09_write_lba: Out of unused blocks\n"); -- return USB_STOR_TRANSPORT_ERROR; -+ return -ENOSPC; - } - info->pba_to_lba[pba] = lba; - info->lba_to_pba[lba] = pba; -@@ -855,7 +849,7 @@ sddr09_write_lba(struct us_data *us, uns - /* Maybe it is impossible to write to PBA 1. - Fake success, but don't do anything. */ - printk("sddr09: avoid writing to pba 1\n"); -- return USB_STOR_TRANSPORT_GOOD; -+ return 0; - } - - pagelen = (1 << info->pageshift) + (1 << CONTROL_SHIFT); -@@ -864,7 +858,7 @@ sddr09_write_lba(struct us_data *us, uns - address = (pba << (info->pageshift + info->blockshift)); - result = sddr09_read22(us, address>>1, info->blocksize, - info->pageshift, blockbuffer, 0); -- if (result != USB_STOR_TRANSPORT_GOOD) -+ if (result) - return result; - - /* check old contents and fill lba */ -@@ -911,7 +905,7 @@ sddr09_write_lba(struct us_data *us, uns - { - unsigned char status = 0; - int result2 = sddr09_read_status(us, &status); -- if (result2 != USB_STOR_TRANSPORT_GOOD) -+ if (result2) - US_DEBUGP("sddr09_write_inplace: cannot read status\n"); - else if (status != 0xc0) - US_DEBUGP("sddr09_write_inplace: status after write: 0x%x\n", -@@ -952,7 +946,7 @@ sddr09_write_data(struct us_data *us, - blockbuffer = kmalloc(blocklen, GFP_NOIO); - if (!blockbuffer) { - printk("sddr09_write_data: Out of memory\n"); -- return USB_STOR_TRANSPORT_ERROR; -+ return -ENOMEM; - } - - // Since we don't write the user data directly to the device, -@@ -964,14 +958,14 @@ sddr09_write_data(struct us_data *us, - if (buffer == NULL) { - printk("sddr09_write_data: Out of memory\n"); - kfree(blockbuffer); -- return USB_STOR_TRANSPORT_ERROR; -+ return -ENOMEM; - } - - // Figure out the initial LBA and page - lba = address >> info->blockshift; - page = (address & info->blockmask); - -- result = USB_STOR_TRANSPORT_GOOD; -+ result = 0; - index = offset = 0; - - while (sectors > 0) { -@@ -987,7 +981,7 @@ sddr09_write_data(struct us_data *us, - - result = sddr09_write_lba(us, lba, page, pages, - buffer, blockbuffer); -- if (result != USB_STOR_TRANSPORT_GOOD) -+ if (result) - break; - - page = 0; -@@ -1036,7 +1030,7 @@ sddr09_read_deviceID(struct us_data *us, - command[1] = LUNBITS; - - result = sddr09_send_scsi_command(us, command, 12); -- if (result != USB_STOR_TRANSPORT_GOOD) -+ if (result) - return result; - - result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, -@@ -1045,8 +1039,7 @@ sddr09_read_deviceID(struct us_data *us, - for (i = 0; i < 4; i++) - deviceID[i] = content[i]; - -- return (result == USB_STOR_XFER_GOOD ? -- USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR); -+ return (result == USB_STOR_XFER_GOOD ? 0 : -EIO); - } - - static int -@@ -1055,7 +1048,7 @@ sddr09_get_wp(struct us_data *us, struct - unsigned char status; - - result = sddr09_read_status(us, &status); -- if (result != USB_STOR_TRANSPORT_GOOD) { -+ if (result) { - US_DEBUGP("sddr09_get_wp: read_status fails\n"); - return result; - } -@@ -1071,7 +1064,7 @@ sddr09_get_wp(struct us_data *us, struct - if (status & 0x1) - US_DEBUGP(" Error"); - US_DEBUGP("\n"); -- return USB_STOR_TRANSPORT_GOOD; -+ return 0; - } - - #if 0 -@@ -1103,7 +1096,7 @@ sddr09_get_cardinfo(struct us_data *us, - - result = sddr09_read_deviceID(us, deviceID); - -- if (result != USB_STOR_TRANSPORT_GOOD) { -+ if (result) { - US_DEBUGP("Result of read_deviceID is %d\n", result); - printk("sddr09: could not read card info\n"); - return NULL; -@@ -1214,7 +1207,7 @@ sddr09_read_map(struct us_data *us) { - us, address>>1, - min(alloc_blocks, numblocks - i), - buffer, 0); -- if (result != USB_STOR_TRANSPORT_GOOD) { -+ if (result) { - result = -1; - goto done; - } -@@ -1402,7 +1395,7 @@ usb_stor_sddr09_dpcm_init(struct us_data - return result; - - result = sddr09_send_command(us, 0x01, USB_DIR_IN, data, 2); -- if (result != USB_STOR_TRANSPORT_GOOD) { -+ if (result) { - US_DEBUGP("sddr09_init: send_command fails\n"); - return result; - } -@@ -1411,7 +1404,7 @@ usb_stor_sddr09_dpcm_init(struct us_data - // get 07 02 - - result = sddr09_send_command(us, 0x08, USB_DIR_IN, data, 2); -- if (result != USB_STOR_TRANSPORT_GOOD) { -+ if (result) { - US_DEBUGP("sddr09_init: 2nd send_command fails\n"); - return result; - } -@@ -1420,7 +1413,7 @@ usb_stor_sddr09_dpcm_init(struct us_data - // get 07 00 - - result = sddr09_request_sense(us, data, 18); -- if (result == USB_STOR_TRANSPORT_GOOD && data[2] != 0) { -+ if (result == 0 && data[2] != 0) { - int j; - for (j=0; j<18; j++) - printk(" %02X", data[j]); -@@ -1567,7 +1560,9 @@ int sddr09_transport(struct scsi_cmnd *s - US_DEBUGP("READ_10: read page %d pagect %d\n", - page, pages); - -- return sddr09_read_data(us, page, pages); -+ result = sddr09_read_data(us, page, pages); -+ return (result == 0 ? USB_STOR_TRANSPORT_GOOD : -+ USB_STOR_TRANSPORT_ERROR); - } - - if (srb->cmnd[0] == WRITE_10) { -@@ -1580,7 +1575,9 @@ int sddr09_transport(struct scsi_cmnd *s - US_DEBUGP("WRITE_10: write page %d pagect %d\n", - page, pages); - -- return sddr09_write_data(us, page, pages); -+ result = sddr09_write_data(us, page, pages); -+ return (result == 0 ? USB_STOR_TRANSPORT_GOOD : -+ USB_STOR_TRANSPORT_ERROR); - } - - /* catch-all for all other commands, except -@@ -1606,10 +1603,10 @@ int sddr09_transport(struct scsi_cmnd *s - US_DEBUGP("SDDR09: Send control for command %s\n", ptr); - - result = sddr09_send_scsi_command(us, srb->cmnd, 12); -- if (result != USB_STOR_TRANSPORT_GOOD) { -+ if (result) { - US_DEBUGP("sddr09_transport: sddr09_send_scsi_command " - "returns %d\n", result); -- return result; -+ return USB_STOR_TRANSPORT_ERROR; - } - - if (srb->request_bufflen == 0) diff --git a/usb/usb-storage-update-maintainers.patch b/usb/usb-storage-update-maintainers.patch deleted file mode 100644 index 62102b7a90df5..0000000000000 --- a/usb/usb-storage-update-maintainers.patch +++ /dev/null @@ -1,29 +0,0 @@ -From mdharm@multivac.one-eyed-alien.net Sun Dec 4 22:07:14 2005 -Date: Sun, 4 Dec 2005 22:03:47 -0800 -From: Matthew Dharm <mdharm-usb@one-eyed-alien.net> -To: Greg KH <greg@kroah.com> -Subject: USB Storage: update MAINTAINERS -Message-ID: <20051205060347.GF15047@one-eyed-alien.net> -Content-Disposition: inline - -Someone recently pointed out to me that the MAINTAINERS entry for -usb-storage was, perhaps, in need of changing. - -Signed-off-by: Matthew Dharm <mdharm-usb@one-eyed-alien.net> -Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> - ---- - MAINTAINERS | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- gregkh-2.6.orig/MAINTAINERS -+++ gregkh-2.6/MAINTAINERS -@@ -2658,7 +2658,7 @@ USB MASS STORAGE DRIVER - P: Matthew Dharm - M: mdharm-usb@one-eyed-alien.net - L: linux-usb-users@lists.sourceforge.net --L: linux-usb-devel@lists.sourceforge.net -+L: usb-storage@lists.one-eyed-alien.net - S: Maintained - W: http://www.one-eyed-alien.net/~mdharm/linux-usb/ - diff --git a/usb/usb-store-port-number-in-usb_device.patch b/usb/usb-store-port-number-in-usb_device.patch deleted file mode 100644 index bcabafef8b220..0000000000000 --- a/usb/usb-store-port-number-in-usb_device.patch +++ /dev/null @@ -1,181 +0,0 @@ -From stern@rowland.harvard.edu Wed Nov 23 10:03:10 2005 -Date: Wed, 23 Nov 2005 12:09:52 -0500 (EST) -From: Alan Stern <stern@rowland.harvard.edu> -To: Greg KH <greg@kroah.com> -Subject: USB: Store port number in usb_device -Message-ID: <Pine.LNX.4.44L0.0511231204280.12957-100000@iolanthe.rowland.org> - -This patch (as610) adds a field to struct usb_device to store the device's -port number. This allows us to remove several loops in the hub driver -(searching for a particular device among all the entries in the parent's -array of children). - -Signed-off-by: Alan Stern <stern@rowland.harvard.edu> -Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> - ---- - drivers/usb/core/hub.c | 79 +++++++++++-------------------------------------- - drivers/usb/core/usb.c | 1 - include/linux/usb.h | 1 - 3 files changed, 20 insertions(+), 61 deletions(-) - ---- gregkh-2.6.orig/drivers/usb/core/hub.c -+++ gregkh-2.6/drivers/usb/core/hub.c -@@ -946,24 +946,21 @@ static int locktree(struct usb_device *u - t = locktree(hdev); - if (t < 0) - return t; -- for (t = 0; t < hdev->maxchild; t++) { -- if (hdev->children[t] == udev) { -- /* everything is fail-fast once disconnect -- * processing starts -- */ -- if (udev->state == USB_STATE_NOTATTACHED) -- break; - -- /* when everyone grabs locks top->bottom, -- * non-overlapping work may be concurrent -- */ -- usb_lock_device(udev); -- usb_unlock_device(hdev); -- return t + 1; -- } -+ /* everything is fail-fast once disconnect -+ * processing starts -+ */ -+ if (udev->state == USB_STATE_NOTATTACHED) { -+ usb_unlock_device(hdev); -+ return -ENODEV; - } -+ -+ /* when everyone grabs locks top->bottom, -+ * non-overlapping work may be concurrent -+ */ -+ usb_lock_device(udev); - usb_unlock_device(hdev); -- return -ENODEV; -+ return udev->portnum; - } - - static void recursively_mark_NOTATTACHED(struct usb_device *udev) -@@ -1335,15 +1332,9 @@ int usb_new_device(struct usb_device *ud - le16_to_cpu(udev->config[0].desc.wTotalLength), - USB_DT_OTG, (void **) &desc) == 0) { - if (desc->bmAttributes & USB_OTG_HNP) { -- unsigned port1; -+ unsigned port1 = udev->portnum; - struct usb_device *root = udev->parent; - -- for (port1 = 1; port1 <= root->maxchild; -- port1++) { -- if (root->children[port1-1] == udev) -- break; -- } -- - dev_info(&udev->dev, - "Dual-Role OTG device on %sHNP port\n", - (port1 == bus->otg_port) -@@ -1720,22 +1711,9 @@ static int __usb_suspend_device (struct - int usb_suspend_device(struct usb_device *udev) - { - #ifdef CONFIG_USB_SUSPEND -- int port1; -- - if (udev->state == USB_STATE_NOTATTACHED) - return -ENODEV; -- if (!udev->parent) -- port1 = 0; -- else { -- for (port1 = udev->parent->maxchild; port1 > 0; --port1) { -- if (udev->parent->children[port1-1] == udev) -- break; -- } -- if (port1 == 0) -- return -ENODEV; -- } -- -- return __usb_suspend_device(udev, port1); -+ return __usb_suspend_device(udev, udev->portnum); - #else - /* NOTE: udev->state unchanged, it's not lying ... */ - udev->dev.power.power_state = PMSG_SUSPEND; -@@ -1893,20 +1871,10 @@ hub_port_resume(struct usb_hub *hub, int - */ - int usb_resume_device(struct usb_device *udev) - { -- int port1, status; -+ int status; - - if (udev->state == USB_STATE_NOTATTACHED) - return -ENODEV; -- if (!udev->parent) -- port1 = 0; -- else { -- for (port1 = udev->parent->maxchild; port1 > 0; --port1) { -- if (udev->parent->children[port1-1] == udev) -- break; -- } -- if (port1 == 0) -- return -ENODEV; -- } - - #ifdef CONFIG_USB_SUSPEND - /* selective resume of one downstream hub-to-device port */ -@@ -1915,7 +1883,7 @@ int usb_resume_device(struct usb_device - // NOTE swsusp may bork us, device state being wrong... - // NOTE this fails if parent is also suspended... - status = hub_port_resume(hdev_to_hub(udev->parent), -- port1, udev); -+ udev->portnum, udev); - } else - status = 0; - } else -@@ -3029,7 +2997,8 @@ int usb_reset_device(struct usb_device * - struct usb_hub *parent_hub; - struct usb_device_descriptor descriptor = udev->descriptor; - struct usb_hub *hub = NULL; -- int i, ret = 0, port1 = -1; -+ int i, ret = 0; -+ int port1 = udev->portnum; - - if (udev->state == USB_STATE_NOTATTACHED || - udev->state == USB_STATE_SUSPENDED) { -@@ -3043,18 +3012,6 @@ int usb_reset_device(struct usb_device * - dev_dbg(&udev->dev, "%s for root hub!\n", __FUNCTION__); - return -EISDIR; - } -- -- for (i = 0; i < parent_hdev->maxchild; i++) -- if (parent_hdev->children[i] == udev) { -- port1 = i + 1; -- break; -- } -- -- if (port1 < 0) { -- /* If this ever happens, it's very bad */ -- dev_err(&udev->dev, "Can't locate device's port!\n"); -- return -ENOENT; -- } - parent_hub = hdev_to_hub(parent_hdev); - - /* If we're resetting an active hub, take some special actions */ ---- gregkh-2.6.orig/include/linux/usb.h -+++ gregkh-2.6/include/linux/usb.h -@@ -348,6 +348,7 @@ struct usb_device { - char **rawdescriptors; /* Raw descriptors for each config */ - - unsigned short bus_mA; /* Current available from the bus */ -+ u8 portnum; /* Parent port number (origin 1) */ - - int have_langid; /* whether string_langid is valid */ - int string_langid; /* language ID for strings */ ---- gregkh-2.6.orig/drivers/usb/core/usb.c -+++ gregkh-2.6/drivers/usb/core/usb.c -@@ -436,6 +436,7 @@ usb_alloc_dev(struct usb_device *parent, - /* hub driver sets up TT records */ - } - -+ dev->portnum = port1; - dev->bus = bus; - dev->parent = parent; - INIT_LIST_HEAD(&dev->filelist); diff --git a/usb/usb-support-for-posiflex-pp-7000-retail-printer-in-linux.patch b/usb/usb-support-for-posiflex-pp-7000-retail-printer-in-linux.patch deleted file mode 100644 index 8942ce4f453e7..0000000000000 --- a/usb/usb-support-for-posiflex-pp-7000-retail-printer-in-linux.patch +++ /dev/null @@ -1,44 +0,0 @@ -From sonic_amiga@rambler.ru Fri Dec 9 01:27:44 2005 -Message-ID: <439924A3.9050800@rambler.ru> -Date: Fri, 09 Dec 2005 09:30:59 +0300 -From: Pavel Fedin <sonic_amiga@rambler.ru> -To: greg@kroah.com -Subject: USB: Support for Posiflex PP-7000 retail printer in Linux - -This little patch adds recognition of Posiflex PP-7000 retail printer to -ftdo_sio module. The printer uses FT232BM bridge programmed with custom -VID/PID. The patch posted to lkml and sf.net was for 2.6.11.1 kernel, -here is one reworked for 2.6.12. - -Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> - ---- - drivers/usb/serial/ftdi_sio.c | 1 + - drivers/usb/serial/ftdi_sio.h | 6 ++++++ - 2 files changed, 7 insertions(+) - ---- gregkh-2.6.orig/drivers/usb/serial/ftdi_sio.c -+++ gregkh-2.6/drivers/usb/serial/ftdi_sio.c -@@ -477,6 +477,7 @@ static struct usb_device_id id_table_com - { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16HR_PID) }, - { USB_DEVICE(KOBIL_VID, KOBIL_CONV_B1_PID) }, - { USB_DEVICE(KOBIL_VID, KOBIL_CONV_KAAN_PID) }, -+ { USB_DEVICE(POSIFLEX_VID, POSIFLEX_PP7000_PID) }, - { }, /* Optional parameter entry */ - { } /* Terminating entry */ - }; ---- gregkh-2.6.orig/drivers/usb/serial/ftdi_sio.h -+++ gregkh-2.6/drivers/usb/serial/ftdi_sio.h -@@ -352,6 +352,12 @@ - /* Pyramid Computer GmbH */ - #define FTDI_PYRAMID_PID 0xE6C8 /* Pyramid Appliance Display */ - -+/* -+ * Posiflex inc retail equipment (http://www.posiflex.com.tw) -+ */ -+#define POSIFLEX_VID 0x0d3a /* Vendor ID */ -+#define POSIFLEX_PP7000_PID 0x0300 /* PP-7000II thermal printer */ -+ - /* Commands */ - #define FTDI_SIO_RESET 0 /* Reset the port */ - #define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */ diff --git a/usb/usb-ub-00-implement-retries-and-resets.patch b/usb/usb-ub-00-implement-retries-and-resets.patch deleted file mode 100644 index 8172a20d3d4e4..0000000000000 --- a/usb/usb-ub-00-implement-retries-and-resets.patch +++ /dev/null @@ -1,748 +0,0 @@ -From zaitcev@redhat.com Sat Dec 17 02:17:55 2005 -Date: Sat, 17 Dec 2005 02:16:43 -0800 -From: Pete Zaitcev <zaitcev@redhat.com> -To: greg@kroah.com -Cc: zaitcev@redhat.com -Subject: usb: ub 00 implement retries and resets -Message-Id: <20051217021643.01ff8b56.zaitcev@redhat.com> - -Implement command retries and resets in ub. It is advantageous for users -to know if their devices are getting bad. However, failing every I/O -is not practical if you have a external USB enclosure with a hard drive. - -Signed-off-by: Pete Zaitcev <zaitcev@redhat.com> -Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> - ---- - drivers/block/ub.c | 404 +++++++++++++++++++++++++++++++++++++---------------- - 1 file changed, 287 insertions(+), 117 deletions(-) - ---- gregkh-2.6.orig/drivers/block/ub.c -+++ gregkh-2.6/drivers/block/ub.c -@@ -9,7 +9,6 @@ - * - * TODO (sorted by decreasing priority) - * -- Kill first_open (Al Viro fixed the block layer now) -- * -- Do resets with usb_device_reset (needs a thread context, use khubd) - * -- set readonly flag for CDs, set removable flag for CF readers - * -- do inquiry and verify we got a disk and not a tape (for LUN mismatch) - * -- special case some senses, e.g. 3a/0 -> no media present, reduce retries -@@ -236,6 +235,13 @@ struct ub_scsi_cmd { - void *back; - }; - -+struct ub_request { -+ struct request *rq; -+ unsigned int current_try; -+ unsigned int nsg; /* sgv[nsg] */ -+ struct scatterlist sgv[UB_MAX_REQ_SG]; -+}; -+ - /* - */ - struct ub_capacity { -@@ -331,6 +337,8 @@ struct ub_lun { - int readonly; - int first_open; /* Kludge. See ub_bd_open. */ - -+ struct ub_request urq; -+ - /* Use Ingo's mempool if or when we have more than one command. */ - /* - * Currently we never need more than one command for the whole device. -@@ -351,6 +359,7 @@ struct ub_dev { - atomic_t poison; /* The USB device is disconnected */ - int openc; /* protected by ub_lock! */ - /* kref is too implicit for our taste */ -+ int reset; /* Reset is running */ - unsigned int tagcnt; - char name[12]; - struct usb_device *dev; -@@ -378,6 +387,9 @@ struct ub_dev { - struct bulk_cs_wrap work_bcs; - struct usb_ctrlrequest work_cr; - -+ struct work_struct reset_work; -+ wait_queue_head_t reset_wait; -+ - int sg_stat[6]; - struct ub_scsi_trace tr; - }; -@@ -386,12 +398,14 @@ struct ub_dev { - */ - static void ub_cleanup(struct ub_dev *sc); - static int ub_request_fn_1(struct ub_lun *lun, struct request *rq); --static int ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, -- struct ub_scsi_cmd *cmd, struct request *rq); --static int ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun, -- struct ub_scsi_cmd *cmd, struct request *rq); -+static void ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, -+ struct ub_scsi_cmd *cmd, struct ub_request *urq); -+static void ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun, -+ struct ub_scsi_cmd *cmd, struct ub_request *urq); - static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd); - static void ub_end_rq(struct request *rq, int uptodate); -+static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun, -+ struct ub_request *urq, struct ub_scsi_cmd *cmd); - static int ub_submit_scsi(struct ub_dev *sc, struct ub_scsi_cmd *cmd); - static void ub_urb_complete(struct urb *urb, struct pt_regs *pt); - static void ub_scsi_action(unsigned long _dev); -@@ -406,6 +420,8 @@ static void ub_state_sense(struct ub_dev - static int ub_submit_clear_stall(struct ub_dev *sc, struct ub_scsi_cmd *cmd, - int stalled_pipe); - static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd); -+static void ub_reset_enter(struct ub_dev *sc); -+static void ub_reset_task(void *arg); - static int ub_sync_tur(struct ub_dev *sc, struct ub_lun *lun); - static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun, - struct ub_capacity *ret); -@@ -518,6 +534,9 @@ static ssize_t ub_diag_show(struct devic - spin_lock_irqsave(&sc->lock, flags); - - cnt += sprintf(page + cnt, -+ "poison %d reset %d\n", -+ atomic_read(&sc->poison), sc->reset); -+ cnt += sprintf(page + cnt, - "qlen %d qmax %d\n", - sc->cmd_queue.qlen, sc->cmd_queue.qmax); - cnt += sprintf(page + cnt, -@@ -766,7 +785,8 @@ static int ub_request_fn_1(struct ub_lun - { - struct ub_dev *sc = lun->udev; - struct ub_scsi_cmd *cmd; -- int rc; -+ struct ub_request *urq; -+ int n_elem; - - if (atomic_read(&sc->poison) || lun->changed) { - blkdev_dequeue_request(rq); -@@ -774,65 +794,70 @@ static int ub_request_fn_1(struct ub_lun - return 0; - } - -+ if (lun->urq.rq != NULL) -+ return -1; - if ((cmd = ub_get_cmd(lun)) == NULL) - return -1; - memset(cmd, 0, sizeof(struct ub_scsi_cmd)); - - blkdev_dequeue_request(rq); -+ -+ urq = &lun->urq; -+ memset(urq, 0, sizeof(struct ub_request)); -+ urq->rq = rq; -+ -+ /* -+ * get scatterlist from block layer -+ */ -+ n_elem = blk_rq_map_sg(lun->disk->queue, rq, &urq->sgv[0]); -+ if (n_elem < 0) { -+ printk(KERN_INFO "%s: failed request map (%d)\n", -+ lun->name, n_elem); /* P3 */ -+ goto drop; -+ } -+ if (n_elem > UB_MAX_REQ_SG) { /* Paranoia */ -+ printk(KERN_WARNING "%s: request with %d segments\n", -+ lun->name, n_elem); -+ goto drop; -+ } -+ urq->nsg = n_elem; -+ sc->sg_stat[n_elem < 5 ? n_elem : 5]++; -+ - if (blk_pc_request(rq)) { -- rc = ub_cmd_build_packet(sc, lun, cmd, rq); -+ ub_cmd_build_packet(sc, lun, cmd, urq); - } else { -- rc = ub_cmd_build_block(sc, lun, cmd, rq); -- } -- if (rc != 0) { -- ub_put_cmd(lun, cmd); -- ub_end_rq(rq, 0); -- return 0; -+ ub_cmd_build_block(sc, lun, cmd, urq); - } - cmd->state = UB_CMDST_INIT; - cmd->lun = lun; - cmd->done = ub_rw_cmd_done; -- cmd->back = rq; -+ cmd->back = urq; - - cmd->tag = sc->tagcnt++; -- if (ub_submit_scsi(sc, cmd) != 0) { -- ub_put_cmd(lun, cmd); -- ub_end_rq(rq, 0); -- return 0; -- } -+ if (ub_submit_scsi(sc, cmd) != 0) -+ goto drop; - - return 0; -+ -+drop: -+ ub_put_cmd(lun, cmd); -+ ub_end_rq(rq, 0); -+ return 0; - } - --static int ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, -- struct ub_scsi_cmd *cmd, struct request *rq) -+static void ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, -+ struct ub_scsi_cmd *cmd, struct ub_request *urq) - { -- int ub_dir; -- int n_elem; -+ struct request *rq = urq->rq; - unsigned int block, nblks; - - if (rq_data_dir(rq) == WRITE) -- ub_dir = UB_DIR_WRITE; -+ cmd->dir = UB_DIR_WRITE; - else -- ub_dir = UB_DIR_READ; -- cmd->dir = ub_dir; -+ cmd->dir = UB_DIR_READ; - -- /* -- * get scatterlist from block layer -- */ -- n_elem = blk_rq_map_sg(lun->disk->queue, rq, &cmd->sgv[0]); -- if (n_elem <= 0) { -- printk(KERN_INFO "%s: failed request map (%d)\n", -- sc->name, n_elem); /* P3 */ -- return -1; /* request with no s/g entries? */ -- } -- if (n_elem > UB_MAX_REQ_SG) { /* Paranoia */ -- printk(KERN_WARNING "%s: request with %d segments\n", -- sc->name, n_elem); -- return -1; -- } -- cmd->nsg = n_elem; -- sc->sg_stat[n_elem < 5 ? n_elem : 5]++; -+ cmd->nsg = urq->nsg; -+ memcpy(cmd->sgv, urq->sgv, sizeof(struct scatterlist) * cmd->nsg); - - /* - * build the command -@@ -843,7 +868,7 @@ static int ub_cmd_build_block(struct ub_ - block = rq->sector >> lun->capacity.bshift; - nblks = rq->nr_sectors >> lun->capacity.bshift; - -- cmd->cdb[0] = (ub_dir == UB_DIR_READ)? READ_10: WRITE_10; -+ cmd->cdb[0] = (cmd->dir == UB_DIR_READ)? READ_10: WRITE_10; - /* 10-byte uses 4 bytes of LBA: 2147483648KB, 2097152MB, 2048GB */ - cmd->cdb[2] = block >> 24; - cmd->cdb[3] = block >> 16; -@@ -854,14 +879,12 @@ static int ub_cmd_build_block(struct ub_ - cmd->cdb_len = 10; - - cmd->len = rq->nr_sectors * 512; -- -- return 0; - } - --static int ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun, -- struct ub_scsi_cmd *cmd, struct request *rq) -+static void ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun, -+ struct ub_scsi_cmd *cmd, struct ub_request *urq) - { -- int n_elem; -+ struct request *rq = urq->rq; - - if (rq->data_len == 0) { - cmd->dir = UB_DIR_NONE; -@@ -870,40 +893,26 @@ static int ub_cmd_build_packet(struct ub - cmd->dir = UB_DIR_WRITE; - else - cmd->dir = UB_DIR_READ; -- - } - -- /* -- * get scatterlist from block layer -- */ -- n_elem = blk_rq_map_sg(lun->disk->queue, rq, &cmd->sgv[0]); -- if (n_elem < 0) { -- printk(KERN_INFO "%s: failed request map (%d)\n", -- sc->name, n_elem); /* P3 */ -- return -1; -- } -- if (n_elem > UB_MAX_REQ_SG) { /* Paranoia */ -- printk(KERN_WARNING "%s: request with %d segments\n", -- sc->name, n_elem); -- return -1; -- } -- cmd->nsg = n_elem; -- sc->sg_stat[n_elem < 5 ? n_elem : 5]++; -+ cmd->nsg = urq->nsg; -+ memcpy(cmd->sgv, urq->sgv, sizeof(struct scatterlist) * cmd->nsg); - - memcpy(&cmd->cdb, rq->cmd, rq->cmd_len); - cmd->cdb_len = rq->cmd_len; - - cmd->len = rq->data_len; -- -- return 0; - } - - static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) - { -- struct request *rq = cmd->back; - struct ub_lun *lun = cmd->lun; -+ struct ub_request *urq = cmd->back; -+ struct request *rq; - int uptodate; - -+ rq = urq->rq; -+ - if (cmd->error == 0) { - uptodate = 1; - -@@ -924,9 +933,16 @@ static void ub_rw_cmd_done(struct ub_dev - rq->errors = SAM_STAT_CHECK_CONDITION; - else - rq->errors = DID_ERROR << 16; -+ } else { -+ if (cmd->error == -EIO) { -+ if (ub_rw_cmd_retry(sc, lun, urq, cmd) == 0) -+ return; -+ } - } - } - -+ urq->rq = NULL; -+ - ub_put_cmd(lun, cmd); - ub_end_rq(rq, uptodate); - blk_start_queue(lun->disk->queue); -@@ -941,6 +957,41 @@ static void ub_end_rq(struct request *rq - end_that_request_last(rq); - } - -+static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun, -+ struct ub_request *urq, struct ub_scsi_cmd *cmd) -+{ -+ -+ if (atomic_read(&sc->poison)) -+ return -ENXIO; -+ -+ ub_reset_enter(sc); -+ -+ if (urq->current_try >= 3) -+ return -EIO; -+ urq->current_try++; -+ /* P3 */ printk("%s: dir %c len/act %d/%d " -+ "[sense %x %02x %02x] retry %d\n", -+ sc->name, UB_DIR_CHAR(cmd->dir), cmd->len, cmd->act_len, -+ cmd->key, cmd->asc, cmd->ascq, urq->current_try); -+ -+ memset(cmd, 0, sizeof(struct ub_scsi_cmd)); -+ ub_cmd_build_block(sc, lun, cmd, urq); -+ -+ cmd->state = UB_CMDST_INIT; -+ cmd->lun = lun; -+ cmd->done = ub_rw_cmd_done; -+ cmd->back = urq; -+ -+ cmd->tag = sc->tagcnt++; -+ -+#if 0 /* Wasteful */ -+ return ub_submit_scsi(sc, cmd); -+#else -+ ub_cmdq_add(sc, cmd); -+ return 0; -+#endif -+} -+ - /* - * Submit a regular SCSI operation (not an auto-sense). - * -@@ -1071,7 +1122,7 @@ static void ub_scsi_dispatch(struct ub_d - struct ub_scsi_cmd *cmd; - int rc; - -- while ((cmd = ub_cmdq_peek(sc)) != NULL) { -+ while (!sc->reset && (cmd = ub_cmdq_peek(sc)) != NULL) { - if (cmd->state == UB_CMDST_DONE) { - ub_cmdq_pop(sc); - (*cmd->done)(sc, cmd); -@@ -1094,11 +1145,12 @@ static void ub_scsi_urb_compl(struct ub_ - { - struct urb *urb = &sc->work_urb; - struct bulk_cs_wrap *bcs; -+ int len; - int rc; - - if (atomic_read(&sc->poison)) { -- /* A little too simplistic, I feel... */ -- goto Bad_End; -+ ub_state_done(sc, cmd, -ENODEV); -+ return; - } - - if (cmd->state == UB_CMDST_CLEAR) { -@@ -1106,7 +1158,6 @@ static void ub_scsi_urb_compl(struct ub_ - /* - * STALL while clearning STALL. - * The control pipe clears itself - nothing to do. -- * XXX Might try to reset the device here and retry. - */ - printk(KERN_NOTICE "%s: stall on control pipe\n", - sc->name); -@@ -1125,11 +1176,6 @@ static void ub_scsi_urb_compl(struct ub_ - - } else if (cmd->state == UB_CMDST_CLR2STS) { - if (urb->status == -EPIPE) { -- /* -- * STALL while clearning STALL. -- * The control pipe clears itself - nothing to do. -- * XXX Might try to reset the device here and retry. -- */ - printk(KERN_NOTICE "%s: stall on control pipe\n", - sc->name); - goto Bad_End; -@@ -1147,11 +1193,6 @@ static void ub_scsi_urb_compl(struct ub_ - - } else if (cmd->state == UB_CMDST_CLRRS) { - if (urb->status == -EPIPE) { -- /* -- * STALL while clearning STALL. -- * The control pipe clears itself - nothing to do. -- * XXX Might try to reset the device here and retry. -- */ - printk(KERN_NOTICE "%s: stall on control pipe\n", - sc->name); - goto Bad_End; -@@ -1168,7 +1209,12 @@ static void ub_scsi_urb_compl(struct ub_ - ub_state_stat_counted(sc, cmd); - - } else if (cmd->state == UB_CMDST_CMD) { -- if (urb->status == -EPIPE) { -+ switch (urb->status) { -+ case 0: -+ break; -+ case -EOVERFLOW: -+ goto Bad_End; -+ case -EPIPE: - rc = ub_submit_clear_stall(sc, cmd, sc->last_pipe); - if (rc != 0) { - printk(KERN_NOTICE "%s: " -@@ -1178,17 +1224,20 @@ static void ub_scsi_urb_compl(struct ub_ - * This is typically ENOMEM or some other such shit. - * Retrying is pointless. Just do Bad End on it... - */ -- goto Bad_End; -+ ub_state_done(sc, cmd, rc); -+ return; - } - cmd->state = UB_CMDST_CLEAR; - ub_cmdtr_state(sc, cmd); - return; -- } -- if (urb->status != 0) { -+ case -ESHUTDOWN: /* unplug */ -+ case -EILSEQ: /* unplug timeout on uhci */ -+ ub_state_done(sc, cmd, -ENODEV); -+ return; -+ default: - goto Bad_End; - } - if (urb->actual_length != US_BULK_CB_WRAP_LEN) { -- /* XXX Must do reset here to unconfuse the device */ - goto Bad_End; - } - -@@ -1207,11 +1256,8 @@ static void ub_scsi_urb_compl(struct ub_ - printk(KERN_NOTICE "%s: " - "unable to submit clear (%d)\n", - sc->name, rc); -- /* -- * This is typically ENOMEM or some other such shit. -- * Retrying is pointless. Just do Bad End on it... -- */ -- goto Bad_End; -+ ub_state_done(sc, cmd, rc); -+ return; - } - cmd->state = UB_CMDST_CLR2STS; - ub_cmdtr_state(sc, cmd); -@@ -1220,14 +1266,50 @@ static void ub_scsi_urb_compl(struct ub_ - if (urb->status == -EOVERFLOW) { - /* - * A babble? Failure, but we must transfer CSW now. -- * XXX This is going to end in perpetual babble. Reset. - */ - cmd->error = -EOVERFLOW; /* A cheap trick... */ - ub_state_stat(sc, cmd); - return; - } -- if (urb->status != 0) -- goto Bad_End; -+ -+ if (cmd->dir == UB_DIR_WRITE) { -+ /* -+ * Do not continue writes in case of a failure. -+ * Doing so would cause sectors to be mixed up, -+ * which is worse than sectors lost. -+ * -+ * We must try to read the CSW, or many devices -+ * get confused. -+ */ -+ len = urb->actual_length; -+ if (urb->status != 0 || -+ len != cmd->sgv[cmd->current_sg].length) { -+ cmd->act_len += len; -+ ub_cmdtr_act_len(sc, cmd); -+ -+ cmd->error = -EIO; -+ ub_state_stat(sc, cmd); -+ return; -+ } -+ -+ } else { -+ /* -+ * If an error occurs on read, we record it, and -+ * continue to fetch data in order to avoid bubble. -+ * -+ * As a small shortcut, we stop if we detect that -+ * a CSW mixed into data. -+ */ -+ if (urb->status != 0) -+ cmd->error = -EIO; -+ -+ len = urb->actual_length; -+ if (urb->status != 0 || -+ len != cmd->sgv[cmd->current_sg].length) { -+ if ((len & 0x1FF) == US_BULK_CS_WRAP_LEN) -+ goto Bad_End; -+ } -+ } - - cmd->act_len += urb->actual_length; - ub_cmdtr_act_len(sc, cmd); -@@ -1245,11 +1327,8 @@ static void ub_scsi_urb_compl(struct ub_ - printk(KERN_NOTICE "%s: " - "unable to submit clear (%d)\n", - sc->name, rc); -- /* -- * This is typically ENOMEM or some other such shit. -- * Retrying is pointless. Just do Bad End on it... -- */ -- goto Bad_End; -+ ub_state_done(sc, cmd, rc); -+ return; - } - - /* -@@ -1262,14 +1341,8 @@ static void ub_scsi_urb_compl(struct ub_ - ub_cmdtr_state(sc, cmd); - return; - } -- if (urb->status == -EOVERFLOW) { -- /* -- * XXX We are screwed here. Retrying is pointless, -- * because the pipelined data will not get in until -- * we read with a big enough buffer. We must reset XXX. -- */ -- goto Bad_End; -- } -+ -+ /* Catch everything, including -EOVERFLOW and other nasties. */ - if (urb->status != 0) - goto Bad_End; - -@@ -1315,15 +1388,15 @@ static void ub_scsi_urb_compl(struct ub_ - return; - } - -- rc = le32_to_cpu(bcs->Residue); -- if (rc != cmd->len - cmd->act_len) { -+ len = le32_to_cpu(bcs->Residue); -+ if (len != cmd->len - cmd->act_len) { - /* - * It is all right to transfer less, the caller has - * to check. But it's not all right if the device - * counts disagree with our counts. - */ - /* P3 */ printk("%s: resid %d len %d act %d\n", -- sc->name, rc, cmd->len, cmd->act_len); -+ sc->name, len, cmd->len, cmd->act_len); - goto Bad_End; - } - -@@ -1334,13 +1407,13 @@ static void ub_scsi_urb_compl(struct ub_ - ub_state_sense(sc, cmd); - return; - case US_BULK_STAT_PHASE: -- /* XXX We must reset the transport here */ - /* P3 */ printk("%s: status PHASE\n", sc->name); - goto Bad_End; - default: - printk(KERN_INFO "%s: unknown CSW status 0x%x\n", - sc->name, bcs->Status); -- goto Bad_End; -+ ub_state_done(sc, cmd, -EINVAL); -+ return; - } - - /* Not zeroing error to preserve a babble indicator */ -@@ -1360,7 +1433,8 @@ static void ub_scsi_urb_compl(struct ub_ - printk(KERN_WARNING "%s: " - "wrong command state %d\n", - sc->name, cmd->state); -- goto Bad_End; -+ ub_state_done(sc, cmd, -EINVAL); -+ return; - } - return; - -@@ -1608,6 +1682,93 @@ static void ub_top_sense_done(struct ub_ - } - - /* -+ * Reset management -+ */ -+ -+static void ub_reset_enter(struct ub_dev *sc) -+{ -+ -+ if (sc->reset) { -+ /* This happens often on multi-LUN devices. */ -+ return; -+ } -+ sc->reset = 1; -+ -+#if 0 /* Not needed because the disconnect waits for us. */ -+ unsigned long flags; -+ spin_lock_irqsave(&ub_lock, flags); -+ sc->openc++; -+ spin_unlock_irqrestore(&ub_lock, flags); -+#endif -+ -+#if 0 /* We let them stop themselves. */ -+ struct list_head *p; -+ struct ub_lun *lun; -+ list_for_each(p, &sc->luns) { -+ lun = list_entry(p, struct ub_lun, link); -+ blk_stop_queue(lun->disk->queue); -+ } -+#endif -+ -+ schedule_work(&sc->reset_work); -+} -+ -+static void ub_reset_task(void *arg) -+{ -+ struct ub_dev *sc = arg; -+ unsigned long flags; -+ struct list_head *p; -+ struct ub_lun *lun; -+ int lkr, rc; -+ -+ if (!sc->reset) { -+ printk(KERN_WARNING "%s: Running reset unrequested\n", -+ sc->name); -+ return; -+ } -+ -+ if (atomic_read(&sc->poison)) { -+ printk(KERN_NOTICE "%s: Not resetting disconnected device\n", -+ sc->name); /* P3 This floods. Remove soon. XXX */ -+ } else if (sc->dev->actconfig->desc.bNumInterfaces != 1) { -+ printk(KERN_NOTICE "%s: Not resetting multi-interface device\n", -+ sc->name); /* P3 This floods. Remove soon. XXX */ -+ } else { -+ if ((lkr = usb_lock_device_for_reset(sc->dev, sc->intf)) < 0) { -+ printk(KERN_NOTICE -+ "%s: usb_lock_device_for_reset failed (%d)\n", -+ sc->name, lkr); -+ } else { -+ rc = usb_reset_device(sc->dev); -+ if (rc < 0) { -+ printk(KERN_NOTICE "%s: " -+ "usb_lock_device_for_reset failed (%d)\n", -+ sc->name, rc); -+ } -+ -+ if (lkr) -+ usb_unlock_device(sc->dev); -+ } -+ } -+ -+ /* -+ * In theory, no commands can be running while reset is active, -+ * so nobody can ask for another reset, and so we do not need any -+ * queues of resets or anything. We do need a spinlock though, -+ * to interact with block layer. -+ */ -+ spin_lock_irqsave(&sc->lock, flags); -+ sc->reset = 0; -+ tasklet_schedule(&sc->tasklet); -+ list_for_each(p, &sc->luns) { -+ lun = list_entry(p, struct ub_lun, link); -+ blk_start_queue(lun->disk->queue); -+ } -+ wake_up(&sc->reset_wait); -+ spin_unlock_irqrestore(&sc->lock, flags); -+} -+ -+/* - * This is called from a process context. - */ - static void ub_revalidate(struct ub_dev *sc, struct ub_lun *lun) -@@ -2142,7 +2303,7 @@ static int ub_get_pipes(struct ub_dev *s - if (ep_in == NULL || ep_out == NULL) { - printk(KERN_NOTICE "%s: failed endpoint check\n", - sc->name); -- return -EIO; -+ return -ENODEV; - } - - /* Calculate and store the pipe values */ -@@ -2180,6 +2341,8 @@ static int ub_probe(struct usb_interface - usb_init_urb(&sc->work_urb); - tasklet_init(&sc->tasklet, ub_scsi_action, (unsigned long)sc); - atomic_set(&sc->poison, 0); -+ INIT_WORK(&sc->reset_work, ub_reset_task, sc); -+ init_waitqueue_head(&sc->reset_wait); - - init_timer(&sc->work_timer); - sc->work_timer.data = (unsigned long) sc; -@@ -2200,7 +2363,8 @@ static int ub_probe(struct usb_interface - - /* XXX Verify that we can handle the device (from descriptors) */ - -- ub_get_pipes(sc, sc->dev, intf); -+ if (ub_get_pipes(sc, sc->dev, intf) != 0) -+ goto err_dev_desc; - - if (device_create_file(&sc->intf->dev, &dev_attr_diag) != 0) - goto err_diag; -@@ -2271,6 +2435,7 @@ static int ub_probe(struct usb_interface - - /* device_remove_file(&sc->intf->dev, &dev_attr_diag); */ - err_diag: -+err_dev_desc: - usb_set_intfdata(intf, NULL); - // usb_put_intf(sc->intf); - usb_put_dev(sc->dev); -@@ -2379,6 +2544,11 @@ static void ub_disconnect(struct usb_int - atomic_set(&sc->poison, 1); - - /* -+ * Wait for reset to end, if any. -+ */ -+ wait_event(sc->reset_wait, !sc->reset); -+ -+ /* - * Blow away queued commands. - * - * Actually, this never works, because before we get here -@@ -2391,7 +2561,7 @@ static void ub_disconnect(struct usb_int - { - struct ub_scsi_cmd *cmd; - int cnt = 0; -- while ((cmd = ub_cmdq_pop(sc)) != NULL) { -+ while ((cmd = ub_cmdq_peek(sc)) != NULL) { - cmd->error = -ENOTCONN; - cmd->state = UB_CMDST_DONE; - ub_cmdtr_state(sc, cmd); diff --git a/usb/usb-ub-01-rename.patch b/usb/usb-ub-01-rename.patch deleted file mode 100644 index 29f5d74374876..0000000000000 --- a/usb/usb-ub-01-rename.patch +++ /dev/null @@ -1,45 +0,0 @@ -From zaitcev@redhat.com Sat Dec 17 02:38:38 2005 -Date: Sat, 17 Dec 2005 02:34:12 -0800 -From: Pete Zaitcev <zaitcev@redhat.com> -To: greg@kroah.com -Cc: zaitcev@redhat.com, jgarzik@redhat.com -Subject: usb: ub 01 rename -Message-Id: <20051217023412.54e37b60.zaitcev@redhat.com> - -Rename misleading UB_MINORS_PER_MAJOR into UB_PARTS_PER_LUN. - -Signed-off-by: Pete Zaitcev <zaitcev@redhat.com> -Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> - ---- - drivers/block/ub.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - ---- gregkh-2.6.orig/drivers/block/ub.c -+++ gregkh-2.6/drivers/block/ub.c -@@ -115,7 +115,7 @@ - /* - */ - --#define UB_MINORS_PER_MAJOR 8 -+#define UB_PARTS_PER_LUN 8 - - #define UB_MAX_CDB_SIZE 16 /* Corresponds to Bulk */ - -@@ -2473,14 +2473,14 @@ static int ub_probe_lun(struct ub_dev *s - ub_revalidate(sc, lun); - - rc = -ENOMEM; -- if ((disk = alloc_disk(UB_MINORS_PER_MAJOR)) == NULL) -+ if ((disk = alloc_disk(UB_PARTS_PER_LUN)) == NULL) - goto err_diskalloc; - - lun->disk = disk; - sprintf(disk->disk_name, DRV_NAME "%c", lun->id + 'a'); - sprintf(disk->devfs_name, DEVFS_NAME "/%c", lun->id + 'a'); - disk->major = UB_MAJOR; -- disk->first_minor = lun->id * UB_MINORS_PER_MAJOR; -+ disk->first_minor = lun->id * UB_PARTS_PER_LUN; - disk->fops = &ub_bd_fops; - disk->private_data = lun; - disk->driverfs_dev = &sc->intf->dev; diff --git a/usb/usb-ub-02-removed-unused-variable.patch b/usb/usb-ub-02-removed-unused-variable.patch deleted file mode 100644 index 6de01b4c358a7..0000000000000 --- a/usb/usb-ub-02-removed-unused-variable.patch +++ /dev/null @@ -1,34 +0,0 @@ -From zaitcev@redhat.com Sat Dec 17 02:43:51 2005 -Date: Sat, 17 Dec 2005 02:38:46 -0800 -From: Pete Zaitcev <zaitcev@redhat.com> -To: greg@kroah.com -Cc: zaitcev@redhat.com -Subject: usb: ub 02 Removed unused variable -Message-Id: <20051217023846.371889c1.zaitcev@redhat.com> - -From: Daniel Marjamaki <daniel.marjamaki@comhem.se> - -Removed an unused variable - -Signed-off-by: Daniel Marjamaki <daniel.marjamaki@comhem.se> -Signed-off-by: Pete Zaitcev <zaitcev@redhat.com> -Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> - ---- - drivers/block/ub.c | 5 +---- - 1 file changed, 1 insertion(+), 4 deletions(-) - ---- gregkh-2.6.orig/drivers/block/ub.c -+++ gregkh-2.6/drivers/block/ub.c -@@ -950,10 +950,7 @@ static void ub_rw_cmd_done(struct ub_dev - - static void ub_end_rq(struct request *rq, int uptodate) - { -- int rc; -- -- rc = end_that_request_first(rq, uptodate, rq->hard_nr_sectors); -- // assert(rc == 0); -+ end_that_request_first(rq, uptodate, rq->hard_nr_sectors); - end_that_request_last(rq); - } - diff --git a/usb/usb-use-array_size-macro.patch b/usb/usb-use-array_size-macro.patch deleted file mode 100644 index caa397ac948e8..0000000000000 --- a/usb/usb-use-array_size-macro.patch +++ /dev/null @@ -1,265 +0,0 @@ -From kernel-janitors-bounces@lists.osdl.org Sun Dec 11 07:24:02 2005 -Date: Sun, 11 Dec 2005 16:20:08 +0100 -From: Tobias Klauser <tklauser@nuerscht.ch> -To: kernel-janitors@lists.osdl.org -Message-ID: <20051211152007.GA1545@neon.tklauser.home> -Cc: akpm@osdl.org, gregkh@suse.de -Subject: USB: Use ARRAY_SIZE macro - -Use ARRAY_SIZE macro instead of sizeof(x)/sizeof(x[0]) and remove -duplicates of ARRAY_SIZE. Some trailing whitespaces are also removed. - -Patch is compile-tested on i386. - -Signed-off-by: Tobias Klauser <tklauser@nuerscht.ch> -Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> - ---- - drivers/usb/gadget/dummy_hcd.c | 2 +- - drivers/usb/input/aiptek.c | 4 ++-- - drivers/usb/media/ibmcam.c | 2 +- - drivers/usb/media/sn9c102_core.c | 23 ++++++++++------------- - drivers/usb/media/w9968cf.c | 2 +- - drivers/usb/net/zd1201.c | 8 ++++---- - drivers/usb/serial/io_edgeport.c | 2 +- - drivers/usb/serial/io_edgeport.h | 3 --- - drivers/usb/serial/safe_serial.c | 2 +- - drivers/usb/serial/ti_usb_3410_5052.c | 7 ++----- - drivers/usb/storage/sddr09.c | 4 +--- - 11 files changed, 24 insertions(+), 35 deletions(-) - ---- gregkh-2.6.orig/drivers/usb/gadget/dummy_hcd.c -+++ gregkh-2.6/drivers/usb/gadget/dummy_hcd.c -@@ -138,7 +138,7 @@ static const char *const ep_name [] = { - /* or like sa1100: two fixed function endpoints */ - "ep1out-bulk", "ep2in-bulk", - }; --#define DUMMY_ENDPOINTS (sizeof(ep_name)/sizeof(char *)) -+#define DUMMY_ENDPOINTS ARRAY_SIZE(ep_name) - - /*-------------------------------------------------------------------------*/ - ---- gregkh-2.6.orig/drivers/usb/input/aiptek.c -+++ gregkh-2.6/drivers/usb/input/aiptek.c -@@ -2093,7 +2093,7 @@ aiptek_probe(struct usb_interface *intf, - /* Programming the tablet macro keys needs to be done with a for loop - * as the keycodes are discontiguous. - */ -- for (i = 0; i < sizeof(macroKeyEvents) / sizeof(macroKeyEvents[0]); ++i) -+ for (i = 0; i < ARRAY_SIZE(macroKeyEvents); ++i) - set_bit(macroKeyEvents[i], inputdev->keybit); - - /* -@@ -2135,7 +2135,7 @@ aiptek_probe(struct usb_interface *intf, - * not an error :-) - */ - -- for (i = 0; i < sizeof(speeds) / sizeof(speeds[0]); ++i) { -+ for (i = 0; i < ARRAY_SIZE(speeds); ++i) { - aiptek->curSetting.programmableDelay = speeds[i]; - (void)aiptek_program_tablet(aiptek); - if (aiptek->inputdev->absmax[ABS_X] > 0) { ---- gregkh-2.6.orig/drivers/usb/media/ibmcam.c -+++ gregkh-2.6/drivers/usb/media/ibmcam.c -@@ -3457,7 +3457,7 @@ static void ibmcam_model3_setup_after_vi - if(init_model3_input) { - if (debug > 0) - info("Setting input to RCA."); -- for (i=0; i < (sizeof(initData)/sizeof(initData[0])); i++) { -+ for (i=0; i < ARRAY_SIZE(initData); i++) { - ibmcam_veio(uvd, initData[i].req, initData[i].value, initData[i].index); - } - } ---- gregkh-2.6.orig/drivers/usb/media/sn9c102_core.c -+++ gregkh-2.6/drivers/usb/media/sn9c102_core.c -@@ -1316,7 +1316,7 @@ static int sn9c102_init(struct sn9c102_d - struct v4l2_control ctrl; - struct v4l2_queryctrl *qctrl; - struct v4l2_rect* rect; -- u8 i = 0, n = 0; -+ u8 i = 0; - int err = 0; - - if (!(cam->state & DEV_INITIALIZED)) { -@@ -1352,7 +1352,7 @@ static int sn9c102_init(struct sn9c102_d - return err; - - if (s->pix_format.pixelformat == V4L2_PIX_FMT_SN9C10X) -- DBG(3, "Compressed video format is active, quality %d", -+ DBG(3, "Compressed video format is active, quality %d", - cam->compression.quality) - else - DBG(3, "Uncompressed video format is active") -@@ -1364,9 +1364,8 @@ static int sn9c102_init(struct sn9c102_d - } - - if (s->set_ctrl) { -- n = sizeof(s->qctrl) / sizeof(s->qctrl[0]); -- for (i = 0; i < n; i++) -- if (s->qctrl[i].id != 0 && -+ for (i = 0; i < ARRAY_SIZE(s->qctrl); i++) -+ if (s->qctrl[i].id != 0 && - !(s->qctrl[i].flags & V4L2_CTRL_FLAG_DISABLED)) { - ctrl.id = s->qctrl[i].id; - ctrl.value = qctrl[i].default_value; -@@ -1388,7 +1387,7 @@ static int sn9c102_init(struct sn9c102_d - init_waitqueue_head(&cam->wait_stream); - cam->nreadbuffers = 2; - memcpy(s->_qctrl, s->qctrl, sizeof(s->qctrl)); -- memcpy(&(s->_rect), &(s->cropcap.defrect), -+ memcpy(&(s->_rect), &(s->cropcap.defrect), - sizeof(struct v4l2_rect)); - cam->state |= DEV_INITIALIZED; - } -@@ -1810,13 +1809,12 @@ static int sn9c102_ioctl_v4l2(struct ino - { - struct sn9c102_sensor* s = cam->sensor; - struct v4l2_queryctrl qc; -- u8 i, n; -+ u8 i; - - if (copy_from_user(&qc, arg, sizeof(qc))) - return -EFAULT; - -- n = sizeof(s->qctrl) / sizeof(s->qctrl[0]); -- for (i = 0; i < n; i++) -+ for (i = 0; i < ARRAY_SIZE(s->qctrl); i++) - if (qc.id && qc.id == s->qctrl[i].id) { - memcpy(&qc, &(s->qctrl[i]), sizeof(qc)); - if (copy_to_user(arg, &qc, sizeof(qc))) -@@ -1852,7 +1850,7 @@ static int sn9c102_ioctl_v4l2(struct ino - { - struct sn9c102_sensor* s = cam->sensor; - struct v4l2_control ctrl; -- u8 i, n; -+ u8 i; - int err = 0; - - if (!s->set_ctrl) -@@ -1861,8 +1859,7 @@ static int sn9c102_ioctl_v4l2(struct ino - if (copy_from_user(&ctrl, arg, sizeof(ctrl))) - return -EFAULT; - -- n = sizeof(s->qctrl) / sizeof(s->qctrl[0]); -- for (i = 0; i < n; i++) -+ for (i = 0; i < ARRAY_SIZE(s->qctrl); i++) - if (ctrl.id == s->qctrl[i].id) { - if (ctrl.value < s->qctrl[i].minimum || - ctrl.value > s->qctrl[i].maximum) -@@ -2544,7 +2541,7 @@ sn9c102_usb_probe(struct usb_interface* - unsigned int i, n; - int err = 0, r; - -- n = sizeof(sn9c102_id_table)/sizeof(sn9c102_id_table[0]); -+ n = ARRAY_SIZE(sn9c102_id_table); - for (i = 0; i < n-1; i++) - if (le16_to_cpu(udev->descriptor.idVendor) == - sn9c102_id_table[i].idVendor && ---- gregkh-2.6.orig/drivers/usb/media/w9968cf.c -+++ gregkh-2.6/drivers/usb/media/w9968cf.c -@@ -2958,7 +2958,7 @@ static int w9968cf_v4l_ioctl(struct inod - }; - - #define V4L1_IOCTL(cmd) \ -- ((_IOC_NR((cmd)) < sizeof(v4l1_ioctls)/sizeof(char*)) ? \ -+ ((_IOC_NR((cmd)) < ARRAY_SIZE(v4l1_ioctls)) ? \ - v4l1_ioctls[_IOC_NR((cmd))] : "?") - - cam = (struct w9968cf_device*)video_get_drvdata(video_devdata(filp)); ---- gregkh-2.6.orig/drivers/usb/net/zd1201.c -+++ gregkh-2.6/drivers/usb/net/zd1201.c -@@ -1722,7 +1722,7 @@ static const struct iw_priv_args zd1201_ - IW_PRIV_TYPE_NONE, "sethostauth" }, - { ZD1201GIWHOSTAUTH, IW_PRIV_TYPE_NONE, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "gethostauth" }, -- { ZD1201SIWAUTHSTA, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, -+ { ZD1201SIWAUTHSTA, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, - IW_PRIV_TYPE_NONE, "authstation" }, - { ZD1201SIWMAXASSOC, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, - IW_PRIV_TYPE_NONE, "setmaxassoc" }, -@@ -1731,9 +1731,9 @@ static const struct iw_priv_args zd1201_ - }; - - static const struct iw_handler_def zd1201_iw_handlers = { -- .num_standard = sizeof(zd1201_iw_handler)/sizeof(iw_handler), -- .num_private = sizeof(zd1201_private_handler)/sizeof(iw_handler), -- .num_private_args = sizeof(zd1201_private_args)/sizeof(struct iw_priv_args), -+ .num_standard = ARRAY_SIZE(zd1201_iw_handler), -+ .num_private = ARRAY_SIZE(zd1201_private_handler), -+ .num_private_args = ARRAY_SIZE(zd1201_private_args), - .standard = (iw_handler *)zd1201_iw_handler, - .private = (iw_handler *)zd1201_private_handler, - .private_args = (struct iw_priv_args *) zd1201_private_args, ---- gregkh-2.6.orig/drivers/usb/serial/io_edgeport.c -+++ gregkh-2.6/drivers/usb/serial/io_edgeport.c -@@ -2353,7 +2353,7 @@ static int calc_baud_rate_divisor (int b - - dbg("%s - %d", __FUNCTION__, baudrate); - -- for (i = 0; i < NUM_ENTRIES(divisor_table); i++) { -+ for (i = 0; i < ARRAY_SIZE(divisor_table); i++) { - if ( divisor_table[i].BaudRate == baudrate ) { - *divisor = divisor_table[i].Divisor; - return 0; ---- gregkh-2.6.orig/drivers/usb/serial/io_edgeport.h -+++ gregkh-2.6/drivers/usb/serial/io_edgeport.h -@@ -31,9 +31,6 @@ - #ifndef HIGH8 - #define HIGH8(a) ((unsigned char)((a & 0xff00) >> 8)) - #endif --#ifndef NUM_ENTRIES -- #define NUM_ENTRIES(x) (sizeof(x)/sizeof((x)[0])) --#endif - - #ifndef __KERNEL__ - #define __KERNEL__ ---- gregkh-2.6.orig/drivers/usb/serial/safe_serial.c -+++ gregkh-2.6/drivers/usb/serial/safe_serial.c -@@ -425,7 +425,7 @@ static int __init safe_init (void) - if (vendor || product) { - info ("vendor: %x product: %x\n", vendor, product); - -- for (i = 0; i < (sizeof (id_table) / sizeof (struct usb_device_id)); i++) { -+ for (i = 0; i < ARRAY_SIZE(id_table); i++) { - if (!id_table[i].idVendor && !id_table[i].idProduct) { - id_table[i].idVendor = vendor; - id_table[i].idProduct = product; ---- gregkh-2.6.orig/drivers/usb/serial/ti_usb_3410_5052.c -+++ gregkh-2.6/drivers/usb/serial/ti_usb_3410_5052.c -@@ -351,17 +351,14 @@ static int __init ti_init(void) - int i,j; - int ret; - -- - /* insert extra vendor and product ids */ -- j = sizeof(ti_id_table_3410)/sizeof(struct usb_device_id) -- - TI_EXTRA_VID_PID_COUNT - 1; -+ j = ARRAY_SIZE(ti_id_table_3410) - TI_EXTRA_VID_PID_COUNT - 1; - for (i=0; i<min(vendor_3410_count,product_3410_count); i++,j++) { - ti_id_table_3410[j].idVendor = vendor_3410[i]; - ti_id_table_3410[j].idProduct = product_3410[i]; - ti_id_table_3410[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE; - } -- j = sizeof(ti_id_table_5052)/sizeof(struct usb_device_id) -- - TI_EXTRA_VID_PID_COUNT - 1; -+ j = ARRAY_SIZE(ti_id_table_5052) - TI_EXTRA_VID_PID_COUNT - 1; - for (i=0; i<min(vendor_5052_count,product_5052_count); i++,j++) { - ti_id_table_5052[j].idVendor = vendor_5052[i]; - ti_id_table_5052[j].idProduct = product_5052[i]; ---- gregkh-2.6.orig/drivers/usb/storage/sddr09.c -+++ gregkh-2.6/drivers/usb/storage/sddr09.c -@@ -133,13 +133,11 @@ static struct nand_flash_dev nand_flash_ - { 0,} - }; - --#define SIZE(a) (sizeof(a)/sizeof((a)[0])) -- - static struct nand_flash_dev * - nand_find_id(unsigned char id) { - int i; - -- for (i = 0; i < SIZE(nand_flash_ids); i++) -+ for (i = 0; i < ARRAY_SIZE(nand_flash_ids); i++) - if (nand_flash_ids[i].model_id == id) - return &(nand_flash_ids[i]); - return NULL; diff --git a/usb/usb-wakeup-flag-updates-isp116x-hcd.patch b/usb/usb-wakeup-flag-updates-isp116x-hcd.patch deleted file mode 100644 index 29a9078cf1d8d..0000000000000 --- a/usb/usb-wakeup-flag-updates-isp116x-hcd.patch +++ /dev/null @@ -1,40 +0,0 @@ -From david-b@pacbell.net Mon Nov 7 15:43:21 2005 -Message-ID: <20051107233824.60767.qmail@web80708.mail.yahoo.com> -Date: Mon, 7 Nov 2005 15:38:24 -0800 (PST) -From: David Brownell <david-b@pacbell.net> -Subject: USB: wakeup flag updates (3/3) isp116x-hcd -To: greg@kroah.com -Cc: linux-usb-devel@lists.sourceforge.net - - -This makes the ISP116x HCD use the driver model wakeup flags for its -controller, not the flags in the HCD glue (which will be removed). - -Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> -Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> - ---- - drivers/usb/host/isp116x-hcd.c | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - ---- gregkh-2.6.orig/drivers/usb/host/isp116x-hcd.c -+++ gregkh-2.6/drivers/usb/host/isp116x-hcd.c -@@ -1378,7 +1378,8 @@ static int isp116x_start(struct usb_hcd - - val = 0; - if (board->remote_wakeup_enable) { -- hcd->can_wakeup = 1; -+ if (!device_can_wakeup(hcd->self.controller)) -+ device_init_wakeup(hcd->self.controller, 1); - val |= RH_HS_DRWE; - } - isp116x_write_reg32(isp116x, HCRHSTATUS, val); -@@ -1428,7 +1429,7 @@ static int isp116x_bus_suspend(struct us - hcd->state = HC_STATE_QUIESCING; - val &= (~HCCONTROL_HCFS & ~HCCONTROL_RWE); - val |= HCCONTROL_USB_SUSPEND; -- if (hcd->remote_wakeup) -+ if (device_may_wakeup(&hcd->self.root_hub->dev)) - val |= HCCONTROL_RWE; - /* Wait for usb transfers to finish */ - mdelay(2); diff --git a/usb/usb-wakeup-flag-updates-sl811-hcd.patch b/usb/usb-wakeup-flag-updates-sl811-hcd.patch deleted file mode 100644 index 4efa8760260ad..0000000000000 --- a/usb/usb-wakeup-flag-updates-sl811-hcd.patch +++ /dev/null @@ -1,40 +0,0 @@ -From david-b@pacbell.net Mon Nov 7 15:32:37 2005 -Message-ID: <20051107233125.97726.qmail@web80709.mail.yahoo.com> -Date: Mon, 7 Nov 2005 15:31:25 -0800 (PST) -From: David Brownell <david-b@pacbell.net> -Subject: USB: wakeup flag updates (1/3) sl811-hcd -To: greg@kroah.com - - -This makes the SL811 HCD use the driver model wakeup flags for its -controller, not the flags in the HCD glue (which will be removed). - -From: David Brownell <dbrownell@users.sourceforge.net> -Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> - - drivers/usb/host/sl811-hcd.c | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - ---- ---- gregkh-2.6.orig/drivers/usb/host/sl811-hcd.c -+++ gregkh-2.6/drivers/usb/host/sl811-hcd.c -@@ -1581,7 +1581,9 @@ sl811h_start(struct usb_hcd *hcd) - hcd->state = HC_STATE_RUNNING; - - if (sl811->board) { -- hcd->can_wakeup = sl811->board->can_wakeup; -+ if (!device_can_wakeup(hcd->self.controller)) -+ device_init_wakeup(hcd->self.controller, -+ sl811->board->can_wakeup); - hcd->power_budget = sl811->board->power * 2; - } - -@@ -1805,7 +1807,7 @@ sl811h_resume(struct platform_device *de - * let's assume it'd only be powered to enable remote wakeup. - */ - if (dev->dev.power.power_state.event == PM_EVENT_SUSPEND -- || !hcd->can_wakeup) { -+ || !device_can_wakeup(&hcd->self.root_hub->dev)) { - sl811->port1 = 0; - port_power(sl811, 1); - return 0; diff --git a/usb/usb-wakeup-flag-updates-uhci-hcd.patch b/usb/usb-wakeup-flag-updates-uhci-hcd.patch deleted file mode 100644 index b282a8afc53ca..0000000000000 --- a/usb/usb-wakeup-flag-updates-uhci-hcd.patch +++ /dev/null @@ -1,38 +0,0 @@ -From david-b@pacbell.net Mon Nov 7 15:37:57 2005 -Message-ID: <20051107233442.59301.qmail@web80721.mail.yahoo.com> -Date: Mon, 7 Nov 2005 15:34:41 -0800 (PST) -From: David Brownell <david-b@pacbell.net> -Subject: USB: wakeup flag updates (2/3) uhci-hcd -To: greg@kroah.com - - -This makes UHCI stop using the HCD glue wakeup flags to report whether -the controller can wake the system. The existing code was wrong anyway; -having a PCI PM capability doesn't imply it reports PME# is supported. - -I skimmed Intel's ICH7 datasheet and that basically says the wakeup -signaling gets routed only through ACPI registers. (On the other hand, -many VIA chips provide the PCI PM capabilities...) I think that doing -this correctly with UHCI is going to require the ACPI folk to associate -the /proc/acpi/wakeup identifiers (and wakeup enable/disable flags) -with the relevant /sys/devices/pci*/... devices. - -From: David Brownell <dbrownell@users.sourceforge.net> -Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> - - ---- - drivers/usb/host/uhci-hcd.c | 2 -- - 1 file changed, 2 deletions(-) - ---- gregkh-2.6.orig/drivers/usb/host/uhci-hcd.c -+++ gregkh-2.6/drivers/usb/host/uhci-hcd.c -@@ -478,8 +478,6 @@ static int uhci_start(struct usb_hcd *hc - struct dentry *dentry; - - hcd->uses_new_polling = 1; -- if (pci_find_capability(to_pci_dev(uhci_dev(uhci)), PCI_CAP_ID_PM)) -- hcd->can_wakeup = 1; /* Assume it supports PME# */ - - dentry = debugfs_create_file(hcd->self.bus_name, - S_IFREG|S_IRUGO|S_IWUSR, uhci_debugfs_root, uhci, diff --git a/usb/usb-zd1201-make-sysfs-device-symlink.patch b/usb/usb-zd1201-make-sysfs-device-symlink.patch deleted file mode 100644 index 8003d211c9f11..0000000000000 --- a/usb/usb-zd1201-make-sysfs-device-symlink.patch +++ /dev/null @@ -1,43 +0,0 @@ -From linux-usb-devel-admin@lists.sourceforge.net Sun Dec 18 21:48:07 2005 -From: Nathan Lynch <ntl@pobox.com> -Cc: pe1rxq@amsat.org -Message-ID: <20051219054137.GA17414@localhost.localdomain> -Content-Disposition: inline -Subject: USB: zd1201: make sysfs device symlink -Date: Sun, 18 Dec 2005 23:41:38 -0600 - -Noticed that my zd1201 adapter isn't "seen" by hal and NetworkManager. -The problem seems to be that unlike other network device drivers I -checked, zd1201 does not do a SET_NETDEV_DEV(), which makes it so a -"device" symlink is created under /sys/class/net/wlan0. - -With the following patch the device symlink shows up, and now I am -happily using NetworkManager to control the adapter: - -$ ls -l /sys/class/net/wlan0 -total 0 --r--r--r-- 1 root root 4096 Dec 18 13:42 address --r--r--r-- 1 root root 4096 Dec 18 13:42 addr_len --r--r--r-- 1 root root 4096 Dec 18 13:42 broadcast --r--r--r-- 1 root root 4096 Dec 18 13:42 carrier -lrwxrwxrwx 1 root root 0 Dec 18 13:42 device -> ../../../devices/pci0001:10/0001:10:1b.1/usb4/4-1 --r--r--r-- 1 root root 4096 Dec 18 13:42 features - -Signed-off-by: Nathan Lynch <ntl@pobox.com> -Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> - ---- - drivers/usb/net/zd1201.c | 2 ++ - 1 file changed, 2 insertions(+) - ---- gregkh-2.6.orig/drivers/usb/net/zd1201.c -+++ gregkh-2.6/drivers/usb/net/zd1201.c -@@ -1829,6 +1829,8 @@ static int zd1201_probe(struct usb_inter - if (err) - goto err_net; - -+ SET_NETDEV_DEV(zd->dev, &usb->dev); -+ - err = register_netdev(zd->dev); - if (err) - goto err_net; diff --git a/usb/usbcore-central-handling-for-host-controllers-that-were-reset-during-suspend-resume.patch b/usb/usbcore-central-handling-for-host-controllers-that-were-reset-during-suspend-resume.patch deleted file mode 100644 index 742d24eab39c9..0000000000000 --- a/usb/usbcore-central-handling-for-host-controllers-that-were-reset-during-suspend-resume.patch +++ /dev/null @@ -1,151 +0,0 @@ -From stern@rowland.harvard.edu Mon Nov 14 08:32:36 2005 -Date: Mon, 14 Nov 2005 11:45:38 -0500 (EST) -From: Alan Stern <stern@rowland.harvard.edu> -To: Greg KH <greg@kroah.com> -Subject: [PATCH] usbcore: central handling for host controllers that were reset during suspend/resume -Message-ID: <Pine.LNX.4.44L0.0511141137380.13996-100000@iolanthe.rowland.org> - -This patch (as515b) adds a routine to usbcore to simplify handling of -host controllers that lost power or were reset during suspend/resume. -The new core routine marks all the child devices of the root hub as -NOTATTACHED and tells khubd to disconnect the device structures as soon -as possible. - -Signed-off-by: Alan Stern <stern@rowland.harvard.edu> -Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> - ---- - drivers/usb/core/hcd.h | 1 + - drivers/usb/core/hub.c | 33 +++++++++++++++++++++++++++++++++ - drivers/usb/host/ehci-pci.c | 9 +-------- - drivers/usb/host/ohci-hcd.c | 7 +------ - drivers/usb/host/sl811-hcd.c | 1 + - drivers/usb/host/uhci-hcd.c | 6 +++++- - 6 files changed, 42 insertions(+), 15 deletions(-) - ---- gregkh-2.6.orig/drivers/usb/core/hub.c -+++ gregkh-2.6/drivers/usb/core/hub.c -@@ -1039,6 +1039,39 @@ void usb_set_device_state(struct usb_dev - EXPORT_SYMBOL(usb_set_device_state); - - -+#ifdef CONFIG_PM -+ -+/** -+ * usb_root_hub_lost_power - called by HCD if the root hub lost Vbus power -+ * @rhdev: struct usb_device for the root hub -+ * -+ * The USB host controller driver calls this function when its root hub -+ * is resumed and Vbus power has been interrupted or the controller -+ * has been reset. The routine marks all the children of the root hub -+ * as NOTATTACHED and marks logical connect-change events on their ports. -+ */ -+void usb_root_hub_lost_power(struct usb_device *rhdev) -+{ -+ struct usb_hub *hub; -+ int port1; -+ unsigned long flags; -+ -+ dev_warn(&rhdev->dev, "root hub lost power or was reset\n"); -+ spin_lock_irqsave(&device_state_lock, flags); -+ hub = hdev_to_hub(rhdev); -+ for (port1 = 1; port1 <= rhdev->maxchild; ++port1) { -+ if (rhdev->children[port1 - 1]) { -+ recursively_mark_NOTATTACHED( -+ rhdev->children[port1 - 1]); -+ set_bit(port1, hub->change_bits); -+ } -+ } -+ spin_unlock_irqrestore(&device_state_lock, flags); -+} -+EXPORT_SYMBOL_GPL(usb_root_hub_lost_power); -+ -+#endif -+ - static void choose_address(struct usb_device *udev) - { - int devnum; ---- gregkh-2.6.orig/drivers/usb/core/hcd.h -+++ gregkh-2.6/drivers/usb/core/hcd.h -@@ -380,6 +380,7 @@ extern int usb_find_interface_driver (st - #ifdef CONFIG_PM - extern void usb_hcd_suspend_root_hub (struct usb_hcd *hcd); - extern void usb_hcd_resume_root_hub (struct usb_hcd *hcd); -+extern void usb_root_hub_lost_power (struct usb_device *rhdev); - extern int hcd_bus_suspend (struct usb_bus *bus); - extern int hcd_bus_resume (struct usb_bus *bus); - #else ---- gregkh-2.6.orig/drivers/usb/host/ehci-pci.c -+++ gregkh-2.6/drivers/usb/host/ehci-pci.c -@@ -278,7 +278,6 @@ static int ehci_pci_resume(struct usb_hc - { - struct ehci_hcd *ehci = hcd_to_ehci(hcd); - unsigned port; -- struct usb_device *root = hcd->self.root_hub; - struct pci_dev *pdev = to_pci_dev(hcd->self.controller); - int retval = -EINVAL; - -@@ -312,13 +311,7 @@ static int ehci_pci_resume(struct usb_hc - - restart: - ehci_dbg(ehci, "lost power, restarting\n"); -- for (port = HCS_N_PORTS(ehci->hcs_params); port > 0; ) { -- port--; -- if (!root->children [port]) -- continue; -- usb_set_device_state(root->children[port], -- USB_STATE_NOTATTACHED); -- } -+ usb_root_hub_lost_power(hcd->self.root_hub); - - /* Else reset, to cope with power loss or flush-to-storage - * style "resume" having let BIOS kick in during reboot. ---- gregkh-2.6.orig/drivers/usb/host/uhci-hcd.c -+++ gregkh-2.6/drivers/usb/host/uhci-hcd.c -@@ -748,8 +748,12 @@ static int uhci_resume(struct usb_hcd *h - check_and_reset_hc(uhci); - configure_hc(uhci); - -- if (uhci->rh_state == UHCI_RH_RESET) -+ if (uhci->rh_state == UHCI_RH_RESET) { -+ -+ /* The controller had to be reset */ -+ usb_root_hub_lost_power(hcd->self.root_hub); - suspend_rh(uhci, UHCI_RH_SUSPENDED); -+ } - - spin_unlock_irq(&uhci->lock); - ---- gregkh-2.6.orig/drivers/usb/host/ohci-hcd.c -+++ gregkh-2.6/drivers/usb/host/ohci-hcd.c -@@ -795,7 +795,6 @@ static int ohci_restart (struct ohci_hcd - int temp; - int i; - struct urb_priv *priv; -- struct usb_device *root = ohci_to_hcd(ohci)->self.root_hub; - - /* mark any devices gone, so they do nothing till khubd disconnects. - * recycle any "live" eds/tds (and urbs) right away. -@@ -804,11 +803,7 @@ static int ohci_restart (struct ohci_hcd - */ - spin_lock_irq(&ohci->lock); - disable (ohci); -- for (i = 0; i < root->maxchild; i++) { -- if (root->children [i]) -- usb_set_device_state (root->children[i], -- USB_STATE_NOTATTACHED); -- } -+ usb_root_hub_lost_power(ohci_to_hcd(ohci)->self.root_hub); - if (!list_empty (&ohci->pending)) - ohci_dbg(ohci, "abort schedule...\n"); - list_for_each_entry (priv, &ohci->pending, pending) { ---- gregkh-2.6.orig/drivers/usb/host/sl811-hcd.c -+++ gregkh-2.6/drivers/usb/host/sl811-hcd.c -@@ -1803,6 +1803,7 @@ sl811h_resume(struct platform_device *de - || !device_can_wakeup(&hcd->self.root_hub->dev)) { - sl811->port1 = 0; - port_power(sl811, 1); -+ usb_root_hub_lost_power(hcd->self.root_hub); - return 0; - } - diff --git a/usb/usbcore-consider-power-budget-when-choosing-configuration.patch b/usb/usbcore-consider-power-budget-when-choosing-configuration.patch deleted file mode 100644 index ce66ba1ab63fa..0000000000000 --- a/usb/usbcore-consider-power-budget-when-choosing-configuration.patch +++ /dev/null @@ -1,454 +0,0 @@ -From stern@rowland.harvard.edu Wed Nov 23 10:02:34 2005 -Date: Wed, 23 Nov 2005 12:03:12 -0500 (EST) -From: Alan Stern <stern@rowland.harvard.edu> -To: Greg KH <greg@kroah.com> -Subject: usbcore: Consider power budget when choosing configuration -Message-ID: <Pine.LNX.4.44L0.0511231128400.4477-100000@iolanthe.rowland.org> - -This patch (as609) changes the way we keep track of power budgeting for -USB hubs and devices, and it updates the choose_configuration routine to -take this information into account. (This is something we should have -been doing all along.) A new field in struct usb_device holds the amount -of bus current available from the upstream port, and the usb_hub structure -keeps track of the current available for each downstream port. - -Two new rules for configuration selection are added: - - Don't select a self-powered configuration when only bus power - is available. - - Don't select a configuration requiring more bus power than is - available. - -However the first rule is #if-ed out, because I found that the internal -hub in my HP USB keyboard claims that its only configuration is -self-powered. The rule would prevent the configuration from being chosen, -leaving the hub & keyboard unconfigured. Since similar descriptor errors -may turn out to be fairly common, it seemed wise not to include a rule -that would break automatic configuration unnecessarily for such devices. - -The second rule may also trigger unnecessarily, although this should be -less common. More likely it will annoy people by sometimes failing to -accept configurations that should never have been chosen in the first -place. - -The patch also changes usbcore's reaction when no configuration is -suitable. Instead of raising an error and rejecting the device, now -the core will simply leave the device unconfigured. People can always -work around such problems by installing configurations manually through -sysfs. - -Signed-off-by: Alan Stern <stern@rowland.harvard.edu> -Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> - ---- - drivers/usb/core/hcd.c | 5 - drivers/usb/core/hub.c | 231 +++++++++++++++++++++++++++++---------------- - drivers/usb/core/hub.h | 3 - drivers/usb/core/message.c | 6 + - include/linux/usb.h | 2 - 5 files changed, 165 insertions(+), 82 deletions(-) - ---- gregkh-2.6.orig/drivers/usb/core/hub.c -+++ gregkh-2.6/drivers/usb/core/hub.c -@@ -702,26 +702,40 @@ static int hub_configure(struct usb_hub - * and battery-powered root hubs (may provide just 8 mA). - */ - ret = usb_get_status(hdev, USB_RECIP_DEVICE, 0, &hubstatus); -- if (ret < 0) { -+ if (ret < 2) { - message = "can't get hub status"; - goto fail; - } - le16_to_cpus(&hubstatus); - if (hdev == hdev->bus->root_hub) { -- struct usb_hcd *hcd = -- container_of(hdev->bus, struct usb_hcd, self); -- -- hub->power_budget = min(500u, hcd->power_budget) / 2; -+ if (hdev->bus_mA == 0 || hdev->bus_mA >= 500) -+ hub->mA_per_port = 500; -+ else { -+ hub->mA_per_port = hdev->bus_mA; -+ hub->limited_power = 1; -+ } - } else if ((hubstatus & (1 << USB_DEVICE_SELF_POWERED)) == 0) { - dev_dbg(hub_dev, "hub controller current requirement: %dmA\n", - hub->descriptor->bHubContrCurrent); -- hub->power_budget = (501 - hub->descriptor->bHubContrCurrent) -- / 2; -- } -- if (hub->power_budget) -- dev_dbg(hub_dev, "%dmA bus power budget for children\n", -- hub->power_budget * 2); -- -+ hub->limited_power = 1; -+ if (hdev->maxchild > 0) { -+ int remaining = hdev->bus_mA - -+ hub->descriptor->bHubContrCurrent; -+ -+ if (remaining < hdev->maxchild * 100) -+ dev_warn(hub_dev, -+ "insufficient power available " -+ "to use all downstream ports\n"); -+ hub->mA_per_port = 100; /* 7.2.1.1 */ -+ } -+ } else { /* Self-powered external hub */ -+ /* FIXME: What about battery-powered external hubs that -+ * provide less current per port? */ -+ hub->mA_per_port = 500; -+ } -+ if (hub->mA_per_port < 500) -+ dev_dbg(hub_dev, "%umA bus power budget for each child\n", -+ hub->mA_per_port); - - ret = hub_hub_status(hub, &hubstatus, &hubchange); - if (ret < 0) { -@@ -1136,45 +1150,107 @@ void usb_disconnect(struct usb_device ** - device_unregister(&udev->dev); - } - -+static inline const char *plural(int n) -+{ -+ return (n == 1 ? "" : "s"); -+} -+ - static int choose_configuration(struct usb_device *udev) - { -- int c, i; -+ int i; -+ u16 devstatus; -+ int bus_powered; -+ int num_configs; -+ struct usb_host_config *c, *best; -+ -+ /* If this fails, assume the device is bus-powered */ -+ devstatus = 0; -+ usb_get_status(udev, USB_RECIP_DEVICE, 0, &devstatus); -+ le16_to_cpus(&devstatus); -+ bus_powered = ((devstatus & (1 << USB_DEVICE_SELF_POWERED)) == 0); -+ dev_dbg(&udev->dev, "device is %s-powered\n", -+ bus_powered ? "bus" : "self"); -+ -+ best = NULL; -+ c = udev->config; -+ num_configs = udev->descriptor.bNumConfigurations; -+ for (i = 0; i < num_configs; (i++, c++)) { -+ struct usb_interface_descriptor *desc = -+ &c->intf_cache[0]->altsetting->desc; -+ -+ /* -+ * HP's USB bus-powered keyboard has only one configuration -+ * and it claims to be self-powered; other devices may have -+ * similar errors in their descriptors. If the next test -+ * were allowed to execute, such configurations would always -+ * be rejected and the devices would not work as expected. -+ */ -+#if 0 -+ /* Rule out self-powered configs for a bus-powered device */ -+ if (bus_powered && (c->desc.bmAttributes & -+ USB_CONFIG_ATT_SELFPOWER)) -+ continue; -+#endif - -- /* NOTE: this should interact with hub power budgeting */ -+ /* -+ * The next test may not be as effective as it should be. -+ * Some hubs have errors in their descriptor, claiming -+ * to be self-powered when they are really bus-powered. -+ * We will overestimate the amount of current such hubs -+ * make available for each port. -+ * -+ * This is a fairly benign sort of failure. It won't -+ * cause us to reject configurations that we should have -+ * accepted. -+ */ - -- c = udev->config[0].desc.bConfigurationValue; -- if (udev->descriptor.bNumConfigurations != 1) { -- for (i = 0; i < udev->descriptor.bNumConfigurations; i++) { -- struct usb_interface_descriptor *desc; -+ /* Rule out configs that draw too much bus current */ -+ if (c->desc.bMaxPower * 2 > udev->bus_mA) -+ continue; - -- /* heuristic: Linux is more likely to have class -- * drivers, so avoid vendor-specific interfaces. -- */ -- desc = &udev->config[i].intf_cache[0] -- ->altsetting->desc; -- if (desc->bInterfaceClass == USB_CLASS_VENDOR_SPEC) -- continue; -- /* COMM/2/all is CDC ACM, except 0xff is MSFT RNDIS. -- * MSFT needs this to be the first config; never use -- * it as the default unless Linux has host-side RNDIS. -- * A second config would ideally be CDC-Ethernet, but -- * may instead be the "vendor specific" CDC subset -- * long used by ARM Linux for sa1100 or pxa255. -- */ -- if (desc->bInterfaceClass == USB_CLASS_COMM -- && desc->bInterfaceSubClass == 2 -- && desc->bInterfaceProtocol == 0xff) { -- c = udev->config[1].desc.bConfigurationValue; -- continue; -- } -- c = udev->config[i].desc.bConfigurationValue; -+ /* If the first config's first interface is COMM/2/0xff -+ * (MSFT RNDIS), rule it out unless Linux has host-side -+ * RNDIS support. */ -+ if (i == 0 && desc->bInterfaceClass == USB_CLASS_COMM -+ && desc->bInterfaceSubClass == 2 -+ && desc->bInterfaceProtocol == 0xff) { -+#ifndef CONFIG_USB_NET_RNDIS -+ continue; -+#else -+ best = c; -+#endif -+ } -+ -+ /* From the remaining configs, choose the first one whose -+ * first interface is for a non-vendor-specific class. -+ * Reason: Linux is more likely to have a class driver -+ * than a vendor-specific driver. */ -+ else if (udev->descriptor.bDeviceClass != -+ USB_CLASS_VENDOR_SPEC && -+ desc->bInterfaceClass != -+ USB_CLASS_VENDOR_SPEC) { -+ best = c; - break; - } -+ -+ /* If all the remaining configs are vendor-specific, -+ * choose the first one. */ -+ else if (!best) -+ best = c; -+ } -+ -+ if (best) { -+ i = best->desc.bConfigurationValue; - dev_info(&udev->dev, -- "configuration #%d chosen from %d choices\n", -- c, udev->descriptor.bNumConfigurations); -+ "configuration #%d chosen from %d choice%s\n", -+ i, num_configs, plural(num_configs)); -+ } else { -+ i = -1; -+ dev_warn(&udev->dev, -+ "no configuration chosen from %d choice%s\n", -+ num_configs, plural(num_configs)); - } -- return c; -+ return i; - } - - #ifdef DEBUG -@@ -1327,17 +1403,13 @@ int usb_new_device(struct usb_device *ud - * with the driver core, and lets usb device drivers bind to them. - */ - c = choose_configuration(udev); -- if (c < 0) -- dev_warn(&udev->dev, -- "can't choose an initial configuration\n"); -- else { -+ if (c >= 0) { - err = usb_set_configuration(udev, c); - if (err) { - dev_err(&udev->dev, "can't set config #%d, error %d\n", - c, err); -- usb_remove_sysfs_dev_files(udev); -- device_del(&udev->dev); -- goto fail; -+ /* This need not be fatal. The user can try to -+ * set other configurations. */ - } - } - -@@ -1702,7 +1774,7 @@ static int finish_device_resume(struct u - * and device drivers will know about any resume quirks. - */ - status = usb_get_status(udev, USB_RECIP_DEVICE, 0, &devstatus); -- if (status < 0) -+ if (status < 2) - dev_dbg(&udev->dev, - "gone after usb resume? status %d\n", - status); -@@ -1711,7 +1783,7 @@ static int finish_device_resume(struct u - int (*resume)(struct device *); - - le16_to_cpus(&devstatus); -- if (devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP) -+ if ((devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP)) - && udev->parent) { - status = usb_control_msg(udev, - usb_sndctrlpipe(udev, 0), -@@ -2374,39 +2446,36 @@ hub_power_remaining (struct usb_hub *hub - { - struct usb_device *hdev = hub->hdev; - int remaining; -- unsigned i; -+ int port1; - -- remaining = hub->power_budget; -- if (!remaining) /* self-powered */ -+ if (!hub->limited_power) - return 0; - -- for (i = 0; i < hdev->maxchild; i++) { -- struct usb_device *udev = hdev->children[i]; -- int delta, ceiling; -+ remaining = hdev->bus_mA - hub->descriptor->bHubContrCurrent; -+ for (port1 = 1; port1 <= hdev->maxchild; ++port1) { -+ struct usb_device *udev = hdev->children[port1 - 1]; -+ int delta; - - if (!udev) - continue; - -- /* 100mA per-port ceiling, or 8mA for OTG ports */ -- if (i != (udev->bus->otg_port - 1) || hdev->parent) -- ceiling = 50; -- else -- ceiling = 4; -- -+ /* Unconfigured devices may not use more than 100mA, -+ * or 8mA for OTG ports */ - if (udev->actconfig) -- delta = udev->actconfig->desc.bMaxPower; -+ delta = udev->actconfig->desc.bMaxPower * 2; -+ else if (port1 != udev->bus->otg_port || hdev->parent) -+ delta = 100; - else -- delta = ceiling; -- // dev_dbg(&udev->dev, "budgeted %dmA\n", 2 * delta); -- if (delta > ceiling) -- dev_warn(&udev->dev, "%dmA over %dmA budget!\n", -- 2 * (delta - ceiling), 2 * ceiling); -+ delta = 8; -+ if (delta > hub->mA_per_port) -+ dev_warn(&udev->dev, "%dmA is over %umA budget " -+ "for port %d!\n", -+ delta, hub->mA_per_port, port1); - remaining -= delta; - } - if (remaining < 0) { -- dev_warn(hub->intfdev, -- "%dmA over power budget!\n", -- -2 * remaining); -+ dev_warn(hub->intfdev, "%dmA over power budget!\n", -+ - remaining); - remaining = 0; - } - return remaining; -@@ -2501,7 +2570,8 @@ static void hub_port_connect_change(stru - - usb_set_device_state(udev, USB_STATE_POWERED); - udev->speed = USB_SPEED_UNKNOWN; -- -+ udev->bus_mA = hub->mA_per_port; -+ - /* set the address */ - choose_address(udev); - if (udev->devnum <= 0) { -@@ -2521,16 +2591,16 @@ static void hub_port_connect_change(stru - * on the parent. - */ - if (udev->descriptor.bDeviceClass == USB_CLASS_HUB -- && hub->power_budget) { -+ && udev->bus_mA <= 100) { - u16 devstat; - - status = usb_get_status(udev, USB_RECIP_DEVICE, 0, - &devstat); -- if (status < 0) { -+ if (status < 2) { - dev_dbg(&udev->dev, "get status %d ?\n", status); - goto loop_disable; - } -- cpu_to_le16s(&devstat); -+ le16_to_cpus(&devstat); - if ((devstat & (1 << USB_DEVICE_SELF_POWERED)) == 0) { - dev_err(&udev->dev, - "can't connect bus-powered hub " -@@ -2583,9 +2653,7 @@ static void hub_port_connect_change(stru - - status = hub_power_remaining(hub); - if (status) -- dev_dbg(hub_dev, -- "%dmA power budget left\n", -- 2 * status); -+ dev_dbg(hub_dev, "%dmA power budget left\n", status); - - return; - -@@ -2797,6 +2865,11 @@ static void hub_events(void) - if (hubchange & HUB_CHANGE_LOCAL_POWER) { - dev_dbg (hub_dev, "power change\n"); - clear_hub_feature(hdev, C_HUB_LOCAL_POWER); -+ if (hubstatus & HUB_STATUS_LOCAL_POWER) -+ /* FIXME: Is this always true? */ -+ hub->limited_power = 0; -+ else -+ hub->limited_power = 1; - } - if (hubchange & HUB_CHANGE_OVERCURRENT) { - dev_dbg (hub_dev, "overcurrent change\n"); ---- gregkh-2.6.orig/drivers/usb/core/hub.h -+++ gregkh-2.6/drivers/usb/core/hub.h -@@ -220,8 +220,9 @@ struct usb_hub { - struct usb_hub_descriptor *descriptor; /* class descriptor */ - struct usb_tt tt; /* Transaction Translator */ - -- u8 power_budget; /* in 2mA units; or zero */ -+ unsigned mA_per_port; /* current for each child */ - -+ unsigned limited_power:1; - unsigned quiescing:1; - unsigned activating:1; - unsigned resume_root_hub:1; ---- gregkh-2.6.orig/drivers/usb/core/hcd.c -+++ gregkh-2.6/drivers/usb/core/hcd.c -@@ -1825,8 +1825,6 @@ int usb_add_hcd(struct usb_hcd *hcd, - retval = -ENOMEM; - goto err_allocate_root_hub; - } -- rhdev->speed = (hcd->driver->flags & HCD_USB2) ? USB_SPEED_HIGH : -- USB_SPEED_FULL; - - /* Although in principle hcd->driver->start() might need to use rhdev, - * none of the current drivers do. -@@ -1844,6 +1842,9 @@ int usb_add_hcd(struct usb_hcd *hcd, - dev_dbg(hcd->self.controller, "supports USB remote wakeup\n"); - hcd->remote_wakeup = hcd->can_wakeup; - -+ rhdev->speed = (hcd->driver->flags & HCD_USB2) ? USB_SPEED_HIGH : -+ USB_SPEED_FULL; -+ rhdev->bus_mA = min(500u, hcd->power_budget); - if ((retval = register_root_hub(rhdev, hcd)) != 0) - goto err_register_root_hub; - ---- gregkh-2.6.orig/include/linux/usb.h -+++ gregkh-2.6/include/linux/usb.h -@@ -347,6 +347,8 @@ struct usb_device { - - char **rawdescriptors; /* Raw descriptors for each config */ - -+ unsigned short bus_mA; /* Current available from the bus */ -+ - int have_langid; /* whether string_langid is valid */ - int string_langid; /* language ID for strings */ - ---- gregkh-2.6.orig/drivers/usb/core/message.c -+++ gregkh-2.6/drivers/usb/core/message.c -@@ -1387,6 +1387,12 @@ free_interfaces: - if (dev->state != USB_STATE_ADDRESS) - usb_disable_device (dev, 1); // Skip ep0 - -+ n = dev->bus_mA - cp->desc.bMaxPower * 2; -+ if (n < 0) -+ dev_warn(&dev->dev, "new config #%d exceeds power " -+ "limit by %dmA\n", -+ configuration, -n); -+ - if ((ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - USB_REQ_SET_CONFIGURATION, 0, configuration, 0, - NULL, 0, USB_CTRL_SET_TIMEOUT)) < 0) diff --git a/usb/usbcore-fix-local-variable-clash.patch b/usb/usbcore-fix-local-variable-clash.patch deleted file mode 100644 index d4dbaa1c85819..0000000000000 --- a/usb/usbcore-fix-local-variable-clash.patch +++ /dev/null @@ -1,35 +0,0 @@ -From stern@rowland.harvard.edu Tue Dec 13 07:35:15 2005 -Date: Tue, 13 Dec 2005 10:32:13 -0500 (EST) -From: Alan Stern <stern@rowland.harvard.edu> -To: Greg KH <greg@kroah.com> -cc: "J.A. Magallon" <jamagallon@able.es> -Subject: usbcore: fix local variable clash -Message-ID: <Pine.LNX.4.44L0.0512131029580.4831-100000@iolanthe.rowland.org> - -This patch (as621) fixes a local variable conflict I accidently -introduced into usb_set_configuration. - -Signed-off-by: Alan Stern <stern@rowland.harvard.edu> -Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> - ---- - drivers/usb/core/message.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - ---- gregkh-2.6.orig/drivers/usb/core/message.c -+++ gregkh-2.6/drivers/usb/core/message.c -@@ -1387,11 +1387,11 @@ free_interfaces: - if (dev->state != USB_STATE_ADDRESS) - usb_disable_device (dev, 1); // Skip ep0 - -- n = dev->bus_mA - cp->desc.bMaxPower * 2; -- if (n < 0) -+ i = dev->bus_mA - cp->desc.bMaxPower * 2; -+ if (i < 0) - dev_warn(&dev->dev, "new config #%d exceeds power " - "limit by %dmA\n", -- configuration, -n); -+ configuration, -i); - - if ((ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - USB_REQ_SET_CONFIGURATION, 0, configuration, 0, diff --git a/usb/usbserial-adds-missing-checks-and-bug-fix.patch b/usb/usbserial-adds-missing-checks-and-bug-fix.patch deleted file mode 100644 index e38f80a15b261..0000000000000 --- a/usb/usbserial-adds-missing-checks-and-bug-fix.patch +++ /dev/null @@ -1,130 +0,0 @@ -From lcapitulino@mandriva.com.br Mon Nov 28 13:24:54 2005 -Date: Mon, 28 Nov 2005 19:16:05 -0200 -From: Luiz Fernando Capitulino <lcapitulino@mandriva.com.br> -To: gregkh@suse.de -Cc: akpm <akpm@osdl.org>, <ehabkost@mandriva.com> -Subject: usbserial: Adds missing checks and bug fix. -Message-Id: <20051128191605.096bb777.lcapitulino@mandriva.com.br> - - -Checks if 'port' is NULL before using it in all tty operations, this -can avoid NULL pointer dereferences. - -Signed-off-by: Luiz Capitulino <lcapitulino@mandriva.com.br> -Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> - ---- - drivers/usb/serial/usb-serial.c | 32 ++++++++++++++++++++++++++++++++ - 1 file changed, 32 insertions(+) - ---- gregkh-2.6.orig/drivers/usb/serial/usb-serial.c -+++ gregkh-2.6/drivers/usb/serial/usb-serial.c -@@ -188,6 +188,8 @@ static int serial_open (struct tty_struc - - portNumber = tty->index - serial->minor; - port = serial->port[portNumber]; -+ if (!port) -+ return -ENODEV; - - ++port->open_count; - -@@ -258,6 +260,9 @@ static int serial_write (struct tty_stru - struct usb_serial_port *port = tty->driver_data; - int retval = -EINVAL; - -+ if (!port) -+ goto exit; -+ - dbg("%s - port %d, %d byte(s)", __FUNCTION__, port->number, count); - - if (!port->open_count) { -@@ -277,6 +282,9 @@ static int serial_write_room (struct tty - struct usb_serial_port *port = tty->driver_data; - int retval = -EINVAL; - -+ if (!port) -+ goto exit; -+ - dbg("%s - port %d", __FUNCTION__, port->number); - - if (!port->open_count) { -@@ -296,6 +304,9 @@ static int serial_chars_in_buffer (struc - struct usb_serial_port *port = tty->driver_data; - int retval = -EINVAL; - -+ if (!port) -+ goto exit; -+ - dbg("%s = port %d", __FUNCTION__, port->number); - - if (!port->open_count) { -@@ -314,6 +325,9 @@ static void serial_throttle (struct tty_ - { - struct usb_serial_port *port = tty->driver_data; - -+ if (!port) -+ return; -+ - dbg("%s - port %d", __FUNCTION__, port->number); - - if (!port->open_count) { -@@ -330,6 +344,9 @@ static void serial_unthrottle (struct tt - { - struct usb_serial_port *port = tty->driver_data; - -+ if (!port) -+ return; -+ - dbg("%s - port %d", __FUNCTION__, port->number); - - if (!port->open_count) { -@@ -347,6 +364,9 @@ static int serial_ioctl (struct tty_stru - struct usb_serial_port *port = tty->driver_data; - int retval = -ENODEV; - -+ if (!port) -+ goto exit; -+ - dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd); - - if (!port->open_count) { -@@ -368,6 +388,9 @@ static void serial_set_termios (struct t - { - struct usb_serial_port *port = tty->driver_data; - -+ if (!port) -+ return; -+ - dbg("%s - port %d", __FUNCTION__, port->number); - - if (!port->open_count) { -@@ -384,6 +407,9 @@ static void serial_break (struct tty_str - { - struct usb_serial_port *port = tty->driver_data; - -+ if (!port) -+ return; -+ - dbg("%s - port %d", __FUNCTION__, port->number); - - if (!port->open_count) { -@@ -445,6 +471,9 @@ static int serial_tiocmget (struct tty_s - { - struct usb_serial_port *port = tty->driver_data; - -+ if (!port) -+ goto exit; -+ - dbg("%s - port %d", __FUNCTION__, port->number); - - if (!port->open_count) { -@@ -464,6 +493,9 @@ static int serial_tiocmset (struct tty_s - { - struct usb_serial_port *port = tty->driver_data; - -+ if (!port) -+ goto exit; -+ - dbg("%s - port %d", __FUNCTION__, port->number); - - if (!port->open_count) { diff --git a/usb/usbserial-race-condition-fix.patch b/usb/usbserial-race-condition-fix.patch deleted file mode 100644 index 54ffc20329191..0000000000000 --- a/usb/usbserial-race-condition-fix.patch +++ /dev/null @@ -1,126 +0,0 @@ -From lcapitulino@mandriva.com.br Mon Nov 28 13:24:54 2005 -Date: Mon, 28 Nov 2005 19:16:07 -0200 -From: Luiz Fernando Capitulino <lcapitulino@mandriva.com.br> -To: gregkh@suse.de -Cc: akpm <akpm@osdl.org>, <ehabkost@mandriva.com> -Subject: usbserial: race-condition fix. -Message-Id: <20051128191607.595f1725.lcapitulino@mandriva.com.br> - - -There is a race-condition in usb-serial driver that can be triggered if -a processes does 'port->tty->driver_data = NULL' in serial_close() while -other processes is in kernel-space about to call serial_ioctl() on the -same port. - -This happens because a process can open the device while there is -another one closing it. - -The patch below fixes that by adding a semaphore to ensure that no -process will open the device while another process is closing it. - -Note that we can't use spinlocks here, since serial_open() and -serial_close() can sleep. - - -Signed-off-by: Luiz Capitulino <lcapitulino@mandriva.com.br> -Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> - - ---- - drivers/usb/serial/usb-serial.c | 14 +++++++++++++- - drivers/usb/serial/usb-serial.h | 4 ++++ - 2 files changed, 17 insertions(+), 1 deletion(-) - ---- gregkh-2.6.orig/drivers/usb/serial/usb-serial.c -+++ gregkh-2.6/drivers/usb/serial/usb-serial.c -@@ -30,6 +30,7 @@ - #include <linux/list.h> - #include <linux/smp_lock.h> - #include <asm/uaccess.h> -+#include <asm/semaphore.h> - #include <linux/usb.h> - #include "usb-serial.h" - #include "pl2303.h" -@@ -190,6 +191,9 @@ static int serial_open (struct tty_struc - port = serial->port[portNumber]; - if (!port) - return -ENODEV; -+ -+ if (down_interruptible(&port->sem)) -+ return -ERESTARTSYS; - - ++port->open_count; - -@@ -215,6 +219,7 @@ static int serial_open (struct tty_struc - goto bailout_module_put; - } - -+ up(&port->sem); - return 0; - - bailout_module_put: -@@ -222,6 +227,7 @@ bailout_module_put: - bailout_kref_put: - kref_put(&serial->kref, destroy_serial); - port->open_count = 0; -+ up(&port->sem); - return retval; - } - -@@ -234,8 +240,10 @@ static void serial_close(struct tty_stru - - dbg("%s - port %d", __FUNCTION__, port->number); - -+ down(&port->sem); -+ - if (port->open_count == 0) -- return; -+ goto out; - - --port->open_count; - if (port->open_count == 0) { -@@ -253,6 +261,9 @@ static void serial_close(struct tty_stru - } - - kref_put(&port->serial->kref, destroy_serial); -+ -+out: -+ up(&port->sem); - } - - static int serial_write (struct tty_struct * tty, const unsigned char *buf, int count) -@@ -774,6 +785,7 @@ int usb_serial_probe(struct usb_interfac - port->number = i + serial->minor; - port->serial = serial; - spin_lock_init(&port->lock); -+ sema_init(&port->sem, 1); - INIT_WORK(&port->work, usb_serial_port_softint, port); - serial->port[i] = port; - } ---- gregkh-2.6.orig/drivers/usb/serial/usb-serial.h -+++ gregkh-2.6/drivers/usb/serial/usb-serial.h -@@ -16,6 +16,7 @@ - - #include <linux/config.h> - #include <linux/kref.h> -+#include <asm/semaphore.h> - - #define SERIAL_TTY_MAJOR 188 /* Nice legal number now */ - #define SERIAL_TTY_MINORS 255 /* loads of devices :) */ -@@ -30,6 +31,8 @@ - * @serial: pointer back to the struct usb_serial owner of this port. - * @tty: pointer to the corresponding tty for this port. - * @lock: spinlock to grab when updating portions of this structure. -+ * @sem: semaphore used to synchronize serial_open() and serial_close() -+ * access for this port. - * @number: the number of the port (the minor number). - * @interrupt_in_buffer: pointer to the interrupt in buffer for this port. - * @interrupt_in_urb: pointer to the interrupt in struct urb for this port. -@@ -60,6 +63,7 @@ struct usb_serial_port { - struct usb_serial * serial; - struct tty_struct * tty; - spinlock_t lock; -+ struct semaphore sem; - unsigned char number; - - unsigned char * interrupt_in_buffer; |