|
@@ -112,14 +112,19 @@ static int oxnas_nand_probe(struct platform_device *pdev)
|
|
if (count > 1)
|
|
if (count > 1)
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
|
|
|
- clk_prepare_enable(oxnas->clk);
|
|
|
|
|
|
+ err = clk_prepare_enable(oxnas->clk);
|
|
|
|
+ if (err)
|
|
|
|
+ return err;
|
|
|
|
+
|
|
device_reset_optional(&pdev->dev);
|
|
device_reset_optional(&pdev->dev);
|
|
|
|
|
|
for_each_child_of_node(np, nand_np) {
|
|
for_each_child_of_node(np, nand_np) {
|
|
chip = devm_kzalloc(&pdev->dev, sizeof(struct nand_chip),
|
|
chip = devm_kzalloc(&pdev->dev, sizeof(struct nand_chip),
|
|
GFP_KERNEL);
|
|
GFP_KERNEL);
|
|
- if (!chip)
|
|
|
|
- return -ENOMEM;
|
|
|
|
|
|
+ if (!chip) {
|
|
|
|
+ err = -ENOMEM;
|
|
|
|
+ goto err_clk_unprepare;
|
|
|
|
+ }
|
|
|
|
|
|
chip->controller = &oxnas->base;
|
|
chip->controller = &oxnas->base;
|
|
|
|
|
|
@@ -139,12 +144,12 @@ static int oxnas_nand_probe(struct platform_device *pdev)
|
|
/* Scan to find existence of the device */
|
|
/* Scan to find existence of the device */
|
|
err = nand_scan(mtd, 1);
|
|
err = nand_scan(mtd, 1);
|
|
if (err)
|
|
if (err)
|
|
- return err;
|
|
|
|
|
|
+ goto err_clk_unprepare;
|
|
|
|
|
|
err = mtd_device_register(mtd, NULL, 0);
|
|
err = mtd_device_register(mtd, NULL, 0);
|
|
if (err) {
|
|
if (err) {
|
|
nand_release(mtd);
|
|
nand_release(mtd);
|
|
- return err;
|
|
|
|
|
|
+ goto err_clk_unprepare;
|
|
}
|
|
}
|
|
|
|
|
|
oxnas->chips[nchips] = chip;
|
|
oxnas->chips[nchips] = chip;
|
|
@@ -152,12 +157,18 @@ static int oxnas_nand_probe(struct platform_device *pdev)
|
|
}
|
|
}
|
|
|
|
|
|
/* Exit if no chips found */
|
|
/* Exit if no chips found */
|
|
- if (!nchips)
|
|
|
|
- return -ENODEV;
|
|
|
|
|
|
+ if (!nchips) {
|
|
|
|
+ err = -ENODEV;
|
|
|
|
+ goto err_clk_unprepare;
|
|
|
|
+ }
|
|
|
|
|
|
platform_set_drvdata(pdev, oxnas);
|
|
platform_set_drvdata(pdev, oxnas);
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
|
|
+
|
|
|
|
+err_clk_unprepare:
|
|
|
|
+ clk_disable_unprepare(oxnas->clk);
|
|
|
|
+ return err;
|
|
}
|
|
}
|
|
|
|
|
|
static int oxnas_nand_remove(struct platform_device *pdev)
|
|
static int oxnas_nand_remove(struct platform_device *pdev)
|