mtd: rawnand: qcom: convert driver to nand_scan()
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() instead of the nand_scan_ident() + nand_scan_tail() pair. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>
This commit is contained in:
parent
fe13ae02b0
commit
6a3cec64f1
1 changed files with 26 additions and 49 deletions
|
@ -2475,10 +2475,10 @@ qcom_nandc_calc_ecc_bytes(int step_size, int strength)
|
||||||
NAND_ECC_CAPS_SINGLE(qcom_nandc_ecc_caps, qcom_nandc_calc_ecc_bytes,
|
NAND_ECC_CAPS_SINGLE(qcom_nandc_ecc_caps, qcom_nandc_calc_ecc_bytes,
|
||||||
NANDC_STEP_SIZE, 4, 8);
|
NANDC_STEP_SIZE, 4, 8);
|
||||||
|
|
||||||
static int qcom_nand_host_setup(struct qcom_nand_host *host)
|
static int qcom_nand_attach_chip(struct nand_chip *chip)
|
||||||
{
|
{
|
||||||
struct nand_chip *chip = &host->chip;
|
|
||||||
struct mtd_info *mtd = nand_to_mtd(chip);
|
struct mtd_info *mtd = nand_to_mtd(chip);
|
||||||
|
struct qcom_nand_host *host = to_qcom_nand_host(chip);
|
||||||
struct nand_ecc_ctrl *ecc = &chip->ecc;
|
struct nand_ecc_ctrl *ecc = &chip->ecc;
|
||||||
struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
|
struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
|
||||||
int cwperpage, bad_block_byte, ret;
|
int cwperpage, bad_block_byte, ret;
|
||||||
|
@ -2640,6 +2640,10 @@ static int qcom_nand_host_setup(struct qcom_nand_host *host)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct nand_controller_ops qcom_nandc_ops = {
|
||||||
|
.attach_chip = qcom_nand_attach_chip,
|
||||||
|
};
|
||||||
|
|
||||||
static int qcom_nandc_alloc(struct qcom_nand_controller *nandc)
|
static int qcom_nandc_alloc(struct qcom_nand_controller *nandc)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -2729,6 +2733,7 @@ static int qcom_nandc_alloc(struct qcom_nand_controller *nandc)
|
||||||
INIT_LIST_HEAD(&nandc->host_list);
|
INIT_LIST_HEAD(&nandc->host_list);
|
||||||
|
|
||||||
nand_controller_init(&nandc->controller);
|
nand_controller_init(&nandc->controller);
|
||||||
|
nandc->controller.ops = &qcom_nandc_ops;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2781,9 +2786,9 @@ static int qcom_nandc_setup(struct qcom_nand_controller *nandc)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qcom_nand_host_init(struct qcom_nand_controller *nandc,
|
static int qcom_nand_host_init_and_register(struct qcom_nand_controller *nandc,
|
||||||
struct qcom_nand_host *host,
|
struct qcom_nand_host *host,
|
||||||
struct device_node *dn)
|
struct device_node *dn)
|
||||||
{
|
{
|
||||||
struct nand_chip *chip = &host->chip;
|
struct nand_chip *chip = &host->chip;
|
||||||
struct mtd_info *mtd = nand_to_mtd(chip);
|
struct mtd_info *mtd = nand_to_mtd(chip);
|
||||||
|
@ -2830,30 +2835,13 @@ static int qcom_nand_host_init(struct qcom_nand_controller *nandc,
|
||||||
/* set up initial status value */
|
/* set up initial status value */
|
||||||
host->status = NAND_STATUS_READY | NAND_STATUS_WP;
|
host->status = NAND_STATUS_READY | NAND_STATUS_WP;
|
||||||
|
|
||||||
ret = nand_scan_ident(mtd, 1, NULL);
|
ret = nand_scan(mtd, 1);
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
ret = qcom_nand_host_setup(host);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int qcom_nand_mtd_register(struct qcom_nand_controller *nandc,
|
|
||||||
struct qcom_nand_host *host,
|
|
||||||
struct device_node *dn)
|
|
||||||
{
|
|
||||||
struct nand_chip *chip = &host->chip;
|
|
||||||
struct mtd_info *mtd = nand_to_mtd(chip);
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = nand_scan_tail(mtd);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = mtd_device_register(mtd, NULL, 0);
|
ret = mtd_device_register(mtd, NULL, 0);
|
||||||
if (ret)
|
if (ret)
|
||||||
nand_cleanup(mtd_to_nand(mtd));
|
nand_cleanup(chip);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -2862,28 +2850,9 @@ static int qcom_probe_nand_devices(struct qcom_nand_controller *nandc)
|
||||||
{
|
{
|
||||||
struct device *dev = nandc->dev;
|
struct device *dev = nandc->dev;
|
||||||
struct device_node *dn = dev->of_node, *child;
|
struct device_node *dn = dev->of_node, *child;
|
||||||
struct qcom_nand_host *host, *tmp;
|
struct qcom_nand_host *host;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
for_each_available_child_of_node(dn, child) {
|
|
||||||
host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL);
|
|
||||||
if (!host) {
|
|
||||||
of_node_put(child);
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = qcom_nand_host_init(nandc, host, child);
|
|
||||||
if (ret) {
|
|
||||||
devm_kfree(dev, host);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
list_add_tail(&host->node, &nandc->host_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (list_empty(&nandc->host_list))
|
|
||||||
return -ENODEV;
|
|
||||||
|
|
||||||
if (nandc->props->is_bam) {
|
if (nandc->props->is_bam) {
|
||||||
free_bam_transaction(nandc);
|
free_bam_transaction(nandc);
|
||||||
nandc->bam_txn = alloc_bam_transaction(nandc);
|
nandc->bam_txn = alloc_bam_transaction(nandc);
|
||||||
|
@ -2894,12 +2863,20 @@ static int qcom_probe_nand_devices(struct qcom_nand_controller *nandc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list_for_each_entry_safe(host, tmp, &nandc->host_list, node) {
|
for_each_available_child_of_node(dn, child) {
|
||||||
ret = qcom_nand_mtd_register(nandc, host, child);
|
host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL);
|
||||||
if (ret) {
|
if (!host) {
|
||||||
list_del(&host->node);
|
of_node_put(child);
|
||||||
devm_kfree(dev, host);
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = qcom_nand_host_init_and_register(nandc, host, child);
|
||||||
|
if (ret) {
|
||||||
|
devm_kfree(dev, host);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
list_add_tail(&host->node, &nandc->host_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list_empty(&nandc->host_list))
|
if (list_empty(&nandc->host_list))
|
||||||
|
|
Loading…
Add table
Reference in a new issue