Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2693015lqo; Tue, 14 May 2024 06:42:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXEvm+djlmAvk8PyZ5nKQBI8uEMbyFsqCK35V2bdES8rxo1kQo80TgRdIozrFGWyhZPloCVTi+LL+5UULUrmCgOJyo7rLnI4VgbfDPX2Q== X-Google-Smtp-Source: AGHT+IEhPnD5quKHh7RKIa+WRQR5OOjya3872dreErtdobjDdTvF922M7merio9Qfs4g4aQwXyZt X-Received: by 2002:a05:6a00:3a2a:b0:6ea:bb66:9448 with SMTP id d2e1a72fcca58-6f4e0347c0emr12541324b3a.22.1715694120463; Tue, 14 May 2024 06:42:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715694120; cv=pass; d=google.com; s=arc-20160816; b=ooZwXiy8mMw0Q1+PUcLVwibcQlaSAvNbcifVraOLDr9ibOknJNIgtT3ZtkBm1DEyBj KAAf8xKr6Tao7AaZ5axeuq6/LEQUFMwZ1tYJf0SlSJeZAf/ufdPfTD2WR0lcb6BuG4AI o1Im32VWCmwiZeSmIWJi5BBBNTK1ajwyKCIL+j/w/6aXJigQ/3NpNYu51qAcI3gBSzjm kDPFuuy8w4wVJndB423wmYlcoJUw9YOHLT54O7r7BuzqAqVYRVcKXf7DVI3omuy+OTri JlizpFg8dZxEXLPJ+JHz3SxgrfR46/wscndJ0RykPE4O8IANfboaM/hljoR86thTSXWB a9zg== 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:message-id:date:subject:cc:to :from; bh=ZRabjFkomokev0lY+di94TXLTxA3ooANImBM0/ftwkU=; fh=U6CGyhe0nAc68QPSdw/7pBff6XxSx5Ch7bP8crz+iAM=; b=fsI3ykLbjapM8puofxMA6y3rXdBEJhdPD71nC8ZsHwL0GKALJxs1+gyYMy+grzP1jf YsZ4G0k0OrBnoPrbaKIGEFNBmncKU0MisrxSy5/ujZ3yZnwP7tha3IxFB2Z3syYKvrmt v3FxWIitzPtWRYB7jeGQmUT61X8z0sraU+sKhhKlaUutGdXgcGgzytojpzyep5VWkIbz QznNUAaEhxnjBNNMTOH9a48slnJfCMybHotHnQUgVP9DmMtMulK411SU6Az9/gEP7QXV vEakpUV5QioimjwimVb3RpkVdAcY5UfuLeQm1UeuYsuE4R9453p28zt9ChYTCurMeOw7 hXnA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-178761-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178761-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f4d2b1e710si11334043b3a.277.2024.05.14.06.42.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 06:42:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-178761-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-178761-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178761-linux.lists.archive=gmail.com@vger.kernel.org" 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 0DAEF281D0A for ; Tue, 14 May 2024 13:42:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 41FA91448CB; Tue, 14 May 2024 13:41:55 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 8F67D13E030 for ; Tue, 14 May 2024 13:41:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715694114; cv=none; b=KUVnhN6zF4rkiN+8FLxp2eeOiPIP3C1iq3nnL+wmzsN9wD48E2BxpbfgjPuaIPeZO8khbYNMH5Oeh0IuF+Ekd8nhO135qKNRVqTSyJsb83RcW3u4pILHa07vnpTKyUOVc/0owrWi/mnI5zTjFWtoT1l4kqdQBnXU5McMi95YwbM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715694114; c=relaxed/simple; bh=AG+Ue9kB0biuaCxRpv5D3JyapkxKk0KbbofClJQTYiU=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ZNywS8TOraJJ222DT0EfCbnPdaEfb4J1sr+1yqSyMbRBYyUl1GYH0BKNBWiQGu5Adm5ZfnfJfNx1M3K6Sfo0t0enJ/ILZGx+QA+BKcSGpYVgcJVTCcZL3gsHoM2eeeoZxK+34oJT/r3jj+NlkmHOgL6ayTb1oAq5osEfWP3AMNI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1s6sPX-0002ov-DC; Tue, 14 May 2024 15:41:43 +0200 Received: from [2a0a:edc0:0:1101:1d::28] (helo=dude02.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s6sPW-001MiW-1J; Tue, 14 May 2024 15:41:42 +0200 Received: from localhost ([::1] helo=dude02.red.stw.pengutronix.de) by dude02.red.stw.pengutronix.de with esmtp (Exim 4.96) (envelope-from ) id 1s6sPV-004PBy-2w; Tue, 14 May 2024 15:41:41 +0200 From: Sascha Hauer To: linux-mtd@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Miquel Raynal , Richard Weinberger , Sascha Hauer Subject: [PATCH] mtd: rawnand: onfi: read parameter pages in one go Date: Tue, 14 May 2024 15:41:40 +0200 Message-Id: <20240514134140.1050141-1-s.hauer@pengutronix.de> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: s.hauer@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org nand_read_data_op() is not supported by all NAND controllers. nand_change_read_column_op() is not supported or at least is hard to support by NAND controllers that use a different page layout than expected by the NAND core. Instead of relying on these functions just read the three parameter pages in one go. Signed-off-by: Sascha Hauer --- drivers/mtd/nand/raw/nand_onfi.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_onfi.c b/drivers/mtd/nand/raw/nand_onfi.c index 861975e44b552..df1750692404d 100644 --- a/drivers/mtd/nand/raw/nand_onfi.c +++ b/drivers/mtd/nand/raw/nand_onfi.c @@ -148,7 +148,6 @@ int nand_onfi_detect(struct nand_chip *chip) struct nand_memory_organization *memorg; struct nand_onfi_params *p = NULL, *pbuf; struct onfi_params *onfi; - bool use_datain = false; int onfi_version = 0; char id[4]; int i, ret, val; @@ -166,25 +165,11 @@ int nand_onfi_detect(struct nand_chip *chip) if (!pbuf) return -ENOMEM; - if (!nand_has_exec_op(chip) || chip->controller->supported_op.data_only_read) - use_datain = true; + ret = nand_read_param_page_op(chip, 0, pbuf, sizeof(*pbuf) * ONFI_PARAM_PAGES); + if (ret) + return ret; for (i = 0; i < ONFI_PARAM_PAGES; i++) { - if (!i) - ret = nand_read_param_page_op(chip, 0, &pbuf[i], - sizeof(*pbuf)); - else if (use_datain) - ret = nand_read_data_op(chip, &pbuf[i], sizeof(*pbuf), - true, false); - else - ret = nand_change_read_column_op(chip, sizeof(*pbuf) * i, - &pbuf[i], sizeof(*pbuf), - true); - if (ret) { - ret = 0; - goto free_onfi_param_page; - } - crc = onfi_crc16(ONFI_CRC_BASE, (u8 *)&pbuf[i], 254); if (crc == le16_to_cpu(pbuf[i].crc)) { p = &pbuf[i]; -- 2.39.2