linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: vzapolskiy@gmail.com (Vladimir Zapolskiy)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2 v2] imx: optimize __clk_enable() and __clk_disable() functions.
Date: Thu, 18 Mar 2010 17:23:34 +0300	[thread overview]
Message-ID: <fcda838a1003180723x42eb01f1rcf0843aacb7b5f82@mail.gmail.com> (raw)
In-Reply-To: <1268918865-15401-1-git-send-email-vzapolskiy@gmail.com>

On Thu, Mar 18, 2010 at 4:27 PM, Vladimir Zapolskiy
<vzapolskiy@gmail.com> wrote:
> To remove unnecessary calls of functions with invalid argumets make
> the checks before a call.
>
> Signed-off-by: Vladimir Zapolskiy <vzapolskiy@gmail.com>
> ---
> ?arch/arm/plat-mxc/clock.c | ? 25 ++++++++++++-------------
> ?1 files changed, 12 insertions(+), 13 deletions(-)
>
> diff --git a/arch/arm/plat-mxc/clock.c b/arch/arm/plat-mxc/clock.c
> index 323ff8c..ec4af90 100644
> --- a/arch/arm/plat-mxc/clock.c
> +++ b/arch/arm/plat-mxc/clock.c
> @@ -50,24 +50,25 @@ static DEFINE_MUTEX(clocks_mutex);
>
> ?static void __clk_disable(struct clk *clk)
> ?{
> - ? ? ? if (clk == NULL || IS_ERR(clk))
> - ? ? ? ? ? ? ? return;
> -
> - ? ? ? __clk_disable(clk->parent);
> - ? ? ? __clk_disable(clk->secondary);
> -
> ? ? ? ?WARN_ON(!clk->usecount);
> +
> ? ? ? ?if (!(--clk->usecount) && clk->disable)
> ? ? ? ? ? ? ? ?clk->disable(clk);
> +
> + ? ? ? if (clk->secondary)
> + ? ? ? ? ? ? ? __clk_disable(clk->secondary);
> +
> + ? ? ? if (clk->parent)
> + ? ? ? ? ? ? ? __clk_disable(clk->parent);
> ?}
>
> ?static int __clk_enable(struct clk *clk)
> ?{
> - ? ? ? if (clk == NULL || IS_ERR(clk))
> - ? ? ? ? ? ? ? return -EINVAL;
> + ? ? ? if (clk->parent)
> + ? ? ? ? ? ? ? __clk_enable(clk->parent);
>
> - ? ? ? __clk_enable(clk->parent);
> - ? ? ? __clk_enable(clk->secondary);
> + ? ? ? if (clk->secondary)
> + ? ? ? ? ? ? ? __clk_enable(clk->secondary);
>
> ? ? ? ?if (clk->usecount++ == 0 && clk->enable)
> ? ? ? ? ? ? ? ?clk->enable(clk);
> @@ -99,9 +100,7 @@ EXPORT_SYMBOL(clk_enable);
> ?*/
> ?void clk_disable(struct clk *clk)
> ?{
> - ? ? ? if (clk == NULL || IS_ERR(clk))
> - ? ? ? ? ? ? ? return;
> -
> + ? ? ? BUG_ON(clk == NULL || IS_ERR(clk));
> ? ? ? ?mutex_lock(&clocks_mutex);
> ? ? ? ?__clk_disable(clk);
> ? ? ? ?mutex_unlock(&clocks_mutex);
> --
> 1.6.6.1
>
>
One potential issue is still exists, there is no valid checks and
unbinding of return values in __clk_enable() recursive calls.

With best wishes,
Vladimir

      reply	other threads:[~2010-03-18 14:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-17  7:11 [PATCH 1/2] [ARM] [IMX]: Removed superfluous checks for argument validity Vladimir Zapolskiy
2010-03-17  7:11 ` [PATCH 2/2] [ARM] [IMX]: Fix clock usecount counter from underflow Vladimir Zapolskiy
2010-03-17  9:20   ` Uwe Kleine-König
2010-03-17 10:15     ` javier Martin
2010-03-17 10:57       ` Vladimir Zapolskiy
2010-03-17 11:03     ` [PATCH 2/2 v2] [ARM] [IMX]: Fix clock use counter from underflow on multiple clk_disable() Vladimir Zapolskiy
2010-03-18  8:30       ` Uwe Kleine-König
2010-03-18 13:21         ` Vladimir Zapolskiy
2010-03-17  9:13 ` [PATCH 1/2] [ARM] [IMX]: Removed superfluous checks for argument validity Uwe Kleine-König
2010-03-17 10:34   ` Vladimir Zapolskiy
2010-03-18  8:37     ` Uwe Kleine-König
2010-03-18 13:07       ` Vladimir Zapolskiy
2010-03-18 13:27       ` [PATCH 1/2 v2] imx: optimize __clk_enable() and __clk_disable() functions Vladimir Zapolskiy
2010-03-18 14:23         ` Vladimir Zapolskiy [this message]

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=fcda838a1003180723x42eb01f1rcf0843aacb7b5f82@mail.gmail.com \
    --to=vzapolskiy@gmail.com \
    --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).