common: scsi: Remove completely unused functions
PATCH 1/5 common: scsi: Remove completely unused functions
These functions are not called for any location.
This patch removes them scsi_trim_trail(), scsi_get_disk_count() and scsi_setup_read6().
---
common/scsi.c | 35 ----------------------------------- include/scsi.h | 3 --- 2 files changed, 38 deletions(-)
common/scsi.c +0 -35
@@ -119,22 +119,6 @@ void scsi_setup_write_ext(ccb *pccb, lbaint_t start, unsigned short blocks) pccb->cmd[7], pccb->cmd[8]); } -void scsi_setup_read6 (ccb *pccb,lbaint_t start,unsigned short blocks) -{ - pccb->cmd[0 ] =SCSI_READ6 ; - pccb->cmd[1 ] = pccb->lun <<5 | ((unsigned char )(start >>16 ) &0x1f ); - pccb->cmd[2 ] = (unsigned char )(start >>8 ) &0xff ; - pccb->cmd[3 ] = (unsigned char )start &0xff ; - pccb->cmd[4 ] = (unsigned char )blocks &0xff ; - pccb->cmd[5 ] =0 ; - pccb->cmdlen =6 ; - pccb->msgout[0 ] =SCSI_IDENTIFY ;/* NOT USED */ -debug ("scsi_setup_read6: cmd: %02X %02X startblk %02X%02X blccnt %02X\n" , - pccb->cmd[0 ], pccb->cmd[1 ], - pccb->cmd[2 ], pccb->cmd[3 ], pccb->cmd[4 ]); -} - -void scsi_setup_inquiry (ccb *pccb) { pccb->cmd[0 ] =SCSI_INQUIRY ;
@@ -277,11 +261,6 @@ static ulong scsi_write(struct blk_desc *block_dev, lbaint_t blknr,return blkcnt; } -int scsi_get_disk_count (void ) -{ -return scsi_max_devs; -} -#if defined(CONFIG_PCI ) && !defined(CONFIG_SCSI_AHCI_PLAT )void scsi_init (void ) {
@@ -363,20 +342,6 @@ void scsi_ident_cpy(unsigned char *dest, unsigned char *src, unsigned int len) *dest ='\0' ; } - -/* Trim trailing blanks, and NUL-terminate string -*/ -void scsi_trim_trail (unsigned char *str,unsigned int len) -{ -unsigned char *p = str + len -1 ; - -while (len-- >0 ) { - *p-- ='\0' ; -if (*p !=' ' ) -return ; - } -} -int scsi_read_capacity (ccb *pccb,lbaint_t *capacity,unsigned long *blksz) { *capacity =0 ;
include/scsi.h +0 -3
@@ -175,9 +175,6 @@ void scsi_low_level_init(int busdevfunc);void scsi_init (void );void scsi_scan (int mode); -/** @return the number of scsi disks */ -int scsi_get_disk_count (void ); -#define SCSI_IDENTIFY 0xC0/* not used */ /* Hardware errors */
Signature · 1 line
1.9.1
PATCH 2/5 common: scsi: Make private functions static
Several functions should be static because they are not exported to any other file.
Warnings were reported by sparse C=1.
---
common/scsi.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
common/scsi.c +10 -6
@@ -78,7 +78,8 @@ void scsi_setup_read16(ccb *pccb, lbaint_t start, unsigned long blocks) }#endif -void scsi_setup_read_ext (ccb *pccb,lbaint_t start,unsigned short blocks) +static void scsi_setup_read_ext (ccb *pccb,lbaint_t start, +unsigned short blocks) { pccb->cmd[0 ] =SCSI_READ10 ; pccb->cmd[1 ] = pccb->lun <<5 ;
@@ -98,7 +99,8 @@ void scsi_setup_read_ext(ccb *pccb, lbaint_t start, unsigned short blocks) pccb->cmd[7], pccb->cmd[8]); } -void scsi_setup_write_ext (ccb *pccb,lbaint_t start,unsigned short blocks) +static void scsi_setup_write_ext (ccb *pccb,lbaint_t start, +unsigned short blocks) { pccb->cmd[0 ] =SCSI_WRITE10 ; pccb->cmd[1 ] = pccb->lun <<5 ;
@@ -119,7 +121,7 @@ void scsi_setup_write_ext(ccb *pccb, lbaint_t start, unsigned short blocks) pccb->cmd[7], pccb->cmd[8]); } -void scsi_setup_inquiry (ccb *pccb) +static void scsi_setup_inquiry (ccb *pccb) { pccb->cmd[0 ] =SCSI_INQUIRY ; pccb->cmd[1 ] = pccb->lun <<5 ;
@@ -321,7 +323,8 @@ void scsi_init(void)/* copy src to dest, skipping leading and trailing blanks * and null terminate the string */ -void scsi_ident_cpy (unsigned char *dest,unsigned char *src,unsigned int len) +static void scsi_ident_cpy (unsigned char *dest,unsigned char *src, +unsigned int len) {int start, end;
@@ -342,7 +345,8 @@ void scsi_ident_cpy(unsigned char *dest, unsigned char *src, unsigned int len) *dest ='\0' ; } -int scsi_read_capacity (ccb *pccb,lbaint_t *capacity,unsigned long *blksz) +static int scsi_read_capacity (ccb *pccb,lbaint_t *capacity, +unsigned long *blksz) { *capacity =0 ;
@@ -406,7 +410,7 @@ int scsi_read_capacity(ccb *pccb, lbaint_t *capacity, unsigned long *blksz)/* * Some setup (fill-in) routines */ -void scsi_setup_test_unit_ready (ccb *pccb) +static void scsi_setup_test_unit_ready (ccb *pccb) { pccb->cmd[0 ] =SCSI_TST_U_RDY ; pccb->cmd[1 ] = pccb->lun <<5 ;
Signature · 1 line
1.9.1
PATCH 2/5 common: scsi: Make private functions static
Quoted 5 lines · Michal Simek
Several functions should be static because they are not exported to any other file.
Warnings were reported by sparse C=1.Signed-off-by Michal Simek <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161130/33b62d28/attachment.sig>
PATCH 2/5 common: scsi: Make private functions static
In reply to Michal SimekQuoted 9 lines · Michal Simek
Several functions should be static because they are not exported to any other file.
Warnings were reported by sparse C=1.Signed-off-by Michal Simek <[email protected]>---
common/scsi.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
PATCH 3/5 cmd: scsi: Make private functions static
In reply to Michal SimekTwo functions should be static because they are not exported to any other file.
Warnings were reported by sparse C=1.
---
cmd/scsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
cmd/scsi.c +2 -2
@@ -17,7 +17,7 @@ static int scsi_curr_dev; /* current device *//* * scsi boot command intepreter. Derived from diskboot */ -int do_scsiboot (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +static int do_scsiboot (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) {return common_diskboot (cmdtp,"scsi" , argc, argv); }
@@ -25,7 +25,7 @@ int do_scsiboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])/* * scsi command intepreter */ -int do_scsi (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +static int do_scsi (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) {switch (argc) {case 0 :
Signature · 1 line
1.9.1
PATCH 3/5 cmd: scsi: Make private functions static
Quoted 5 lines · Michal Simek
Two functions should be static because they are not exported to any other file.
Warnings were reported by sparse C=1.Signed-off-by Michal Simek <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161130/34ee9f99/attachment.sig>
PATCH 3/5 cmd: scsi: Make private functions static
In reply to Michal SimekQuoted 9 lines · Michal Simek
Two functions should be static because they are not exported to any other file.
Warnings were reported by sparse C=1.Signed-off-by Michal Simek <[email protected]>---
cmd/scsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
PATCH 4/5 scsi: Change scsi_scan() to be able to return value
In reply to Michal SimekWith DM_SCSI this function will return more than one return value to cover errors.
---
cmd/scsi.c | 14 ++++++++++---- common/scsi.c | 3 ++- include/scsi.h | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-)
cmd/scsi.c +10 -4
@@ -27,6 +27,8 @@ static int do_scsiboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])*/ static int do_scsi (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) { +int ret; +switch (argc) {case 0 :case 1 :
@@ -35,8 +37,10 @@ static int do_scsi(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])if (strncmp (argv[1 ],"res" ,3 ) ==0 ) {printf ("\nReset SCSI\n" );scsi_bus_reset (); -scsi_scan (1 ); -return 0 ; + ret =scsi_scan (1 ); +if (ret) +return CMD_RET_FAILURE ; +return ret; }if (strncmp (argv[1 ],"inf" ,3 ) ==0 ) {blk_list_devices (IF_TYPE_SCSI );
@@ -51,8 +55,10 @@ static int do_scsi(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])return 0 ; }if (strncmp (argv[1 ],"scan" ,4 ) ==0 ) { -scsi_scan (1 ); -return 0 ; + ret =scsi_scan (1 ); +if (ret) +return CMD_RET_FAILURE ; +return ret; }if (strncmp (argv[1 ],"part" ,4 ) ==0 ) {if (blk_list_part (IF_TYPE_SCSI ))
common/scsi.c +2 -1
@@ -524,7 +524,7 @@ removable:* (re)-scan the scsi bus and reports scsi device info * to the user if mode = 1 */ -void scsi_scan (int mode) +int scsi_scan (int mode) {unsigned char i, lun;int ret;
@@ -558,6 +558,7 @@ void scsi_scan(int mode)#ifndef CONFIG_SPL_BUILD setenv_ulong ("scsidevs" , scsi_max_devs);#endif +return 0 ; }#ifdef CONFIG_BLK
include/scsi.h +1 -1
@@ -173,7 +173,7 @@ void scsi_low_level_init(int busdevfunc);* functions residing inside cmd_scsi.c */ void scsi_init (void ); -void scsi_scan (int mode); +int scsi_scan (int mode);#define SCSI_IDENTIFY 0xC0/* not used */
Signature · 1 line
1.9.1
PATCH 4/5 scsi: Change scsi_scan() to be able to return value
Quoted 5 lines · Michal Simek
With
DM_SCSIthis function will return more than one return value to cover errors.Suggested-by Simon Glass <[email protected]>Signed-off-by Michal Simek <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161130/77ffe918/attachment.sig>
PATCH 4/5 scsi: Change scsi_scan() to be able to return value
In reply to Michal SimekQuoted 11 lines · Michal Simek
With
DM_SCSIthis function will return more than one return value to cover errors.Suggested-by Simon Glass <[email protected]>Signed-off-by Michal Simek <[email protected]>---
cmd/scsi.c | 14 ++++++++++---- common/scsi.c | 3 ++- include/scsi.h | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-)
PATCH 5/5 scsi: Separate SCSI private block description initialization
In reply to Michal SimekWhen 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.
---
common/scsi.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-)
common/scsi.c +22 -6
@@ -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
Signature · 1 line
1.9.1
PATCH 5/5 scsi: Separate SCSI private block description initialization
Quoted 5 lines · Michal Simek
When
blk_create_device()is called some parameters inblk_descare automatically filled. Separate SCSI private initialization and SCSI full block device initialization not to rewrite already prepared data.Signed-off-by Michal Simek <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161130/1eb41b89/attachment.sig>
PATCH 5/5 scsi: Separate SCSI private block description initialization
In reply to Michal SimekQuoted 9 lines · Michal Simek
When
blk_create_device()is called some parameters inblk_descare automatically filled. Separate SCSI private initialization and SCSI full block device initialization not to rewrite already prepared data.Signed-off-by Michal Simek <[email protected]>---
common/scsi.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-)
PATCH 1/5 common: scsi: Remove completely unused functions
In reply to Michal SimekQuoted 5 lines · Michal Simek
These functions are not called for any location.
This patch removes themscsi_trim_trail(),scsi_get_disk_count()andscsi_setup_read6().Signed-off-by Michal Simek <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161130/8f91806a/attachment.sig>
PATCH 1/5 common: scsi: Remove completely unused functions
In reply to Michal SimekQuoted 10 lines · Michal Simek
These functions are not called for any location.
This patch removes themscsi_trim_trail(),scsi_get_disk_count()andscsi_setup_read6().Signed-off-by Michal Simek <[email protected]>---
common/scsi.c | 35 ----------------------------------- include/scsi.h | 3 --- 2 files changed, 38 deletions(-)