Re: [PATCH] remoteproc: fix a ! vs ~ typo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Dan

On 12/18/18 9:16 AM, Dan Carpenter wrote:
> This is from static analysis and not from testing.  It doesn't really
> make sense to talk about !BIT(0) so probably ~BIT(0) was intended.
> I had to cast it from unsigned long to unsigned int to silence a GCC
> warning.
> 
> Fixes: bb6869b21478 ("Peter Griffin <peter.griffin@xxxxxxxxxx>")
> Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> ---
> 
> Sorry for the crap commit message.  I'm pretty sure the static checker
> warning is correct, but I don't know what the run time impact of this
> bug would be.
> 
>  drivers/remoteproc/st_slim_rproc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/remoteproc/st_slim_rproc.c b/drivers/remoteproc/st_slim_rproc.c
> index d711d9430a4f..a646dfb9d6cd 100644
> --- a/drivers/remoteproc/st_slim_rproc.c
> +++ b/drivers/remoteproc/st_slim_rproc.c
> @@ -128,7 +128,7 @@ static int slim_rproc_start(struct rproc *rproc)
>  	writel(SLIM_STBUS_SYNC_DIS, slim_rproc->peri + SLIM_STBUS_SYNC_OFST);
>  
>  	/* enable cpu pipeline clock */
> -	writel(!SLIM_CLK_GATE_DIS,
> +	writel((unsigned int)~SLIM_CLK_GATE_DIS,
>  		slim_rproc->slimcore + SLIM_CLK_GATE_OFST);
>  
>  	/* clear int & cmd mailbox */
> @@ -167,7 +167,7 @@ static int slim_rproc_stop(struct rproc *rproc)
>  	/* disable cpu pipeline clock */
>  	writel(SLIM_CLK_GATE_DIS, slim_rproc->slimcore + SLIM_CLK_GATE_OFST);
>  
> -	writel(!SLIM_EN_RUN, slim_rproc->slimcore + SLIM_EN_OFST);
> +	writel((unsigned int)~SLIM_EN_RUN, slim_rproc->slimcore + SLIM_EN_OFST);
>  
>  	val = readl(slim_rproc->slimcore + SLIM_EN_OFST);
>  	if (val & SLIM_EN_RUN)
> 

Writing !SLIM_CLK_GATE_DIS or (unsigned int)~SLIM_CLK_GATE_DIS don't
give the same result:

!SLIM_CLK_GATE_DIS = 0

(unsigned int)~SLIM_CLK_GATE_DIS = 0xfffffffe

Patrice





[Index of Archives]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux