Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mtd: spinand: Gather all the bus interface steps in one single function

Writing the quad enable bit in one helper and doing the chip
configuration in another does not make much sense from a bus interface
setup point of view.

Instead, let's create a broader helper which is going to be in charge of
all the bus configuration steps at once. This will specifically allow to
transition to octal DDR mode, and even fallback to quad (if suppoorted)
or single mode otherwise.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

+37 -25
+37 -25
drivers/mtd/nand/spi/core.c
··· 261 261 return 0; 262 262 } 263 263 264 - static int spinand_init_quad_enable(struct spinand_device *spinand) 264 + static int spinand_init_quad_enable(struct spinand_device *spinand, 265 + bool enable) 265 266 { 266 - bool enable = false; 267 - 268 - if (!(spinand->flags & SPINAND_HAS_QE_BIT)) 269 - return 0; 270 - 271 - if (spinand->op_templates->read_cache->data.buswidth == 4 || 272 - spinand->op_templates->write_cache->data.buswidth == 4 || 273 - spinand->op_templates->update_cache->data.buswidth == 4) 274 - enable = true; 275 - 276 267 return spinand_upd_cfg(spinand, CFG_QUAD_ENABLE, 277 268 enable ? CFG_QUAD_ENABLE : 0); 278 269 } ··· 1383 1392 return ret; 1384 1393 } 1385 1394 1386 - if (spinand->configure_chip) { 1387 - ret = spinand->configure_chip(spinand); 1388 - if (ret) 1389 - return ret; 1390 - } 1391 - 1392 1395 return 0; 1393 1396 } 1394 1397 ··· 1585 1600 return 0; 1586 1601 } 1587 1602 1603 + static int spinand_configure_chip(struct spinand_device *spinand) 1604 + { 1605 + bool quad_enable = false; 1606 + int ret; 1607 + 1608 + if (spinand->flags & SPINAND_HAS_QE_BIT) { 1609 + if (spinand->ssdr_op_templates.read_cache->data.buswidth == 4 || 1610 + spinand->ssdr_op_templates.write_cache->data.buswidth == 4 || 1611 + spinand->ssdr_op_templates.update_cache->data.buswidth == 4) 1612 + quad_enable = true; 1613 + } 1614 + 1615 + ret = spinand_init_quad_enable(spinand, quad_enable); 1616 + if (ret) 1617 + return ret; 1618 + 1619 + if (spinand->configure_chip) { 1620 + ret = spinand->configure_chip(spinand); 1621 + if (ret) 1622 + return ret; 1623 + } 1624 + 1625 + return ret; 1626 + } 1627 + 1588 1628 static int spinand_init_flash(struct spinand_device *spinand) 1589 1629 { 1590 1630 struct device *dev = &spinand->spimem->spi->dev; ··· 1617 1607 int ret, i; 1618 1608 1619 1609 ret = spinand_read_cfg(spinand); 1620 - if (ret) 1621 - return ret; 1622 - 1623 - ret = spinand_init_quad_enable(spinand); 1624 1610 if (ret) 1625 1611 return ret; 1626 1612 ··· 1632 1626 return ret; 1633 1627 } 1634 1628 1629 + ret = spinand_configure_chip(spinand); 1630 + if (ret) 1631 + goto manuf_cleanup; 1632 + 1635 1633 /* After power up, all blocks are locked, so unlock them here. */ 1636 1634 for (i = 0; i < nand->memorg.ntargets; i++) { 1637 1635 ret = spinand_select_target(spinand, i); 1638 1636 if (ret) 1639 - break; 1637 + goto manuf_cleanup; 1640 1638 1641 1639 ret = spinand_lock_block(spinand, BL_ALL_UNLOCKED); 1642 1640 if (ret) 1643 - break; 1641 + goto manuf_cleanup; 1644 1642 } 1645 1643 1646 - if (ret) 1647 - spinand_manufacturer_cleanup(spinand); 1644 + return 0; 1645 + 1646 + manuf_cleanup: 1647 + spinand_manufacturer_cleanup(spinand); 1648 1648 1649 1649 return ret; 1650 1650 }