2022-02-09 06:22:20

by Yang Li

[permalink] [raw]
Subject: [PATCH -next v3] scsi: pm8001: clean up some inconsistent indentin

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

Reported-by: Abaci Robot <[email protected]>
Signed-off-by: Yang Li <[email protected]>
---

Changes in v3:
--According to Damien's suggestion
1) "u32 fc_len = 0;" -> "u32 fc_len;".
2) Add spaces around the "-" and remove the unnecessary parenthesis.
3) Move "fc_len = (partitionSize + HEADER_LEN) % IOCTL_BUF_SIZE;"down,
right above the "if" where the variable is used.

drivers/scsi/pm8001/pm8001_ctl.c | 61 ++++++++++++++++----------------
1 file changed, 31 insertions(+), 30 deletions(-)

diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c
index 41a63c9b719b..66307783c73c 100644
--- a/drivers/scsi/pm8001/pm8001_ctl.c
+++ b/drivers/scsi/pm8001/pm8001_ctl.c
@@ -727,6 +727,8 @@ static int pm8001_update_flash(struct pm8001_hba_info *pm8001_ha)
u32 sizeRead = 0;
u32 ret = 0;
u32 length = 1024 * 16 + sizeof(*payload) - 1;
+ u32 fc_len;
+ u8 *read_buf;

if (pm8001_ha->fw_image->size < 28) {
pm8001_ha->fw_status = FAIL_FILE_SIZE;
@@ -755,36 +757,35 @@ 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
+ */
+
+ read_buf = (u8 *)pm8001_ha->fw_image->data + sizeRead;
+ fc_len = (partitionSize + HEADER_LEN) % IOCTL_BUF_SIZE;
+
+ if (loopcount - loopNumber == 1 && fc_len) {
+ fwControl->len = fc_len;
+ memcpy((u8 *)fwControl->buffer, read_buf, fc_len);
+ sizeRead += fc_len;
+ } else {
+ memcpy((u8 *)fwControl->buffer, read_buf, 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



2022-02-09 09:57:07

by Jinpu Wang

[permalink] [raw]
Subject: Re: [PATCH -next v3] scsi: pm8001: clean up some inconsistent indentin

On Tue, Feb 8, 2022 at 3:55 AM Yang Li <[email protected]> wrote:
>
> Eliminate the follow smatch warning:
> drivers/scsi/pm8001/pm8001_ctl.c:760 pm8001_update_flash() warn:
> inconsistent indenting
>
> Reported-by: Abaci Robot <[email protected]>
> Signed-off-by: Yang Li <[email protected]>
Acked-by: Jack Wang <[email protected]>
Thanks!
> ---
>
> Changes in v3:
> --According to Damien's suggestion
> 1) "u32 fc_len = 0;" -> "u32 fc_len;".
> 2) Add spaces around the "-" and remove the unnecessary parenthesis.
> 3) Move "fc_len = (partitionSize + HEADER_LEN) % IOCTL_BUF_SIZE;"down,
> right above the "if" where the variable is used.
>
> drivers/scsi/pm8001/pm8001_ctl.c | 61 ++++++++++++++++----------------
> 1 file changed, 31 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c
> index 41a63c9b719b..66307783c73c 100644
> --- a/drivers/scsi/pm8001/pm8001_ctl.c
> +++ b/drivers/scsi/pm8001/pm8001_ctl.c
> @@ -727,6 +727,8 @@ static int pm8001_update_flash(struct pm8001_hba_info *pm8001_ha)
> u32 sizeRead = 0;
> u32 ret = 0;
> u32 length = 1024 * 16 + sizeof(*payload) - 1;
> + u32 fc_len;
> + u8 *read_buf;
>
> if (pm8001_ha->fw_image->size < 28) {
> pm8001_ha->fw_status = FAIL_FILE_SIZE;
> @@ -755,36 +757,35 @@ 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
> + */
> +
> + read_buf = (u8 *)pm8001_ha->fw_image->data + sizeRead;
> + fc_len = (partitionSize + HEADER_LEN) % IOCTL_BUF_SIZE;
> +
> + if (loopcount - loopNumber == 1 && fc_len) {
> + fwControl->len = fc_len;
> + memcpy((u8 *)fwControl->buffer, read_buf, fc_len);
> + sizeRead += fc_len;
> + } else {
> + memcpy((u8 *)fwControl->buffer, read_buf, 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
>

2022-02-14 11:44:02

by Martin K. Petersen

[permalink] [raw]
Subject: Re: [PATCH -next v3] scsi: pm8001: clean up some inconsistent indentin


Yang,

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

Applied to 5.18/scsi-staging, thanks!

--
Martin K. Petersen Oracle Linux Engineering

2022-02-15 07:01:12

by Martin K. Petersen

[permalink] [raw]
Subject: Re: [PATCH -next v3] scsi: pm8001: clean up some inconsistent indentin

On Tue, 8 Feb 2022 10:55:00 +0800, Yang Li wrote:

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

Applied to 5.18/scsi-queue, thanks!

[1/1] scsi: pm8001: clean up some inconsistent indentin
https://git.kernel.org/mkp/scsi/c/106b7a2549b4

--
Martin K. Petersen Oracle Linux Engineering