Skip to content

Commit d45bc58

Browse files
Marc GonzalezBoris Brezillon
authored andcommitted
mtd: nand: import nand_hw_control_init()
The code to initialize a struct nand_hw_control is duplicated across several drivers. Factorize it using an inline function. Signed-off-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
1 parent 29b4817 commit d45bc58

14 files changed

Lines changed: 20 additions & 26 deletions

File tree

‎drivers/mtd/nand/bf5xx_nand.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,8 +761,7 @@ static int bf5xx_nand_probe(struct platform_device *pdev)
761761

762762
platform_set_drvdata(pdev, info);
763763

764-
spin_lock_init(&info->controller.lock);
765-
init_waitqueue_head(&info->controller.wq);
764+
nand_hw_control_init(&info->controller);
766765

767766
info->device = &pdev->dev;
768767
info->platform = plat;

‎drivers/mtd/nand/brcmnand/brcmnand.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2370,8 +2370,7 @@ int brcmnand_probe(struct platform_device *pdev, struct brcmnand_soc *soc)
23702370

23712371
init_completion(&ctrl->done);
23722372
init_completion(&ctrl->dma_done);
2373-
spin_lock_init(&ctrl->controller.lock);
2374-
init_waitqueue_head(&ctrl->controller.wq);
2373+
nand_hw_control_init(&ctrl->controller);
23752374
INIT_LIST_HEAD(&ctrl->host_list);
23762375

23772376
/* NAND register range */

‎drivers/mtd/nand/docg4.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,8 +1249,7 @@ static void __init init_mtd_structs(struct mtd_info *mtd)
12491249
nand->options = NAND_BUSWIDTH_16 | NAND_NO_SUBPAGE_WRITE;
12501250
nand->IO_ADDR_R = nand->IO_ADDR_W = doc->virtadr + DOC_IOSPACE_DATA;
12511251
nand->controller = &nand->hwcontrol;
1252-
spin_lock_init(&nand->controller->lock);
1253-
init_waitqueue_head(&nand->controller->wq);
1252+
nand_hw_control_init(nand->controller);
12541253

12551254
/* methods */
12561255
nand->cmdfunc = docg4_command;

‎drivers/mtd/nand/fsl_elbc_nand.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -879,8 +879,7 @@ static int fsl_elbc_nand_probe(struct platform_device *pdev)
879879
}
880880
elbc_fcm_ctrl->counter++;
881881

882-
spin_lock_init(&elbc_fcm_ctrl->controller.lock);
883-
init_waitqueue_head(&elbc_fcm_ctrl->controller.wq);
882+
nand_hw_control_init(&elbc_fcm_ctrl->controller);
884883
fsl_lbc_ctrl_dev->nand = elbc_fcm_ctrl;
885884
} else {
886885
elbc_fcm_ctrl = fsl_lbc_ctrl_dev->nand;

‎drivers/mtd/nand/fsl_ifc_nand.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -987,8 +987,7 @@ static int fsl_ifc_nand_probe(struct platform_device *dev)
987987
ifc_nand_ctrl->addr = NULL;
988988
fsl_ifc_ctrl_dev->nand = ifc_nand_ctrl;
989989

990-
spin_lock_init(&ifc_nand_ctrl->controller.lock);
991-
init_waitqueue_head(&ifc_nand_ctrl->controller.wq);
990+
nand_hw_control_init(&ifc_nand_ctrl->controller);
992991
} else {
993992
ifc_nand_ctrl = fsl_ifc_ctrl_dev->nand;
994993
}

‎drivers/mtd/nand/jz4780_nand.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,8 @@ static int jz4780_nand_probe(struct platform_device *pdev)
368368
nfc->dev = dev;
369369
nfc->num_banks = num_banks;
370370

371-
spin_lock_init(&nfc->controller.lock);
371+
nand_hw_control_init(&nfc->controller);
372372
INIT_LIST_HEAD(&nfc->chips);
373-
init_waitqueue_head(&nfc->controller.wq);
374373

375374
ret = jz4780_nand_init_chips(nfc, pdev);
376375
if (ret) {

‎drivers/mtd/nand/nand_base.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3191,8 +3191,7 @@ static void nand_set_defaults(struct nand_chip *chip, int busw)
31913191

31923192
if (!chip->controller) {
31933193
chip->controller = &chip->hwcontrol;
3194-
spin_lock_init(&chip->controller->lock);
3195-
init_waitqueue_head(&chip->controller->wq);
3194+
nand_hw_control_init(chip->controller);
31963195
}
31973196

31983197
}

‎drivers/mtd/nand/ndfc.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,7 @@ static int ndfc_probe(struct platform_device *ofdev)
218218
ndfc = &ndfc_ctrl[cs];
219219
ndfc->chip_select = cs;
220220

221-
spin_lock_init(&ndfc->ndfc_control.lock);
222-
init_waitqueue_head(&ndfc->ndfc_control.wq);
221+
nand_hw_control_init(&ndfc->ndfc_control);
223222
ndfc->ofdev = ofdev;
224223
dev_set_drvdata(&ofdev->dev, ndfc);
225224

‎drivers/mtd/nand/pxa3xx_nand.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,8 +1810,7 @@ static int alloc_nand_resource(struct platform_device *pdev)
18101810
chip->cmdfunc = nand_cmdfunc;
18111811
}
18121812

1813-
spin_lock_init(&chip->controller->lock);
1814-
init_waitqueue_head(&chip->controller->wq);
1813+
nand_hw_control_init(chip->controller);
18151814
info->clk = devm_clk_get(&pdev->dev, NULL);
18161815
if (IS_ERR(info->clk)) {
18171816
dev_err(&pdev->dev, "failed to get nand clock\n");

‎drivers/mtd/nand/qcom_nandc.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,8 +1957,7 @@ static int qcom_nandc_alloc(struct qcom_nand_controller *nandc)
19571957
INIT_LIST_HEAD(&nandc->desc_list);
19581958
INIT_LIST_HEAD(&nandc->host_list);
19591959

1960-
spin_lock_init(&nandc->controller.lock);
1961-
init_waitqueue_head(&nandc->controller.wq);
1960+
nand_hw_control_init(&nandc->controller);
19621961

19631962
return 0;
19641963
}

0 commit comments

Comments
 (0)