Skip to contentSkip to conversation

scsi: pm8001: clean up some inconsistent indenting

PATCH Superseded Yang Li 2 participants 2 messages Feb 6, 2022 – Feb 7, 2022

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Yang Li

author
#0 lore raw

PATCH 1/1 scsi: pm8001: clean up some inconsistent indenting

Eliminate the follow smatch warning:
drivers/scsi/pm8001/pm8001_ctl.c:760 pm8001_update_flash() warn:
inconsistent indenting

---
 drivers/scsi/pm8001/pm8001_ctl.c | 65 +++++++++++++++++---------------
 1 file changed, 35 insertions(+), 30 deletions(-)
drivers/scsi/pm8001/pm8001_ctl.c +35 -30
index 41a63c9b719b..213ebf39261f 100644
@@ -755,36 +755,41 @@ static int pm8001_update_flash(struct pm8001_hba_info *pm8001_ha)
 			fwControl->retcode = 0;/* OUT */
 			fwControl->offset = loopNumber * IOCTL_BUF_SIZE;/*OUT */
 
-		/* for the last chunk of data in case file size is not even with
-		4k, load only the rest*/
-		if (((loopcount-loopNumber) == 1) &&
-			((partitionSize + HEADER_LEN) % IOCTL_BUF_SIZE)) {
-			fwControl->len =
-				(partitionSize + HEADER_LEN) % IOCTL_BUF_SIZE;
-			memcpy((u8 *)fwControl->buffer,
-				(u8 *)pm8001_ha->fw_image->data + sizeRead,
-				(partitionSize + HEADER_LEN) % IOCTL_BUF_SIZE);
-			sizeRead +=
-				(partitionSize + HEADER_LEN) % IOCTL_BUF_SIZE;
-		} else {
-			memcpy((u8 *)fwControl->buffer,
-				(u8 *)pm8001_ha->fw_image->data + sizeRead,
-				IOCTL_BUF_SIZE);
-			sizeRead += IOCTL_BUF_SIZE;
-		}
-
-		pm8001_ha->nvmd_completion = &completion;
-		ret = PM8001_CHIP_DISP->fw_flash_update_req(pm8001_ha, payload);
-		if (ret) {
-			pm8001_ha->fw_status = FAIL_OUT_MEMORY;
-			goto out;
-		}
-		wait_for_completion(&completion);
-		if (fwControl->retcode > FLASH_UPDATE_IN_PROGRESS) {
-			pm8001_ha->fw_status = fwControl->retcode;
-			ret = -EFAULT;
-			goto out;
-		}
+			/* for the last chunk of data in case file
+			 * size is not even with 4k, load only the rest
+			 */
+			if (((loopcount-loopNumber) == 1) &&
+				((partitionSize + HEADER_LEN) % IOCTL_BUF_SIZE)) {
+				fwControl->len =
+					(partitionSize + HEADER_LEN) %
+					IOCTL_BUF_SIZE;
+				memcpy((u8 *)fwControl->buffer,
+					(u8 *)pm8001_ha->fw_image->data + sizeRead,
+					(partitionSize + HEADER_LEN) %
+					IOCTL_BUF_SIZE);
+				sizeRead +=
+					(partitionSize + HEADER_LEN) %
+					IOCTL_BUF_SIZE;
+			} else {
+				memcpy((u8 *)fwControl->buffer,
+					(u8 *)pm8001_ha->fw_image->data + sizeRead,
+					IOCTL_BUF_SIZE);
+				sizeRead += IOCTL_BUF_SIZE;
+			}
+
+			pm8001_ha->nvmd_completion = &completion;
+			ret = PM8001_CHIP_DISP->fw_flash_update_req(pm8001_ha,
+				payload);
+			if (ret) {
+				pm8001_ha->fw_status = FAIL_OUT_MEMORY;
+				goto out;
+			}
+			wait_for_completion(&completion);
+			if (fwControl->retcode > FLASH_UPDATE_IN_PROGRESS) {
+				pm8001_ha->fw_status = fwControl->retcode;
+				ret = -EFAULT;
+				goto out;
+			}
 		}
 	}
 out:
Signature · 1 line
2.20.1.7.g153144c
#1 lore raw
Quoted 41 lines · Yang Li

Eliminate the follow smatch warning:
drivers/scsi/pm8001/pm8001_ctl.c:760 pm8001_update_flash() warn:
inconsistent indenting

---
 drivers/scsi/pm8001/pm8001_ctl.c | 65 +++++++++++++++++---------------
 1 file changed, 35 insertions(+), 30 deletions(-)
drivers/scsi/pm8001/pm8001_ctl.c +0 -23
index 41a63c9b719b..213ebf39261f 100644
@@ -755,36 +755,41 @@ static int pm8001_update_flash(struct pm8001_hba_info *pm8001_ha)
 			fwControl->retcode = 0;/* OUT */
 			fwControl->offset = loopNumber * IOCTL_BUF_SIZE;/*OUT */
 
-		/* for the last chunk of data in case file size is not even with
-		4k, load only the rest*/
-		if (((loopcount-loopNumber) == 1) &&
-			((partitionSize + HEADER_LEN) % IOCTL_BUF_SIZE)) {
-			fwControl->len =
-				(partitionSize + HEADER_LEN) % IOCTL_BUF_SIZE;
-			memcpy((u8 *)fwControl->buffer,
-				(u8 *)pm8001_ha->fw_image->data + sizeRead,
-				(partitionSize + HEADER_LEN) % IOCTL_BUF_SIZE);
-			sizeRead +=
-				(partitionSize + HEADER_LEN) % IOCTL_BUF_SIZE;
-		} else {
-			memcpy((u8 *)fwControl->buffer,
-				(u8 *)pm8001_ha->fw_image->data + sizeRead,
-				IOCTL_BUF_SIZE);
-			sizeRead += IOCTL_BUF_SIZE;
-		}
-
-		pm8001_ha->nvmd_completion = &completion;
-		ret = PM8001_CHIP_DISP->fw_flash_update_req(pm8001_ha, payload);
-		if (ret) {
-			pm8001_ha->fw_status = FAIL_OUT_MEMORY;
-			goto out;

drivers/scsi/pm8001/pm8001_ctl.c static int pm8001_update_flash(struct pm8001_hba_info *pm8001_ha) · line 760

Quoted 10 lines
drivers/scsi/pm8001/pm8001_ctl.c +3 -7
-		}
-		wait_for_completion(&completion);
-		if (fwControl->retcode > FLASH_UPDATE_IN_PROGRESS) {
-			pm8001_ha->fw_status = fwControl->retcode;
-			ret = -EFAULT;
-			goto out;
-		}
+			/* for the last chunk of data in case file
+			 * size is not even with 4k, load only the rest
+			 */

Please start multi-line comments with a line that has only "/*". It would be good to add a blnak line before that too, for readability.

drivers/scsi/pm8001/pm8001_ctl.c static int pm8001_update_flash(struct pm8001_hba_info *pm8001_ha) · line 762

Quoted 2 lines
drivers/scsi/pm8001/pm8001_ctl.c +2 -0
+			if (((loopcount-loopNumber) == 1) &&
+				((partitionSize + HEADER_LEN) % IOCTL_BUF_SIZE)) {

While at it, align the conditions together to make this code more readable. As is, it is really unpleasant to read :)

Also, "(partitionSize + HEADER_LEN) % IOCTL_BUF_SIZE" is calculated way too many times. Using a local variable for the value would be nice.

Quoted 33 lines
drivers/scsi/pm8001/pm8001_ctl.c +30 -0
+				fwControl->len =
+					(partitionSize + HEADER_LEN) %
+					IOCTL_BUF_SIZE;
+				memcpy((u8 *)fwControl->buffer,
+					(u8 *)pm8001_ha->fw_image->data + sizeRead,
+					(partitionSize + HEADER_LEN) %
+					IOCTL_BUF_SIZE);
+				sizeRead +=
+					(partitionSize + HEADER_LEN) %
+					IOCTL_BUF_SIZE;
+			} else {
+				memcpy((u8 *)fwControl->buffer,
+					(u8 *)pm8001_ha->fw_image->data + sizeRead,
+					IOCTL_BUF_SIZE);
+				sizeRead += IOCTL_BUF_SIZE;
+			}
+
+			pm8001_ha->nvmd_completion = &completion;
+			ret = PM8001_CHIP_DISP->fw_flash_update_req(pm8001_ha,
+				payload);
+			if (ret) {
+				pm8001_ha->fw_status = FAIL_OUT_MEMORY;
+				goto out;
+			}
+			wait_for_completion(&completion);
+			if (fwControl->retcode > FLASH_UPDATE_IN_PROGRESS) {
+				pm8001_ha->fw_status = fwControl->retcode;
+				ret = -EFAULT;
+				goto out;
+			}
 		}
 	}
 out:
Signature · 2 lines
Damien Le Moal
Western Digital Research