From patchwork Sat Feb 1 20:55:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 1232319 X-Patchwork-Delegate: tudor.ambarus@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=cogentembedded.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=DYynH7SI; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=cogentembedded-com.20150623.gappssmtp.com header.i=@cogentembedded-com.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=Nt9YjEwe; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4895wD6DwLz9sRK for ; Sun, 2 Feb 2020 07:55:54 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:References:To:Subject:From:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=l5LLw+WDEyZXLu0qY1IqX2zTAd/IAajAb1W2uLg7+Tk=; b=DYynH7SIDfprVb3l5Ag3zBURWs FuXaxKFvWUU86lVeK+duJ+kmxaHky3nj0p65yS1UIjhVz8Y7KfZdYiqjzz4+JfNEUqKNdzex5ud+6 ITxaoHrm82ylXHcidDZT90gYY/W4LwKrrX+Tz+1kSkYUrGE41AefzmKi2ekm/ia7N4QX/9zUJ2zzZ 7/mnKOf1SN3Hf7iD/H9ZIak8cVew+uvU/4cfZkc5ha1af8CrtUli2eiRMtAZSx1L3CLqxfaaSKhqD qXS0a03Er+1s+r3SB6J/JyD1OQ2blTpA1U1UQ5NrrTkzJESGaGgIkw19HMFV9oFK+H0uByrcG+H8J ILDimWEA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ixzna-0003um-1q; Sat, 01 Feb 2020 20:55:26 +0000 Received: from mail-lj1-x242.google.com ([2a00:1450:4864:20::242]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ixznR-0003uF-BI for linux-mtd@lists.infradead.org; Sat, 01 Feb 2020 20:55:18 +0000 Received: by mail-lj1-x242.google.com with SMTP id w1so10728829ljh.5 for ; Sat, 01 Feb 2020 12:55:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=from:subject:to:references:organization:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=aDR7arjSMlMRJkwpPKCJoDo6pUjhnLXb2qa3+5T1Qe0=; b=Nt9YjEweiI8OfS/osWukAGNplcqDrBbC8dToCOwfdo9fiv4+2c4eQuSsLxgdKTSs2f rjb0NfdvyWOSrjBCoRp4NA0ebRJq3zLklaaWzLUhgFoxWlpXjHRas22rYULf3qKDnhWM 3Tem1w/ZTuJf4o+wXbk/EmkNnQfoISdMDji9du5x5TWS0s2gOuKcIoztvRR2Q8kn9Q2m cNhRAT93skGLO9st3QuNFFsTabjmcWt0qCJrmoC57TBX6RLaevyB4zNZ1DrtdwfUIhzK YJU8L46iZmm+PwToi4+h4ykCVqXCazNIUPo1Fcpxy584XpLhhuVp4nkwtrLTwYoXHZF7 NERA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:references:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=aDR7arjSMlMRJkwpPKCJoDo6pUjhnLXb2qa3+5T1Qe0=; b=dmn2fILaoEQT79ukTnchZadB1vfcDTWNhDKg83+NPvyYFke858v34TmNk6G802xoE7 R7IjiAPtsbjBRfeKiE/oWXlM7Ec/+tXgivCqlaHH4njfupkyJbWrLzBklaOSZaBgSrKv XVgLBb9XMZOAWh4DCtr0lAgpnG13r9tzzzPzqQJa0VkIgJ5T/IXomYGbEv+Pknf6e9dH /wR2896NYJxkbRgypvqqH5SHqBBskE+fbSGEAhbTTQM89OJFXiNzd/heW7dPOlU1XZe9 6XRELD9mcxBEX2+LC7uaA84KXQBe3Ten1TtAbyxkQuqc+s9rEsb83PFi27O+9SP+9itX wZBQ== X-Gm-Message-State: APjAAAXL7PF7ius9FWfsXqzYszVK/PtcXaVwWSH8VimCRYjPEdtc+2+0 twkdjv/tIY3qRi3JUCWnYx8DLw== X-Google-Smtp-Source: APXvYqzrckxinsJ/vh8oucx5/g5YpZqyBhzxt//Q3BTnbKB2dPYT89z3zTG1WbGsO3rm2wtySQgYNw== X-Received: by 2002:a2e:9942:: with SMTP id r2mr9164394ljj.182.1580590510819; Sat, 01 Feb 2020 12:55:10 -0800 (PST) Received: from wasted.cogentembedded.com ([2a00:1fa0:43e:23d7:3996:dfcf:1d71:1e48]) by smtp.gmail.com with ESMTPSA id r2sm7774392lff.63.2020.02.01.12.55.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Feb 2020 12:55:09 -0800 (PST) From: Sergei Shtylyov Subject: [PATCH] mtd: spi-nor: use le32_to_cpu_array() To: Richard Weinberger , linux-mtd@lists.infradead.org, Miquel Raynal , Vignesh Raghavendra , Tudor Ambarus References: <610761cf-5a19-c182-07d8-8d118ca20035@cogentembedded.com> Organization: Cogent Embedded Message-ID: <70ea17c5-c4cf-819c-9b47-5755d821b4b3@cogentembedded.com> Date: Sat, 1 Feb 2020 23:55:08 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <610761cf-5a19-c182-07d8-8d118ca20035@cogentembedded.com> Content-Language: en-MW X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200201_125517_461043_281A522B X-CRM114-Status: GOOD ( 14.28 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:242 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The driver calls le32_to_cpu() to convert the little-endian tables to a CPU endianness, where le32_to_cpus() should have been called. Was going to use that one... and then discovered a whole array converter, le32_to_cpu_array()! :-) Signed-off-by: Sergei Shtylyov --- This patch is against the 'spi-nor/next' branch of the MTD 'linux.git' repo plus couple of SPI NOR patches posted earlier... drivers/mtd/spi-nor/spi-nor.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) Index: linux/drivers/mtd/spi-nor/spi-nor.c =================================================================== --- linux.orig/drivers/mtd/spi-nor/spi-nor.c +++ linux/drivers/mtd/spi-nor/spi-nor.c @@ -3626,8 +3626,7 @@ static int spi_nor_parse_bfpt(struct spi return err; /* Fix endianness of the BFPT DWORDs. */ - for (i = 0; i < BFPT_DWORD_MAX; i++) - bfpt.dwords[i] = le32_to_cpu(bfpt.dwords[i]); + le32_to_cpu_array(bfpt.dwords, BFPT_DWORD_MAX); /* Number of address bytes. */ switch (bfpt.dwords[BFPT_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK) { @@ -4085,7 +4084,7 @@ static int spi_nor_parse_smpt(struct spi u32 *smpt; size_t len; u32 addr; - int i, ret; + int ret; /* Read the Sector Map Parameter Table. */ len = smpt_header->length * sizeof(*smpt); @@ -4099,8 +4098,7 @@ static int spi_nor_parse_smpt(struct spi goto out; /* Fix endianness of the SMPT DWORDs. */ - for (i = 0; i < smpt_header->length; i++) - smpt[i] = le32_to_cpu(smpt[i]); + le32_to_cpu_array(smpt, smpt_header->length); sector_map = spi_nor_get_map_in_use(nor, smpt, smpt_header->length); if (IS_ERR(sector_map)) { @@ -4193,8 +4191,7 @@ static int spi_nor_parse_4bait(struct sp goto out; /* Fix endianness of the 4BAIT DWORDs. */ - for (i = 0; i < SFDP_4BAIT_DWORD_MAX; i++) - dwords[i] = le32_to_cpu(dwords[i]); + le32_to_cpu_array(dwords, SFDP_4BAIT_DWORD_MAX); /* * Compute the subset of (Fast) Read commands for which the 4-byte