From mboxrd@z Thu Jan 1 00:00:00 1970 From: arnd@arndb.de (Arnd Bergmann) Date: Wed, 22 Feb 2012 12:29:17 +0000 Subject: [PATCH 6/7] rtc: sa1100: enable clk support In-Reply-To: <1329815096-6200-7-git-send-email-haojian.zhuang@marvell.com> References: <1329815096-6200-1-git-send-email-haojian.zhuang@marvell.com> <1329815096-6200-7-git-send-email-haojian.zhuang@marvell.com> Message-ID: <201202221229.17934.arnd@arndb.de> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Tuesday 21 February 2012, Haojian Zhuang wrote: > @@ -306,6 +308,13 @@ static int sa1100_rtc_probe(struct platform_device *pdev) > if (!info) > return -ENOMEM; > > + info->clk = clk_get(&pdev->dev, NULL); > + if (IS_ERR(info->clk)) { > + dev_err(&pdev->dev, "failed to find rtc clock source\n"); > + ret = PTR_ERR(info->clk); > + goto err_clk; > + } > + clk_prepare_enable(info->clk); > info->iobase = res->start; > info->iosize = resource_size(res); > info->irq_1hz = irq_1hz; > @@ -379,6 +388,9 @@ err_dev: > iounmap(info->reg_base); > err_map: > platform_set_drvdata(pdev, NULL); > + clk_disable_unprepare(info->clk); > + clk_put(info->clk); > +err_clk: > kfree(info); > return ret; I wonder whether it would be easier to just make the clk handling conditional here, like info->clk = clk_get(&pdev->dev, NULL); if (PTR_ERR(info->clk) == -ENOENT) info->clk = NULL; if (IS_ERR(info->clk)) { ret = PTR_ERR(info->clk); goto err_clk; } if (info->clk) clk_prepare_enable(info->clk); ... if (info->clk) { clk_disable_unprepare(info->clk); clk_put(info->clk); } With this, you would no longer need to add dummy clocks in platforms that really have no clock handling. Arnd