diff mbox series

scsi: myrs: fix build failure on 32 bit

Message ID 1539906656.18970.34.camel@HansenPartnership.com (mailing list archive)
State Accepted
Headers show
Series scsi: myrs: fix build failure on 32 bit | expand

Commit Message

James Bottomley Oct. 18, 2018, 11:50 p.m. UTC
For 32 bit versions we have to be careful about divisions of 64 bit
quantities so use do_div() instead of a direct division.  This fixes a
warning about _uldivmod being undefined in certain configurations

Fixes: 77266186397c ("scsi: myrs: Add Mylex RAID controller")
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
---
 drivers/scsi/myrs.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Hannes Reinecke Oct. 19, 2018, 7:05 a.m. UTC | #1
On 10/19/18 1:50 AM, James Bottomley wrote:
> For 32 bit versions we have to be careful about divisions of 64 bit
> quantities so use do_div() instead of a direct division.  This fixes a
> warning about _uldivmod being undefined in certain configurations
> 
> Fixes: 77266186397c ("scsi: myrs: Add Mylex RAID controller")
> Reported-by: kbuild test robot <lkp@intel.com>
> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
> ---
>   drivers/scsi/myrs.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c
> index b02ee0b0dd55..a9f9c77e889f 100644
> --- a/drivers/scsi/myrs.c
> +++ b/drivers/scsi/myrs.c
> @@ -1978,7 +1978,8 @@ myrs_get_resync(struct device *dev)
>   	struct scsi_device *sdev = to_scsi_device(dev);
>   	struct myrs_hba *cs = shost_priv(sdev->host);
>   	struct myrs_ldev_info *ldev_info = sdev->hostdata;
> -	u8 percent_complete = 0, status;
> +	u64 percent_complete = 0;
> +	u8 status;
>   
>   	if (sdev->channel < cs->ctlr_info->physchan_present || !ldev_info)
>   		return;
> @@ -1986,8 +1987,8 @@ myrs_get_resync(struct device *dev)
>   		unsigned short ldev_num = ldev_info->ldev_num;
>   
>   		status = myrs_get_ldev_info(cs, ldev_num, ldev_info);
> -		percent_complete = ldev_info->rbld_lba * 100 /
> -			ldev_info->cfg_devsize;
> +		percent_complete = ldev_info->rbld_lba * 100;
> +		do_div(percent_complete, ldev_info->cfg_devsize);
>   	}
>   	raid_set_resync(myrs_raid_template, dev, percent_complete);
>   }
> 
Thanks James.

Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
Randy Dunlap Oct. 19, 2018, 7:19 p.m. UTC | #2
On 10/18/18 4:50 PM, James Bottomley wrote:
> For 32 bit versions we have to be careful about divisions of 64 bit
> quantities so use do_div() instead of a direct division.  This fixes a
> warning about _uldivmod being undefined in certain configurations

on i386 it was:
ERROR: "__udivdi3" [drivers/scsi/myrs.ko] undefined!

and this patch fixes that build error.

Tested-by: Randy Dunlap <rdunlap@infradead.org> # build-tested

thanks.

> 
> Fixes: 77266186397c ("scsi: myrs: Add Mylex RAID controller")
> Reported-by: kbuild test robot <lkp@intel.com>
> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
> ---
>  drivers/scsi/myrs.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c
> index b02ee0b0dd55..a9f9c77e889f 100644
> --- a/drivers/scsi/myrs.c
> +++ b/drivers/scsi/myrs.c
> @@ -1978,7 +1978,8 @@ myrs_get_resync(struct device *dev)
>  	struct scsi_device *sdev = to_scsi_device(dev);
>  	struct myrs_hba *cs = shost_priv(sdev->host);
>  	struct myrs_ldev_info *ldev_info = sdev->hostdata;
> -	u8 percent_complete = 0, status;
> +	u64 percent_complete = 0;
> +	u8 status;
>  
>  	if (sdev->channel < cs->ctlr_info->physchan_present || !ldev_info)
>  		return;
> @@ -1986,8 +1987,8 @@ myrs_get_resync(struct device *dev)
>  		unsigned short ldev_num = ldev_info->ldev_num;
>  
>  		status = myrs_get_ldev_info(cs, ldev_num, ldev_info);
> -		percent_complete = ldev_info->rbld_lba * 100 /
> -			ldev_info->cfg_devsize;
> +		percent_complete = ldev_info->rbld_lba * 100;
> +		do_div(percent_complete, ldev_info->cfg_devsize);
>  	}
>  	raid_set_resync(myrs_raid_template, dev, percent_complete);
>  }
>
Martin K. Petersen Oct. 19, 2018, 10:09 p.m. UTC | #3
James,

> For 32 bit versions we have to be careful about divisions of 64 bit
> quantities so use do_div() instead of a direct division.  This fixes a
> warning about _uldivmod being undefined in certain configurations

Applied to 4.20/scsi-queue.
diff mbox series

Patch

diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c
index b02ee0b0dd55..a9f9c77e889f 100644
--- a/drivers/scsi/myrs.c
+++ b/drivers/scsi/myrs.c
@@ -1978,7 +1978,8 @@  myrs_get_resync(struct device *dev)
 	struct scsi_device *sdev = to_scsi_device(dev);
 	struct myrs_hba *cs = shost_priv(sdev->host);
 	struct myrs_ldev_info *ldev_info = sdev->hostdata;
-	u8 percent_complete = 0, status;
+	u64 percent_complete = 0;
+	u8 status;
 
 	if (sdev->channel < cs->ctlr_info->physchan_present || !ldev_info)
 		return;
@@ -1986,8 +1987,8 @@  myrs_get_resync(struct device *dev)
 		unsigned short ldev_num = ldev_info->ldev_num;
 
 		status = myrs_get_ldev_info(cs, ldev_num, ldev_info);
-		percent_complete = ldev_info->rbld_lba * 100 /
-			ldev_info->cfg_devsize;
+		percent_complete = ldev_info->rbld_lba * 100;
+		do_div(percent_complete, ldev_info->cfg_devsize);
 	}
 	raid_set_resync(myrs_raid_template, dev, percent_complete);
 }