[linux-oxnas] Re: [PATCH 2/6] mtd: oxnas_nand: Handle clk_prepare_enable/clk_disable_unprepare. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/linux-oxnas Archives
]
- To: Arvind Yadav <arvind.yadav.cs@xxxxxxxxx>, boris.brezillon@xxxxxxxxxxxxxxxxxx, richard@xxxxxx, dwmw2@xxxxxxxxxxxxx, computersforpeace@xxxxxxxxx, marek.vasut@xxxxxxxxx, cyrille.pitchen@xxxxxxxxxx
- Subject: [linux-oxnas] Re: [PATCH 2/6] mtd: oxnas_nand: Handle clk_prepare_enable/clk_disable_unprepare.
- From: Neil Armstrong <narmstrong@xxxxxxxxxxxx>
- Date: Tue, 1 Aug 2017 13:49:22 +0200
- Cc: linux-mtd@xxxxxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, linux-arm-kernel@xxxxxxxxxxxxxxxxxxx, linux-oxnas@xxxxxxxxxxxxxxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:organization:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=pUXErLnFHydDV/2I768VyhJZciWkznJz6qV5a06CrdE=; b=EcakaC3DWkSvocxTUfWtzN8om4E48mAMZwlDHjV0JnfLxmVCBaDLCXq9E9HNBvKpM7 0fwPk1Jh3LaiGHZfkCeGQuPQ+4bKH6OzqgUhGQ3VBJB46ru0v3GXfbkLRAw8fghtv1Dv zOPBWMysYzwoFmtqUYltAh7Ohy/zZ/s0KRwrn2Gz0ow9P2EOBZknlPMZKVI3fhK/dUOH m8AzTvxvlnTWYq8YlDA2Dc4Cu10aHkF7bmMBLwP1W3YKJO+hEmFxIW/98u3jxdWsvwb+ D+5nM++CFpWmBPxrTZKJqjbexUqJI6vG+mhMYU22rZxQ4JgSlcqvtndyBIFZHSOlI6Z7 sJVg==
- Organization: Baylibre
On 08/01/2017 01:37 PM, Arvind Yadav wrote:
> - clk_prepare_enable() can fail here and we must check its return value.
> - oxnas_nand_probe() can fail here and we must disable clock.
>
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@xxxxxxxxx>
> ---
> drivers/mtd/nand/oxnas_nand.c | 25 ++++++++++++++++++-------
> 1 file changed, 18 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/mtd/nand/oxnas_nand.c b/drivers/mtd/nand/oxnas_nand.c
> index 1b207aa..7061bb2 100644
> --- a/drivers/mtd/nand/oxnas_nand.c
> +++ b/drivers/mtd/nand/oxnas_nand.c
> @@ -112,14 +112,19 @@ static int oxnas_nand_probe(struct platform_device *pdev)
> if (count > 1)
> return -EINVAL;
>
> - clk_prepare_enable(oxnas->clk);
> + err = clk_prepare_enable(oxnas->clk);
> + if (err)
> + return err;
> +
> device_reset_optional(&pdev->dev);
>
> for_each_child_of_node(np, nand_np) {
> chip = devm_kzalloc(&pdev->dev, sizeof(struct nand_chip),
> GFP_KERNEL);
> - if (!chip)
> - return -ENOMEM;
> + if (!chip) {
> + err = -ENOMEM;
> + goto err_clk_unprepare;
> + }
>
> chip->controller = &oxnas->base;
>
> @@ -139,12 +144,12 @@ static int oxnas_nand_probe(struct platform_device *pdev)
> /* Scan to find existence of the device */
> err = nand_scan(mtd, 1);
> if (err)
> - return err;
> + goto err_clk_unprepare;
>
> err = mtd_device_register(mtd, NULL, 0);
> if (err) {
> nand_release(mtd);
> - return err;
> + goto err_clk_unprepare;
> }
>
> oxnas->chips[nchips] = chip;
> @@ -152,12 +157,18 @@ static int oxnas_nand_probe(struct platform_device *pdev)
> }
>
> /* Exit if no chips found */
> - if (!nchips)
> - return -ENODEV;
> + if (!nchips) {
> + err = -ENODEV;
> + goto err_clk_unprepare;
> + }
>
> platform_set_drvdata(pdev, oxnas);
>
> return 0;
> +
> +err_clk_unprepare:
> + clk_disable_unprepare(oxnas->clk);
> + return err;
> }
>
> static int oxnas_nand_remove(struct platform_device *pdev)
>
Indeed, Thanks,
Acked-by: Neil Armstrong <narmstrong@xxxxxxxxxxxx>