Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp978719pxb; Tue, 8 Feb 2022 06:47:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJyzjUHQJTFRFN+FT9DV6C7J+IGQ9k4z0Y13a+C7k7Ey+jN1zDRT28mLY5iS2xAJx+EkhH3s X-Received: by 2002:a05:6402:144d:: with SMTP id d13mr4909569edx.278.1644331672067; Tue, 08 Feb 2022 06:47:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644331672; cv=none; d=google.com; s=arc-20160816; b=ySnyChP6AuYAmr6Pk2sq+W3ZyIZeY4U61uIGzuJ6KQ7qbtrvVT2VvFHlyFROhH8GeC Jh0oZCDnkP5ArcQxXQu3iV4S0zJWCIUT5xCU94ZJzHivrvdSpVU14xlmcW2tK1hpbbdw h++d1y7sZVDM3l/9IEUcNAmuj7Yqr31fEZC2XH7cIk0ph4Uiab2JjexR+0pE4ZfEZh+X wSm5OQPk9mUYFbnP9SP//svvCLtshgpueEOqSz9bmJJyRfwVdnCeWVM9twD6zxd8vrBJ +4cG7i3GF2Yggv2INLFshMHFth3RZn7/deIIPshCIe9/VSGHvI3bkzQHrCU0LR+jDEai NyHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=S1fON1AjQSJbYGZNuG771vyCrXc88eLAT62a96fUlmk=; b=WvB8dNn3igEfpZ4Af+i/VKdxxfMNe98X+5cR8LamxuV+jDCz9x/PKMt95hl4ViHDqW X/Ubz+cDwTKW+YFkY7x4TXe1eaUQta+hm4u32PAeWCHrghusdUsMb3LIvtGjN3wKrdLu wyFz/6ZIv+lb/1uf48Y2OIpqDdZCPjrclRMCbOkDPAfRijn4G3CMHJzYFxF+S+fnoCzM Jq4BL9y92+6SU8V5c4p0Vc6wPMGNvODWgwYHqODtnVIR4O2Zkms5IvvwddsJMNEQOB+m iVXGrdi5iNjk/YYbmw0Xw5B02mp0OXbIhtiRlWwk3fkjQAnwj4NHN+/w9t6hgoUMCGg/ yQ5Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y20si10945817edd.9.2022.02.08.06.47.26; Tue, 08 Feb 2022 06:47:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236134AbiBGISB (ORCPT + 99 others); Mon, 7 Feb 2022 03:18:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243699AbiBGIP3 (ORCPT ); Mon, 7 Feb 2022 03:15:29 -0500 Received: from out30-57.freemail.mail.aliyun.com (out30-57.freemail.mail.aliyun.com [115.124.30.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F283AC043185; Mon, 7 Feb 2022 00:15:27 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=yang.lee@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0V3nfmXb_1644221724; Received: from localhost(mailfrom:yang.lee@linux.alibaba.com fp:SMTPD_---0V3nfmXb_1644221724) by smtp.aliyun-inc.com(127.0.0.1); Mon, 07 Feb 2022 16:15:24 +0800 From: Yang Li To: damien.lemoal@opensource.wdc.com, jejb@linux.ibm.com Cc: jinpu.wang@cloud.ionos.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Yang Li , Abaci Robot Subject: [PATCH -next v2] scsi: pm8001: clean up some inconsistent indenting Date: Mon, 7 Feb 2022 16:15:22 +0800 Message-Id: <20220207081522.12111-1-yang.lee@linux.alibaba.com> X-Mailer: git-send-email 2.20.1.7.g153144c MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Eliminate the follow smatch warning: drivers/scsi/pm8001/pm8001_ctl.c:760 pm8001_update_flash() warn: inconsistent indenting Reported-by: Abaci Robot Signed-off-by: Yang Li --- Changes in v2: --According to Damien's suggestion 1) Start multi-line comments with a line that has only "/*". 2) Align the conditions together to make this code more readable. 3) Using a local variable for value which is calculated too many times. 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..0d9533ba8d27 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 = 0; + 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 + */ + + fc_len = (partitionSize + HEADER_LEN) % IOCTL_BUF_SIZE; + read_buf = (u8 *)pm8001_ha->fw_image->data + sizeRead; + + 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