* [PATCH -next] scsi: pm8001: clean up some inconsistent indenting
@ 2022-02-06 12:55 Yang Li
2022-02-07 3:25 ` Damien Le Moal
0 siblings, 1 reply; 2+ messages in thread
From: Yang Li @ 2022-02-06 12:55 UTC (permalink / raw)
To: jejb
Cc: martin.petersen, jinpu.wang, linux-scsi, linux-kernel, Yang Li,
Abaci Robot
Eliminate the follow smatch warning:
drivers/scsi/pm8001/pm8001_ctl.c:760 pm8001_update_flash() warn:
inconsistent indenting
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
---
drivers/scsi/pm8001/pm8001_ctl.c | 65 +++++++++++++++++---------------
1 file changed, 35 insertions(+), 30 deletions(-)
diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c
index 41a63c9b719b..213ebf39261f 100644
--- a/drivers/scsi/pm8001/pm8001_ctl.c
+++ b/drivers/scsi/pm8001/pm8001_ctl.c
@@ -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:
--
2.20.1.7.g153144c
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH -next] scsi: pm8001: clean up some inconsistent indenting
2022-02-06 12:55 [PATCH -next] scsi: pm8001: clean up some inconsistent indenting Yang Li
@ 2022-02-07 3:25 ` Damien Le Moal
0 siblings, 0 replies; 2+ messages in thread
From: Damien Le Moal @ 2022-02-07 3:25 UTC (permalink / raw)
To: Yang Li, jejb
Cc: martin.petersen, jinpu.wang, linux-scsi, linux-kernel,
Abaci Robot
On 2/6/22 21:55, Yang Li wrote:
> Eliminate the follow smatch warning:
> drivers/scsi/pm8001/pm8001_ctl.c:760 pm8001_update_flash() warn:
> inconsistent indenting
>
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
> ---
> drivers/scsi/pm8001/pm8001_ctl.c | 65 +++++++++++++++++---------------
> 1 file changed, 35 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c
> index 41a63c9b719b..213ebf39261f 100644
> --- a/drivers/scsi/pm8001/pm8001_ctl.c
> +++ b/drivers/scsi/pm8001/pm8001_ctl.c
> @@ -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
> + */
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.
> + 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.
> + 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:
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-02-07 6:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-06 12:55 [PATCH -next] scsi: pm8001: clean up some inconsistent indenting Yang Li
2022-02-07 3:25 ` Damien Le Moal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox