diff mbox

[U-Boot,v1,5/5] scsi: Separate SCSI private block description initialization

Message ID 5e3c8532a75bf03f100ea3565a7cd9f50b17f91a.1480538807.git.michal.simek@xilinx.com
State Accepted
Commit 0b3a58eeee43e52ae1cfef920844952bc45d5cdb
Delegated to: Michal Simek
Headers show

Commit Message

Michal Simek Nov. 30, 2016, 8:46 p.m. UTC
When blk_create_device() is called some parameters in blk_desc are
automatically filled. Separate SCSI private initialization and SCSI full
block device initialization not to rewrite already prepared data.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 common/scsi.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

Comments

Tom Rini Dec. 1, 2016, 1:04 a.m. UTC | #1
On Wed, Nov 30, 2016 at 09:46:51PM +0100, Michal Simek wrote:

> When blk_create_device() is called some parameters in blk_desc are
> automatically filled. Separate SCSI private initialization and SCSI full
> block device initialization not to rewrite already prepared data.
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>

Reviewed-by: Tom Rini <trini@konsulko.com>
Simon Glass Dec. 1, 2016, 2:20 a.m. UTC | #2
On 30 November 2016 at 13:46, Michal Simek <michal.simek@xilinx.com> wrote:
> When blk_create_device() is called some parameters in blk_desc are
> automatically filled. Separate SCSI private initialization and SCSI full
> block device initialization not to rewrite already prepared data.
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>
>  common/scsi.c | 28 ++++++++++++++++++++++------
>  1 file changed, 22 insertions(+), 6 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox

Patch

diff --git a/common/scsi.c b/common/scsi.c
index 839b30b9bb8e..04add624958f 100644
--- a/common/scsi.c
+++ b/common/scsi.c
@@ -422,12 +422,15 @@  static void scsi_setup_test_unit_ready(ccb *pccb)
 	pccb->msgout[0] = SCSI_IDENTIFY; /* NOT USED */
 }
 
-static void scsi_init_dev_desc(struct blk_desc *dev_desc, int devnum)
+/**
+ * scsi_init_dev_desc_priv - initialize only SCSI specific blk_desc properties
+ *
+ * @dev_desc: Block device description pointer
+ */
+static void scsi_init_dev_desc_priv(struct blk_desc *dev_desc)
 {
 	dev_desc->target = 0xff;
 	dev_desc->lun = 0xff;
-	dev_desc->lba = 0;
-	dev_desc->blksz = 0;
 	dev_desc->log2blksz =
 		LOG2_INVALID(typeof(dev_desc->log2blksz));
 	dev_desc->type = DEV_TYPE_UNKNOWN;
@@ -435,15 +438,28 @@  static void scsi_init_dev_desc(struct blk_desc *dev_desc, int devnum)
 	dev_desc->product[0] = 0;
 	dev_desc->revision[0] = 0;
 	dev_desc->removable = false;
-	dev_desc->if_type = IF_TYPE_SCSI;
-	dev_desc->devnum = devnum;
-	dev_desc->part_type = PART_TYPE_UNKNOWN;
 #ifndef CONFIG_BLK
 	dev_desc->block_read = scsi_read;
 	dev_desc->block_write = scsi_write;
 #endif
 }
 
+/**
+ * scsi_init_dev_desc - initialize all SCSI specific blk_desc properties
+ *
+ * @dev_desc: Block device description pointer
+ * @devnum: Device number
+ */
+static void scsi_init_dev_desc(struct blk_desc *dev_desc, int devnum)
+{
+	dev_desc->lba = 0;
+	dev_desc->blksz = 0;
+	dev_desc->if_type = IF_TYPE_SCSI;
+	dev_desc->devnum = devnum;
+	dev_desc->part_type = PART_TYPE_UNKNOWN;
+
+	scsi_init_dev_desc_priv(dev_desc);
+}
 
 /**
  * scsi_detect_dev - Detect scsi device