// SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) 2017 Free Electrons * * Authors: * Boris Brezillon <[email protected]> * Peter Pan <[email protected]> */ #define pr_fmt(fmt) … #include <linux/module.h> #include <linux/mtd/nand.h> /** * nanddev_isbad() - Check if a block is bad * @nand: NAND device * @pos: position pointing to the block we want to check * * Return: true if the block is bad, false otherwise. */ bool nanddev_isbad(struct nand_device *nand, const struct nand_pos *pos) { … } EXPORT_SYMBOL_GPL(…); /** * nanddev_markbad() - Mark a block as bad * @nand: NAND device * @pos: position of the block to mark bad * * Mark a block bad. This function is updating the BBT if available and * calls the low-level markbad hook (nand->ops->markbad()). * * Return: 0 in case of success, a negative error code otherwise. */ int nanddev_markbad(struct nand_device *nand, const struct nand_pos *pos) { … } EXPORT_SYMBOL_GPL(…); /** * nanddev_isreserved() - Check whether an eraseblock is reserved or not * @nand: NAND device * @pos: NAND position to test * * Checks whether the eraseblock pointed by @pos is reserved or not. * * Return: true if the eraseblock is reserved, false otherwise. */ bool nanddev_isreserved(struct nand_device *nand, const struct nand_pos *pos) { … } EXPORT_SYMBOL_GPL(…); /** * nanddev_erase() - Erase a NAND portion * @nand: NAND device * @pos: position of the block to erase * * Erases the block if it's not bad. * * Return: 0 in case of success, a negative error code otherwise. */ static int nanddev_erase(struct nand_device *nand, const struct nand_pos *pos) { … } /** * nanddev_mtd_erase() - Generic mtd->_erase() implementation for NAND devices * @mtd: MTD device * @einfo: erase request * * This is a simple mtd->_erase() implementation iterating over all blocks * concerned by @einfo and calling nand->ops->erase() on each of them. * * Note that mtd->_erase should not be directly assigned to this helper, * because there's no locking here. NAND specialized layers should instead * implement there own wrapper around nanddev_mtd_erase() taking the * appropriate lock before calling nanddev_mtd_erase(). * * Return: 0 in case of success, a negative error code otherwise. */ int nanddev_mtd_erase(struct mtd_info *mtd, struct erase_info *einfo) { … } EXPORT_SYMBOL_GPL(…); /** * nanddev_mtd_max_bad_blocks() - Get the maximum number of bad eraseblock on * a specific region of the NAND device * @mtd: MTD device * @offs: offset of the NAND region * @len: length of the NAND region * * Default implementation for mtd->_max_bad_blocks(). Only works if * nand->memorg.max_bad_eraseblocks_per_lun is > 0. * * Return: a positive number encoding the maximum number of eraseblocks on a * portion of memory, a negative error code otherwise. */ int nanddev_mtd_max_bad_blocks(struct mtd_info *mtd, loff_t offs, size_t len) { … } EXPORT_SYMBOL_GPL(…); /** * nanddev_get_ecc_engine() - Find and get a suitable ECC engine * @nand: NAND device */ static int nanddev_get_ecc_engine(struct nand_device *nand) { … } /** * nanddev_put_ecc_engine() - Dettach and put the in-use ECC engine * @nand: NAND device */ static int nanddev_put_ecc_engine(struct nand_device *nand) { … } /** * nanddev_find_ecc_configuration() - Find a suitable ECC configuration * @nand: NAND device */ static int nanddev_find_ecc_configuration(struct nand_device *nand) { … } /** * nanddev_ecc_engine_init() - Initialize an ECC engine for the chip * @nand: NAND device */ int nanddev_ecc_engine_init(struct nand_device *nand) { … } EXPORT_SYMBOL_GPL(…); /** * nanddev_ecc_engine_cleanup() - Cleanup ECC engine initializations * @nand: NAND device */ void nanddev_ecc_engine_cleanup(struct nand_device *nand) { … } EXPORT_SYMBOL_GPL(…); /** * nanddev_init() - Initialize a NAND device * @nand: NAND device * @ops: NAND device operations * @owner: NAND device owner * * Initializes a NAND device object. Consistency checks are done on @ops and * @nand->memorg. Also takes care of initializing the BBT. * * Return: 0 in case of success, a negative error code otherwise. */ int nanddev_init(struct nand_device *nand, const struct nand_ops *ops, struct module *owner) { … } EXPORT_SYMBOL_GPL(…); /** * nanddev_cleanup() - Release resources allocated in nanddev_init() * @nand: NAND device * * Basically undoes what has been done in nanddev_init(). */ void nanddev_cleanup(struct nand_device *nand) { … } EXPORT_SYMBOL_GPL(…); MODULE_DESCRIPTION(…) …; MODULE_AUTHOR(…) …; MODULE_LICENSE(…) …;