From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To: Arvind Yadav <arvind.yadav.cs@gmail.com>
Cc: gregkh@linuxfoundation.org, nicolas.ferre@microchip.com,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2] misc: atmel-ssc: Handle return value of clk_prepare_enable and clk_prepare
Date: Sun, 4 Jun 2017 00:17:53 +0200 [thread overview]
Message-ID: <20170603221753.lfiqthuc7dxy3dmc@piout.net> (raw)
In-Reply-To: <3a6a9ccd68fe298ab33009eaaace85c5af73e1ea.1496381884.git.arvind.yadav.cs@gmail.com>
Hi,
It is getting tiring to get patches that are nor even compile tested
resulting from whatever static analysis tool you used.
This patch has almost no value and v1 was clearly wrong.
Do you realize clk_prepare and clk_prepare_enable will never fail for
the SSC?
On 02/06/2017 at 11:09:02 +0530, Arvind Yadav wrote:
> clk_prepare_enable() and clk_prepare() can fail here and
> we must check its return value.
>
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> ---
> drivers/misc/atmel-ssc.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c
> index b2a0340..df34b81 100644
> --- a/drivers/misc/atmel-ssc.c
> +++ b/drivers/misc/atmel-ssc.c
> @@ -30,6 +30,7 @@ struct ssc_device *ssc_request(unsigned int ssc_num)
> {
> int ssc_valid = 0;
> struct ssc_device *ssc;
> + int ret;
>
> spin_lock(&user_lock);
> list_for_each_entry(ssc, &ssc_list, list) {
> @@ -60,7 +61,11 @@ struct ssc_device *ssc_request(unsigned int ssc_num)
> ssc->user++;
> spin_unlock(&user_lock);
>
> - clk_prepare(ssc->clk);
> + ret = clk_prepare(ssc->clk);
> + if (ret) {
> + pr_err("Failed to prepare clock\n");
> + return ERR_PTR(ret);
> + }
>
> return ssc;
> }
> @@ -195,6 +200,7 @@ static int ssc_probe(struct platform_device *pdev)
> struct resource *regs;
> struct ssc_device *ssc;
> const struct atmel_ssc_platform_data *plat_dat;
> + int ret;
>
> ssc = devm_kzalloc(&pdev->dev, sizeof(struct ssc_device), GFP_KERNEL);
> if (!ssc) {
> @@ -229,7 +235,9 @@ static int ssc_probe(struct platform_device *pdev)
> }
>
> /* disable all interrupts */
> - clk_prepare_enable(ssc->clk);
> + ret = clk_prepare_enable(ssc->clk);
> + if (ret)
> + return ret;
> ssc_writel(ssc->regs, IDR, -1);
> ssc_readl(ssc->regs, SR);
> clk_disable_unprepare(ssc->clk);
> --
> 1.9.1
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
--
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
next prev parent reply other threads:[~2017-06-03 22:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-02 5:39 Arvind Yadav
2017-06-03 9:50 ` Greg KH
2017-06-03 22:17 ` Alexandre Belloni [this message]
2017-06-05 9:23 ` Arvind Yadav
2017-06-05 9:36 ` Alexandre Belloni
2017-06-05 12:05 ` Greg KH
2017-06-05 13:13 ` Alexandre Belloni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170603221753.lfiqthuc7dxy3dmc@piout.net \
--to=alexandre.belloni@free-electrons.com \
--cc=arvind.yadav.cs@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®