mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 00/26] USB storage improvements
@ 2019-03-07  8:00 Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 01/26] usb: storage: Simplify memory allocation in usb_stor_probe() Andrey Smirnov
                   ` (26 more replies)
  0 siblings, 27 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Everyone:

While creating fix found in "usb: storage: Don't use "unsigned long"
for 32-bit values" I spent some time reading code of our USB storage
implementation. The other 25 patches is the result of that effort and
my attempt to improve/simplify that codebase. Hopefuly each patch is
self-explanatory.

Feedback is welcome!

Thanks,
Andrey Smirnov

Andrey Smirnov (26):
  usb: storage: Simplify memory allocation in usb_stor_probe()
  usb: storage: Replace custom debug tracing with dev_dbg
  usb: storage: Don't use "unsigned long" for 32-bit values
  usb: storage: Make usb_stor_read_capacity() a standalone function
  usb: storage: Make usb_stor_inquiry() a standalone function
  usb: storage: Make usb_stor_test_unit_ready() a standalone function
  usb: storage: Make usb_stor_read_10() a standalone function
  usb: storage: Make usb_stor_write_10() a standalone function
  usb: storage: Drop extra call to transport in usb_stor_write_10()
  usb: storage: Share code for READ(10) and WRITE(10)
  usb: storage: Make usb_stor_request_sense() a standalone function
  usb: storage: Remove unused variables
  usb: storage: Drop struct SCSI_cmd_block
  usb: hub: Do not include <scsi.h>
  ata: ahci: Do not include <scsi.h>
  usb: storage: Drop unused fields in struct us_data
  usb: storage: Drop unused us_blkdev_list
  usb: storage: Introduce usb_stor_transport()
  usb: storage: Use put_unaligned_be* helpers
  usb: Drop usb_disable_asynch()
  usb: storage: Drop unnecessary check in usb_stor_blk_io()
  usb: storage: Drop needless macro
  usb: storage: Use simple boolean to speficy read vs. write operation
  usb: storage: Simplify I/O loop in usb_stor_blk_io()
  usb: storage: Drop unnecessary assignment
  usb: storage: Inline usb_limit_blk_cnt()

 drivers/ata/ahci.c              |   1 -
 drivers/usb/core/hub.c          |   1 -
 drivers/usb/core/usb.c          |  24 +-
 drivers/usb/storage/transport.c |  87 +++---
 drivers/usb/storage/transport.h |   2 +-
 drivers/usb/storage/usb.c       | 484 ++++++++++++++------------------
 drivers/usb/storage/usb.h       |  19 +-
 include/scsi.h                  |  22 --
 include/usb/usb.h               |   1 -
 9 files changed, 265 insertions(+), 376 deletions(-)

-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 01/26] usb: storage: Simplify memory allocation in usb_stor_probe()
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
@ 2019-03-07  8:00 ` Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 02/26] usb: storage: Replace custom debug tracing with dev_dbg Andrey Smirnov
                   ` (25 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Replace explicit malloc() + OOM check and memset() with a single call
to xzalloc().

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/storage/usb.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 8218bb2a7..d25e19473 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -541,10 +541,7 @@ static int usb_stor_probe(struct usb_device *usbdev,
 	US_DEBUGP("Selected interface %d\n", (int)intf->desc.bInterfaceNumber);
 
 	/* allocate us_data structure */
-	us = (struct us_data *)malloc(sizeof(struct us_data));
-	if (!us)
-		return -ENOMEM;
-	memset(us, 0, sizeof(struct us_data));
+	us = xzalloc(sizeof(*us));
 
 	/* initialize the us_data structure */
 	us->pusb_dev = usbdev;
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 02/26] usb: storage: Replace custom debug tracing with dev_dbg
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 01/26] usb: storage: Simplify memory allocation in usb_stor_probe() Andrey Smirnov
@ 2019-03-07  8:00 ` Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 03/26] usb: storage: Don't use "unsigned long" for 32-bit values Andrey Smirnov
                   ` (24 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Replace custom debug tracing macros with a call to dev_dbg to simplify
code and add device info into degug output.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/storage/transport.c |  59 ++++++++--------
 drivers/usb/storage/usb.c       | 118 +++++++++++++++++---------------
 drivers/usb/storage/usb.h       |   7 --
 3 files changed, 94 insertions(+), 90 deletions(-)

diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 414099134..cd66d2bfe 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -24,8 +24,6 @@
 #include <errno.h>
 #include <dma.h>
 
-#undef USB_STOR_DEBUG
-
 #include "usb.h"
 #include "transport.h"
 
@@ -62,6 +60,7 @@ static int usb_stor_Bulk_clear_endpt_stall(struct us_data *us, unsigned int pipe
 /* Determine what the maximum LUN supported is */
 int usb_stor_Bulk_max_lun(struct us_data *us)
 {
+	struct device_d *dev = &us->pusb_dev->dev;
 	int len, ret = 0;
 	unsigned char *iobuf = dma_alloc(1);
 
@@ -73,8 +72,8 @@ int usb_stor_Bulk_max_lun(struct us_data *us)
 	                      USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
 	                      0, us->ifnum, iobuf, 1, USB_CNTL_TIMEOUT);
 
-	US_DEBUGP("GetMaxLUN command result is %d, data is %d\n",
-	          len, (int)iobuf[0]);
+	dev_dbg(dev, "GetMaxLUN command result is %d, data is %d\n",
+		len, (int)iobuf[0]);
 
 	/* if we have a successful request, return the result */
 	if (len > 0)
@@ -94,6 +93,7 @@ int usb_stor_Bulk_max_lun(struct us_data *us)
 
 int usb_stor_Bulk_transport(ccb *srb, struct us_data *us)
 {
+	struct device_d *dev = &us->pusb_dev->dev;
 	struct bulk_cb_wrap cbw;
 	struct bulk_cs_wrap csw;
 	int actlen, data_actlen;
@@ -117,14 +117,14 @@ int usb_stor_Bulk_transport(ccb *srb, struct us_data *us)
 	memcpy(cbw.CDB, srb->cmd, cbw.Length);
 
 	/* send it to out endpoint */
-	US_DEBUGP("Bulk Command S 0x%x T 0x%x L %d F %d Trg %d LUN %d CL %d\n",
-	                le32_to_cpu(cbw.Signature), cbw.Tag,
-	                le32_to_cpu(cbw.DataTransferLength), cbw.Flags,
-	                (cbw.Lun >> 4), (cbw.Lun & 0x0F),
-	                cbw.Length);
+	dev_dbg(dev, "Bulk Command S 0x%x T 0x%x L %d F %d Trg %d LUN %d CL %d\n",
+		le32_to_cpu(cbw.Signature), cbw.Tag,
+		le32_to_cpu(cbw.DataTransferLength), cbw.Flags,
+		(cbw.Lun >> 4), (cbw.Lun & 0x0F),
+		cbw.Length);
 	result = usb_bulk_msg(us->pusb_dev, pipeout, &cbw, US_BULK_CB_WRAP_LEN,
 			      &actlen, USB_BULK_TO);
-	US_DEBUGP("Bulk command transfer result=%d\n", result);
+	dev_dbg(dev, "Bulk command transfer result=%d\n", result);
 	if (result < 0) {
 		usb_stor_Bulk_reset(us);
 		return USB_STOR_TRANSPORT_FAILED;
@@ -140,32 +140,32 @@ int usb_stor_Bulk_transport(ccb *srb, struct us_data *us)
 		unsigned int pipe = dir_in ? pipein : pipeout;
 		result = usb_bulk_msg(us->pusb_dev, pipe, srb->pdata,
 		                      srb->datalen, &data_actlen, USB_BULK_TO);
-		US_DEBUGP("Bulk data transfer result 0x%x\n", result);
+		dev_dbg(dev, "Bulk data transfer result 0x%x\n", result);
 		/* special handling of STALL in DATA phase */
 		if ((result < 0) && (us->pusb_dev->status & USB_ST_STALLED)) {
-			US_DEBUGP("DATA: stall\n");
+			dev_dbg(dev, "DATA: stall\n");
 			/* clear the STALL on the endpoint */
 			result = usb_stor_Bulk_clear_endpt_stall(us, pipe);
 		}
 		if (result < 0) {
-			US_DEBUGP("Device status: %lx\n", us->pusb_dev->status);
+			dev_dbg(dev, "Device status: %lx\n", us->pusb_dev->status);
 			usb_stor_Bulk_reset(us);
 			return USB_STOR_TRANSPORT_FAILED;
 		}
 	}
 
 	/* STATUS phase + error handling */
-	US_DEBUGP("Attempting to get CSW...\n");
+	dev_dbg(dev, "Attempting to get CSW...\n");
 	result = usb_bulk_msg(us->pusb_dev, pipein, &csw, US_BULK_CS_WRAP_LEN,
 	                      &actlen, USB_BULK_TO);
 
 	/* did the endpoint stall? */
 	if ((result < 0) && (us->pusb_dev->status & USB_ST_STALLED)) {
-		US_DEBUGP("STATUS: stall\n");
+		dev_dbg(dev, "STATUS: stall\n");
 		/* clear the STALL on the endpoint */
 		result = usb_stor_Bulk_clear_endpt_stall(us, pipein);
 		if (result >= 0) {
-			US_DEBUGP("Attempting to get CSW...\n");
+			dev_dbg(dev, "Attempting to get CSW...\n");
 			result = usb_bulk_msg(us->pusb_dev, pipein,
 			                      &csw, US_BULK_CS_WRAP_LEN,
 			                      &actlen, USB_BULK_TO);
@@ -173,33 +173,33 @@ int usb_stor_Bulk_transport(ccb *srb, struct us_data *us)
 	}
 
 	if (result < 0) {
-		US_DEBUGP("Device status: %lx\n", us->pusb_dev->status);
+		dev_dbg(dev, "Device status: %lx\n", us->pusb_dev->status);
 		usb_stor_Bulk_reset(us);
 		return USB_STOR_TRANSPORT_FAILED;
 	}
 
 	/* check bulk status */
 	residue = le32_to_cpu(csw.Residue);
-	US_DEBUGP("Bulk Status S 0x%x T 0x%x R %u Stat 0x%x\n",
-	          le32_to_cpu(csw.Signature), csw.Tag, residue, csw.Status);
+	dev_dbg(dev, "Bulk Status S 0x%x T 0x%x R %u Stat 0x%x\n",
+		le32_to_cpu(csw.Signature), csw.Tag, residue, csw.Status);
 	if (csw.Signature != cpu_to_le32(US_BULK_CS_SIGN)) {
-		US_DEBUGP("Bad CSW signature\n");
+		dev_dbg(dev, "Bad CSW signature\n");
 		usb_stor_Bulk_reset(us);
 		return USB_STOR_TRANSPORT_FAILED;
 	} else if (csw.Tag != cbw_tag) {
-		US_DEBUGP("Mismatching tag\n");
+		dev_dbg(dev, "Mismatching tag\n");
 		usb_stor_Bulk_reset(us);
 		return USB_STOR_TRANSPORT_FAILED;
 	} else if (csw.Status >= US_BULK_STAT_PHASE) {
-		US_DEBUGP("Status >= phase\n");
+		dev_dbg(dev, "Status >= phase\n");
 		usb_stor_Bulk_reset(us);
 		return USB_STOR_TRANSPORT_ERROR;
 	} else if (residue > srb->datalen) {
-		US_DEBUGP("residue (%uB) > req data (%luB)\n",
+		dev_dbg(dev, "residue (%uB) > req data (%luB)\n",
 		          residue, srb->datalen);
 		return USB_STOR_TRANSPORT_FAILED;
 	} else if (csw.Status == US_BULK_STAT_FAIL) {
-		US_DEBUGP("FAILED\n");
+		dev_dbg(dev, "FAILED\n");
 		return USB_STOR_TRANSPORT_FAILED;
 	}
 	srb->trans_bytes = min(srb->datalen - residue, (ulong)data_actlen);
@@ -213,11 +213,12 @@ int usb_stor_Bulk_transport(ccb *srb, struct us_data *us)
  */
 int usb_stor_Bulk_reset(struct us_data *us)
 {
+	struct device_d *dev = &us->pusb_dev->dev;
 	int result;
 	int result2;
 	unsigned int pipe;
 
-	US_DEBUGP("%s called\n", __func__);
+	dev_dbg(dev, "%s called\n", __func__);
 
 	/* issue the command */
 	result = usb_control_msg(us->pusb_dev,
@@ -226,24 +227,24 @@ int usb_stor_Bulk_reset(struct us_data *us)
 	                         USB_TYPE_CLASS | USB_RECIP_INTERFACE,
 	                         0, us->ifnum, 0, 0, USB_CNTL_TIMEOUT);
 	if ((result < 0) && (us->pusb_dev->status & USB_ST_STALLED)) {
-		US_DEBUGP("Soft reset stalled: %d\n", result);
+		dev_dbg(dev, "Soft reset stalled: %d\n", result);
 		return result;
 	}
 	mdelay(150);
 
 	/* clear the bulk endpoints halt */
-	US_DEBUGP("Soft reset: clearing %s endpoint halt\n", "bulk-in");
+	dev_dbg(dev, "Soft reset: clearing %s endpoint halt\n", "bulk-in");
 	pipe = usb_rcvbulkpipe(us->pusb_dev, us->recv_bulk_ep);
 	result = usb_clear_halt(us->pusb_dev, pipe);
 	mdelay(150);
-	US_DEBUGP("Soft reset: clearing %s endpoint halt\n", "bulk-out");
+	dev_dbg(dev, "Soft reset: clearing %s endpoint halt\n", "bulk-out");
 	pipe = usb_sndbulkpipe(us->pusb_dev, us->send_bulk_ep);
 	result2 = usb_clear_halt(us->pusb_dev, pipe);
 	mdelay(150);
 
 	if (result >= 0)
 		result = result2;
-	US_DEBUGP("Soft reset %s\n", ((result < 0) ? "failed" : "done"));
+	dev_dbg(dev, "Soft reset %s\n", ((result < 0) ? "failed" : "done"));
 
 	return result;
 }
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index d25e19473..89a80c483 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -26,8 +26,6 @@
 #include <usb/usb.h>
 #include <usb/usb_defs.h>
 
-#undef USB_STOR_DEBUG
-
 #include "usb.h"
 #include "transport.h"
 
@@ -41,24 +39,25 @@ static LIST_HEAD(us_blkdev_list);
 
 static int usb_stor_inquiry(ccb *srb, struct us_data *us)
 {
+	struct device_d *dev = &us->pusb_dev->dev;
 	int retries, result;
 
 	srb->datalen = min(128UL, srb->datalen);
 	if (srb->datalen < 5) {
-		US_DEBUGP("SCSI_INQUIRY: invalid data buffer size\n");
+		dev_dbg(dev, "SCSI_INQUIRY: invalid data buffer size\n");
 		return -EINVAL;
 	}
 
 	retries = 3;
 	do {
-		US_DEBUGP("SCSI_INQUIRY\n");
+		dev_dbg(dev, "SCSI_INQUIRY\n");
 		memset(&srb->cmd[0], 0, 6);
 		srb->cmdlen = 6;
 		srb->cmd[0] = SCSI_INQUIRY;
 		srb->cmd[3] = (u8)(srb->datalen >> 8);
 		srb->cmd[4] = (u8)(srb->datalen >> 0);
 		result = us->transport(srb, us);
-		US_DEBUGP("SCSI_INQUIRY returns %d\n", result);
+		dev_dbg(dev, "SCSI_INQUIRY returns %d\n", result);
 	} while ((result != USB_STOR_TRANSPORT_GOOD) && retries--);
 
 	return (result != USB_STOR_TRANSPORT_GOOD) ? -EIO : 0;
@@ -66,10 +65,11 @@ static int usb_stor_inquiry(ccb *srb, struct us_data *us)
 
 static int usb_stor_request_sense(ccb *srb, struct us_data *us)
 {
+	struct device_d *dev = &us->pusb_dev->dev;
 	unsigned char *pdata = srb->pdata;
 	unsigned long datalen = srb->datalen;
 
-	US_DEBUGP("SCSI_REQ_SENSE\n");
+	dev_dbg(dev, "SCSI_REQ_SENSE\n");
 	srb->pdata = &srb->sense_buf[0];
 	srb->datalen = 18;
 	memset(&srb->cmd[0], 0, 6);
@@ -77,8 +77,8 @@ static int usb_stor_request_sense(ccb *srb, struct us_data *us)
 	srb->cmd[0] = SCSI_REQ_SENSE;
 	srb->cmd[4] = (u8)(srb->datalen >> 0);
 	us->transport(srb, us);
-	US_DEBUGP("Request Sense returned %02X %02X %02X\n",
-	          srb->sense_buf[2], srb->sense_buf[12], srb->sense_buf[13]);
+	dev_dbg(dev, "Request Sense returned %02X %02X %02X\n",
+		 srb->sense_buf[2], srb->sense_buf[12], srb->sense_buf[13]);
 	srb->pdata = pdata;
 	srb->datalen = datalen;
 
@@ -87,17 +87,18 @@ static int usb_stor_request_sense(ccb *srb, struct us_data *us)
 
 static int usb_stor_test_unit_ready(ccb *srb, struct us_data *us)
 {
+	struct device_d *dev = &us->pusb_dev->dev;
 	int retries, result;
 
 	retries = 10;
 	do {
-		US_DEBUGP("SCSI_TST_U_RDY\n");
+		dev_dbg(dev, "SCSI_TST_U_RDY\n");
 		memset(&srb->cmd[0], 0, 12);
 		srb->cmdlen = 12;
 		srb->cmd[0] = SCSI_TST_U_RDY;
 		srb->datalen = 0;
 		result = us->transport(srb, us);
-		US_DEBUGP("SCSI_TST_U_RDY returns %d\n", result);
+		dev_dbg(dev, "SCSI_TST_U_RDY returns %d\n", result);
 		if (result == USB_STOR_TRANSPORT_GOOD)
 			return 0;
 		usb_stor_request_sense(srb, us);
@@ -109,22 +110,23 @@ static int usb_stor_test_unit_ready(ccb *srb, struct us_data *us)
 
 static int usb_stor_read_capacity(ccb *srb, struct us_data *us)
 {
+	struct device_d *dev = &us->pusb_dev->dev;
 	int retries, result;
 
 	if (srb->datalen < 8) {
-		US_DEBUGP("SCSI_RD_CAPAC: invalid data buffer size\n");
+		dev_dbg(dev, "SCSI_RD_CAPAC: invalid data buffer size\n");
 		return -EINVAL;
 	}
 
 	retries = 3;
 	do {
-		US_DEBUGP("SCSI_RD_CAPAC\n");
+		dev_dbg(dev, "SCSI_RD_CAPAC\n");
 		memset(&srb->cmd[0], 0, 10);
 		srb->cmdlen = 10;
 		srb->cmd[0] = SCSI_RD_CAPAC;
 		srb->datalen = 8;
 		result = us->transport(srb, us);
-		US_DEBUGP("SCSI_RD_CAPAC returns %d\n", result);
+		dev_dbg(dev, "SCSI_RD_CAPAC returns %d\n", result);
 	} while ((result != USB_STOR_TRANSPORT_GOOD) && retries--);
 
 	return (result != USB_STOR_TRANSPORT_GOOD) ? -EIO : 0;
@@ -133,11 +135,12 @@ static int usb_stor_read_capacity(ccb *srb, struct us_data *us)
 static int usb_stor_read_10(ccb *srb, struct us_data *us,
                             unsigned long start, unsigned short blocks)
 {
+	struct device_d *dev = &us->pusb_dev->dev;
 	int retries, result;
 
 	retries = 2;
 	do {
-		US_DEBUGP("SCSI_READ10: start %lx blocks %x\n", start, blocks);
+		dev_dbg(dev, "SCSI_READ10: start %lx blocks %x\n", start, blocks);
 		memset(&srb->cmd[0], 0, 10);
 		srb->cmdlen = 10;
 		srb->cmd[0] = SCSI_READ10;
@@ -148,7 +151,7 @@ static int usb_stor_read_10(ccb *srb, struct us_data *us,
 		srb->cmd[7] = (u8)(blocks >> 8);
 		srb->cmd[8] = (u8)(blocks >> 0);
 		result = us->transport(srb, us);
-		US_DEBUGP("SCSI_READ10 returns %d\n", result);
+		dev_dbg(dev, "SCSI_READ10 returns %d\n", result);
 		if (result == USB_STOR_TRANSPORT_GOOD)
 			return 0;
 		usb_stor_request_sense(srb, us);
@@ -160,11 +163,12 @@ static int usb_stor_read_10(ccb *srb, struct us_data *us,
 static int usb_stor_write_10(ccb *srb, struct us_data *us,
                              unsigned long start, unsigned short blocks)
 {
+	struct device_d *dev = &us->pusb_dev->dev;
 	int retries, result;
 
 	retries = 2;
 	do {
-		US_DEBUGP("SCSI_WRITE10: start %lx blocks %x\n", start, blocks);
+		dev_dbg(dev, "SCSI_WRITE10: start %lx blocks %x\n", start, blocks);
 		memset(&srb->cmd[0], 0, 10);
 		srb->cmdlen = 10;
 		srb->cmd[0] = SCSI_WRITE10;
@@ -175,7 +179,7 @@ static int usb_stor_write_10(ccb *srb, struct us_data *us,
 		srb->cmd[7] = (u8)(blocks >> 8);
 		srb->cmd[8] = (u8)(blocks >> 0);
 		result = us->transport(srb, us);
-		US_DEBUGP("SCSI_WRITE10 returns %d\n", result);
+		dev_dbg(dev, "SCSI_WRITE10 returns %d\n", result);
 		if (result == USB_STOR_TRANSPORT_GOOD)
 			return 0;
 		usb_stor_request_sense(srb, us);
@@ -201,6 +205,7 @@ static int usb_stor_blk_io(int io_op, struct block_device *disk_dev,
 {
 	struct us_blk_dev *pblk_dev = to_usb_mass_storage(disk_dev);
 	struct us_data *us = pblk_dev->us;
+	struct device_d *dev = &us->pusb_dev->dev;
 	ccb us_ccb;
 	unsigned sectors_done;
 
@@ -209,15 +214,15 @@ static int usb_stor_blk_io(int io_op, struct block_device *disk_dev,
 
 	/* check for unsupported block size */
 	if (pblk_dev->blk.blockbits != SECTOR_SHIFT) {
-		US_DEBUGP("%s: unsupported block shift %d\n",
-		          __func__, pblk_dev->blk.blockbits);
+		dev_dbg(dev, "%s: unsupported block shift %d\n",
+			 __func__, pblk_dev->blk.blockbits);
 		return -EINVAL;
 	}
 
 	/* check for invalid sector_start */
 	if (sector_start >= pblk_dev->blk.num_blocks || sector_start > (ulong)-1) {
-		US_DEBUGP("%s: start sector %d too large\n",
-		          __func__, sector_start);
+		dev_dbg(dev, "%s: start sector %d too large\n",
+			 __func__, sector_start);
 		return -EINVAL;
 	}
 
@@ -225,9 +230,9 @@ static int usb_stor_blk_io(int io_op, struct block_device *disk_dev,
 	usb_disable_asynch(1);
 
 	/* ensure unit ready */
-	US_DEBUGP("Testing for unit ready\n");
+	dev_dbg(dev, "Testing for unit ready\n");
 	if (usb_stor_test_unit_ready(&us_ccb, us)) {
-		US_DEBUGP("Device NOT ready\n");
+		dev_dbg(dev, "Device NOT ready\n");
 		usb_disable_asynch(0);
 		return -EIO;
 	}
@@ -235,17 +240,17 @@ static int usb_stor_blk_io(int io_op, struct block_device *disk_dev,
 	/* possibly limit the amount of I/O data */
 	if (sector_count > INT_MAX) {
 		sector_count = INT_MAX;
-		US_DEBUGP("Restricting I/O to %u blocks\n", sector_count);
+		dev_dbg(dev, "Restricting I/O to %u blocks\n", sector_count);
 	}
 	if (sector_start + sector_count > pblk_dev->blk.num_blocks) {
 		sector_count = pblk_dev->blk.num_blocks - sector_start;
-		US_DEBUGP("Restricting I/O to %u blocks\n", sector_count);
+		dev_dbg(dev, "Restricting I/O to %u blocks\n", sector_count);
 	}
 
 	/* read / write the requested data */
-	US_DEBUGP("%s %u block(s), starting from %d\n",
-	          ((io_op == io_rd) ? "Read" : "Write"),
-	          sector_count, sector_start);
+	dev_dbg(dev, "%s %u block(s), starting from %d\n",
+		 (io_op == io_rd) ? "Read" : "Write",
+		 sector_count, sector_start);
 	sectors_done = 0;
 	while (sector_count > 0) {
 		int result;
@@ -259,7 +264,7 @@ static int usb_stor_blk_io(int io_op, struct block_device *disk_dev,
 			result = usb_stor_write_10(&us_ccb, us,
 			                           (ulong)sector_start, n);
 		if (result != 0) {
-			US_DEBUGP("I/O error at sector %d\n", sector_start);
+			dev_dbg(dev, "I/O error at sector %d\n", sector_start);
 			break;
 		}
 		sector_start += n;
@@ -269,7 +274,7 @@ static int usb_stor_blk_io(int io_op, struct block_device *disk_dev,
 
 	usb_disable_asynch(0);
 
-	US_DEBUGP("Successful I/O of %d blocks\n", sectors_done);
+	dev_dbg(dev, "Successful I/O of %d blocks\n", sectors_done);
 
 	return (sector_count != 0) ? -EIO : 0;
 }
@@ -315,6 +320,7 @@ static int usb_limit_blk_cnt(unsigned cnt)
 static int usb_stor_init_blkdev(struct us_blk_dev *pblk_dev)
 {
 	struct us_data *us = pblk_dev->us;
+	struct device_d *dev = &us->pusb_dev->dev;
 	ccb us_ccb;
 	unsigned long *pcap;
 	int result = 0;
@@ -326,45 +332,45 @@ static int usb_stor_init_blkdev(struct us_blk_dev *pblk_dev)
 	usb_disable_asynch(1);
 
 	/* get device info */
-	US_DEBUGP("Reading device info\n");
+	dev_dbg(dev, "Reading device info\n");
 	us_ccb.datalen = 36;
 	if (usb_stor_inquiry(&us_ccb, us)) {
-		US_DEBUGP("Cannot read device info\n");
+		dev_dbg(dev, "Cannot read device info\n");
 		result = -ENODEV;
 		goto Exit;
 	}
-	US_DEBUGP("Peripheral type: %x, removable: %x\n",
+	dev_dbg(dev, "Peripheral type: %x, removable: %x\n",
 	          us_io_buf[0], (us_io_buf[1] >> 7));
-	US_DEBUGP("ISO ver: %x, resp format: %x\n", us_io_buf[2], us_io_buf[3]);
-	US_DEBUGP("Vendor/product/rev: %28s\n", &us_io_buf[8]);
+	dev_dbg(dev, "ISO ver: %x, resp format: %x\n", us_io_buf[2], us_io_buf[3]);
+	dev_dbg(dev, "Vendor/product/rev: %28s\n", &us_io_buf[8]);
 	// TODO:  process and store device info
 
 	/* ensure unit ready */
-	US_DEBUGP("Testing for unit ready\n");
+	dev_dbg(dev, "Testing for unit ready\n");
 	us_ccb.datalen = 0;
 	if (usb_stor_test_unit_ready(&us_ccb, us)) {
-		US_DEBUGP("Device NOT ready\n");
+		dev_dbg(dev, "Device NOT ready\n");
 		result = -ENODEV;
 		goto Exit;
 	}
 
 	/* read capacity */
-	US_DEBUGP("Reading capacity\n");
+	dev_dbg(dev, "Reading capacity\n");
 	memset(us_ccb.pdata, 0, 8);
 	us_ccb.datalen = sizeof(us_io_buf);
 	if (usb_stor_read_capacity(&us_ccb, us) != 0) {
-		US_DEBUGP("Cannot read device capacity\n");
+		dev_dbg(dev, "Cannot read device capacity\n");
 		result = -EIO;
 		goto Exit;
 	}
 	pcap = (unsigned long *)us_ccb.pdata;
-	US_DEBUGP("Read Capacity returns: 0x%lx, 0x%lx\n", pcap[0], pcap[1]);
+	dev_dbg(dev, "Read Capacity returns: 0x%lx, 0x%lx\n", pcap[0], pcap[1]);
 	pblk_dev->blk.num_blocks = usb_limit_blk_cnt(be32_to_cpu(pcap[0]) + 1);
 	if (be32_to_cpu(pcap[1]) != SECTOR_SIZE)
 		pr_warn("Support only %d bytes sectors\n", SECTOR_SIZE);
 	pblk_dev->blk.blockbits = SECTOR_SHIFT;
-	US_DEBUGP("Capacity = 0x%x, blockshift = 0x%x\n",
-	          pblk_dev->blk.num_blocks, pblk_dev->blk.blockbits);
+	dev_dbg(dev, "Capacity = 0x%x, blockshift = 0x%x\n",
+		 pblk_dev->blk.num_blocks, pblk_dev->blk.blockbits);
 
 Exit:
 	usb_disable_asynch(0);
@@ -372,9 +378,9 @@ Exit:
 }
 
 /* Create and register a disk device for the specified LUN */
-static int usb_stor_add_blkdev(struct us_data *us, struct device_d *dev,
-							unsigned char lun)
+static int usb_stor_add_blkdev(struct us_data *us, unsigned char lun)
 {
+	struct device_d *dev = &us->pusb_dev->dev;
 	struct us_blk_dev *pblk_dev;
 	int result;
 
@@ -412,12 +418,12 @@ static int usb_stor_add_blkdev(struct us_data *us, struct device_d *dev,
 		dev_warn(dev, "No partition table found\n");
 
 	list_add_tail(&pblk_dev->list, &us->blk_dev_list);
-	US_DEBUGP("USB disk device successfully added\n");
+	dev_dbg(dev, "USB disk device successfully added\n");
 
 	return 0;
 
 BadDevice:
-	US_DEBUGP("%s failed with %d\n", __func__, result);
+	dev_dbg(dev, "%s failed with %d\n", __func__, result);
 	free(pblk_dev);
 	return result;
 }
@@ -429,6 +435,7 @@ BadDevice:
 /* Get the transport settings */
 static void get_transport(struct us_data *us)
 {
+	struct device_d *dev = &us->pusb_dev->dev;
 	switch (us->protocol) {
 	case US_PR_BULK:
 		us->transport_name = "Bulk";
@@ -437,12 +444,13 @@ static void get_transport(struct us_data *us)
 		break;
 	}
 
-	US_DEBUGP("Transport: %s\n", us->transport_name);
+	dev_dbg(dev, "Transport: %s\n", us->transport_name);
 }
 
 /* Get the endpoint settings */
 static int get_pipes(struct us_data *us, struct usb_interface *intf)
 {
+	struct device_d *dev = &us->pusb_dev->dev;
 	unsigned int i;
 	struct usb_endpoint_descriptor *ep;
 	struct usb_endpoint_descriptor *ep_in = NULL;
@@ -474,7 +482,7 @@ static int get_pipes(struct us_data *us, struct usb_interface *intf)
 		}
 	}
 	if (!ep_in || !ep_out || (us->protocol == US_PR_CBI && !ep_int)) {
-		US_DEBUGP("Endpoint sanity check failed! Rejecting dev.\n");
+		dev_dbg(dev, "Endpoint sanity check failed! Rejecting dev.\n");
 		return -EIO;
 	}
 
@@ -491,21 +499,22 @@ static int get_pipes(struct us_data *us, struct usb_interface *intf)
 /* Scan device's LUNs, registering a disk device for each LUN */
 static int usb_stor_scan(struct usb_device *usbdev, struct us_data *us)
 {
+	struct device_d *dev = &usbdev->dev;
 	unsigned char lun;
 	int num_devs = 0;
 
 	/* obtain the max LUN */
-	us->max_lun = 0;
+	us->max_lun = 1;
 	if (us->protocol == US_PR_BULK)
 		us->max_lun = usb_stor_Bulk_max_lun(us);
 
 	/* register a disk device for each active LUN */
 	for (lun=0; lun<=us->max_lun; lun++) {
-		if (usb_stor_add_blkdev(us, &usbdev->dev, lun) == 0)
+		if (usb_stor_add_blkdev(us, lun) == 0)
 			num_devs++;
 	}
 
-	US_DEBUGP("Found %d block devices on %s\n", num_devs, usbdev->dev.name);
+	dev_dbg(dev, "Found %d block devices on %s\n", num_devs, usbdev->dev.name);
 
 	return  num_devs ? 0 : -ENODEV;
 }
@@ -514,12 +523,13 @@ static int usb_stor_scan(struct usb_device *usbdev, struct us_data *us)
 static int usb_stor_probe(struct usb_device *usbdev,
 			 const struct usb_device_id *id)
 {
+	struct device_d *dev = &usbdev->dev;
 	struct us_data *us;
 	int result;
 	int ifno;
 	struct usb_interface *intf;
 
-	US_DEBUGP("Supported USB Mass Storage device detected\n");
+	dev_dbg(dev, "Supported USB Mass Storage device detected\n");
 
 	/* scan usbdev interfaces again to find one that we can handle */
 	for (ifno=0; ifno<usbdev->config.no_of_if; ifno++) {
@@ -538,7 +548,7 @@ static int usb_stor_probe(struct usb_device *usbdev,
 	if (result)
 		return result;
 
-	US_DEBUGP("Selected interface %d\n", (int)intf->desc.bInterfaceNumber);
+	dev_dbg(dev, "Selected interface %d\n", (int)intf->desc.bInterfaceNumber);
 
 	/* allocate us_data structure */
 	us = xzalloc(sizeof(*us));
@@ -568,7 +578,7 @@ static int usb_stor_probe(struct usb_device *usbdev,
 	return 0;
 
 BadDevice:
-	US_DEBUGP("%s failed with %d\n", __func__, result);
+	dev_dbg(dev, "%s failed with %d\n", __func__, result);
 	free(us);
 	return result;
 }
diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
index e649d5336..544537089 100644
--- a/drivers/usb/storage/usb.h
+++ b/drivers/usb/storage/usb.h
@@ -28,13 +28,6 @@
 #include <linux/list.h>
 
 
-#ifdef  USB_STOR_DEBUG
-#define US_DEBUGP(fmt, args...)    printf(fmt , ##args)
-#else
-#define US_DEBUGP(fmt, args...)
-#endif
-
-
 /* some defines, similar to ch9.h */
 #define USB_EP_NUM(epd) \
 	((epd)->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK)
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 03/26] usb: storage: Don't use "unsigned long" for 32-bit values
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 01/26] usb: storage: Simplify memory allocation in usb_stor_probe() Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 02/26] usb: storage: Replace custom debug tracing with dev_dbg Andrey Smirnov
@ 2019-03-07  8:00 ` Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 04/26] usb: storage: Make usb_stor_read_capacity() a standalone function Andrey Smirnov
                   ` (23 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Unsignled long will expand to 64-bit unsigned integer on 64-bit
CPUs. This will break current code using it to read out two 32-bit
values returned by READ_CAPACITY. Fix the proble by using "u32"
explicitly.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/storage/usb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 89a80c483..db839e39a 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -322,7 +322,7 @@ static int usb_stor_init_blkdev(struct us_blk_dev *pblk_dev)
 	struct us_data *us = pblk_dev->us;
 	struct device_d *dev = &us->pusb_dev->dev;
 	ccb us_ccb;
-	unsigned long *pcap;
+	u32 *pcap;
 	int result = 0;
 
 	us_ccb.pdata = us_io_buf;
@@ -363,8 +363,8 @@ static int usb_stor_init_blkdev(struct us_blk_dev *pblk_dev)
 		result = -EIO;
 		goto Exit;
 	}
-	pcap = (unsigned long *)us_ccb.pdata;
-	dev_dbg(dev, "Read Capacity returns: 0x%lx, 0x%lx\n", pcap[0], pcap[1]);
+	pcap = (u32 *)us_ccb.pdata;
+	dev_dbg(dev, "Read Capacity returns: 0x%x, 0x%x\n", pcap[0], pcap[1]);
 	pblk_dev->blk.num_blocks = usb_limit_blk_cnt(be32_to_cpu(pcap[0]) + 1);
 	if (be32_to_cpu(pcap[1]) != SECTOR_SIZE)
 		pr_warn("Support only %d bytes sectors\n", SECTOR_SIZE);
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 04/26] usb: storage: Make usb_stor_read_capacity() a standalone function
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
                   ` (2 preceding siblings ...)
  2019-03-07  8:00 ` [PATCH 03/26] usb: storage: Don't use "unsigned long" for 32-bit values Andrey Smirnov
@ 2019-03-07  8:00 ` Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 05/26] usb: storage: Make usb_stor_inquiry() " Andrey Smirnov
                   ` (22 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Move special preparation steps done before and after call to
usb_stor_read_capacity() inside the function itself for clarity and to
allow futher code improvements. No functional change intended.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/storage/usb.c | 53 +++++++++++++++++++++++----------------
 1 file changed, 31 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index db839e39a..f439cd825 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -108,28 +108,39 @@ static int usb_stor_test_unit_ready(ccb *srb, struct us_data *us)
 	return -1;
 }
 
-static int usb_stor_read_capacity(ccb *srb, struct us_data *us)
+static int usb_stor_read_capacity(struct us_blk_dev *usb_blkdev,
+				  u32 *last_lba, u32 *block_length)
 {
+	struct us_data *us = usb_blkdev->us;
 	struct device_d *dev = &us->pusb_dev->dev;
 	int retries, result;
-
-	if (srb->datalen < 8) {
-		dev_dbg(dev, "SCSI_RD_CAPAC: invalid data buffer size\n");
-		return -EINVAL;
-	}
+	ccb srb;
+	u32 *data = xzalloc(8);
 
 	retries = 3;
 	do {
 		dev_dbg(dev, "SCSI_RD_CAPAC\n");
-		memset(&srb->cmd[0], 0, 10);
-		srb->cmdlen = 10;
-		srb->cmd[0] = SCSI_RD_CAPAC;
-		srb->datalen = 8;
-		result = us->transport(srb, us);
+		memset(&srb.cmd[0], 0, 10);
+		srb.cmdlen = 10;
+		srb.lun = usb_blkdev->lun;
+		srb.cmd[0] = SCSI_RD_CAPAC;
+		srb.pdata = (void *)data;
+		srb.datalen = 8;
+		result = us->transport(&srb, us);
 		dev_dbg(dev, "SCSI_RD_CAPAC returns %d\n", result);
-	} while ((result != USB_STOR_TRANSPORT_GOOD) && retries--);
 
-	return (result != USB_STOR_TRANSPORT_GOOD) ? -EIO : 0;
+		if (result == USB_STOR_TRANSPORT_GOOD) {
+			dev_dbg(dev, "Read Capacity returns: 0x%x, 0x%x\n",
+				data[0], data[1]);
+			*last_lba = be32_to_cpu(data[0]);
+			*block_length = be32_to_cpu(data[1]);
+			break;
+		}
+	} while (retries--);
+
+	free(data);
+
+	return result ? -EIO : 0;
 }
 
 static int usb_stor_read_10(ccb *srb, struct us_data *us,
@@ -322,7 +333,7 @@ static int usb_stor_init_blkdev(struct us_blk_dev *pblk_dev)
 	struct us_data *us = pblk_dev->us;
 	struct device_d *dev = &us->pusb_dev->dev;
 	ccb us_ccb;
-	u32 *pcap;
+	u32 last_lba = 0, block_length = 0;
 	int result = 0;
 
 	us_ccb.pdata = us_io_buf;
@@ -356,17 +367,15 @@ static int usb_stor_init_blkdev(struct us_blk_dev *pblk_dev)
 
 	/* read capacity */
 	dev_dbg(dev, "Reading capacity\n");
-	memset(us_ccb.pdata, 0, 8);
-	us_ccb.datalen = sizeof(us_io_buf);
-	if (usb_stor_read_capacity(&us_ccb, us) != 0) {
+
+	result = usb_stor_read_capacity(pblk_dev, &last_lba, &block_length);
+	if (result < 0) {
 		dev_dbg(dev, "Cannot read device capacity\n");
-		result = -EIO;
 		goto Exit;
 	}
-	pcap = (u32 *)us_ccb.pdata;
-	dev_dbg(dev, "Read Capacity returns: 0x%x, 0x%x\n", pcap[0], pcap[1]);
-	pblk_dev->blk.num_blocks = usb_limit_blk_cnt(be32_to_cpu(pcap[0]) + 1);
-	if (be32_to_cpu(pcap[1]) != SECTOR_SIZE)
+
+	pblk_dev->blk.num_blocks = usb_limit_blk_cnt(last_lba + 1);
+	if (block_length != SECTOR_SIZE)
 		pr_warn("Support only %d bytes sectors\n", SECTOR_SIZE);
 	pblk_dev->blk.blockbits = SECTOR_SHIFT;
 	dev_dbg(dev, "Capacity = 0x%x, blockshift = 0x%x\n",
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 05/26] usb: storage: Make usb_stor_inquiry() a standalone function
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
                   ` (3 preceding siblings ...)
  2019-03-07  8:00 ` [PATCH 04/26] usb: storage: Make usb_stor_read_capacity() a standalone function Andrey Smirnov
@ 2019-03-07  8:00 ` Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 06/26] usb: storage: Make usb_stor_test_unit_ready() " Andrey Smirnov
                   ` (21 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Move special preparation steps done before and after call to
usb_stor_inquiry() inside the function itself for clarity and to allow
futher code improvements. No functional change intended.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/storage/usb.c | 52 ++++++++++++++++++++++-----------------
 1 file changed, 30 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index f439cd825..05a3a03c4 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -37,30 +37,43 @@ static LIST_HEAD(us_blkdev_list);
  * USB Storage routines
  ***********************************************************************/
 
-static int usb_stor_inquiry(ccb *srb, struct us_data *us)
+static int usb_stor_inquiry(struct us_blk_dev *usb_blkdev)
 {
+	struct us_data *us = usb_blkdev->us;
 	struct device_d *dev = &us->pusb_dev->dev;
 	int retries, result;
+	ccb srb;
+	u8 *data = xzalloc(36);
 
-	srb->datalen = min(128UL, srb->datalen);
-	if (srb->datalen < 5) {
-		dev_dbg(dev, "SCSI_INQUIRY: invalid data buffer size\n");
-		return -EINVAL;
-	}
+	srb.lun = usb_blkdev->lun;
+	srb.pdata = data;
+	srb.datalen = 36;
 
 	retries = 3;
 	do {
 		dev_dbg(dev, "SCSI_INQUIRY\n");
-		memset(&srb->cmd[0], 0, 6);
-		srb->cmdlen = 6;
-		srb->cmd[0] = SCSI_INQUIRY;
-		srb->cmd[3] = (u8)(srb->datalen >> 8);
-		srb->cmd[4] = (u8)(srb->datalen >> 0);
-		result = us->transport(srb, us);
+		memset(&srb.cmd[0], 0, 6);
+		srb.cmdlen = 6;
+		srb.cmd[0] = SCSI_INQUIRY;
+		srb.cmd[3] = (u8)(srb.datalen >> 8);
+		srb.cmd[4] = (u8)(srb.datalen >> 0);
+		result = us->transport(&srb, us);
 		dev_dbg(dev, "SCSI_INQUIRY returns %d\n", result);
-	} while ((result != USB_STOR_TRANSPORT_GOOD) && retries--);
+		if (result == USB_STOR_TRANSPORT_GOOD) {
+			dev_dbg(dev, "Peripheral type: %x, removable: %x\n",
+				data[0], (data[1] >> 7));
+			dev_dbg(dev, "ISO ver: %x, resp format: %x\n",
+				data[2], data[3]);
+			dev_dbg(dev, "Vendor/product/rev: %28s\n",
+				&data[8]);
+			// TODO:  process and store device info
+			break;
+		}
+	} while (retries--);
 
-	return (result != USB_STOR_TRANSPORT_GOOD) ? -EIO : 0;
+	free(data);
+
+	return result ? -ENODEV : 0;
 }
 
 static int usb_stor_request_sense(ccb *srb, struct us_data *us)
@@ -344,17 +357,12 @@ static int usb_stor_init_blkdev(struct us_blk_dev *pblk_dev)
 
 	/* get device info */
 	dev_dbg(dev, "Reading device info\n");
-	us_ccb.datalen = 36;
-	if (usb_stor_inquiry(&us_ccb, us)) {
+
+	result = usb_stor_inquiry(pblk_dev);
+	if (result) {
 		dev_dbg(dev, "Cannot read device info\n");
-		result = -ENODEV;
 		goto Exit;
 	}
-	dev_dbg(dev, "Peripheral type: %x, removable: %x\n",
-	          us_io_buf[0], (us_io_buf[1] >> 7));
-	dev_dbg(dev, "ISO ver: %x, resp format: %x\n", us_io_buf[2], us_io_buf[3]);
-	dev_dbg(dev, "Vendor/product/rev: %28s\n", &us_io_buf[8]);
-	// TODO:  process and store device info
 
 	/* ensure unit ready */
 	dev_dbg(dev, "Testing for unit ready\n");
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 06/26] usb: storage: Make usb_stor_test_unit_ready() a standalone function
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
                   ` (4 preceding siblings ...)
  2019-03-07  8:00 ` [PATCH 05/26] usb: storage: Make usb_stor_inquiry() " Andrey Smirnov
@ 2019-03-07  8:00 ` Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 07/26] usb: storage: Make usb_stor_read_10() " Andrey Smirnov
                   ` (20 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Move special preparation steps done before the call to
usb_stor_test_unit_ready() inside the function itself for clarity and
to allow futher code improvements. No functional change intended.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/storage/usb.c | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 05a3a03c4..52d4e24de 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -98,27 +98,31 @@ static int usb_stor_request_sense(ccb *srb, struct us_data *us)
 	return 0;
 }
 
-static int usb_stor_test_unit_ready(ccb *srb, struct us_data *us)
+static int usb_stor_test_unit_ready(struct us_blk_dev *usb_blkdev)
 {
+	struct us_data *us = usb_blkdev->us;
 	struct device_d *dev = &us->pusb_dev->dev;
 	int retries, result;
+	ccb srb;
+
+	srb.lun = usb_blkdev->lun;
 
 	retries = 10;
 	do {
 		dev_dbg(dev, "SCSI_TST_U_RDY\n");
-		memset(&srb->cmd[0], 0, 12);
-		srb->cmdlen = 12;
-		srb->cmd[0] = SCSI_TST_U_RDY;
-		srb->datalen = 0;
-		result = us->transport(srb, us);
+		memset(&srb.cmd[0], 0, 12);
+		srb.cmdlen = 12;
+		srb.cmd[0] = SCSI_TST_U_RDY;
+		srb.datalen = 0;
+		result = us->transport(&srb, us);
 		dev_dbg(dev, "SCSI_TST_U_RDY returns %d\n", result);
 		if (result == USB_STOR_TRANSPORT_GOOD)
 			return 0;
-		usb_stor_request_sense(srb, us);
+		usb_stor_request_sense(&srb, us);
 		mdelay(100);
 	} while (retries--);
 
-	return -1;
+	return -ENODEV;
 }
 
 static int usb_stor_read_capacity(struct us_blk_dev *usb_blkdev,
@@ -255,7 +259,7 @@ static int usb_stor_blk_io(int io_op, struct block_device *disk_dev,
 
 	/* ensure unit ready */
 	dev_dbg(dev, "Testing for unit ready\n");
-	if (usb_stor_test_unit_ready(&us_ccb, us)) {
+	if (usb_stor_test_unit_ready(pblk_dev)) {
 		dev_dbg(dev, "Device NOT ready\n");
 		usb_disable_asynch(0);
 		return -EIO;
@@ -366,10 +370,10 @@ static int usb_stor_init_blkdev(struct us_blk_dev *pblk_dev)
 
 	/* ensure unit ready */
 	dev_dbg(dev, "Testing for unit ready\n");
-	us_ccb.datalen = 0;
-	if (usb_stor_test_unit_ready(&us_ccb, us)) {
+
+	result = usb_stor_test_unit_ready(pblk_dev);
+	if (result) {
 		dev_dbg(dev, "Device NOT ready\n");
-		result = -ENODEV;
 		goto Exit;
 	}
 
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 07/26] usb: storage: Make usb_stor_read_10() a standalone function
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
                   ` (5 preceding siblings ...)
  2019-03-07  8:00 ` [PATCH 06/26] usb: storage: Make usb_stor_test_unit_ready() " Andrey Smirnov
@ 2019-03-07  8:00 ` Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 08/26] usb: storage: Make usb_stor_write_10() " Andrey Smirnov
                   ` (19 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Move special preparation steps done before the call to
usb_stor_read_10() inside the function itself for clarity and to allow
futher code improvements. No functional change intended.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/storage/usb.c | 41 ++++++++++++++++++++++++---------------
 1 file changed, 25 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 52d4e24de..e6f8f30c6 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -160,29 +160,36 @@ static int usb_stor_read_capacity(struct us_blk_dev *usb_blkdev,
 	return result ? -EIO : 0;
 }
 
-static int usb_stor_read_10(ccb *srb, struct us_data *us,
-                            unsigned long start, unsigned short blocks)
+static int usb_stor_read_10(struct us_blk_dev *usb_blkdev,
+                            unsigned long start, u8 *data,
+			    unsigned short blocks)
 {
+	struct us_data *us = usb_blkdev->us;
 	struct device_d *dev = &us->pusb_dev->dev;
 	int retries, result;
+	ccb srb;
+
+	srb.lun = usb_blkdev->lun;
+	srb.pdata = data;
+	srb.datalen = blocks * SECTOR_SIZE;
 
 	retries = 2;
 	do {
 		dev_dbg(dev, "SCSI_READ10: start %lx blocks %x\n", start, blocks);
-		memset(&srb->cmd[0], 0, 10);
-		srb->cmdlen = 10;
-		srb->cmd[0] = SCSI_READ10;
-		srb->cmd[2] = (u8)(start >> 24);
-		srb->cmd[3] = (u8)(start >> 16);
-		srb->cmd[4] = (u8)(start >> 8);
-		srb->cmd[5] = (u8)(start >> 0);
-		srb->cmd[7] = (u8)(blocks >> 8);
-		srb->cmd[8] = (u8)(blocks >> 0);
-		result = us->transport(srb, us);
+		memset(&srb.cmd[0], 0, 10);
+		srb.cmdlen = 10;
+		srb.cmd[0] = SCSI_READ10;
+		srb.cmd[2] = (u8)(start >> 24);
+		srb.cmd[3] = (u8)(start >> 16);
+		srb.cmd[4] = (u8)(start >> 8);
+		srb.cmd[5] = (u8)(start >> 0);
+		srb.cmd[7] = (u8)(blocks >> 8);
+		srb.cmd[8] = (u8)(blocks >> 0);
+		result = us->transport(&srb, us);
 		dev_dbg(dev, "SCSI_READ10 returns %d\n", result);
 		if (result == USB_STOR_TRANSPORT_GOOD)
 			return 0;
-		usb_stor_request_sense(srb, us);
+		usb_stor_request_sense(&srb, us);
 	} while (retries--);
 
 	return -EIO;
@@ -283,11 +290,13 @@ static int usb_stor_blk_io(int io_op, struct block_device *disk_dev,
 	while (sector_count > 0) {
 		int result;
 		unsigned n = min(sector_count, US_MAX_IO_BLK);
-		us_ccb.pdata = buffer + (sectors_done * SECTOR_SIZE);
+		u8 *data = buffer + (sectors_done * SECTOR_SIZE);
+		us_ccb.pdata = data;
 		us_ccb.datalen = n * SECTOR_SIZE;
 		if (io_op == io_rd)
-			result = usb_stor_read_10(&us_ccb, us,
-			                          (ulong)sector_start, n);
+			result = usb_stor_read_10(pblk_dev,
+			                          (ulong)sector_start,
+						  data, n);
 		else
 			result = usb_stor_write_10(&us_ccb, us,
 			                           (ulong)sector_start, n);
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 08/26] usb: storage: Make usb_stor_write_10() a standalone function
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
                   ` (6 preceding siblings ...)
  2019-03-07  8:00 ` [PATCH 07/26] usb: storage: Make usb_stor_read_10() " Andrey Smirnov
@ 2019-03-07  8:00 ` Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 09/26] usb: storage: Drop extra call to transport in usb_stor_write_10() Andrey Smirnov
                   ` (18 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Move special preparation steps done before the call to
usb_stor_write_10() inside the function itself for clarity and to
allow futher code improvements. No functional change intended.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/storage/usb.c | 43 +++++++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index e6f8f30c6..a3442f576 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -195,32 +195,39 @@ static int usb_stor_read_10(struct us_blk_dev *usb_blkdev,
 	return -EIO;
 }
 
-static int usb_stor_write_10(ccb *srb, struct us_data *us,
-                             unsigned long start, unsigned short blocks)
+static int usb_stor_write_10(struct us_blk_dev *usb_blkdev,
+                             unsigned long start, u8 *data,
+			     unsigned short blocks)
 {
+	struct us_data *us = usb_blkdev->us;
 	struct device_d *dev = &us->pusb_dev->dev;
 	int retries, result;
+	ccb srb;
+
+	srb.lun = usb_blkdev->lun;
+	srb.pdata = data;
+	srb.datalen = blocks * SECTOR_SIZE;
 
 	retries = 2;
 	do {
 		dev_dbg(dev, "SCSI_WRITE10: start %lx blocks %x\n", start, blocks);
-		memset(&srb->cmd[0], 0, 10);
-		srb->cmdlen = 10;
-		srb->cmd[0] = SCSI_WRITE10;
-		srb->cmd[2] = (u8)(start >> 24);
-		srb->cmd[3] = (u8)(start >> 16);
-		srb->cmd[4] = (u8)(start >> 8);
-		srb->cmd[5] = (u8)(start >> 0);
-		srb->cmd[7] = (u8)(blocks >> 8);
-		srb->cmd[8] = (u8)(blocks >> 0);
-		result = us->transport(srb, us);
+		memset(&srb.cmd[0], 0, 10);
+		srb.cmdlen = 10;
+		srb.cmd[0] = SCSI_WRITE10;
+		srb.cmd[2] = (u8)(start >> 24);
+		srb.cmd[3] = (u8)(start >> 16);
+		srb.cmd[4] = (u8)(start >> 8);
+		srb.cmd[5] = (u8)(start >> 0);
+		srb.cmd[7] = (u8)(blocks >> 8);
+		srb.cmd[8] = (u8)(blocks >> 0);
+		result = us->transport(&srb, us);
 		dev_dbg(dev, "SCSI_WRITE10 returns %d\n", result);
 		if (result == USB_STOR_TRANSPORT_GOOD)
 			return 0;
-		usb_stor_request_sense(srb, us);
+		usb_stor_request_sense(&srb, us);
 	} while (retries--);
 
-	return us->transport(srb, us);
+	return us->transport(&srb, us);
 }
 
 
@@ -291,15 +298,15 @@ static int usb_stor_blk_io(int io_op, struct block_device *disk_dev,
 		int result;
 		unsigned n = min(sector_count, US_MAX_IO_BLK);
 		u8 *data = buffer + (sectors_done * SECTOR_SIZE);
-		us_ccb.pdata = data;
-		us_ccb.datalen = n * SECTOR_SIZE;
+
 		if (io_op == io_rd)
 			result = usb_stor_read_10(pblk_dev,
 			                          (ulong)sector_start,
 						  data, n);
 		else
-			result = usb_stor_write_10(&us_ccb, us,
-			                           (ulong)sector_start, n);
+			result = usb_stor_write_10(pblk_dev,
+			                           (ulong)sector_start,
+						   data, n);
 		if (result != 0) {
 			dev_dbg(dev, "I/O error at sector %d\n", sector_start);
 			break;
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 09/26] usb: storage: Drop extra call to transport in usb_stor_write_10()
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
                   ` (7 preceding siblings ...)
  2019-03-07  8:00 ` [PATCH 08/26] usb: storage: Make usb_stor_write_10() " Andrey Smirnov
@ 2019-03-07  8:00 ` Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 10/26] usb: storage: Share code for READ(10) and WRITE(10) Andrey Smirnov
                   ` (17 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

There doesn't seem to be a particularly good reason to call
->trasport() one last time after 2 failures. Drop the call so allow
sharing this code with usb_stor_read_10() in the following commit.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/storage/usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index a3442f576..d601e9ca4 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -227,7 +227,7 @@ static int usb_stor_write_10(struct us_blk_dev *usb_blkdev,
 		usb_stor_request_sense(&srb, us);
 	} while (retries--);
 
-	return us->transport(&srb, us);
+	return -EIO;
 }
 
 
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 10/26] usb: storage: Share code for READ(10) and WRITE(10)
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
                   ` (8 preceding siblings ...)
  2019-03-07  8:00 ` [PATCH 09/26] usb: storage: Drop extra call to transport in usb_stor_write_10() Andrey Smirnov
@ 2019-03-07  8:00 ` Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 11/26] usb: storage: Make usb_stor_request_sense() a standalone function Andrey Smirnov
                   ` (16 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Both usb_stor_read_10() and usb_stor_write_10() do almost exactly the
same thing, so merge them into a signle routine and adjust all of the
users accordingly.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/storage/usb.c | 60 ++++++---------------------------------
 1 file changed, 9 insertions(+), 51 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index d601e9ca4..e63cc40a6 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -160,12 +160,11 @@ static int usb_stor_read_capacity(struct us_blk_dev *usb_blkdev,
 	return result ? -EIO : 0;
 }
 
-static int usb_stor_read_10(struct us_blk_dev *usb_blkdev,
-                            unsigned long start, u8 *data,
-			    unsigned short blocks)
+static int usb_stor_io_10(struct us_blk_dev *usb_blkdev, u8 cmd,
+			  unsigned long start, u8 *data,
+			  unsigned short blocks)
 {
 	struct us_data *us = usb_blkdev->us;
-	struct device_d *dev = &us->pusb_dev->dev;
 	int retries, result;
 	ccb srb;
 
@@ -175,10 +174,9 @@ static int usb_stor_read_10(struct us_blk_dev *usb_blkdev,
 
 	retries = 2;
 	do {
-		dev_dbg(dev, "SCSI_READ10: start %lx blocks %x\n", start, blocks);
 		memset(&srb.cmd[0], 0, 10);
 		srb.cmdlen = 10;
-		srb.cmd[0] = SCSI_READ10;
+		srb.cmd[0] = cmd;
 		srb.cmd[2] = (u8)(start >> 24);
 		srb.cmd[3] = (u8)(start >> 16);
 		srb.cmd[4] = (u8)(start >> 8);
@@ -186,7 +184,6 @@ static int usb_stor_read_10(struct us_blk_dev *usb_blkdev,
 		srb.cmd[7] = (u8)(blocks >> 8);
 		srb.cmd[8] = (u8)(blocks >> 0);
 		result = us->transport(&srb, us);
-		dev_dbg(dev, "SCSI_READ10 returns %d\n", result);
 		if (result == USB_STOR_TRANSPORT_GOOD)
 			return 0;
 		usb_stor_request_sense(&srb, us);
@@ -195,42 +192,6 @@ static int usb_stor_read_10(struct us_blk_dev *usb_blkdev,
 	return -EIO;
 }
 
-static int usb_stor_write_10(struct us_blk_dev *usb_blkdev,
-                             unsigned long start, u8 *data,
-			     unsigned short blocks)
-{
-	struct us_data *us = usb_blkdev->us;
-	struct device_d *dev = &us->pusb_dev->dev;
-	int retries, result;
-	ccb srb;
-
-	srb.lun = usb_blkdev->lun;
-	srb.pdata = data;
-	srb.datalen = blocks * SECTOR_SIZE;
-
-	retries = 2;
-	do {
-		dev_dbg(dev, "SCSI_WRITE10: start %lx blocks %x\n", start, blocks);
-		memset(&srb.cmd[0], 0, 10);
-		srb.cmdlen = 10;
-		srb.cmd[0] = SCSI_WRITE10;
-		srb.cmd[2] = (u8)(start >> 24);
-		srb.cmd[3] = (u8)(start >> 16);
-		srb.cmd[4] = (u8)(start >> 8);
-		srb.cmd[5] = (u8)(start >> 0);
-		srb.cmd[7] = (u8)(blocks >> 8);
-		srb.cmd[8] = (u8)(blocks >> 0);
-		result = us->transport(&srb, us);
-		dev_dbg(dev, "SCSI_WRITE10 returns %d\n", result);
-		if (result == USB_STOR_TRANSPORT_GOOD)
-			return 0;
-		usb_stor_request_sense(&srb, us);
-	} while (retries--);
-
-	return -EIO;
-}
-
-
 /***********************************************************************
  * Disk driver interface
  ***********************************************************************/
@@ -299,14 +260,11 @@ static int usb_stor_blk_io(int io_op, struct block_device *disk_dev,
 		unsigned n = min(sector_count, US_MAX_IO_BLK);
 		u8 *data = buffer + (sectors_done * SECTOR_SIZE);
 
-		if (io_op == io_rd)
-			result = usb_stor_read_10(pblk_dev,
-			                          (ulong)sector_start,
-						  data, n);
-		else
-			result = usb_stor_write_10(pblk_dev,
-			                           (ulong)sector_start,
-						   data, n);
+		result = usb_stor_io_10(pblk_dev,
+					(io_op == io_rd) ?
+					SCSI_READ10 : SCSI_WRITE10,
+					(ulong)sector_start,
+					data, n);
 		if (result != 0) {
 			dev_dbg(dev, "I/O error at sector %d\n", sector_start);
 			break;
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 11/26] usb: storage: Make usb_stor_request_sense() a standalone function
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
                   ` (9 preceding siblings ...)
  2019-03-07  8:00 ` [PATCH 10/26] usb: storage: Share code for READ(10) and WRITE(10) Andrey Smirnov
@ 2019-03-07  8:00 ` Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 12/26] usb: storage: Remove unused variables Andrey Smirnov
                   ` (15 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Don't try to re-use caller's "ccb" and instead convert
usb_stor_request_sense() to use its own for clarity and to allow
futher code improvements. No functional change intended.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/storage/usb.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index e63cc40a6..64142048c 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -76,24 +76,27 @@ static int usb_stor_inquiry(struct us_blk_dev *usb_blkdev)
 	return result ? -ENODEV : 0;
 }
 
-static int usb_stor_request_sense(ccb *srb, struct us_data *us)
+static int usb_stor_request_sense(struct us_blk_dev *usb_blkdev)
 {
+	struct us_data *us = usb_blkdev->us;
 	struct device_d *dev = &us->pusb_dev->dev;
-	unsigned char *pdata = srb->pdata;
-	unsigned long datalen = srb->datalen;
+	ccb srb;
+	u8 *data = xzalloc(18);
+
+	srb.lun = usb_blkdev->lun;
 
 	dev_dbg(dev, "SCSI_REQ_SENSE\n");
-	srb->pdata = &srb->sense_buf[0];
-	srb->datalen = 18;
-	memset(&srb->cmd[0], 0, 6);
-	srb->cmdlen = 6;
-	srb->cmd[0] = SCSI_REQ_SENSE;
-	srb->cmd[4] = (u8)(srb->datalen >> 0);
-	us->transport(srb, us);
+	srb.pdata = data;
+	srb.datalen = 18;
+	memset(&srb.cmd[0], 0, 6);
+	srb.cmdlen = 6;
+	srb.cmd[0] = SCSI_REQ_SENSE;
+	srb.cmd[4] = (u8)(srb.datalen >> 0);
+	us->transport(&srb, us);
 	dev_dbg(dev, "Request Sense returned %02X %02X %02X\n",
-		 srb->sense_buf[2], srb->sense_buf[12], srb->sense_buf[13]);
-	srb->pdata = pdata;
-	srb->datalen = datalen;
+		data[2], data[12], data[13]);
+
+	free(data);
 
 	return 0;
 }
@@ -118,7 +121,7 @@ static int usb_stor_test_unit_ready(struct us_blk_dev *usb_blkdev)
 		dev_dbg(dev, "SCSI_TST_U_RDY returns %d\n", result);
 		if (result == USB_STOR_TRANSPORT_GOOD)
 			return 0;
-		usb_stor_request_sense(&srb, us);
+		usb_stor_request_sense(usb_blkdev);
 		mdelay(100);
 	} while (retries--);
 
@@ -186,7 +189,7 @@ static int usb_stor_io_10(struct us_blk_dev *usb_blkdev, u8 cmd,
 		result = us->transport(&srb, us);
 		if (result == USB_STOR_TRANSPORT_GOOD)
 			return 0;
-		usb_stor_request_sense(&srb, us);
+		usb_stor_request_sense(usb_blkdev);
 	} while (retries--);
 
 	return -EIO;
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 12/26] usb: storage: Remove unused variables
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
                   ` (10 preceding siblings ...)
  2019-03-07  8:00 ` [PATCH 11/26] usb: storage: Make usb_stor_request_sense() a standalone function Andrey Smirnov
@ 2019-03-07  8:00 ` Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 13/26] usb: storage: Drop struct SCSI_cmd_block Andrey Smirnov
                   ` (14 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Drop a number of variables no longer used in the code.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/storage/usb.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 64142048c..69de9ebf3 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -212,7 +212,6 @@ static int usb_stor_blk_io(int io_op, struct block_device *disk_dev,
 	struct us_blk_dev *pblk_dev = to_usb_mass_storage(disk_dev);
 	struct us_data *us = pblk_dev->us;
 	struct device_d *dev = &us->pusb_dev->dev;
-	ccb us_ccb;
 	unsigned sectors_done;
 
 	if (sector_count == 0)
@@ -232,7 +231,6 @@ static int usb_stor_blk_io(int io_op, struct block_device *disk_dev,
 		return -EINVAL;
 	}
 
-	us_ccb.lun = pblk_dev->lun;
 	usb_disable_asynch(1);
 
 	/* ensure unit ready */
@@ -309,8 +307,6 @@ static struct block_device_ops usb_mass_storage_ops = {
  * Block device routines
  ***********************************************************************/
 
-static unsigned char us_io_buf[512];
-
 static int usb_limit_blk_cnt(unsigned cnt)
 {
 	if (cnt > 0x7fffffff) {
@@ -326,13 +322,9 @@ static int usb_stor_init_blkdev(struct us_blk_dev *pblk_dev)
 {
 	struct us_data *us = pblk_dev->us;
 	struct device_d *dev = &us->pusb_dev->dev;
-	ccb us_ccb;
 	u32 last_lba = 0, block_length = 0;
 	int result = 0;
 
-	us_ccb.pdata = us_io_buf;
-	us_ccb.lun = pblk_dev->lun;
-
 	pblk_dev->blk.num_blocks = 0;
 	usb_disable_asynch(1);
 
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 13/26] usb: storage: Drop struct SCSI_cmd_block
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
                   ` (11 preceding siblings ...)
  2019-03-07  8:00 ` [PATCH 12/26] usb: storage: Remove unused variables Andrey Smirnov
@ 2019-03-07  8:00 ` Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 14/26] usb: hub: Do not include <scsi.h> Andrey Smirnov
                   ` (13 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

All the info we need to pass to transport function can be captured in
a struct us_blk_dev and two byte arrays, so having a dedicated struct
with many unused fields doesn't really buy us anything. Drop the
struct and convert the rest of the code to pass needed data
explicitly.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/storage/transport.c |  30 +++++-----
 drivers/usb/storage/transport.h |   2 +-
 drivers/usb/storage/usb.c       | 100 ++++++++++++++------------------
 drivers/usb/storage/usb.h       |   8 ++-
 include/scsi.h                  |  22 -------
 5 files changed, 65 insertions(+), 97 deletions(-)

diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index cd66d2bfe..48ccee207 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -91,8 +91,11 @@ int usb_stor_Bulk_max_lun(struct us_data *us)
 	return ret;
 }
 
-int usb_stor_Bulk_transport(ccb *srb, struct us_data *us)
+int usb_stor_Bulk_transport(struct us_blk_dev *usb_blkdev,
+			    const u8 *cmd, u8 cmdlen,
+			    void *data, u32 datalen)
 {
+	struct us_data *us = usb_blkdev->us;
 	struct device_d *dev = &us->pusb_dev->dev;
 	struct bulk_cb_wrap cbw;
 	struct bulk_cs_wrap csw;
@@ -101,20 +104,18 @@ int usb_stor_Bulk_transport(ccb *srb, struct us_data *us)
 	unsigned int residue;
 	unsigned int pipein = usb_rcvbulkpipe(us->pusb_dev, us->recv_bulk_ep);
 	unsigned int pipeout = usb_sndbulkpipe(us->pusb_dev, us->send_bulk_ep);
-	int dir_in = US_DIRECTION(srb->cmd[0]);
-
-	srb->trans_bytes = 0;
+	int dir_in = US_DIRECTION(cmd[0]);
 
 	/* set up the command wrapper */
 	cbw.Signature = cpu_to_le32(US_BULK_CB_SIGN);
-	cbw.DataTransferLength = cpu_to_le32(srb->datalen);
+	cbw.DataTransferLength = cpu_to_le32(datalen);
 	cbw.Flags = (dir_in ? US_BULK_FLAG_IN : US_BULK_FLAG_OUT);
 	cbw.Tag = ++cbw_tag;
-	cbw.Lun = srb->lun;
-	cbw.Length = srb->cmdlen;
+	cbw.Lun = usb_blkdev->lun;
+	cbw.Length = cmdlen;
 
 	/* copy the command payload */
-	memcpy(cbw.CDB, srb->cmd, cbw.Length);
+	memcpy(cbw.CDB, cmd, cbw.Length);
 
 	/* send it to out endpoint */
 	dev_dbg(dev, "Bulk Command S 0x%x T 0x%x L %d F %d Trg %d LUN %d CL %d\n",
@@ -136,10 +137,10 @@ int usb_stor_Bulk_transport(ccb *srb, struct us_data *us)
 	mdelay(1);
 
 	data_actlen = 0;
-	if (srb->datalen) {
+	if (datalen) {
 		unsigned int pipe = dir_in ? pipein : pipeout;
-		result = usb_bulk_msg(us->pusb_dev, pipe, srb->pdata,
-		                      srb->datalen, &data_actlen, USB_BULK_TO);
+		result = usb_bulk_msg(us->pusb_dev, pipe, data,
+		                      datalen, &data_actlen, USB_BULK_TO);
 		dev_dbg(dev, "Bulk data transfer result 0x%x\n", result);
 		/* special handling of STALL in DATA phase */
 		if ((result < 0) && (us->pusb_dev->status & USB_ST_STALLED)) {
@@ -194,15 +195,14 @@ int usb_stor_Bulk_transport(ccb *srb, struct us_data *us)
 		dev_dbg(dev, "Status >= phase\n");
 		usb_stor_Bulk_reset(us);
 		return USB_STOR_TRANSPORT_ERROR;
-	} else if (residue > srb->datalen) {
-		dev_dbg(dev, "residue (%uB) > req data (%luB)\n",
-		          residue, srb->datalen);
+	} else if (residue > datalen) {
+		dev_dbg(dev, "residue (%uB) > req data (%uB)\n",
+		          residue, datalen);
 		return USB_STOR_TRANSPORT_FAILED;
 	} else if (csw.Status == US_BULK_STAT_FAIL) {
 		dev_dbg(dev, "FAILED\n");
 		return USB_STOR_TRANSPORT_FAILED;
 	}
-	srb->trans_bytes = min(srb->datalen - residue, (ulong)data_actlen);
 
 	return 0;
 }
diff --git a/drivers/usb/storage/transport.h b/drivers/usb/storage/transport.h
index bc8a7693f..22d7dea3f 100644
--- a/drivers/usb/storage/transport.h
+++ b/drivers/usb/storage/transport.h
@@ -84,7 +84,7 @@ struct bulk_cs_wrap {
 
 struct us_data;
 
-extern int usb_stor_Bulk_transport(ccb *, struct us_data *);
+extern trans_cmnd usb_stor_Bulk_transport;
 extern int usb_stor_Bulk_max_lun(struct us_data *);
 extern int usb_stor_Bulk_reset(struct us_data *);
 
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 69de9ebf3..849bce510 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -42,22 +42,19 @@ static int usb_stor_inquiry(struct us_blk_dev *usb_blkdev)
 	struct us_data *us = usb_blkdev->us;
 	struct device_d *dev = &us->pusb_dev->dev;
 	int retries, result;
-	ccb srb;
-	u8 *data = xzalloc(36);
-
-	srb.lun = usb_blkdev->lun;
-	srb.pdata = data;
-	srb.datalen = 36;
+	u8 cmd[6];
+	const u32 datalen = 36;
+	u8 *data = xzalloc(datalen);
 
 	retries = 3;
 	do {
 		dev_dbg(dev, "SCSI_INQUIRY\n");
-		memset(&srb.cmd[0], 0, 6);
-		srb.cmdlen = 6;
-		srb.cmd[0] = SCSI_INQUIRY;
-		srb.cmd[3] = (u8)(srb.datalen >> 8);
-		srb.cmd[4] = (u8)(srb.datalen >> 0);
-		result = us->transport(&srb, us);
+		memset(cmd, 0, sizeof(cmd));
+		cmd[0] = SCSI_INQUIRY;
+		cmd[3] = (u8)(datalen >> 8);
+		cmd[4] = (u8)(datalen >> 0);
+		result = us->transport(usb_blkdev, cmd, sizeof(cmd),
+				       data, datalen);
 		dev_dbg(dev, "SCSI_INQUIRY returns %d\n", result);
 		if (result == USB_STOR_TRANSPORT_GOOD) {
 			dev_dbg(dev, "Peripheral type: %x, removable: %x\n",
@@ -80,19 +77,16 @@ static int usb_stor_request_sense(struct us_blk_dev *usb_blkdev)
 {
 	struct us_data *us = usb_blkdev->us;
 	struct device_d *dev = &us->pusb_dev->dev;
-	ccb srb;
-	u8 *data = xzalloc(18);
-
-	srb.lun = usb_blkdev->lun;
+	u8 cmd[6];
+	const u8 datalen = 18;
+	u8 *data = xzalloc(datalen);
 
 	dev_dbg(dev, "SCSI_REQ_SENSE\n");
-	srb.pdata = data;
-	srb.datalen = 18;
-	memset(&srb.cmd[0], 0, 6);
-	srb.cmdlen = 6;
-	srb.cmd[0] = SCSI_REQ_SENSE;
-	srb.cmd[4] = (u8)(srb.datalen >> 0);
-	us->transport(&srb, us);
+
+	memset(cmd, 0, sizeof(cmd));
+	cmd[0] = SCSI_REQ_SENSE;
+	cmd[4] = datalen;
+	us->transport(usb_blkdev, cmd, sizeof(cmd), data, datalen);
 	dev_dbg(dev, "Request Sense returned %02X %02X %02X\n",
 		data[2], data[12], data[13]);
 
@@ -105,19 +99,16 @@ static int usb_stor_test_unit_ready(struct us_blk_dev *usb_blkdev)
 {
 	struct us_data *us = usb_blkdev->us;
 	struct device_d *dev = &us->pusb_dev->dev;
+	u8 cmd[12];
 	int retries, result;
-	ccb srb;
-
-	srb.lun = usb_blkdev->lun;
 
 	retries = 10;
 	do {
 		dev_dbg(dev, "SCSI_TST_U_RDY\n");
-		memset(&srb.cmd[0], 0, 12);
-		srb.cmdlen = 12;
-		srb.cmd[0] = SCSI_TST_U_RDY;
-		srb.datalen = 0;
-		result = us->transport(&srb, us);
+		memset(cmd, 0, sizeof(cmd));
+		cmd[0] = SCSI_TST_U_RDY;
+		result = us->transport(usb_blkdev, cmd, sizeof(cmd),
+				       NULL, 0);
 		dev_dbg(dev, "SCSI_TST_U_RDY returns %d\n", result);
 		if (result == USB_STOR_TRANSPORT_GOOD)
 			return 0;
@@ -134,19 +125,18 @@ static int usb_stor_read_capacity(struct us_blk_dev *usb_blkdev,
 	struct us_data *us = usb_blkdev->us;
 	struct device_d *dev = &us->pusb_dev->dev;
 	int retries, result;
-	ccb srb;
-	u32 *data = xzalloc(8);
+	const u32 datalen = 8;
+	u32 *data = xzalloc(datalen);
+	u8 cmd[10];
 
 	retries = 3;
 	do {
 		dev_dbg(dev, "SCSI_RD_CAPAC\n");
-		memset(&srb.cmd[0], 0, 10);
-		srb.cmdlen = 10;
-		srb.lun = usb_blkdev->lun;
-		srb.cmd[0] = SCSI_RD_CAPAC;
-		srb.pdata = (void *)data;
-		srb.datalen = 8;
-		result = us->transport(&srb, us);
+		memset(cmd, 0, sizeof(cmd));
+		cmd[0] = SCSI_RD_CAPAC;
+
+		result = us->transport(usb_blkdev, cmd, sizeof(cmd), data,
+				       datalen);
 		dev_dbg(dev, "SCSI_RD_CAPAC returns %d\n", result);
 
 		if (result == USB_STOR_TRANSPORT_GOOD) {
@@ -163,30 +153,28 @@ static int usb_stor_read_capacity(struct us_blk_dev *usb_blkdev,
 	return result ? -EIO : 0;
 }
 
-static int usb_stor_io_10(struct us_blk_dev *usb_blkdev, u8 cmd,
+static int usb_stor_io_10(struct us_blk_dev *usb_blkdev, u8 opcode,
 			  unsigned long start, u8 *data,
 			  unsigned short blocks)
 {
 	struct us_data *us = usb_blkdev->us;
 	int retries, result;
-	ccb srb;
-
-	srb.lun = usb_blkdev->lun;
-	srb.pdata = data;
-	srb.datalen = blocks * SECTOR_SIZE;
+	const u32 datalen = blocks * SECTOR_SIZE;
+	u8 cmd[10];
 
 	retries = 2;
 	do {
-		memset(&srb.cmd[0], 0, 10);
-		srb.cmdlen = 10;
-		srb.cmd[0] = cmd;
-		srb.cmd[2] = (u8)(start >> 24);
-		srb.cmd[3] = (u8)(start >> 16);
-		srb.cmd[4] = (u8)(start >> 8);
-		srb.cmd[5] = (u8)(start >> 0);
-		srb.cmd[7] = (u8)(blocks >> 8);
-		srb.cmd[8] = (u8)(blocks >> 0);
-		result = us->transport(&srb, us);
+		memset(cmd, 0, sizeof(cmd));
+
+		cmd[0] = opcode;
+		cmd[2] = (u8)(start >> 24);
+		cmd[3] = (u8)(start >> 16);
+		cmd[4] = (u8)(start >> 8);
+		cmd[5] = (u8)(start >> 0);
+		cmd[7] = (u8)(blocks >> 8);
+		cmd[8] = (u8)(blocks >> 0);
+		result = us->transport(usb_blkdev, cmd, sizeof(cmd),
+				       data, datalen);
 		if (result == USB_STOR_TRANSPORT_GOOD)
 			return 0;
 		usb_stor_request_sense(usb_blkdev);
diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
index 544537089..3aff15da2 100644
--- a/drivers/usb/storage/usb.h
+++ b/drivers/usb/storage/usb.h
@@ -44,8 +44,11 @@
 
 
 struct us_data;
+struct us_blk_dev;
 
-typedef int (*trans_cmnd)(ccb *cb, struct us_data *data);
+typedef int (trans_cmnd)(struct us_blk_dev *usb_blkdev,
+			 const u8 *cmd, u8 cmdlen,
+			 void *data, u32 datalen);
 typedef int (*trans_reset)(struct us_data *data);
 
 /* one us_data object allocated per usb storage device */
@@ -65,11 +68,10 @@ struct us_data {
 
 	char			*transport_name;
 
-	trans_cmnd		transport;	/* transport function */
+	trans_cmnd		*transport;	/* transport function */
 	trans_reset		transport_reset;/* transport device reset */
 
 	/* SCSI interfaces */
-	ccb			*srb;		/* current srb */
 	struct list_head	blk_dev_list;
 };
 
diff --git a/include/scsi.h b/include/scsi.h
index 00750acac..59d47393c 100644
--- a/include/scsi.h
+++ b/include/scsi.h
@@ -20,26 +20,6 @@
  #ifndef _SCSI_H
  #define _SCSI_H
 
-typedef struct SCSI_cmd_block {
-	unsigned char		cmd[16];		/* command */
-	unsigned char		sense_buf[64];		/* for request sense */
-	unsigned char		status;			/* SCSI Status */
-	unsigned char		target;			/* Target ID */
-	unsigned char		lun;			/* Target LUN */
-	unsigned char		cmdlen;			/* command len */
-	unsigned long		datalen;		/* Total data length */
-	unsigned char	*	pdata;			/* pointer to data */
-	unsigned char		msgout[12];		/* Messge out buffer (NOT USED) */
-	unsigned char		msgin[12];		/* Message in buffer */
-	unsigned char		sensecmdlen;		/* Sense command len */
-	unsigned long		sensedatalen;		/* Sense data len */
-	unsigned char		sensecmd[6];		/* Sense command */
-	unsigned long		contr_stat;		/* Controller Status */
-	unsigned long		trans_bytes;		/* tranfered bytes */
-
-	unsigned int		priv;
-} ccb;
-
 /*-----------------------------------------------------------
 **
 **	SCSI  constants.
@@ -171,8 +151,6 @@ typedef struct SCSI_cmd_block {
  * decleration of functions which have to reside in the LowLevel Part Driver
  */
 
-void scsi_print_error(ccb *pccb);
-int scsi_exec(ccb *pccb);
 void scsi_bus_reset(void);
 void scsi_low_level_init(int busdevfunc);
 
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 14/26] usb: hub: Do not include <scsi.h>
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
                   ` (12 preceding siblings ...)
  2019-03-07  8:00 ` [PATCH 13/26] usb: storage: Drop struct SCSI_cmd_block Andrey Smirnov
@ 2019-03-07  8:00 ` Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 15/26] ata: ahci: " Andrey Smirnov
                   ` (12 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

No symbols found in <scsi.h> are used in this file. Drop it.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/core/hub.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 39e5fe67d..d01a01607 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -21,7 +21,6 @@
 #include <init.h>
 #include <malloc.h>
 #include <errno.h>
-#include <scsi.h>
 #include <usb/phy.h>
 #include <usb/usb.h>
 #include <usb/usb_defs.h>
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 15/26] ata: ahci: Do not include <scsi.h>
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
                   ` (13 preceding siblings ...)
  2019-03-07  8:00 ` [PATCH 14/26] usb: hub: Do not include <scsi.h> Andrey Smirnov
@ 2019-03-07  8:00 ` Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 16/26] usb: storage: Drop unused fields in struct us_data Andrey Smirnov
                   ` (11 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

No symbols found in <scsi.h> are used in this file. Drop it.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/ata/ahci.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 3f0bbb075..7dc09d00c 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -27,7 +27,6 @@
 #include <io.h>
 #include <of.h>
 #include <malloc.h>
-#include <scsi.h>
 #include <linux/ctype.h>
 #include <linux/err.h>
 #include <disks.h>
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 16/26] usb: storage: Drop unused fields in struct us_data
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
                   ` (14 preceding siblings ...)
  2019-03-07  8:00 ` [PATCH 15/26] ata: ahci: " Andrey Smirnov
@ 2019-03-07  8:00 ` Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 17/26] usb: storage: Drop unused us_blkdev_list Andrey Smirnov
                   ` (10 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Only bulk-only transport is supported by the currennt codebase, so
ep_bInterval and recv_intr_ep are not really used. Remove them and all
related code. While at it remove flags and subclass as well since they
are not really used anywhere in the codebase.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/storage/usb.c | 14 ++------------
 drivers/usb/storage/usb.h |  4 ----
 2 files changed, 2 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 849bce510..c04a202bb 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -433,7 +433,6 @@ static int get_pipes(struct us_data *us, struct usb_interface *intf)
 	struct usb_endpoint_descriptor *ep;
 	struct usb_endpoint_descriptor *ep_in = NULL;
 	struct usb_endpoint_descriptor *ep_out = NULL;
-	struct usb_endpoint_descriptor *ep_int = NULL;
 
 	/*
 	 * Find the first endpoint of each type we need.
@@ -454,12 +453,8 @@ static int get_pipes(struct us_data *us, struct usb_interface *intf)
 					ep_out = ep;
 			}
 		}
-		else if (USB_EP_IS_INT_IN(ep)) {
-			if (!ep_int)
-				ep_int = ep;
-		}
 	}
-	if (!ep_in || !ep_out || (us->protocol == US_PR_CBI && !ep_int)) {
+	if (!ep_in || !ep_out || us->protocol == US_PR_CBI) {
 		dev_dbg(dev, "Endpoint sanity check failed! Rejecting dev.\n");
 		return -EIO;
 	}
@@ -467,10 +462,7 @@ static int get_pipes(struct us_data *us, struct usb_interface *intf)
 	/* Store the pipe values */
 	us->send_bulk_ep = USB_EP_NUM(ep_out);
 	us->recv_bulk_ep = USB_EP_NUM(ep_in);
-	if (ep_int) {
-		us->recv_intr_ep = USB_EP_NUM(ep_int);
-		us->ep_bInterval = ep_int->bInterval;
-	}
+
 	return 0;
 }
 
@@ -533,9 +525,7 @@ static int usb_stor_probe(struct usb_device *usbdev,
 
 	/* initialize the us_data structure */
 	us->pusb_dev = usbdev;
-	us->flags = 0;
 	us->ifnum = intf->desc.bInterfaceNumber;
-	us->subclass = intf->desc.bInterfaceSubClass;
 	us->protocol = intf->desc.bInterfaceProtocol;
 	INIT_LIST_HEAD(&us->blk_dev_list);
 
diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
index 3aff15da2..cd4904f03 100644
--- a/drivers/usb/storage/usb.h
+++ b/drivers/usb/storage/usb.h
@@ -54,17 +54,13 @@ typedef int (*trans_reset)(struct us_data *data);
 /* one us_data object allocated per usb storage device */
 struct us_data {
 	struct usb_device	*pusb_dev;	/* this usb_device */
-	unsigned int		flags;		/* from filter */
 	unsigned char		send_bulk_ep;	/* used endpoints */
 	unsigned char		recv_bulk_ep;
-	unsigned char		recv_intr_ep;
 	unsigned char		ifnum;		/* interface number */
 
-	unsigned char		subclass;
 	unsigned char		protocol;
 
 	unsigned char		max_lun;
-	unsigned char		ep_bInterval;
 
 	char			*transport_name;
 
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 17/26] usb: storage: Drop unused us_blkdev_list
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
                   ` (15 preceding siblings ...)
  2019-03-07  8:00 ` [PATCH 16/26] usb: storage: Drop unused fields in struct us_data Andrey Smirnov
@ 2019-03-07  8:00 ` Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 18/26] usb: storage: Introduce usb_stor_transport() Andrey Smirnov
                   ` (9 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

There are no users of us_blkdev_list in the file. Drop it.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/storage/usb.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index c04a202bb..faf9ec2b4 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -30,9 +30,6 @@
 #include "transport.h"
 
 
-static LIST_HEAD(us_blkdev_list);
-
-
 /***********************************************************************
  * USB Storage routines
  ***********************************************************************/
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 18/26] usb: storage: Introduce usb_stor_transport()
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
                   ` (16 preceding siblings ...)
  2019-03-07  8:00 ` [PATCH 17/26] usb: storage: Drop unused us_blkdev_list Andrey Smirnov
@ 2019-03-07  8:00 ` Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 19/26] usb: storage: Use put_unaligned_be* helpers Andrey Smirnov
                   ` (8 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Move retry logic found in all of the low-level usb_stor_* functions
into a standalone subroutine and convert the rest of the code to use
it.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/storage/usb.c | 213 +++++++++++++++++++++-----------------
 1 file changed, 117 insertions(+), 96 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index faf9ec2b4..5a5d075ec 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -34,41 +34,7 @@
  * USB Storage routines
  ***********************************************************************/
 
-static int usb_stor_inquiry(struct us_blk_dev *usb_blkdev)
-{
-	struct us_data *us = usb_blkdev->us;
-	struct device_d *dev = &us->pusb_dev->dev;
-	int retries, result;
-	u8 cmd[6];
-	const u32 datalen = 36;
-	u8 *data = xzalloc(datalen);
-
-	retries = 3;
-	do {
-		dev_dbg(dev, "SCSI_INQUIRY\n");
-		memset(cmd, 0, sizeof(cmd));
-		cmd[0] = SCSI_INQUIRY;
-		cmd[3] = (u8)(datalen >> 8);
-		cmd[4] = (u8)(datalen >> 0);
-		result = us->transport(usb_blkdev, cmd, sizeof(cmd),
-				       data, datalen);
-		dev_dbg(dev, "SCSI_INQUIRY returns %d\n", result);
-		if (result == USB_STOR_TRANSPORT_GOOD) {
-			dev_dbg(dev, "Peripheral type: %x, removable: %x\n",
-				data[0], (data[1] >> 7));
-			dev_dbg(dev, "ISO ver: %x, resp format: %x\n",
-				data[2], data[3]);
-			dev_dbg(dev, "Vendor/product/rev: %28s\n",
-				&data[8]);
-			// TODO:  process and store device info
-			break;
-		}
-	} while (retries--);
-
-	free(data);
-
-	return result ? -ENODEV : 0;
-}
+#define USB_STOR_NO_REQUEST_SENSE	-1
 
 static int usb_stor_request_sense(struct us_blk_dev *usb_blkdev)
 {
@@ -92,92 +58,147 @@ static int usb_stor_request_sense(struct us_blk_dev *usb_blkdev)
 	return 0;
 }
 
-static int usb_stor_test_unit_ready(struct us_blk_dev *usb_blkdev)
+static const char *usb_stor_opcode_name(u8 opcode)
+{
+	switch (opcode) {
+	case SCSI_INQUIRY:
+		return "SCSI_INQUIRY";
+	case SCSI_TST_U_RDY:
+		return "SCSI_TST_U_RDY";
+	case SCSI_RD_CAPAC:
+		return "SCSI_RD_CAPAC";
+	case SCSI_READ10:
+		return "SCSI_READ10";
+	case SCSI_WRITE10:
+		return "SCSI_WRITE10";
+	};
+
+	return "UNKNOWN";
+}
+
+static int usb_stor_transport(struct us_blk_dev *usb_blkdev,
+			      const u8 *cmd, u8 cmdlen,
+			      void *data, u32 datalen,
+			      int retries, int request_sense_delay_ms)
 {
 	struct us_data *us = usb_blkdev->us;
 	struct device_d *dev = &us->pusb_dev->dev;
-	u8 cmd[12];
-	int retries, result;
-
-	retries = 10;
-	do {
-		dev_dbg(dev, "SCSI_TST_U_RDY\n");
-		memset(cmd, 0, sizeof(cmd));
-		cmd[0] = SCSI_TST_U_RDY;
-		result = us->transport(usb_blkdev, cmd, sizeof(cmd),
-				       NULL, 0);
-		dev_dbg(dev, "SCSI_TST_U_RDY returns %d\n", result);
-		if (result == USB_STOR_TRANSPORT_GOOD)
+	int i, ret;
+
+
+	for (i = 0; i < retries; i++) {
+		dev_dbg(dev, "%s\n", usb_stor_opcode_name(cmd[0]));
+		ret = us->transport(usb_blkdev, cmd, cmdlen, data, datalen);
+		dev_dbg(dev, "%s returns %d\n", usb_stor_opcode_name(cmd[0]),
+			ret);
+		if (ret == USB_STOR_TRANSPORT_GOOD)
 			return 0;
+
+		if (request_sense_delay_ms == USB_STOR_NO_REQUEST_SENSE)
+			continue;
+
 		usb_stor_request_sense(usb_blkdev);
-		mdelay(100);
-	} while (retries--);
 
-	return -ENODEV;
+		if (request_sense_delay_ms)
+			mdelay(request_sense_delay_ms);
+	}
+
+	return -EIO;
+}
+
+static int usb_stor_inquiry(struct us_blk_dev *usb_blkdev)
+{
+	struct device_d *dev = &usb_blkdev->us->pusb_dev->dev;
+	int ret;
+	u8 cmd[6];
+	const u32 datalen = 36;
+	u8 *data = xzalloc(datalen);
+
+	memset(cmd, 0, sizeof(cmd));
+	cmd[0] = SCSI_INQUIRY;
+	cmd[3] = (u8)(datalen >> 8);
+	cmd[4] = (u8)(datalen >> 0);
+
+	ret = usb_stor_transport(usb_blkdev, cmd, sizeof(cmd), data, datalen,
+				 3, USB_STOR_NO_REQUEST_SENSE);
+	if (ret < 0) {
+		ret = -ENODEV;
+		goto exit;
+	}
+
+	dev_dbg(dev, "Peripheral type: %x, removable: %x\n",
+		data[0], (data[1] >> 7));
+	dev_dbg(dev, "ISO ver: %x, resp format: %x\n",
+		data[2], data[3]);
+	dev_dbg(dev, "Vendor/product/rev: %28s\n",
+		&data[8]);
+	// TODO:  process and store device info
+
+exit:
+	free(data);
+	return ret;
+}
+
+static int usb_stor_test_unit_ready(struct us_blk_dev *usb_blkdev)
+{
+	u8 cmd[12];
+	int ret;
+
+	memset(cmd, 0, sizeof(cmd));
+	cmd[0] = SCSI_TST_U_RDY;
+
+	ret = usb_stor_transport(usb_blkdev, cmd, sizeof(cmd), NULL, 0,
+				 10, 100);
+	if (ret < 0)
+		return -ENODEV;
+
+	return 0;
 }
 
 static int usb_stor_read_capacity(struct us_blk_dev *usb_blkdev,
 				  u32 *last_lba, u32 *block_length)
 {
-	struct us_data *us = usb_blkdev->us;
-	struct device_d *dev = &us->pusb_dev->dev;
-	int retries, result;
+	struct device_d *dev = &usb_blkdev->us->pusb_dev->dev;
 	const u32 datalen = 8;
 	u32 *data = xzalloc(datalen);
 	u8 cmd[10];
+	int ret;
 
-	retries = 3;
-	do {
-		dev_dbg(dev, "SCSI_RD_CAPAC\n");
-		memset(cmd, 0, sizeof(cmd));
-		cmd[0] = SCSI_RD_CAPAC;
-
-		result = us->transport(usb_blkdev, cmd, sizeof(cmd), data,
-				       datalen);
-		dev_dbg(dev, "SCSI_RD_CAPAC returns %d\n", result);
-
-		if (result == USB_STOR_TRANSPORT_GOOD) {
-			dev_dbg(dev, "Read Capacity returns: 0x%x, 0x%x\n",
-				data[0], data[1]);
-			*last_lba = be32_to_cpu(data[0]);
-			*block_length = be32_to_cpu(data[1]);
-			break;
-		}
-	} while (retries--);
+	memset(cmd, 0, sizeof(cmd));
+	cmd[0] = SCSI_RD_CAPAC;
 
-	free(data);
+	ret = usb_stor_transport(usb_blkdev, cmd, sizeof(cmd), data, datalen,
+				 3, USB_STOR_NO_REQUEST_SENSE);
+	if (ret < 0)
+		goto exit;
+
+	dev_dbg(dev, "Read Capacity returns: 0x%x, 0x%x\n",
+		data[0], data[1]);
+	*last_lba = be32_to_cpu(data[0]);
+	*block_length = be32_to_cpu(data[1]);
 
-	return result ? -EIO : 0;
+exit:
+	free(data);
+	return ret;
 }
 
 static int usb_stor_io_10(struct us_blk_dev *usb_blkdev, u8 opcode,
 			  unsigned long start, u8 *data,
 			  unsigned short blocks)
 {
-	struct us_data *us = usb_blkdev->us;
-	int retries, result;
-	const u32 datalen = blocks * SECTOR_SIZE;
 	u8 cmd[10];
 
-	retries = 2;
-	do {
-		memset(cmd, 0, sizeof(cmd));
-
-		cmd[0] = opcode;
-		cmd[2] = (u8)(start >> 24);
-		cmd[3] = (u8)(start >> 16);
-		cmd[4] = (u8)(start >> 8);
-		cmd[5] = (u8)(start >> 0);
-		cmd[7] = (u8)(blocks >> 8);
-		cmd[8] = (u8)(blocks >> 0);
-		result = us->transport(usb_blkdev, cmd, sizeof(cmd),
-				       data, datalen);
-		if (result == USB_STOR_TRANSPORT_GOOD)
-			return 0;
-		usb_stor_request_sense(usb_blkdev);
-	} while (retries--);
-
-	return -EIO;
+	memset(cmd, 0, sizeof(cmd));
+	cmd[0] = opcode;
+	cmd[2] = (u8)(start >> 24);
+	cmd[3] = (u8)(start >> 16);
+	cmd[4] = (u8)(start >> 8);
+	cmd[5] = (u8)(start >> 0);
+	cmd[7] = (u8)(blocks >> 8);
+	cmd[8] = (u8)(blocks >> 0);
+
+	return usb_stor_transport(usb_blkdev, cmd, sizeof(cmd), data,
+				  blocks * SECTOR_SIZE, 2, 0);
 }
 
 /***********************************************************************
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 19/26] usb: storage: Use put_unaligned_be* helpers
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
                   ` (17 preceding siblings ...)
  2019-03-07  8:00 ` [PATCH 18/26] usb: storage: Introduce usb_stor_transport() Andrey Smirnov
@ 2019-03-07  8:00 ` Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 20/26] usb: Drop usb_disable_asynch() Andrey Smirnov
                   ` (7 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Replace explicit endianness casts with put_unaligned_be* helpers.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/storage/usb.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 5a5d075ec..06ec1eb4e 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -26,6 +26,8 @@
 #include <usb/usb.h>
 #include <usb/usb_defs.h>
 
+#include <asm/unaligned.h>
+
 #include "usb.h"
 #include "transport.h"
 
@@ -111,13 +113,12 @@ static int usb_stor_inquiry(struct us_blk_dev *usb_blkdev)
 	struct device_d *dev = &usb_blkdev->us->pusb_dev->dev;
 	int ret;
 	u8 cmd[6];
-	const u32 datalen = 36;
+	const u16 datalen = 36;
 	u8 *data = xzalloc(datalen);
 
 	memset(cmd, 0, sizeof(cmd));
 	cmd[0] = SCSI_INQUIRY;
-	cmd[3] = (u8)(datalen >> 8);
-	cmd[4] = (u8)(datalen >> 0);
+	put_unaligned_be16(datalen, &cmd[3]);
 
 	ret = usb_stor_transport(usb_blkdev, cmd, sizeof(cmd), data, datalen,
 				 3, USB_STOR_NO_REQUEST_SENSE);
@@ -183,19 +184,14 @@ exit:
 }
 
 static int usb_stor_io_10(struct us_blk_dev *usb_blkdev, u8 opcode,
-			  unsigned long start, u8 *data,
-			  unsigned short blocks)
+			  u32 start, u8 *data, u16 blocks)
 {
 	u8 cmd[10];
 
 	memset(cmd, 0, sizeof(cmd));
 	cmd[0] = opcode;
-	cmd[2] = (u8)(start >> 24);
-	cmd[3] = (u8)(start >> 16);
-	cmd[4] = (u8)(start >> 8);
-	cmd[5] = (u8)(start >> 0);
-	cmd[7] = (u8)(blocks >> 8);
-	cmd[8] = (u8)(blocks >> 0);
+	put_unaligned_be32(start, &cmd[2]);
+	put_unaligned_be16(blocks, &cmd[7]);
 
 	return usb_stor_transport(usb_blkdev, cmd, sizeof(cmd), data,
 				  blocks * SECTOR_SIZE, 2, 0);
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 20/26] usb: Drop usb_disable_asynch()
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
                   ` (18 preceding siblings ...)
  2019-03-07  8:00 ` [PATCH 19/26] usb: storage: Use put_unaligned_be* helpers Andrey Smirnov
@ 2019-03-07  8:00 ` Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 21/26] usb: storage: Drop unnecessary check in usb_stor_blk_io() Andrey Smirnov
                   ` (6 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

There are no users of usb_control_msg() in the codebase that pass
timeout of 0, so it doesn't look like usb_disable_asynch() has any
effect on USB operation. Drop that function and remove all of its uses
to simplify things.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/core/usb.c    | 24 +++---------------------
 drivers/usb/storage/usb.c | 16 ++++------------
 include/usb/usb.h         |  1 -
 3 files changed, 7 insertions(+), 34 deletions(-)

diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 7b008435f..d29cd1328 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -63,7 +63,6 @@
 
 static int dev_count;
 static int dev_index;
-static int asynch_allowed;
 
 static LIST_HEAD(host_list);
 LIST_HEAD(usb_device_list);
@@ -98,7 +97,6 @@ int usb_register_host(struct usb_host *host)
 	list_add_tail(&host->list, &host_list);
 	host->busnum = host_busnum++;
 	host->sem = 0;
-	asynch_allowed = 1;
 	return 0;
 }
 
@@ -559,16 +557,6 @@ void usb_rescan(void)
 	pr_info("%d USB Device(s) found\n", dev_count);
 }
 
-/*
- * disables the asynch behaviour of the control message. This is used for data
- * transfers that uses the exclusiv access to the control and bulk messages.
- */
-void usb_disable_asynch(int disable)
-{
-	asynch_allowed = !disable;
-}
-
-
 /*-------------------------------------------------------------------
  * Message wrappers.
  *
@@ -597,10 +585,9 @@ int usb_submit_int_msg(struct usb_device *dev, unsigned long pipe,
 /*
  * submits a control message and waits for completion (at least timeout * 1ms)
  * If timeout is 0, we don't wait for completion (used as example to set and
- * clear keyboards LEDs). For data transfers, (storage transfers) we don't
- * allow control messages with 0 timeout, by previously resetting the flag
- * asynch_allowed (usb_disable_asynch(1)).
- * returns the transfered length if OK or -1 if error. The transfered length
+ * clear keyboards LEDs).
+ *
+ * Returns the transfered length if OK or -1 if error. The transfered length
  * and the current status are stored in the dev->act_len and dev->status.
  */
 int usb_control_msg(struct usb_device *dev, unsigned int pipe,
@@ -612,11 +599,6 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe,
 	int ret;
 	struct devrequest *setup_packet = dev->setup_packet;
 
-	if ((timeout == 0) && (!asynch_allowed)) {
-		/* request for a asynch control pipe is not allowed */
-		return -1;
-	}
-
 	ret = usb_host_acquire(host);
 	if (ret)
 		return ret;
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 06ec1eb4e..b86e72a6f 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -233,13 +233,10 @@ static int usb_stor_blk_io(int io_op, struct block_device *disk_dev,
 		return -EINVAL;
 	}
 
-	usb_disable_asynch(1);
-
 	/* ensure unit ready */
 	dev_dbg(dev, "Testing for unit ready\n");
 	if (usb_stor_test_unit_ready(pblk_dev)) {
 		dev_dbg(dev, "Device NOT ready\n");
-		usb_disable_asynch(0);
 		return -EIO;
 	}
 
@@ -277,8 +274,6 @@ static int usb_stor_blk_io(int io_op, struct block_device *disk_dev,
 		sectors_done += n;
 	}
 
-	usb_disable_asynch(0);
-
 	dev_dbg(dev, "Successful I/O of %d blocks\n", sectors_done);
 
 	return (sector_count != 0) ? -EIO : 0;
@@ -328,7 +323,6 @@ static int usb_stor_init_blkdev(struct us_blk_dev *pblk_dev)
 	int result = 0;
 
 	pblk_dev->blk.num_blocks = 0;
-	usb_disable_asynch(1);
 
 	/* get device info */
 	dev_dbg(dev, "Reading device info\n");
@@ -336,7 +330,7 @@ static int usb_stor_init_blkdev(struct us_blk_dev *pblk_dev)
 	result = usb_stor_inquiry(pblk_dev);
 	if (result) {
 		dev_dbg(dev, "Cannot read device info\n");
-		goto Exit;
+		return result;
 	}
 
 	/* ensure unit ready */
@@ -345,7 +339,7 @@ static int usb_stor_init_blkdev(struct us_blk_dev *pblk_dev)
 	result = usb_stor_test_unit_ready(pblk_dev);
 	if (result) {
 		dev_dbg(dev, "Device NOT ready\n");
-		goto Exit;
+		return result;
 	}
 
 	/* read capacity */
@@ -354,7 +348,7 @@ static int usb_stor_init_blkdev(struct us_blk_dev *pblk_dev)
 	result = usb_stor_read_capacity(pblk_dev, &last_lba, &block_length);
 	if (result < 0) {
 		dev_dbg(dev, "Cannot read device capacity\n");
-		goto Exit;
+		return result;
 	}
 
 	pblk_dev->blk.num_blocks = usb_limit_blk_cnt(last_lba + 1);
@@ -364,9 +358,7 @@ static int usb_stor_init_blkdev(struct us_blk_dev *pblk_dev)
 	dev_dbg(dev, "Capacity = 0x%x, blockshift = 0x%x\n",
 		 pblk_dev->blk.num_blocks, pblk_dev->blk.blockbits);
 
-Exit:
-	usb_disable_asynch(0);
-	return result;
+	return 0;
 }
 
 /* Create and register a disk device for the specified LUN */
diff --git a/include/usb/usb.h b/include/usb/usb.h
index eb2eeb8db..4698308df 100644
--- a/include/usb/usb.h
+++ b/include/usb/usb.h
@@ -172,7 +172,6 @@ int usb_bulk_msg(struct usb_device *dev, unsigned int pipe,
 			void *data, int len, int *actual_length, int timeout);
 int usb_submit_int_msg(struct usb_device *dev, unsigned long pipe,
 			void *buffer, int transfer_len, int interval);
-void usb_disable_asynch(int disable);
 int usb_maxpacket(struct usb_device *dev, unsigned long pipe);
 int usb_get_configuration_no(struct usb_device *dev, unsigned char *buffer,
 				int cfgno);
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 21/26] usb: storage: Drop unnecessary check in usb_stor_blk_io()
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
                   ` (19 preceding siblings ...)
  2019-03-07  8:00 ` [PATCH 20/26] usb: Drop usb_disable_asynch() Andrey Smirnov
@ 2019-03-07  8:00 ` Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 22/26] usb: storage: Drop needless macro Andrey Smirnov
                   ` (5 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Checking that sector_count is zero, shouldn't be necessary since block
layer won't call this function if there's no data to be read. Drop it.

Checking that blockbits is eqal to SECTOR_SHIFT isn't necessary, since
that field is filled by the driver and is not changed outsied of
it. We know it is going to be SECTOR_SHIFT. Drop it.

Checking sector_start > (ulong)-1 doesn't make sense at all since
sector start is 'int' and it can't possibly be greater that
ULONG_MAX. Drop it.

Checking for sector_start >= pblk_dev->blk.num_blocks isn't necessary
either, since we shouldn't receive request for invalid read from block
layer. Drop it.

Ditto for sector_count > INT_MAX and sector_start + sector_count >
pblk_dev->blk.num_blocks.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/storage/usb.c | 27 ---------------------------
 1 file changed, 27 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index b86e72a6f..29e3792aa 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -216,23 +216,6 @@ static int usb_stor_blk_io(int io_op, struct block_device *disk_dev,
 	struct device_d *dev = &us->pusb_dev->dev;
 	unsigned sectors_done;
 
-	if (sector_count == 0)
-		return 0;
-
-	/* check for unsupported block size */
-	if (pblk_dev->blk.blockbits != SECTOR_SHIFT) {
-		dev_dbg(dev, "%s: unsupported block shift %d\n",
-			 __func__, pblk_dev->blk.blockbits);
-		return -EINVAL;
-	}
-
-	/* check for invalid sector_start */
-	if (sector_start >= pblk_dev->blk.num_blocks || sector_start > (ulong)-1) {
-		dev_dbg(dev, "%s: start sector %d too large\n",
-			 __func__, sector_start);
-		return -EINVAL;
-	}
-
 	/* ensure unit ready */
 	dev_dbg(dev, "Testing for unit ready\n");
 	if (usb_stor_test_unit_ready(pblk_dev)) {
@@ -240,16 +223,6 @@ static int usb_stor_blk_io(int io_op, struct block_device *disk_dev,
 		return -EIO;
 	}
 
-	/* possibly limit the amount of I/O data */
-	if (sector_count > INT_MAX) {
-		sector_count = INT_MAX;
-		dev_dbg(dev, "Restricting I/O to %u blocks\n", sector_count);
-	}
-	if (sector_start + sector_count > pblk_dev->blk.num_blocks) {
-		sector_count = pblk_dev->blk.num_blocks - sector_start;
-		dev_dbg(dev, "Restricting I/O to %u blocks\n", sector_count);
-	}
-
 	/* read / write the requested data */
 	dev_dbg(dev, "%s %u block(s), starting from %d\n",
 		 (io_op == io_rd) ? "Read" : "Write",
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 22/26] usb: storage: Drop needless macro
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
                   ` (20 preceding siblings ...)
  2019-03-07  8:00 ` [PATCH 21/26] usb: storage: Drop unnecessary check in usb_stor_blk_io() Andrey Smirnov
@ 2019-03-07  8:00 ` Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 23/26] usb: storage: Use simple boolean to speficy read vs. write operation Andrey Smirnov
                   ` (4 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

There's only user of the to_usb_mass_storage() so we may as well
inline it.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/storage/usb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 29e3792aa..0ab20f1ac 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -203,15 +203,15 @@ static int usb_stor_io_10(struct us_blk_dev *usb_blkdev, u8 opcode,
 
 #define US_MAX_IO_BLK 32
 
-#define to_usb_mass_storage(x) container_of((x), struct us_blk_dev, blk)
-
 enum { io_rd, io_wr };
 
 /* Read / write a chunk of sectors on media */
 static int usb_stor_blk_io(int io_op, struct block_device *disk_dev,
 			int sector_start, int sector_count, void *buffer)
 {
-	struct us_blk_dev *pblk_dev = to_usb_mass_storage(disk_dev);
+	struct us_blk_dev *pblk_dev = container_of(disk_dev,
+						   struct us_blk_dev,
+						   blk);
 	struct us_data *us = pblk_dev->us;
 	struct device_d *dev = &us->pusb_dev->dev;
 	unsigned sectors_done;
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 23/26] usb: storage: Use simple boolean to speficy read vs. write operation
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
                   ` (21 preceding siblings ...)
  2019-03-07  8:00 ` [PATCH 22/26] usb: storage: Drop needless macro Andrey Smirnov
@ 2019-03-07  8:00 ` Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 24/26] usb: storage: Simplify I/O loop in usb_stor_blk_io() Andrey Smirnov
                   ` (3 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Use simple boolean to speficy read vs. write operation
usb_stor_blk_io() instead of having a custom anonymous enum.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/storage/usb.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 0ab20f1ac..dc63e8ab4 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -203,11 +203,10 @@ static int usb_stor_io_10(struct us_blk_dev *usb_blkdev, u8 opcode,
 
 #define US_MAX_IO_BLK 32
 
-enum { io_rd, io_wr };
-
 /* Read / write a chunk of sectors on media */
-static int usb_stor_blk_io(int io_op, struct block_device *disk_dev,
-			int sector_start, int sector_count, void *buffer)
+static int usb_stor_blk_io(struct block_device *disk_dev,
+			   int sector_start, int sector_count, void *buffer,
+			   bool read)
 {
 	struct us_blk_dev *pblk_dev = container_of(disk_dev,
 						   struct us_blk_dev,
@@ -225,8 +224,8 @@ static int usb_stor_blk_io(int io_op, struct block_device *disk_dev,
 
 	/* read / write the requested data */
 	dev_dbg(dev, "%s %u block(s), starting from %d\n",
-		 (io_op == io_rd) ? "Read" : "Write",
-		 sector_count, sector_start);
+		read ? "Read" : "Write",
+		sector_count, sector_start);
 	sectors_done = 0;
 	while (sector_count > 0) {
 		int result;
@@ -234,8 +233,7 @@ static int usb_stor_blk_io(int io_op, struct block_device *disk_dev,
 		u8 *data = buffer + (sectors_done * SECTOR_SIZE);
 
 		result = usb_stor_io_10(pblk_dev,
-					(io_op == io_rd) ?
-					SCSI_READ10 : SCSI_WRITE10,
+					read ? SCSI_READ10 : SCSI_WRITE10,
 					(ulong)sector_start,
 					data, n);
 		if (result != 0) {
@@ -256,14 +254,14 @@ static int usb_stor_blk_io(int io_op, struct block_device *disk_dev,
 static int __maybe_unused usb_stor_blk_write(struct block_device *blk,
 				const void *buffer, int block, int num_blocks)
 {
-	return usb_stor_blk_io(io_wr, blk, block, num_blocks, (void *)buffer);
+	return usb_stor_blk_io(blk, block, num_blocks, (void *)buffer, false);
 }
 
 /* Read a chunk of sectors from media */
 static int usb_stor_blk_read(struct block_device *blk, void *buffer, int block,
 				int num_blocks)
 {
-	return usb_stor_blk_io(io_rd, blk, block, num_blocks, buffer);
+	return usb_stor_blk_io(blk, block, num_blocks, buffer, true);
 }
 
 static struct block_device_ops usb_mass_storage_ops = {
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 24/26] usb: storage: Simplify I/O loop in usb_stor_blk_io()
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
                   ` (22 preceding siblings ...)
  2019-03-07  8:00 ` [PATCH 23/26] usb: storage: Use simple boolean to speficy read vs. write operation Andrey Smirnov
@ 2019-03-07  8:00 ` Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 25/26] usb: storage: Drop unnecessary assignment Andrey Smirnov
                   ` (2 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Simplify I/O loop a bit, by re-arranging things and dropping
"sectors_done", "result" and "data" local variables.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/storage/usb.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index dc63e8ab4..7df8a52b6 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -213,7 +213,6 @@ static int usb_stor_blk_io(struct block_device *disk_dev,
 						   blk);
 	struct us_data *us = pblk_dev->us;
 	struct device_d *dev = &us->pusb_dev->dev;
-	unsigned sectors_done;
 
 	/* ensure unit ready */
 	dev_dbg(dev, "Testing for unit ready\n");
@@ -226,28 +225,23 @@ static int usb_stor_blk_io(struct block_device *disk_dev,
 	dev_dbg(dev, "%s %u block(s), starting from %d\n",
 		read ? "Read" : "Write",
 		sector_count, sector_start);
-	sectors_done = 0;
+
 	while (sector_count > 0) {
-		int result;
 		unsigned n = min(sector_count, US_MAX_IO_BLK);
-		u8 *data = buffer + (sectors_done * SECTOR_SIZE);
 
-		result = usb_stor_io_10(pblk_dev,
-					read ? SCSI_READ10 : SCSI_WRITE10,
-					(ulong)sector_start,
-					data, n);
-		if (result != 0) {
+		if (usb_stor_io_10(pblk_dev,
+				   read ? SCSI_READ10 : SCSI_WRITE10,
+				   sector_start,
+				   buffer, n)) {
 			dev_dbg(dev, "I/O error at sector %d\n", sector_start);
 			break;
 		}
 		sector_start += n;
 		sector_count -= n;
-		sectors_done += n;
+		buffer += n * SECTOR_SIZE;
 	}
 
-	dev_dbg(dev, "Successful I/O of %d blocks\n", sectors_done);
-
-	return (sector_count != 0) ? -EIO : 0;
+	return sector_count ? -EIO : 0;
 }
 
 /* Write a chunk of sectors to media */
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 25/26] usb: storage: Drop unnecessary assignment
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
                   ` (23 preceding siblings ...)
  2019-03-07  8:00 ` [PATCH 24/26] usb: storage: Simplify I/O loop in usb_stor_blk_io() Andrey Smirnov
@ 2019-03-07  8:00 ` Andrey Smirnov
  2019-03-07  8:00 ` [PATCH 26/26] usb: storage: Inline usb_limit_blk_cnt() Andrey Smirnov
  2019-03-11  7:11 ` [PATCH 00/26] USB storage improvements Sascha Hauer
  26 siblings, 0 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/storage/usb.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 7df8a52b6..335f8033b 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -285,9 +285,7 @@ static int usb_stor_init_blkdev(struct us_blk_dev *pblk_dev)
 	struct us_data *us = pblk_dev->us;
 	struct device_d *dev = &us->pusb_dev->dev;
 	u32 last_lba = 0, block_length = 0;
-	int result = 0;
-
-	pblk_dev->blk.num_blocks = 0;
+	int result;
 
 	/* get device info */
 	dev_dbg(dev, "Reading device info\n");
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 26/26] usb: storage: Inline usb_limit_blk_cnt()
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
                   ` (24 preceding siblings ...)
  2019-03-07  8:00 ` [PATCH 25/26] usb: storage: Drop unnecessary assignment Andrey Smirnov
@ 2019-03-07  8:00 ` Andrey Smirnov
  2019-03-11  7:11 ` [PATCH 00/26] USB storage improvements Sascha Hauer
  26 siblings, 0 replies; 28+ messages in thread
From: Andrey Smirnov @ 2019-03-07  8:00 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Usb_limit_blk_cnt() has only one user so we may as well inline it.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/storage/usb.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 335f8033b..fda24d616 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -269,16 +269,6 @@ static struct block_device_ops usb_mass_storage_ops = {
  * Block device routines
  ***********************************************************************/
 
-static int usb_limit_blk_cnt(unsigned cnt)
-{
-	if (cnt > 0x7fffffff) {
-		pr_warn("Limiting device size due to 31 bit contraints\n");
-		return 0x7fffffff;
-	}
-
-	return (int)cnt;
-}
-
 /* Prepare a disk device */
 static int usb_stor_init_blkdev(struct us_blk_dev *pblk_dev)
 {
@@ -314,7 +304,13 @@ static int usb_stor_init_blkdev(struct us_blk_dev *pblk_dev)
 		return result;
 	}
 
-	pblk_dev->blk.num_blocks = usb_limit_blk_cnt(last_lba + 1);
+	if (last_lba > INT_MAX - 1) {
+		last_lba = INT_MAX - 1;
+		dev_warn(dev,
+			 "Limiting device size due to 31 bit contraints\n");
+	}
+
+	pblk_dev->blk.num_blocks = last_lba + 1;
 	if (block_length != SECTOR_SIZE)
 		pr_warn("Support only %d bytes sectors\n", SECTOR_SIZE);
 	pblk_dev->blk.blockbits = SECTOR_SHIFT;
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 00/26] USB storage improvements
  2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
                   ` (25 preceding siblings ...)
  2019-03-07  8:00 ` [PATCH 26/26] usb: storage: Inline usb_limit_blk_cnt() Andrey Smirnov
@ 2019-03-11  7:11 ` Sascha Hauer
  26 siblings, 0 replies; 28+ messages in thread
From: Sascha Hauer @ 2019-03-11  7:11 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: barebox

On Thu, Mar 07, 2019 at 12:00:10AM -0800, Andrey Smirnov wrote:
> Everyone:
> 
> While creating fix found in "usb: storage: Don't use "unsigned long"
> for 32-bit values" I spent some time reading code of our USB storage
> implementation. The other 25 patches is the result of that effort and
> my attempt to improve/simplify that codebase. Hopefuly each patch is
> self-explanatory.
> 
> Feedback is welcome!

Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2019-03-11  7:11 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-07  8:00 [PATCH 00/26] USB storage improvements Andrey Smirnov
2019-03-07  8:00 ` [PATCH 01/26] usb: storage: Simplify memory allocation in usb_stor_probe() Andrey Smirnov
2019-03-07  8:00 ` [PATCH 02/26] usb: storage: Replace custom debug tracing with dev_dbg Andrey Smirnov
2019-03-07  8:00 ` [PATCH 03/26] usb: storage: Don't use "unsigned long" for 32-bit values Andrey Smirnov
2019-03-07  8:00 ` [PATCH 04/26] usb: storage: Make usb_stor_read_capacity() a standalone function Andrey Smirnov
2019-03-07  8:00 ` [PATCH 05/26] usb: storage: Make usb_stor_inquiry() " Andrey Smirnov
2019-03-07  8:00 ` [PATCH 06/26] usb: storage: Make usb_stor_test_unit_ready() " Andrey Smirnov
2019-03-07  8:00 ` [PATCH 07/26] usb: storage: Make usb_stor_read_10() " Andrey Smirnov
2019-03-07  8:00 ` [PATCH 08/26] usb: storage: Make usb_stor_write_10() " Andrey Smirnov
2019-03-07  8:00 ` [PATCH 09/26] usb: storage: Drop extra call to transport in usb_stor_write_10() Andrey Smirnov
2019-03-07  8:00 ` [PATCH 10/26] usb: storage: Share code for READ(10) and WRITE(10) Andrey Smirnov
2019-03-07  8:00 ` [PATCH 11/26] usb: storage: Make usb_stor_request_sense() a standalone function Andrey Smirnov
2019-03-07  8:00 ` [PATCH 12/26] usb: storage: Remove unused variables Andrey Smirnov
2019-03-07  8:00 ` [PATCH 13/26] usb: storage: Drop struct SCSI_cmd_block Andrey Smirnov
2019-03-07  8:00 ` [PATCH 14/26] usb: hub: Do not include <scsi.h> Andrey Smirnov
2019-03-07  8:00 ` [PATCH 15/26] ata: ahci: " Andrey Smirnov
2019-03-07  8:00 ` [PATCH 16/26] usb: storage: Drop unused fields in struct us_data Andrey Smirnov
2019-03-07  8:00 ` [PATCH 17/26] usb: storage: Drop unused us_blkdev_list Andrey Smirnov
2019-03-07  8:00 ` [PATCH 18/26] usb: storage: Introduce usb_stor_transport() Andrey Smirnov
2019-03-07  8:00 ` [PATCH 19/26] usb: storage: Use put_unaligned_be* helpers Andrey Smirnov
2019-03-07  8:00 ` [PATCH 20/26] usb: Drop usb_disable_asynch() Andrey Smirnov
2019-03-07  8:00 ` [PATCH 21/26] usb: storage: Drop unnecessary check in usb_stor_blk_io() Andrey Smirnov
2019-03-07  8:00 ` [PATCH 22/26] usb: storage: Drop needless macro Andrey Smirnov
2019-03-07  8:00 ` [PATCH 23/26] usb: storage: Use simple boolean to speficy read vs. write operation Andrey Smirnov
2019-03-07  8:00 ` [PATCH 24/26] usb: storage: Simplify I/O loop in usb_stor_blk_io() Andrey Smirnov
2019-03-07  8:00 ` [PATCH 25/26] usb: storage: Drop unnecessary assignment Andrey Smirnov
2019-03-07  8:00 ` [PATCH 26/26] usb: storage: Inline usb_limit_blk_cnt() Andrey Smirnov
2019-03-11  7:11 ` [PATCH 00/26] USB storage improvements Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox