Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C62F6C433EF for ; Thu, 14 Jul 2022 03:16:51 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 43B4184065; Thu, 14 Jul 2022 05:16:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.b="YW9tad/Z"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="dFK4ehPJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5A8F68403D; Thu, 14 Jul 2022 05:15:50 +0200 (CEST) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 050998405D for ; Thu, 14 Jul 2022 05:15:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 3C2955C00F4; Wed, 13 Jul 2022 23:15:35 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 13 Jul 2022 23:15:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1657768535; x=1657854935; bh=MP wcLlj8+icDLKrbsW4lomid5S1gh6fOjcQy13rXywE=; b=YW9tad/Zs0PAUwj5DX m/0vVwt3ayqCtRewAeSkpqiaRTnWdgqt3RJCTUSaIciWdPfJ+oI7SddMfMV2jbDv MvnPefd6ogNiDwLiZAgkfiaGPhzVSIfTj5BGM4qO7NxEJNIW3A1mRTeKiCqxrKpO EQNWLEs+RTO6zZqUJvhCnIf+umiCfVFKh1zzm+nNvUiifq2GqmOQs8QwcrzrZsHt vuUbPg10F4eDAUFAz71JdLl3jTTogeRQ/edmJdY+TR/b3vjnwTmlbPt1cfDYln3+ yP5FA5v4cL2RTE4Rv71MHVjzkLq7oEeEjPWBAWuuUeBb7XLdI4NCJM00gGJ+wJXb LTMA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1657768535; x=1657854935; bh=MPwcLlj8+icDL KrbsW4lomid5S1gh6fOjcQy13rXywE=; b=dFK4ehPJ/AcU5TFKyjlNu6GoQ+uzR AGHjT/yAL13y4L34jw9cufFIeNaZWeR2Urt+8QWLUX9f9yvzzzEaa3E1ePTnmH5/ nUWtPm1fPR+zvnUjyOH9gKdYFGcYozxqy+p0XLg09h/EBCicDhDOGavsO2IUZVVL NgV0ltGJTpLDHNpr/kzHX/Pnjowv4QPFswIF4Bg6eUXie9zDnfKWgjC5W1QbVzv0 D2jKR8NKaaHTGlQyggzXUfG6de7MVTFpg60bDVKBQIqSSa4A6cbKwAyiT0IkUPol h9QwcoB7WHUMJI2Fsc354Mt8rXtioHIsbhARymeKppc9ZAkXezAG1BJrw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudejkedgieekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepudekteeuudehtdelteevgfduvddvjefhfedulefgudevgeeghefg udefiedtveetnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 13 Jul 2022 23:15:34 -0400 (EDT) From: Samuel Holland To: u-boot@lists.denx.de, Jagan Teki , Andre Przywara Cc: Samuel Holland , Dario Binacchi , Hans de Goede , Lukasz Majewski , Michael Trimarchi , Sean Anderson , Simon Glass Subject: [PATCH 6/6] mtd: nand: sunxi: Pass the device to the init function Date: Wed, 13 Jul 2022 22:15:26 -0500 Message-Id: <20220714031526.33697-7-samuel@sholland.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220714031526.33697-1-samuel@sholland.org> References: <20220714031526.33697-1-samuel@sholland.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean This more closely matches the U-Boot driver to the Linux version. Signed-off-by: Samuel Holland --- drivers/mtd/nand/raw/sunxi_nand.c | 39 ++++++++++++++++--------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c index dda51a39b065..c0fa1e310c66 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -1604,7 +1604,8 @@ static int sunxi_nand_ecc_init(struct mtd_info *mtd, struct nand_ecc_ctrl *ecc) return 0; } -static int sunxi_nand_chip_init(ofnode np, struct sunxi_nfc *nfc, int devnum) +static int sunxi_nand_chip_init(struct udevice *dev, struct sunxi_nfc *nfc, + ofnode np, int devnum) { const struct nand_sdr_timings *timings; struct sunxi_nand_chip *chip; @@ -1620,7 +1621,7 @@ static int sunxi_nand_chip_init(ofnode np, struct sunxi_nfc *nfc, int devnum) nsels /= sizeof(u32); if (!nsels || nsels > 8) { - dev_err(nfc->dev, "invalid reg property size\n"); + dev_err(dev, "invalid reg property size\n"); return -EINVAL; } @@ -1628,7 +1629,7 @@ static int sunxi_nand_chip_init(ofnode np, struct sunxi_nfc *nfc, int devnum) (nsels * sizeof(struct sunxi_nand_chip_sel)), GFP_KERNEL); if (!chip) { - dev_err(nfc->dev, "could not allocate chip\n"); + dev_err(dev, "could not allocate chip\n"); return -ENOMEM; } @@ -1638,19 +1639,19 @@ static int sunxi_nand_chip_init(ofnode np, struct sunxi_nfc *nfc, int devnum) for (i = 0; i < nsels; i++) { ret = ofnode_read_u32_index(np, "reg", i, &tmp); if (ret) { - dev_err(nfc->dev, "could not retrieve reg property: %d\n", + dev_err(dev, "could not retrieve reg property: %d\n", ret); return ret; } if (tmp > NFC_MAX_CS) { - dev_err(nfc->dev, + dev_err(dev, "invalid reg value: %u (max CS = 7)\n", tmp); return -EINVAL; } if (test_and_set_bit(tmp, &nfc->assigned_cs)) { - dev_err(nfc->dev, "CS %d already assigned\n", tmp); + dev_err(dev, "CS %d already assigned\n", tmp); return -EINVAL; } @@ -1661,9 +1662,9 @@ static int sunxi_nand_chip_init(ofnode np, struct sunxi_nfc *nfc, int devnum) chip->sels[i].rb.type = RB_NATIVE; chip->sels[i].rb.info.nativeid = tmp; } else { - ret = gpio_request_by_name_nodev(np, "rb-gpios", i, - &chip->sels[i].rb.info.gpio, - GPIOD_IS_IN); + ret = gpio_request_by_name(dev, "rb-gpios", i, + &chip->sels[i].rb.info.gpio, + GPIOD_IS_IN); if (ret) chip->sels[i].rb.type = RB_GPIO; else @@ -1674,7 +1675,7 @@ static int sunxi_nand_chip_init(ofnode np, struct sunxi_nfc *nfc, int devnum) timings = onfi_async_timing_mode_to_sdr_timings(0); if (IS_ERR(timings)) { ret = PTR_ERR(timings); - dev_err(nfc->dev, + dev_err(dev, "could not retrieve timings for ONFI mode 0: %d\n", ret); return ret; @@ -1682,7 +1683,7 @@ static int sunxi_nand_chip_init(ofnode np, struct sunxi_nfc *nfc, int devnum) ret = sunxi_nand_chip_set_timings(nfc, chip, timings); if (ret) { - dev_err(nfc->dev, "could not configure chip timings: %d\n", ret); + dev_err(dev, "could not configure chip timings: %d\n", ret); return ret; } @@ -1717,25 +1718,25 @@ static int sunxi_nand_chip_init(ofnode np, struct sunxi_nfc *nfc, int devnum) ret = sunxi_nand_chip_init_timings(nfc, chip); if (ret) { - dev_err(nfc->dev, "could not configure chip timings: %d\n", ret); + dev_err(dev, "could not configure chip timings: %d\n", ret); return ret; } ret = sunxi_nand_ecc_init(mtd, &nand->ecc); if (ret) { - dev_err(nfc->dev, "ECC init failed: %d\n", ret); + dev_err(dev, "ECC init failed: %d\n", ret); return ret; } ret = nand_scan_tail(mtd); if (ret) { - dev_err(nfc->dev, "nand_scan_tail failed: %d\n", ret); + dev_err(dev, "nand_scan_tail failed: %d\n", ret); return ret; } ret = nand_register(devnum, mtd); if (ret) { - dev_err(nfc->dev, "failed to register mtd device: %d\n", ret); + dev_err(dev, "failed to register mtd device: %d\n", ret); return ret; } @@ -1744,13 +1745,13 @@ static int sunxi_nand_chip_init(ofnode np, struct sunxi_nfc *nfc, int devnum) return 0; } -static int sunxi_nand_chips_init(ofnode node, struct sunxi_nfc *nfc) +static int sunxi_nand_chips_init(struct udevice *dev, struct sunxi_nfc *nfc) { ofnode nand_np; int ret, i = 0; - ofnode_for_each_subnode(nand_np, node) { - ret = sunxi_nand_chip_init(nand_np, nfc, i++); + dev_for_each_subnode(nand_np, dev) { + ret = sunxi_nand_chip_init(dev, nfc, nand_np, i++); if (ret) return ret; } @@ -1802,7 +1803,7 @@ static int sunxi_nand_probe(struct udevice *dev) if (ret) return ret; - ret = sunxi_nand_chips_init(dev_ofnode(dev), nfc); + ret = sunxi_nand_chips_init(dev, nfc); if (ret) { dev_err(dev, "failed to init nand chips\n"); return ret; -- 2.35.1