Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp180323lqo; Tue, 7 May 2024 16:59:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU5DOPJ95Cr1OmPcrfk+Mfdom2eTOlQBPCuZ50jpttZNsBpzdV9FfgY9MI4+HIW2hjFrwTKJt095b4VkI+iA65hty6P5A/j0xLk5zvNYw== X-Google-Smtp-Source: AGHT+IGn3wyHQeK7jGf7MCGgoOIJj6Z5mZhRErmgw55jYAfrrcipokRf80SRrrVrNPga6Z52/X6M X-Received: by 2002:ac2:42cd:0:b0:51c:d876:710c with SMTP id 2adb3069b0e04-5217c667197mr519765e87.37.1715126376660; Tue, 07 May 2024 16:59:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715126376; cv=pass; d=google.com; s=arc-20160816; b=VPbsBMDWnsysN701BSWodHh+QkaNTQc6+DNjxz3uEJ3Y3BKAGfI68VMtcNYLBmJfdn c9T77qCkgcndlGF0toyBcjIRGnVwz9xOG7jQ0q8iwhix+7jP50AArE7s4yBALoLdkVvW 9iAmgEpHmJafZeut8pqD500UwevAU0/S/yUqm6kVUxBxfm4nPmMxFn2GQF0sR1xUAU0w t8wXDiC2MiU6OHK355411mJHZvCz/XZyYjQPtNd3pqTpCBJEp84U1dlOEB4x6PQDDdB7 PeVrh74AYOXGa2NX1Bk8CkXtE6G4NRQTELjT+nS4W/XlVB1mLNwurPT1cIeeI33X5TWU iPsA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-filter; bh=JONu+0vUGzTkLvKnbTuMAODEVQdfxNTslB9TaWIptHk=; fh=nhecQrwVApGCu1TdcailefrHyWo/zWU/hH6HfNaDWJI=; b=RiFOGWew3voDfX0HynN8oKWuxvVBCoJCepG0moo1/l7KUg0S2q4n0Ztwp/t6/2sXUc 0r5z969arforXRMVd8zDNtcaoPePDgRkDZnNC8tB8IVpibWzizeFvA6HF3lczL3VE1dc +HLwPDuvfrk9SnzNLSXcv3lHiKt0H6tyFF+wgwL/p0o42I8ketsUc+lsbLjnxep3sG+u MEIFv3q7SM6bqq9Brtk12YLMDhtx6YEmxJZas0RXKtwyET6V6wU0EdIdDkGcB+naOh1d YehBo/ND/W7SHPsKdFbZT+fO7Lk1gKOyCQ0odeQlqmc11WkJMnvjdKWRNQV5fFMMKfqc Ufmw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=p68wFcxT; arc=pass (i=1 spf=pass spfdomain=salutedevices.com dkim=pass dkdomain=salutedevices.com dmarc=pass fromdomain=salutedevices.com); spf=pass (google.com: domain of linux-kernel+bounces-172506-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172506-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=salutedevices.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id cm9-20020a170906f58900b00a59cc4e729bsi3012048ejd.486.2024.05.07.16.59.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 16:59:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172506-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=p68wFcxT; arc=pass (i=1 spf=pass spfdomain=salutedevices.com dkim=pass dkdomain=salutedevices.com dmarc=pass fromdomain=salutedevices.com); spf=pass (google.com: domain of linux-kernel+bounces-172506-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172506-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=salutedevices.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 272831F21B8E for ; Tue, 7 May 2024 23:59:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C0C2513B290; Tue, 7 May 2024 23:20:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=salutedevices.com header.i=@salutedevices.com header.b="p68wFcxT" Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 72FA312B154; Tue, 7 May 2024 23:20:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.89.224.132 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715124008; cv=none; b=WWgwPfEcxTMWkqSgTV0MxO+hfGpUAWrH8fxETUoQb3J7Pnt7c+sqBK0PUBMGVN9nElGnV5dgeREtHUh1XW0+Hl8ASEI+SRi2Z3JGT2FjDCW0za3mJRtgvzq4q43t5qzV/N3kpEMm6gILSImeV1/pCMwnZFpmSDhtbqfKL38OvxA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715124008; c=relaxed/simple; bh=QwwAqOn46R/jiuKaFnlOs6padCpr74/QcIK37vuNntA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TfQSlXwU27S1VyOouBT4SXuwmjo+8F9VFfzuNkQycaj2AkObkRvGB0Iw4dLhDMDOjV2Gqdn0L61hWHaDWlFGTKb49s4Tza1RW2utj4I5linj64jLZ7HjaMVWLkblfJhAa6THuIsy3Qux0oNlt8Fg+0SGkeRs8UdjNSakCy9LyeU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=salutedevices.com; spf=pass smtp.mailfrom=salutedevices.com; dkim=pass (2048-bit key) header.d=salutedevices.com header.i=@salutedevices.com header.b=p68wFcxT; arc=none smtp.client-ip=45.89.224.132 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=salutedevices.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=salutedevices.com Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 85E17120008; Wed, 8 May 2024 02:20:01 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 85E17120008 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1715124001; bh=JONu+0vUGzTkLvKnbTuMAODEVQdfxNTslB9TaWIptHk=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=p68wFcxTIL6zAYmhhobGhbu3l6gisJYcjZU30d2ezLJvM04Fh6Ng1f9aB8aLZS9l3 rGrwrrCbOFJt5H3Ic+6AKVTmZvslZBCjLRv7z0SnCKGOU3cwWtyO/4RlHQ+3KjPE5K gKUyF6WsW5xIK2PQZ0FU+E2LVra/1D280NIijFKfcAEbikpgS2MX9h3BBbBUTbgY20 Ix9OVu+O4OkpAt9o3PvdW0+nF/bocb2g8Dq1MfPUqyN7bayzWKIXxPrEPEieuzpLOi kNP07Khlm0GLrlWfsHQDJUvz9aGCOHwDxsw2bEsgtCrGYt3nswKsfWqokYJ08HPNrU Qe5BmLEBx0NVA== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Wed, 8 May 2024 02:20:01 +0300 (MSK) Received: from localhost.localdomain (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Wed, 8 May 2024 02:20:00 +0300 From: Arseniy Krasnov To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl CC: , , , , , , , Arseniy Krasnov Subject: [PATCH v6 2/3] mtd: rawnand: meson: refactor use of 'meson_nfc_cmd_access()' Date: Wed, 8 May 2024 02:09:02 +0300 Message-ID: <20240507230903.3399594-3-avkrasnov@salutedevices.com> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20240507230903.3399594-1-avkrasnov@salutedevices.com> References: <20240507230903.3399594-1-avkrasnov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 185123 [May 07 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 X-KSMG-AntiSpam-Envelope-From: avkrasnov@salutedevices.com X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 19 0.3.19 07c7fa124d1a1dc9662cdc5aace418c06ae99d2b, {Tracking_from_domain_doesnt_match_to}, salutedevices.com:7.1.1;100.64.160.123:7.1.2;smtp.sberdevices.ru:7.1.1,5.0.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;127.0.0.199:7.1.2, FromAlignment: s, ApMailHostAddress: 100.64.160.123 X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean X-KSMG-LinksScanning: Clean X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2024/05/07 17:58:00 #25118681 X-KSMG-AntiVirus-Status: Clean, skipped Move call 'meson_nfc_cmd_seed()' and check for 'NAND_NEED_SCRAMBLING' to 'meson_nfc_cmd_access()', thus removing code duplication. Signed-off-by: Arseniy Krasnov --- drivers/mtd/nand/raw/meson_nand.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c index 00ce0e5bb970..39f50cbd4ab9 100644 --- a/drivers/mtd/nand/raw/meson_nand.c +++ b/drivers/mtd/nand/raw/meson_nand.c @@ -298,14 +298,19 @@ static void meson_nfc_cmd_seed(struct meson_nfc *nfc, u32 seed) nfc->reg_base + NFC_REG_CMD); } -static void meson_nfc_cmd_access(struct nand_chip *nand, int raw, bool dir, - int scrambler) +static void meson_nfc_cmd_access(struct nand_chip *nand, int raw, bool dir, int page) { struct mtd_info *mtd = nand_to_mtd(nand); struct meson_nfc *nfc = nand_get_controller_data(mtd_to_nand(mtd)); struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand); u32 bch = meson_chip->bch_mode, cmd; int len = mtd->writesize, pagesize, pages; + int scrambler; + + if (nand->options & NAND_NEED_SCRAMBLING) + scrambler = NFC_CMD_SCRAMBLER_ENABLE; + else + scrambler = NFC_CMD_SCRAMBLER_DISABLE; pagesize = nand->ecc.size; @@ -321,6 +326,9 @@ static void meson_nfc_cmd_access(struct nand_chip *nand, int raw, bool dir, cmd = CMDRWGEN(DMA_DIR(dir), scrambler, bch, NFC_CMD_SHORTMODE_DISABLE, pagesize, pages); + if (scrambler == NFC_CMD_SCRAMBLER_ENABLE) + meson_nfc_cmd_seed(nfc, page); + writel(cmd, nfc->reg_base + NFC_REG_CMD); } @@ -743,14 +751,7 @@ static int meson_nfc_write_page_sub(struct nand_chip *nand, if (ret) return ret; - if (nand->options & NAND_NEED_SCRAMBLING) { - meson_nfc_cmd_seed(nfc, page); - meson_nfc_cmd_access(nand, raw, DIRWRITE, - NFC_CMD_SCRAMBLER_ENABLE); - } else { - meson_nfc_cmd_access(nand, raw, DIRWRITE, - NFC_CMD_SCRAMBLER_DISABLE); - } + meson_nfc_cmd_access(nand, raw, DIRWRITE, page); cmd = nfc->param.chip_select | NFC_CMD_CLE | NAND_CMD_PAGEPROG; writel(cmd, nfc->reg_base + NFC_REG_CMD); @@ -829,14 +830,7 @@ static int meson_nfc_read_page_sub(struct nand_chip *nand, if (ret) return ret; - if (nand->options & NAND_NEED_SCRAMBLING) { - meson_nfc_cmd_seed(nfc, page); - meson_nfc_cmd_access(nand, raw, DIRREAD, - NFC_CMD_SCRAMBLER_ENABLE); - } else { - meson_nfc_cmd_access(nand, raw, DIRREAD, - NFC_CMD_SCRAMBLER_DISABLE); - } + meson_nfc_cmd_access(nand, raw, DIRREAD, page); ret = meson_nfc_wait_dma_finish(nfc); meson_nfc_check_ecc_pages_valid(nfc, nand, raw); -- 2.35.0