From: James Hilliard <james.hilliard1@gmail.com>
To: Miquel Raynal <miquel.raynal@bootlin.com>,
Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>
Cc: Maxim Levitsky <maximlevitsky@gmail.com>,
Boris Brezillon <bbrezillon@kernel.org>,
Brian Norris <computersforpeace@gmail.com>,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
James Hilliard <james.hilliard1@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH 4/4] mtd: rawnand: r852: restore SmartMedia and ECC initialization
Date: Sun, 08 Nov 2026 18:29:23 -0700 [thread overview]
Message-ID: <20261108-submit-r852-smartmedia-attach-v1-v1-4-56d08c0571a2@gmail.com> (raw)
In-Reply-To: <20261108-submit-r852-smartmedia-attach-v1-v1-0-56d08c0571a2@gmail.com>
r852 uses its own NAND controller and attach_chip callback, but
sm_register_device() installs sm_attach_chip() on the unused legacy
dummy controller. nand_scan_with_ids() only calls the active controller's
callback, so the SmartMedia setup is skipped.
This leaves the generic OOB layout and bad-block criteria in place,
omits the SmartMedia bad-block marking callback, and skips rejection of
unsupported page sizes.
The same conversion removed the hardware-ECC default from probe. This
PCI driver does not set a NAND device-tree node, so rawnand_dt_init()
returns without selecting an ECC engine. The zero-initialized engine
type remains invalid and nand_scan_tail() fails with -EINVAL.
Restore the hardware-ECC default in probe. Export sm_attach_chip() and
call it from r852_attach_chip() before the ECC-engine check, so both
hardware and software ECC configurations get the media layout. Propagate
its error before scanning finishes or the MTD device is published.
Remove the unused dummy-controller setup; r852 is the only caller of
sm_register_device().
Fixes: 7ef969a04228 ("mtd: rawnand: r852: Move the ECC initialization to ->attach_chip()")
Closes: https://lore.kernel.org/r/sashiko-outbox-204208@kernel.org/
Cc: stable@vger.kernel.org
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/mtd/nand/raw/r852.c | 8 ++++++++
drivers/mtd/nand/raw/sm_common.c | 8 ++------
drivers/mtd/nand/raw/sm_common.h | 3 +++
3 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/drivers/mtd/nand/raw/r852.c b/drivers/mtd/nand/raw/r852.c
index e78606b97b42..ce7def018099 100644
--- a/drivers/mtd/nand/raw/r852.c
+++ b/drivers/mtd/nand/raw/r852.c
@@ -820,6 +820,12 @@ static irqreturn_t r852_irq(int irq, void *data)
static int r852_attach_chip(struct nand_chip *chip)
{
+ int ret;
+
+ ret = sm_attach_chip(chip);
+ if (ret)
+ return ret;
+
if (chip->ecc.engine_type != NAND_ECC_ENGINE_TYPE_ON_HOST)
return 0;
@@ -883,6 +889,8 @@ static int r852_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
chip->legacy.read_buf = r852_read_buf;
chip->legacy.write_buf = r852_write_buf;
+ chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST;
+
/* init our device structure */
dev = kzalloc_obj(struct r852_device);
diff --git a/drivers/mtd/nand/raw/sm_common.c b/drivers/mtd/nand/raw/sm_common.c
index a6387111d271..291aa21dff4f 100644
--- a/drivers/mtd/nand/raw/sm_common.c
+++ b/drivers/mtd/nand/raw/sm_common.c
@@ -167,7 +167,7 @@ static struct nand_flash_dev nand_xd_flash_ids[] = {
{NULL}
};
-static int sm_attach_chip(struct nand_chip *chip)
+int sm_attach_chip(struct nand_chip *chip)
{
struct mtd_info *mtd = nand_to_mtd(chip);
@@ -186,10 +186,7 @@ static int sm_attach_chip(struct nand_chip *chip)
return 0;
}
-
-static const struct nand_controller_ops sm_controller_ops = {
- .attach_chip = sm_attach_chip,
-};
+EXPORT_SYMBOL_GPL(sm_attach_chip);
int sm_register_device(struct mtd_info *mtd, int smartmedia)
{
@@ -200,7 +197,6 @@ int sm_register_device(struct mtd_info *mtd, int smartmedia)
chip->options |= NAND_SKIP_BBTSCAN;
/* Scan for card properties */
- chip->legacy.dummy_controller.ops = &sm_controller_ops;
flash_ids = smartmedia ? nand_smartmedia_flash_ids : nand_xd_flash_ids;
ret = nand_scan_with_ids(chip, 1, flash_ids);
if (ret)
diff --git a/drivers/mtd/nand/raw/sm_common.h b/drivers/mtd/nand/raw/sm_common.h
index 57fc9f86f9ee..599fce778fb2 100644
--- a/drivers/mtd/nand/raw/sm_common.h
+++ b/drivers/mtd/nand/raw/sm_common.h
@@ -33,6 +33,9 @@ struct sm_oob {
#define SM_SMALL_OOB_SIZE 8
+struct nand_chip;
+
+int sm_attach_chip(struct nand_chip *chip);
int sm_register_device(struct mtd_info *mtd, int smartmedia);
--
2.53.0
prev parent reply other threads:[~2026-11-09 1:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 1:29 [PATCH 0/4] mtd: rawnand: restore SmartMedia setup in r852 James Hilliard
2026-11-09 1:29 ` [PATCH 1/4] mtd: rawnand: sm_common: restore the first ECC region offset James Hilliard
2026-11-09 1:29 ` [PATCH 2/4] mtd: rawnand: sm_common: avoid recursive locking when marking bad blocks James Hilliard
2026-11-09 1:29 ` [PATCH 3/4] mtd: rawnand: r852: use the standard OOB write operation James Hilliard
2026-11-09 1:29 ` James Hilliard [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261108-submit-r852-smartmedia-attach-v1-v1-4-56d08c0571a2@gmail.com \
--to=james.hilliard1@gmail.com \
--cc=bbrezillon@kernel.org \
--cc=computersforpeace@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=maximlevitsky@gmail.com \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=stable@vger.kernel.org \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®