Skip to content

Commit fe13ae0

Browse files
committed
mtd: rawnand: sm_common: convert driver to nand_scan_with_ids()
Two helpers have been added to the core to do all kind of controller side configuration/initialization between the detection phase and the final NAND scan. Implement these hooks so that we can convert the driver to just use nand_scan_with_ids() (alternative to nand_scan() for passing a flash IDs table) instead of the nand_scan_ident() + nand_scan_tail() pair. Signed-off-by: Miquel Raynal <[email protected]> Reviewed-by: Boris Brezillon <[email protected]>
1 parent 92aa292 commit fe13ae0

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

drivers/mtd/nand/raw/sm_common.c

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -160,19 +160,9 @@ static struct nand_flash_dev nand_xd_flash_ids[] = {
160160
{NULL}
161161
};
162162

163-
int sm_register_device(struct mtd_info *mtd, int smartmedia)
163+
static int sm_attach_chip(struct nand_chip *chip)
164164
{
165-
struct nand_chip *chip = mtd_to_nand(mtd);
166-
int ret;
167-
168-
chip->options |= NAND_SKIP_BBTSCAN;
169-
170-
/* Scan for card properties */
171-
ret = nand_scan_ident(mtd, 1, smartmedia ?
172-
nand_smartmedia_flash_ids : nand_xd_flash_ids);
173-
174-
if (ret)
175-
return ret;
165+
struct mtd_info *mtd = nand_to_mtd(chip);
176166

177167
/* Bad block marker position */
178168
chip->badblockpos = 0x05;
@@ -187,8 +177,25 @@ int sm_register_device(struct mtd_info *mtd, int smartmedia)
187177
else
188178
return -ENODEV;
189179

190-
ret = nand_scan_tail(mtd);
180+
return 0;
181+
}
182+
183+
static const struct nand_controller_ops sm_controller_ops = {
184+
.attach_chip = sm_attach_chip,
185+
};
191186

187+
int sm_register_device(struct mtd_info *mtd, int smartmedia)
188+
{
189+
struct nand_chip *chip = mtd_to_nand(mtd);
190+
struct nand_flash_dev *flash_ids;
191+
int ret;
192+
193+
chip->options |= NAND_SKIP_BBTSCAN;
194+
195+
/* Scan for card properties */
196+
chip->dummy_controller.ops = &sm_controller_ops;
197+
flash_ids = smartmedia ? nand_smartmedia_flash_ids : nand_xd_flash_ids;
198+
ret = nand_scan_with_ids(mtd, 1, flash_ids);
192199
if (ret)
193200
return ret;
194201

0 commit comments

Comments
 (0)