public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@codeaurora.org>
To: sean.wang@mediatek.com
Cc: dan.carpenter@oracle.com, linux-mediatek@lists.infradead.org,
	linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] clk: mediatek: fixed static checker warning in clk_cpumux_get_parent call
Date: Wed, 12 Jul 2017 16:17:26 -0700	[thread overview]
Message-ID: <20170712231726.GQ22780@codeaurora.org> (raw)
In-Reply-To: <59fd4aa684632f1d9d2e7573a95bc42850e81690.1499701486.git.sean.wang@mediatek.com>

On 07/11, sean.wang@mediatek.com wrote:
> diff --git a/drivers/clk/mediatek/clk-cpumux.c b/drivers/clk/mediatek/clk-cpumux.c
> index edd8e69..c6a3a1a 100644
> --- a/drivers/clk/mediatek/clk-cpumux.c
> +++ b/drivers/clk/mediatek/clk-cpumux.c
> @@ -27,7 +27,6 @@ static inline struct mtk_clk_cpumux *to_mtk_clk_cpumux(struct clk_hw *_hw)
>  static u8 clk_cpumux_get_parent(struct clk_hw *hw)
>  {
>  	struct mtk_clk_cpumux *mux = to_mtk_clk_cpumux(hw);
> -	int num_parents = clk_hw_get_num_parents(hw);
>  	unsigned int val;
>  
>  	regmap_read(mux->regmap, mux->reg, &val);
> @@ -35,17 +34,18 @@ static u8 clk_cpumux_get_parent(struct clk_hw *hw)
>  	val >>= mux->shift;
>  	val &= mux->mask;
>  
> -	if (val >= num_parents)
> -		return -EINVAL;
> -

Yeah we really need to fix the get_parent() op to return a
clk_hw pointer instead. Time for another migration plan...

>  	return val;
>  }
>  
>  static int clk_cpumux_set_parent(struct clk_hw *hw, u8 index)
>  {
>  	struct mtk_clk_cpumux *mux = to_mtk_clk_cpumux(hw);
> +	int num_parents = clk_hw_get_num_parents(hw);
>  	u32 mask, val;
>  
> +	if (index >= num_parents)
> +		return -EINVAL;

When would we call this function with an invalid index? The
framework should be making sure to only call it with an index
that's valid. So perhaps this hunk can be left out?


-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

  reply	other threads:[~2017-07-12 23:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-11  2:43 [PATCH] clk: mediatek: fixed static checker warning in clk_cpumux_get_parent call sean.wang
2017-07-12 23:17 ` Stephen Boyd [this message]
2017-07-13  3:15   ` Sean Wang

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=20170712231726.GQ22780@codeaurora.org \
    --to=sboyd@codeaurora.org \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=sean.wang@mediatek.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