From: Stephen Boyd <sboyd@codeaurora.org>
To: linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2] clk: let clk_disable() return immediately if clk is NULL or error
Date: Thu, 14 Apr 2016 00:33:41 +0000 [thread overview]
Message-ID: <20160414003341.GH14441@codeaurora.org> (raw)
In-Reply-To: <CAK7LNASW+D0B_k97r__AZeYDR5UqNPqn_j1aoQepHz-bGgV2ng@mail.gmail.com>
On 04/08, Masahiro Yamada wrote:
>
>
> This makes our driver programming life easier.
>
>
> For example, let's see drivers/tty/serial/8250/8250_of.c
>
>
> The "clock-frequency" DT property takes precedence over "clocks" property.
> So, it is valid to probe the driver with a NULL pointer for info->clk.
>
>
> if (of_property_read_u32(np, "clock-frequency", &clk)) {
>
> /* Get clk rate through clk driver if present */
> info->clk = devm_clk_get(&ofdev->dev, NULL);
> if (IS_ERR(info->clk)) {
> dev_warn(&ofdev->dev,
> "clk or clock-frequency not defined\n");
> return PTR_ERR(info->clk);
> }
>
> ret = clk_prepare_enable(info->clk);
> if (ret < 0)
> return ret;
>
> clk = clk_get_rate(info->clk);
> }
>
>
> As a result, we need to make sure the clk pointer is valid
> before calling clk_disable_unprepare().
>
>
> If we could support pointer checking in callees, we would be able to
> clean-up lots of clock consumers.
>
>
I'm not sure if you meant to use that example for the error
pointer case? It bails out if clk_get() returns an error pointer.
I'm all for a no-op in clk_disable()/unprepare() when the pointer
is NULL. But when it's an error pointer the driver should be
handling it and bail out before it would ever call enable/prepare
on it or disable/unprepare.
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
next prev parent reply other threads:[~2016-04-14 0:33 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-05 1:51 [PATCH v2] clk: let clk_disable() return immediately if clk is NULL or error Masahiro Yamada
2016-04-08 0:33 ` Stephen Boyd
2016-04-08 1:52 ` Masahiro Yamada
2016-04-14 0:33 ` Stephen Boyd [this message]
2016-04-14 1:49 ` Masahiro Yamada
2016-04-16 0:04 ` Stephen Boyd
2016-04-08 10:06 ` Ralf Baechle
2016-04-08 11:15 ` Masahiro Yamada
2016-04-14 0:40 ` Stephen Boyd
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=20160414003341.GH14441@codeaurora.org \
--to=sboyd@codeaurora.org \
--cc=linux-arm-kernel@lists.infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).