scsi: core: Fix scsi_get/set_resid() interface
authorDamien Le Moal <damien.lemoal@wdc.com>
Wed, 30 Oct 2019 09:08:47 +0000 (18:08 +0900)
committerMartin K. Petersen <martin.petersen@oracle.com>
Sat, 9 Nov 2019 02:34:49 +0000 (21:34 -0500)
struct scsi_cmnd cmd->req.resid_len which is returned and set respectively
by the helper functions scsi_get_resid() and scsi_set_resid() is an
unsigned int. Reflect this fact in the interface of these helper functions.

Also fix compilation errors due to min() and max() type mismatch introduced
by this change in scsi debug code, usb transport code and in the USB ENE
card reader driver.

Link: https://lore.kernel.org/r/20191030090847.25650-1-damien.lemoal@wdc.com
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/scsi_debug.c
drivers/usb/storage/ene_ub6250.c
drivers/usb/storage/transport.c
include/scsi/scsi_cmnd.h

index d323523..4daf263 100644 (file)
@@ -1025,7 +1025,7 @@ static int fill_from_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr,
 static int p_fill_from_dev_buffer(struct scsi_cmnd *scp, const void *arr,
                                  int arr_len, unsigned int off_dst)
 {
-       int act_len, n;
+       unsigned int act_len, n;
        struct scsi_data_buffer *sdb = &scp->sdb;
        off_t skip = off_dst;
 
@@ -1039,7 +1039,7 @@ static int p_fill_from_dev_buffer(struct scsi_cmnd *scp, const void *arr,
        pr_debug("%s: off_dst=%u, scsi_bufflen=%u, act_len=%u, resid=%d\n",
                 __func__, off_dst, scsi_bufflen(scp), act_len,
                 scsi_get_resid(scp));
-       n = (int)scsi_bufflen(scp) - ((int)off_dst + act_len);
+       n = scsi_bufflen(scp) - (off_dst + act_len);
        scsi_set_resid(scp, min(scsi_get_resid(scp), n));
        return 0;
 }
index 8b1b730..98c1aa5 100644 (file)
@@ -561,7 +561,7 @@ static int ene_send_scsi_cmd(struct us_data *us, u8 fDir, void *buf, int use_sg)
                residue = min(residue, transfer_length);
                if (us->srb != NULL)
                        scsi_set_resid(us->srb, max(scsi_get_resid(us->srb),
-                                                               (int)residue));
+                                                               residue));
        }
 
        if (bcs->Status != US_BULK_STAT_OK)
index 96cb040..238a808 100644 (file)
@@ -1284,8 +1284,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
 
                } else {
                        residue = min(residue, transfer_length);
-                       scsi_set_resid(srb, max(scsi_get_resid(srb),
-                                                              (int) residue));
+                       scsi_set_resid(srb, max(scsi_get_resid(srb), residue));
                }
        }
 
index 9c22e85..a2849bb 100644 (file)
@@ -191,12 +191,12 @@ static inline unsigned scsi_bufflen(struct scsi_cmnd *cmd)
        return cmd->sdb.length;
 }
 
-static inline void scsi_set_resid(struct scsi_cmnd *cmd, int resid)
+static inline void scsi_set_resid(struct scsi_cmnd *cmd, unsigned int resid)
 {
        cmd->req.resid_len = resid;
 }
 
-static inline int scsi_get_resid(struct scsi_cmnd *cmd)
+static inline unsigned int scsi_get_resid(struct scsi_cmnd *cmd)
 {
        return cmd->req.resid_len;
 }