From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C048549363F for ; Sat, 22 Aug 2026 22:41:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787438515; cv=none; b=fDQl074w6b1V/fh0kImm/cFcCUMQcr0oiWj2S5VO9+XK0XcMa0koldLYG1jrL80ZFHPpMnNBJ5I3kEvx/CNgpgDMDxRntbYc4bxVPYQdSVh8tyrtJKjoZSAttL1oGaq69zma8gI0xiR4ucqWp7/JRZfmphXD8b/H4X3xJgPdqB0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787438515; c=relaxed/simple; bh=cMGHcVvmFErsV9Vddw+Q5ZXRH5+6rjgj1/3wuTMmksQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=hqxbq48uCI2bRkg/Mtky0YYQzVCYjKZtLfthrnSWtr1khksms7lGf1F3NxVc5VvEo3r1PsVr/C1c1EMGtwPFaVCP77WQEiMEbps8yTEc08zvjXux+Ikvb7T/+DZm6ckD7Vc/resAn+KPMyoPcR73jJdHpYc3hK5cYYNX8c9d5FA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JqFqwejt; arc=none smtp.client-ip=209.85.215.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JqFqwejt" Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-ca766c1c9ccso1536929a12.0 for ; Sat, 22 Aug 2026 15:41:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787438513; x=1788043313; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=r4j5wv0w/ADuufI7v1wFxK87Vhz8Ot+ciPGoH6CtO5A=; b=JqFqwejt+ZO6vySPNVl+XEN0IZM1sZYnVGx9ZDuzYC8IpnE2lOWIr89UCJL5ph40AP ZFPHxe/FJ2N30ZV6NyBz8iqL59shskdz6HKoXlq6G8+KC9DnBAVys6GGEn7uX0iRvXq7 s0ISBqMXSZPRigSs0l4pS1CrxUvLv8axES9w6pL8br1bY4UdlQ5wU1NnDp4zdeBtjom1 foiqxQ0eMCE4kSyRkH+7Mw+tESq1VLmvT3U26UTNktcp6XBz8VxMY2/Utq15rH0QN3fe VgOuqtYFHVdQKXsmGwmVBRxn0W5y0NxHjQNSZO8MPfh3ivdaGb9Fq4Q35CPLPIlO7bfZ 4G5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787438513; x=1788043313; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=r4j5wv0w/ADuufI7v1wFxK87Vhz8Ot+ciPGoH6CtO5A=; b=NK5V96o1WlfFBWd1CjiXkdt+iXmQpt2I4oTenp2PgT52Wir/hhLYBfAEG/GomdMfGe rRUytEAD4hEsC4mgPvpcdD1QCbaTuYqaRb+xJWxdGWtsn0k5XKTsuAI9f6i3FBiMpbET Er8/FuS6jF7nRk1m6USElAaTqOrYCqBeaq7UAwNOhJbrBuVmf6aQEEremG8eLbT4dIw2 HL1ROeGvbJghas9BKy2pYxbGrUCL4zXUhJRYQDEDYH5in0D0qu4+28kR+YT1y02Nq2Pp LaZ0WI5y8JFtvH26cevFCdvSRGqKdHSuth+w7QEA1ZRyHvEbMo27Up+oBmtfjFRxgYVJ BT7g== X-Forwarded-Encrypted: i=1; AHgh+RpVTLrjlttIkyKw8a06McdV+qOXL/uSf10zNNYJpBTmWNmcGh+C5/NGlxZVTvxkB2onr/IhYw1SczWttmU=@vger.kernel.org X-Gm-Message-State: AFuF++lmHJ3qEZvXG4XogfMG0RD6sxhMjTb8gA4K09PyHnAOFjAU/Ozw j1TzuDaZ+KvG0qdpedeEDW3ik4yQvpfmq4M8K+c2eJ+fJxUR5qNtPPevqzxh2A== X-Gm-Gg: AR+sD130K+GqDACtNl4IEaMrSsby62F3atz3HZXklmtkRmI2qWgfIkBpC1U6CovAUKy mkaL0/7l/tWc8BA7v8nUuDaGmYu4uR07/b5fBE83JlFe0qFQpjiypCoUqqvzGfj+AYYeuGLVZ+L ZyDJo3vHY6VAzOdKhhWhzfY6ij0oLId6aOk0VVhM3176FVw28XsLDmiNS2cooxRFyEswO+7Ybdn q9bODlr+ro5kTqorI5FOisz790d9PVJC6kq6+n313DvtsPs7gr+Zh8n2mUCbvXbnAQWrrCwr760 9Lo/rgw6Zf3aDqjMm4oOvmcJt67tV/LquABUzscMN37qVuHgPgeuFegessEayDwSeJSrAhvJW2U cqBrkcL02+MNPKfYjOCaj0fT4QiySmbeCL5AGzrDHxE3tvSVEvG+eL6Nym0S/WI20blgz8SNEz5 0H+OGfcoYkJd58lRwV9MhIIPBkMvPpog6gQx/teKQ9KrJOVaD6zlLJcfo9Di/OpmAnpCtRv2ohn 4J6wJnLQxDCsigsKS6MMbHb526V0acR4zlvYY+5K62YOtGpGsar4kLo1OErpe9Ah8wxTKWq8TJI H2pNJwGJYyh1fxWLDwc+iI30bssxKmpu+9MEj6Mvnrj3xlpu X-Received: by 2002:a05:6a00:3a12:b0:846:de21:3da4 with SMTP id d2e1a72fcca58-8520b9466c6mr12014353b3a.3.1787438512961; Sat, 22 Aug 2026 15:41:52 -0700 (PDT) Received: from ryzen.lan ([2601:644:8000:7a86::e35]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8520f16d77csm839261b3a.59.2026.08.22.15.41.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Aug 2026 15:41:51 -0700 (PDT) From: Rosen Penev To: linux-mtd@lists.infradead.org Cc: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-kernel@vger.kernel.org (open list) Subject: [PATCH] mtd: rawnand: ndfc: use devm_platform_ioremap_resource Date: Sat, 22 Aug 2026 15:41:50 -0700 Message-ID: <20260822224150.198749-1-rosenp@gmail.com> X-Mailer: git-send-email 2.55.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Replace the open-coded of_iomap()/iounmap() with the managed devm_platform_ioremap_resource() helper. This fixes a mapping leak on probe failure and on driver remove (the old code never called iounmap()) and simplifies the error path by dropping the manual cleanup in ndfc_probe(). There is no overlapping memory-region concern introduced by this change: each supported board DT describes a single ndfc node with a unique 0x2000 register region, and the EBC parent uses dcr-reg rather than a MEM reg resource, so the newly added request_mem_region() cannot conflict with an existing reservation. Distinct chip selects map to distinct 64-bit physical addresses, so CS instances do not overlap. Assisted-by: opencode:hy3-free Signed-off-by: Rosen Penev --- drivers/mtd/nand/raw/ndfc.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/mtd/nand/raw/ndfc.c b/drivers/mtd/nand/raw/ndfc.c index a48274297d3b..6bb22de1f206 100644 --- a/drivers/mtd/nand/raw/ndfc.c +++ b/drivers/mtd/nand/raw/ndfc.c @@ -185,11 +185,16 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc, static int ndfc_probe(struct platform_device *ofdev) { struct ndfc_controller *ndfc; + void __iomem *ndfcbase; const __be32 *reg; u32 ccr; u32 cs; int err, len = 0; + ndfcbase = devm_platform_ioremap_resource(ofdev, 0); + if (IS_ERR(ndfcbase)) + return PTR_ERR(ndfcbase); + /* Read the reg property to get the chip select */ reg = of_get_property(ofdev->dev.of_node, "reg", &len); if (reg == NULL || len != 12) { @@ -210,11 +215,7 @@ static int ndfc_probe(struct platform_device *ofdev) ndfc->ofdev = ofdev; dev_set_drvdata(&ofdev->dev, ndfc); - ndfc->ndfcbase = of_iomap(ofdev->dev.of_node, 0); - if (!ndfc->ndfcbase) { - dev_err(&ofdev->dev, "failed to get memory\n"); - return -EIO; - } + ndfc->ndfcbase = ndfcbase; ccr = NDFC_CCR_BS(ndfc->chip_select); @@ -232,13 +233,7 @@ static int ndfc_probe(struct platform_device *ofdev) iowrite32be(be32_to_cpup(reg), ndfc->ndfcbase + offset); } - err = ndfc_chip_init(ndfc, ofdev->dev.of_node); - if (err) { - iounmap(ndfc->ndfcbase); - return err; - } - - return 0; + return ndfc_chip_init(ndfc, ofdev->dev.of_node); } static void ndfc_remove(struct platform_device *ofdev) -- 2.55.0