mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: rui_feng@realsil.com.cn
Cc: arnd@arndb.de, dan.carpenter@oracle.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] misc: rtsx: Fix impossible condition
Date: Tue, 19 Nov 2019 08:58:59 +0100	[thread overview]
Message-ID: <20191119075859.GC1858193@kroah.com> (raw)
In-Reply-To: <1574148825-2797-1-git-send-email-rui_feng@realsil.com.cn>

On Tue, Nov 19, 2019 at 03:33:45PM +0800, rui_feng@realsil.com.cn wrote:
> From: Rui Feng <rui_feng@realsil.com.cn>
> 
> A u8 can only go up to 255, condition n > 396 is
> impossible, so change u8 to u16.
> 
> Signed-off-by: Rui Feng <rui_feng@realsil.com.cn>
> ---
>  drivers/misc/cardreader/rts5261.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/misc/cardreader/rts5261.c b/drivers/misc/cardreader/rts5261.c
> index 32dcec2..8dba0bf 100644
> --- a/drivers/misc/cardreader/rts5261.c
> +++ b/drivers/misc/cardreader/rts5261.c
> @@ -628,7 +628,8 @@ int rts5261_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,
>  		u8 ssc_depth, bool initial_mode, bool double_clk, bool vpclk)
>  {
>  	int err, clk;
> -	u8 n, clk_divider, mcu_cnt, div;
> +	u16 n;
> +	u8 clk_divider, mcu_cnt, div;
>  	static const u8 depth[] = {
>  		[RTSX_SSC_DEPTH_4M] = RTS5261_SSC_DEPTH_4M,
>  		[RTSX_SSC_DEPTH_2M] = RTS5261_SSC_DEPTH_2M,
> @@ -661,9 +662,9 @@ int rts5261_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,
>  		return 0;
>  
>  	if (pcr->ops->conv_clk_and_div_n)
> -		n = (u8)pcr->ops->conv_clk_and_div_n(clk, CLK_TO_DIV_N);
> +		n = (u16)pcr->ops->conv_clk_and_div_n(clk, CLK_TO_DIV_N);
>  	else
> -		n = (u8)(clk - 4);
> +		n = (u16)(clk - 4);

Why is the cast now needed?  Same for everywhere else.

thanks,

greg k-h

      reply	other threads:[~2019-11-19  7:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-19  7:33 rui_feng
2019-11-19  7:58 ` Greg KH [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=20191119075859.GC1858193@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=arnd@arndb.de \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rui_feng@realsil.com.cn \
    /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

Powered by JetHome