Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5bd355ee authored by Tomas Henzl's avatar Tomas Henzl Committed by Christoph Hellwig
Browse files

pm8001: Fix erratic calculation in update_flash



The loopcount is calculated by using some weird magic. Use instead a boring
macro.

Signed-off-by: default avatarTomas Henzl <thenzl@redhat.com>
Acked-by: default avatarSuresh Thiagarajan <Suresh.Thiagarajan@pmcs.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent f5a7b525
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -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;