aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/ub.c60
1 files changed, 12 insertions, 48 deletions
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index cfb824d90c86..60e9a9457c6b 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -10,17 +10,13 @@
10 * TODO (sorted by decreasing priority) 10 * TODO (sorted by decreasing priority)
11 * -- set readonly flag for CDs, set removable flag for CF readers 11 * -- set readonly flag for CDs, set removable flag for CF readers
12 * -- do inquiry and verify we got a disk and not a tape (for LUN mismatch) 12 * -- do inquiry and verify we got a disk and not a tape (for LUN mismatch)
13 * -- special case some senses, e.g. 3a/0 -> no media present, reduce retries
14 * -- verify the 13 conditions and do bulk resets 13 * -- verify the 13 conditions and do bulk resets
15 * -- kill last_pipe and simply do two-state clearing on both pipes
16 * -- highmem 14 * -- highmem
17 * -- move top_sense and work_bcs into separate allocations (if they survive) 15 * -- move top_sense and work_bcs into separate allocations (if they survive)
18 * for cache purists and esoteric architectures. 16 * for cache purists and esoteric architectures.
19 * -- Allocate structure for LUN 0 before the first ub_sync_tur, avoid NULL. ? 17 * -- Allocate structure for LUN 0 before the first ub_sync_tur, avoid NULL. ?
20 * -- prune comments, they are too volumnous 18 * -- prune comments, they are too volumnous
21 * -- Exterminate P3 printks
22 * -- Resove XXX's 19 * -- Resove XXX's
23 * -- Redo "benh's retries", perhaps have spin-up code to handle them. V:D=?
24 * -- CLEAR, CLR2STS, CLRRS seem to be ripe for refactoring. 20 * -- CLEAR, CLR2STS, CLRRS seem to be ripe for refactoring.
25 */ 21 */
26#include <linux/kernel.h> 22#include <linux/kernel.h>
@@ -180,7 +176,6 @@ struct ub_dev;
180#define UB_DIR_ILLEGAL2 2 176#define UB_DIR_ILLEGAL2 2
181#define UB_DIR_WRITE 3 177#define UB_DIR_WRITE 3
182 178
183/* P3 */
184#define UB_DIR_CHAR(c) (((c)==UB_DIR_WRITE)? 'w': \ 179#define UB_DIR_CHAR(c) (((c)==UB_DIR_WRITE)? 'w': \
185 (((c)==UB_DIR_READ)? 'r': 'n')) 180 (((c)==UB_DIR_READ)? 'r': 'n'))
186 181
@@ -669,8 +664,9 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq)
669 */ 664 */
670 n_elem = blk_rq_map_sg(lun->disk->queue, rq, &urq->sgv[0]); 665 n_elem = blk_rq_map_sg(lun->disk->queue, rq, &urq->sgv[0]);
671 if (n_elem < 0) { 666 if (n_elem < 0) {
667 /* Impossible, because blk_rq_map_sg should not hit ENOMEM. */
672 printk(KERN_INFO "%s: failed request map (%d)\n", 668 printk(KERN_INFO "%s: failed request map (%d)\n",
673 lun->name, n_elem); /* P3 */ 669 lun->name, n_elem);
674 goto drop; 670 goto drop;
675 } 671 }
676 if (n_elem > UB_MAX_REQ_SG) { /* Paranoia */ 672 if (n_elem > UB_MAX_REQ_SG) { /* Paranoia */
@@ -824,7 +820,9 @@ static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun,
824 if (urq->current_try >= 3) 820 if (urq->current_try >= 3)
825 return -EIO; 821 return -EIO;
826 urq->current_try++; 822 urq->current_try++;
827 /* P3 */ printk("%s: dir %c len/act %d/%d " 823
824 /* Remove this if anyone complains of flooding. */
825 printk(KERN_DEBUG "%s: dir %c len/act %d/%d "
828 "[sense %x %02x %02x] retry %d\n", 826 "[sense %x %02x %02x] retry %d\n",
829 sc->name, UB_DIR_CHAR(cmd->dir), cmd->len, cmd->act_len, 827 sc->name, UB_DIR_CHAR(cmd->dir), cmd->len, cmd->act_len,
830 cmd->key, cmd->asc, cmd->ascq, urq->current_try); 828 cmd->key, cmd->asc, cmd->ascq, urq->current_try);
@@ -1241,8 +1239,6 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1241 * to check. But it's not all right if the device 1239 * to check. But it's not all right if the device
1242 * counts disagree with our counts. 1240 * counts disagree with our counts.
1243 */ 1241 */
1244 /* P3 */ printk("%s: resid %d len %d act %d\n",
1245 sc->name, len, cmd->len, cmd->act_len);
1246 goto Bad_End; 1242 goto Bad_End;
1247 } 1243 }
1248 1244
@@ -1253,7 +1249,6 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1253 ub_state_sense(sc, cmd); 1249 ub_state_sense(sc, cmd);
1254 return; 1250 return;
1255 case US_BULK_STAT_PHASE: 1251 case US_BULK_STAT_PHASE:
1256 /* P3 */ printk("%s: status PHASE\n", sc->name);
1257 goto Bad_End; 1252 goto Bad_End;
1258 default: 1253 default:
1259 printk(KERN_INFO "%s: unknown CSW status 0x%x\n", 1254 printk(KERN_INFO "%s: unknown CSW status 0x%x\n",
@@ -1568,16 +1563,14 @@ static void ub_reset_task(void *arg)
1568 } 1563 }
1569 1564
1570 if (atomic_read(&sc->poison)) { 1565 if (atomic_read(&sc->poison)) {
1571 printk(KERN_NOTICE "%s: Not resetting disconnected device\n", 1566 ;
1572 sc->name); /* P3 This floods. Remove soon. XXX */
1573 } else if ((sc->reset & 1) == 0) { 1567 } else if ((sc->reset & 1) == 0) {
1574 ub_sync_reset(sc); 1568 ub_sync_reset(sc);
1575 msleep(700); /* usb-storage sleeps 6s (!) */ 1569 msleep(700); /* usb-storage sleeps 6s (!) */
1576 ub_probe_clear_stall(sc, sc->recv_bulk_pipe); 1570 ub_probe_clear_stall(sc, sc->recv_bulk_pipe);
1577 ub_probe_clear_stall(sc, sc->send_bulk_pipe); 1571 ub_probe_clear_stall(sc, sc->send_bulk_pipe);
1578 } else if (sc->dev->actconfig->desc.bNumInterfaces != 1) { 1572 } else if (sc->dev->actconfig->desc.bNumInterfaces != 1) {
1579 printk(KERN_NOTICE "%s: Not resetting multi-interface device\n", 1573 ;
1580 sc->name); /* P3 This floods. Remove soon. XXX */
1581 } else { 1574 } else {
1582 if ((lkr = usb_lock_device_for_reset(sc->dev, sc->intf)) < 0) { 1575 if ((lkr = usb_lock_device_for_reset(sc->dev, sc->intf)) < 0) {
1583 printk(KERN_NOTICE 1576 printk(KERN_NOTICE
@@ -1819,10 +1812,8 @@ static int ub_sync_tur(struct ub_dev *sc, struct ub_lun *lun)
1819 rc = ub_submit_scsi(sc, cmd); 1812 rc = ub_submit_scsi(sc, cmd);
1820 spin_unlock_irqrestore(sc->lock, flags); 1813 spin_unlock_irqrestore(sc->lock, flags);
1821 1814
1822 if (rc != 0) { 1815 if (rc != 0)
1823 printk("ub: testing ready: submit error (%d)\n", rc); /* P3 */
1824 goto err_submit; 1816 goto err_submit;
1825 }
1826 1817
1827 wait_for_completion(&compl); 1818 wait_for_completion(&compl);
1828 1819
@@ -1880,20 +1871,16 @@ static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun,
1880 rc = ub_submit_scsi(sc, cmd); 1871 rc = ub_submit_scsi(sc, cmd);
1881 spin_unlock_irqrestore(sc->lock, flags); 1872 spin_unlock_irqrestore(sc->lock, flags);
1882 1873
1883 if (rc != 0) { 1874 if (rc != 0)
1884 printk("ub: reading capacity: submit error (%d)\n", rc); /* P3 */
1885 goto err_submit; 1875 goto err_submit;
1886 }
1887 1876
1888 wait_for_completion(&compl); 1877 wait_for_completion(&compl);
1889 1878
1890 if (cmd->error != 0) { 1879 if (cmd->error != 0) {
1891 printk("ub: reading capacity: error %d\n", cmd->error); /* P3 */
1892 rc = -EIO; 1880 rc = -EIO;
1893 goto err_read; 1881 goto err_read;
1894 } 1882 }
1895 if (cmd->act_len != 8) { 1883 if (cmd->act_len != 8) {
1896 printk("ub: reading capacity: size %d\n", cmd->act_len); /* P3 */
1897 rc = -EIO; 1884 rc = -EIO;
1898 goto err_read; 1885 goto err_read;
1899 } 1886 }
@@ -1907,7 +1894,6 @@ static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun,
1907 case 2048: shift = 2; break; 1894 case 2048: shift = 2; break;
1908 case 4096: shift = 3; break; 1895 case 4096: shift = 3; break;
1909 default: 1896 default:
1910 printk("ub: Bad sector size %u\n", bsize); /* P3 */
1911 rc = -EDOM; 1897 rc = -EDOM;
1912 goto err_inv_bsize; 1898 goto err_inv_bsize;
1913 } 1899 }
@@ -2019,17 +2005,8 @@ static int ub_sync_getmaxlun(struct ub_dev *sc)
2019 sc->work_urb.error_count = 0; 2005 sc->work_urb.error_count = 0;
2020 sc->work_urb.status = 0; 2006 sc->work_urb.status = 0;
2021 2007
2022 if ((rc = usb_submit_urb(&sc->work_urb, GFP_KERNEL)) != 0) { 2008 if ((rc = usb_submit_urb(&sc->work_urb, GFP_KERNEL)) != 0)
2023 if (rc == -EPIPE) {
2024 printk("%s: Stall submitting GetMaxLUN, using 1 LUN\n",
2025 sc->name); /* P3 */
2026 } else {
2027 printk(KERN_NOTICE
2028 "%s: Unable to submit GetMaxLUN (%d)\n",
2029 sc->name, rc);
2030 }
2031 goto err_submit; 2009 goto err_submit;
2032 }
2033 2010
2034 init_timer(&timer); 2011 init_timer(&timer);
2035 timer.function = ub_probe_timeout; 2012 timer.function = ub_probe_timeout;
@@ -2042,21 +2019,10 @@ static int ub_sync_getmaxlun(struct ub_dev *sc)
2042 del_timer_sync(&timer); 2019 del_timer_sync(&timer);
2043 usb_kill_urb(&sc->work_urb); 2020 usb_kill_urb(&sc->work_urb);
2044 2021
2045 if ((rc = sc->work_urb.status) < 0) { 2022 if ((rc = sc->work_urb.status) < 0)
2046 if (rc == -EPIPE) {
2047 printk("%s: Stall at GetMaxLUN, using 1 LUN\n",
2048 sc->name); /* P3 */
2049 } else {
2050 printk(KERN_NOTICE
2051 "%s: Error at GetMaxLUN (%d)\n",
2052 sc->name, rc);
2053 }
2054 goto err_io; 2023 goto err_io;
2055 }
2056 2024
2057 if (sc->work_urb.actual_length != 1) { 2025 if (sc->work_urb.actual_length != 1) {
2058 printk("%s: GetMaxLUN returned %d bytes\n", sc->name,
2059 sc->work_urb.actual_length); /* P3 */
2060 nluns = 0; 2026 nluns = 0;
2061 } else { 2027 } else {
2062 if ((nluns = *p) == 55) { 2028 if ((nluns = *p) == 55) {
@@ -2067,8 +2033,6 @@ static int ub_sync_getmaxlun(struct ub_dev *sc)
2067 if (nluns > UB_MAX_LUNS) 2033 if (nluns > UB_MAX_LUNS)
2068 nluns = UB_MAX_LUNS; 2034 nluns = UB_MAX_LUNS;
2069 } 2035 }
2070 printk("%s: GetMaxLUN returned %d, using %d LUNs\n", sc->name,
2071 *p, nluns); /* P3 */
2072 } 2036 }
2073 2037
2074 kfree(p); 2038 kfree(p);
@@ -2266,7 +2230,7 @@ static int ub_probe(struct usb_interface *intf,
2266 * has to succeed, so we clear checks with an additional one here. 2230 * has to succeed, so we clear checks with an additional one here.
2267 * In any case it's not our business how revaliadation is implemented. 2231 * In any case it's not our business how revaliadation is implemented.
2268 */ 2232 */
2269 for (i = 0; i < 3; i++) { /* Retries for benh's key */ 2233 for (i = 0; i < 3; i++) { /* Retries for the schwag key from KS'04 */
2270 if ((rc = ub_sync_tur(sc, NULL)) <= 0) break; 2234 if ((rc = ub_sync_tur(sc, NULL)) <= 0) break;
2271 if (rc != 0x6) break; 2235 if (rc != 0x6) break;
2272 msleep(10); 2236 msleep(10);