diff mbox series

[v3,6/8] qla2xxx: Use scsi_get_sector() instead of scsi_get_lba()

Message ID 20210513223757.3938-7-bvanassche@acm.org
State New
Headers show
Series Rename scsi_get_lba() into scsi_get_sector() | expand

Commit Message

Bart Van Assche May 13, 2021, 10:37 p.m. UTC
Use scsi_get_sector() instead of scsi_get_lba() since the name of the
latter is confusing. Additionally, use lower_32_bits() instead of
open-coding it. This patch does not change any functionality.

Cc: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/qla2xxx/qla_iocb.c | 9 +++------
 drivers/scsi/qla2xxx/qla_isr.c  | 8 ++++----
 2 files changed, 7 insertions(+), 10 deletions(-)

Comments

Damien Le Moal May 14, 2021, 2:02 a.m. UTC | #1
On 2021/05/14 7:38, Bart Van Assche wrote:
> Use scsi_get_sector() instead of scsi_get_lba() since the name of the
> latter is confusing. Additionally, use lower_32_bits() instead of
> open-coding it. This patch does not change any functionality.
> 
> Cc: Nilesh Javali <njavali@marvell.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/qla2xxx/qla_iocb.c | 9 +++------
>  drivers/scsi/qla2xxx/qla_isr.c  | 8 ++++----
>  2 files changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
> index 38b5bdde2405..28e30a7e8883 100644
> --- a/drivers/scsi/qla2xxx/qla_iocb.c
> +++ b/drivers/scsi/qla2xxx/qla_iocb.c
> @@ -778,8 +778,7 @@ qla24xx_set_t10dif_tags(srb_t *sp, struct fw_dif_context *pkt,
>  		 * No check for ql2xenablehba_err_chk, as it would be an
>  		 * I/O error if hba tag generation is not done.
>  		 */
> -		pkt->ref_tag = cpu_to_le32((uint32_t)
> -		    (0xffffffff & scsi_get_lba(cmd)));
> +		pkt->ref_tag = cpu_to_le32(lower_32_bits(scsi_get_sector(cmd)));
>  
>  		if (!qla2x00_hba_err_chk_enabled(sp))
>  			break;
> @@ -799,8 +798,7 @@ qla24xx_set_t10dif_tags(srb_t *sp, struct fw_dif_context *pkt,
>  		pkt->app_tag_mask[0] = 0x0;
>  		pkt->app_tag_mask[1] = 0x0;
>  
> -		pkt->ref_tag = cpu_to_le32((uint32_t)
> -		    (0xffffffff & scsi_get_lba(cmd)));
> +		pkt->ref_tag = cpu_to_le32(lower_32_bits(scsi_get_sector(cmd)));
>  
>  		if (!qla2x00_hba_err_chk_enabled(sp))
>  			break;
> @@ -824,8 +822,7 @@ qla24xx_set_t10dif_tags(srb_t *sp, struct fw_dif_context *pkt,
>  	 * 16 bit app tag.
>  	 */
>  	case SCSI_PROT_DIF_TYPE1:
> -		pkt->ref_tag = cpu_to_le32((uint32_t)
> -		    (0xffffffff & scsi_get_lba(cmd)));
> +		pkt->ref_tag = cpu_to_le32(lower_32_bits(scsi_get_sector(cmd)));
>  		pkt->app_tag = cpu_to_le16(0);
>  		pkt->app_tag_mask[0] = 0x0;
>  		pkt->app_tag_mask[1] = 0x0;
> diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
> index 67229af4c142..24d406411f81 100644
> --- a/drivers/scsi/qla2xxx/qla_isr.c
> +++ b/drivers/scsi/qla2xxx/qla_isr.c
> @@ -2632,7 +2632,7 @@ qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24)
>  	    "DIF ERROR in cmd 0x%x lba 0x%llx act ref"
>  	    " tag=0x%x, exp ref_tag=0x%x, act app tag=0x%x, exp app"
>  	    " tag=0x%x, act guard=0x%x, exp guard=0x%x.\n",
> -	    cmd->cmnd[0], (u64)scsi_get_lba(cmd), a_ref_tag, e_ref_tag,
> +	    cmd->cmnd[0], (u64)scsi_get_sector(cmd), a_ref_tag, e_ref_tag,
>  	    a_app_tag, e_app_tag, a_guard, e_guard);
>  
>  	/*
> @@ -2644,10 +2644,10 @@ qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24)
>  	    (scsi_get_prot_type(cmd) != SCSI_PROT_DIF_TYPE3 ||
>  	     a_ref_tag == be32_to_cpu(T10_PI_REF_ESCAPE))) {
>  		uint32_t blocks_done, resid;
> -		sector_t lba_s = scsi_get_lba(cmd);
> +		sector_t sector = scsi_get_sector(cmd);
>  
>  		/* 2TB boundary case covered automatically with this */
> -		blocks_done = e_ref_tag - (uint32_t)lba_s + 1;
> +		blocks_done = e_ref_tag - (uint32_t)sector + 1;
>  
>  		resid = scsi_bufflen(cmd) - (blocks_done *
>  		    cmd->device->sector_size);
> @@ -2677,7 +2677,7 @@ qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24)
>  			if (k != blocks_done) {
>  				ql_log(ql_log_warn, vha, 0x302f,
>  				    "unexpected tag values tag:lba=%x:%llx)\n",
> -				    e_ref_tag, (unsigned long long)lba_s);
> +				    e_ref_tag, (u64)sector);
>  				return 1;
>  			}
>  
> 

Not entirely convinced the casts are needed for the log calls...
Apart from that, looks good.

Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
Bart Van Assche May 14, 2021, 3:01 a.m. UTC | #2
On 5/13/21 7:02 PM, Damien Le Moal wrote:
> On 2021/05/14 7:38, Bart Van Assche wrote:

>> @@ -2677,7 +2677,7 @@ qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24)

>>  			if (k != blocks_done) {

>>  				ql_log(ql_log_warn, vha, 0x302f,

>>  				    "unexpected tag values tag:lba=%x:%llx)\n",

>> -				    e_ref_tag, (unsigned long long)lba_s);

>> +				    e_ref_tag, (u64)sector);

>>  				return 1;

>>  			}

>>  

>>

> 

> Not entirely convinced the casts are needed for the log calls...

> Apart from that, looks good.

> 

> Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>


Hi Damien,

I will remove the cast from the ql_log() call.

Thanks,

Bart.
diff mbox series

Patch

diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index 38b5bdde2405..28e30a7e8883 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -778,8 +778,7 @@  qla24xx_set_t10dif_tags(srb_t *sp, struct fw_dif_context *pkt,
 		 * No check for ql2xenablehba_err_chk, as it would be an
 		 * I/O error if hba tag generation is not done.
 		 */
-		pkt->ref_tag = cpu_to_le32((uint32_t)
-		    (0xffffffff & scsi_get_lba(cmd)));
+		pkt->ref_tag = cpu_to_le32(lower_32_bits(scsi_get_sector(cmd)));
 
 		if (!qla2x00_hba_err_chk_enabled(sp))
 			break;
@@ -799,8 +798,7 @@  qla24xx_set_t10dif_tags(srb_t *sp, struct fw_dif_context *pkt,
 		pkt->app_tag_mask[0] = 0x0;
 		pkt->app_tag_mask[1] = 0x0;
 
-		pkt->ref_tag = cpu_to_le32((uint32_t)
-		    (0xffffffff & scsi_get_lba(cmd)));
+		pkt->ref_tag = cpu_to_le32(lower_32_bits(scsi_get_sector(cmd)));
 
 		if (!qla2x00_hba_err_chk_enabled(sp))
 			break;
@@ -824,8 +822,7 @@  qla24xx_set_t10dif_tags(srb_t *sp, struct fw_dif_context *pkt,
 	 * 16 bit app tag.
 	 */
 	case SCSI_PROT_DIF_TYPE1:
-		pkt->ref_tag = cpu_to_le32((uint32_t)
-		    (0xffffffff & scsi_get_lba(cmd)));
+		pkt->ref_tag = cpu_to_le32(lower_32_bits(scsi_get_sector(cmd)));
 		pkt->app_tag = cpu_to_le16(0);
 		pkt->app_tag_mask[0] = 0x0;
 		pkt->app_tag_mask[1] = 0x0;
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 67229af4c142..24d406411f81 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -2632,7 +2632,7 @@  qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24)
 	    "DIF ERROR in cmd 0x%x lba 0x%llx act ref"
 	    " tag=0x%x, exp ref_tag=0x%x, act app tag=0x%x, exp app"
 	    " tag=0x%x, act guard=0x%x, exp guard=0x%x.\n",
-	    cmd->cmnd[0], (u64)scsi_get_lba(cmd), a_ref_tag, e_ref_tag,
+	    cmd->cmnd[0], (u64)scsi_get_sector(cmd), a_ref_tag, e_ref_tag,
 	    a_app_tag, e_app_tag, a_guard, e_guard);
 
 	/*
@@ -2644,10 +2644,10 @@  qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24)
 	    (scsi_get_prot_type(cmd) != SCSI_PROT_DIF_TYPE3 ||
 	     a_ref_tag == be32_to_cpu(T10_PI_REF_ESCAPE))) {
 		uint32_t blocks_done, resid;
-		sector_t lba_s = scsi_get_lba(cmd);
+		sector_t sector = scsi_get_sector(cmd);
 
 		/* 2TB boundary case covered automatically with this */
-		blocks_done = e_ref_tag - (uint32_t)lba_s + 1;
+		blocks_done = e_ref_tag - (uint32_t)sector + 1;
 
 		resid = scsi_bufflen(cmd) - (blocks_done *
 		    cmd->device->sector_size);
@@ -2677,7 +2677,7 @@  qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24)
 			if (k != blocks_done) {
 				ql_log(ql_log_warn, vha, 0x302f,
 				    "unexpected tag values tag:lba=%x:%llx)\n",
-				    e_ref_tag, (unsigned long long)lba_s);
+				    e_ref_tag, (u64)sector);
 				return 1;
 			}