]> git.karo-electronics.de Git - linux-beck.git/commitdiff
pm8001: Fix erratic calculation in update_flash
authorTomas Henzl <thenzl@redhat.com>
Wed, 30 Jul 2014 14:40:51 +0000 (16:40 +0200)
committerChristoph Hellwig <hch@lst.de>
Fri, 1 Aug 2014 12:16:40 +0000 (08:16 -0400)
The loopcount is calculated by using some weird magic. Use instead a boring
macro.

Signed-off-by: Tomas Henzl <thenzl@redhat.com>
Acked-by: Suresh Thiagarajan <Suresh.Thiagarajan@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/scsi/pm8001/pm8001_ctl.c

index d3a08aea09487e955d51b394b300826183b5c296..e9b0921e945060fbd0bab15fbe1e714dc93f0d10 100644 (file)
@@ -581,11 +581,8 @@ static int pm8001_update_flash(struct pm8001_hba_info *pm8001_ha)
                partitionSizeTmp =
                        *(u32 *)((u8 *)&image_hdr->image_length + sizeRead);
                partitionSize = be32_to_cpu(partitionSizeTmp);
-               loopcount = (partitionSize + HEADER_LEN)/IOCTL_BUF_SIZE;
-               if (loopcount % IOCTL_BUF_SIZE)
-                       loopcount++;
-               if (loopcount == 0)
-                       loopcount++;
+               loopcount = DIV_ROUND_UP(partitionSize + HEADER_LEN,
+                                       IOCTL_BUF_SIZE);
                for (loopNumber = 0; loopNumber < loopcount; loopNumber++) {
                        payload = (struct pm8001_ioctl_payload *)ioctlbuffer;
                        payload->length = 1024*16;