Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1561731pxb; Tue, 8 Feb 2022 22:22:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwYfKNjpYSRFVyJkHVaeFhUXgVbyTKg4DwX1BxoSAYSZtjRe5doeryDHzV30JBghrB/k1/B X-Received: by 2002:a17:903:2302:: with SMTP id d2mr998206plh.18.1644387740355; Tue, 08 Feb 2022 22:22:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644387740; cv=none; d=google.com; s=arc-20160816; b=CXlCKpmjvQKKZ6rIF3hvDEFuwQSZmrovs/B09fRTQXyZbX6oPyz8fxXhPLaUc5wFBN 2nUx4wy91kcDEn/y2MBis+dMkPdl7VljmA+jzI5pCZvRLtdEI37l8gxfrQqHOzZlgYgt +IwglICsCE+/nCVdOh0R0RTf/ORRMnPccIi4KaYL1XaitdQES+PoE0G0OPlN8Wl7Ls20 PJ094QguEgoi/MGyw+90QvqlLx8l/NoIXz7r2PMs4gzUAJpw+M1+1a3s8j9YvDAX+Rjc K+44L5XIOroqz1pb9N2epEWVBBAa5GBfQBifDizUydvi421ycIBsQRCLoPB99tru7Dxg X3Dw== 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=oVZNEVKE71WNRTpuzCJ3g302X17SaJFOdeMlNFUUOv0=; b=XvBAZPNeCNq//hUzD5Jwk43h6YiSUhxwQLDZ6VVuW+ouf/1atWrVhKwvVsVEetcmnV j167NMOPWnjUrdTh8GoeqVCW9TeiEe/+aMjuM6IfOC1Xkgoi6Isnr4RcDytnF4iSKDQ5 ZNRzPaltAm0poGU+WONcNbQ76E7O4ngx24EtpJQbAZrkkD+976VQ6USQqnRGsDB8aXhn tt/IaWLElNR84xbFgCetT70TpI0/XPioX1nxnGt5ljLpRtGjV6vKWSbnWvQA6GHMGvS1 D8rS0O6Ts+pdoZMTuB7VtQDY1nBXcTyguWecZBGKKAHy8FDIK/W1WzbNpF2RMq667Clb Znpg== 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:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id z4si1899922ple.611.2022.02.08.22.22.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 22:22:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 76E0AE00FEE4; Tue, 8 Feb 2022 22:02:52 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346261AbiBHCzQ (ORCPT + 99 others); Mon, 7 Feb 2022 21:55:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346250AbiBHCzL (ORCPT ); Mon, 7 Feb 2022 21:55:11 -0500 Received: from out30-42.freemail.mail.aliyun.com (out30-42.freemail.mail.aliyun.com [115.124.30.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CCCDC0401DC; Mon, 7 Feb 2022 18:55:08 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04423;MF=yang.lee@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0V3tqOcC_1644288902; Received: from localhost(mailfrom:yang.lee@linux.alibaba.com fp:SMTPD_---0V3tqOcC_1644288902) by smtp.aliyun-inc.com(127.0.0.1); Tue, 08 Feb 2022 10:55:02 +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 v3] scsi: pm8001: clean up some inconsistent indentin Date: Tue, 8 Feb 2022 10:55:00 +0800 Message-Id: <20220208025500.29511-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=-7.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=unavailable 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 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