pwm: sun4i: redundant assignment to variable pval
diff mbox series

Message ID 20191002100844.10490-1-colin.king@canonical.com
State Accepted
Headers show
Series
  • pwm: sun4i: redundant assignment to variable pval
Related show

Commit Message

Colin King Oct. 2, 2019, 10:08 a.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Variable pval is being assigned a value that is never read. The
assignment is redundant and hence can be removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/pwm/pwm-sun4i.c | 1 -
 1 file changed, 1 deletion(-)

Comments

Uwe Kleine-K├Ânig Oct. 2, 2019, 10:16 a.m. UTC | #1
On Wed, Oct 02, 2019 at 11:08:44AM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Variable pval is being assigned a value that is never read. The
> assignment is redundant and hence can be removed.
> 
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/pwm/pwm-sun4i.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c
> index 6f5840a1a82d..53970d4ba695 100644
> --- a/drivers/pwm/pwm-sun4i.c
> +++ b/drivers/pwm/pwm-sun4i.c
> @@ -156,7 +156,6 @@ static int sun4i_pwm_calculate(struct sun4i_pwm_chip *sun4i_pwm,
>  	if (sun4i_pwm->data->has_prescaler_bypass) {
>  		/* First, test without any prescaler when available */
>  		prescaler = PWM_PRESCAL_MASK;
> -		pval = 1;
>  		/*
>  		 * When not using any prescaler, the clock period in nanoseconds
>  		 * is not an integer so round it half up instead of

Looks fine, the issue exists since
deb9c462f4e539cc7f8389b9855eb7a507c78e7e.

You can even make pval a local variable for the second for loop.

Best regards
Uwe
Thierry Reding Oct. 2, 2019, 10:39 a.m. UTC | #2
On Wed, Oct 02, 2019 at 11:08:44AM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Variable pval is being assigned a value that is never read. The
> assignment is redundant and hence can be removed.
> 
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/pwm/pwm-sun4i.c | 1 -
>  1 file changed, 1 deletion(-)

Applied, thanks.

Thierry
Dan Carpenter Oct. 2, 2019, 1:25 p.m. UTC | #3
On Wed, Oct 02, 2019 at 11:08:44AM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Variable pval is being assigned a value that is never read. The
> assignment is redundant and hence can be removed.
> 
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/pwm/pwm-sun4i.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c
> index 6f5840a1a82d..53970d4ba695 100644
> --- a/drivers/pwm/pwm-sun4i.c
> +++ b/drivers/pwm/pwm-sun4i.c
> @@ -156,7 +156,6 @@ static int sun4i_pwm_calculate(struct sun4i_pwm_chip *sun4i_pwm,
>  	if (sun4i_pwm->data->has_prescaler_bypass) {
>  		/* First, test without any prescaler when available */
>  		prescaler = PWM_PRESCAL_MASK;
> -		pval = 1;
>  		/*
>  		 * When not using any prescaler, the clock period in nanoseconds
>  		 * is not an integer so round it half up instead of

Are you sure?  It looks used to me.

regards,
dan carpenter
Colin King Oct. 2, 2019, 1:28 p.m. UTC | #4
On 02/10/2019 14:25, Dan Carpenter wrote:
> On Wed, Oct 02, 2019 at 11:08:44AM +0100, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Variable pval is being assigned a value that is never read. The
>> assignment is redundant and hence can be removed.
>>
>> Addresses-Coverity: ("Unused value")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>  drivers/pwm/pwm-sun4i.c | 1 -
>>  1 file changed, 1 deletion(-)
>>
>> diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c
>> index 6f5840a1a82d..53970d4ba695 100644
>> --- a/drivers/pwm/pwm-sun4i.c
>> +++ b/drivers/pwm/pwm-sun4i.c
>> @@ -156,7 +156,6 @@ static int sun4i_pwm_calculate(struct sun4i_pwm_chip *sun4i_pwm,
>>  	if (sun4i_pwm->data->has_prescaler_bypass) {
>>  		/* First, test without any prescaler when available */
>>  		prescaler = PWM_PRESCAL_MASK;
>> -		pval = 1;
>>  		/*
>>  		 * When not using any prescaler, the clock period in nanoseconds
>>  		 * is not an integer so round it half up instead of
> 
> Are you sure?  It looks used to me.

It's only read in a do_div() and before that it is being assigned:

                        pval = prescaler_table[prescaler];
                        div = clk_rate;
                        do_div(div, pval);

so the assigned value of pval = 1 is never read

Colin
> 
> regards,
> dan carpenter
>
Dan Carpenter Oct. 2, 2019, 1:29 p.m. UTC | #5
On Wed, Oct 02, 2019 at 04:25:06PM +0300, Dan Carpenter wrote:
> On Wed, Oct 02, 2019 at 11:08:44AM +0100, Colin King wrote:
> > From: Colin Ian King <colin.king@canonical.com>
> > 
> > Variable pval is being assigned a value that is never read. The
> > assignment is redundant and hence can be removed.
> > 
> > Addresses-Coverity: ("Unused value")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> >  drivers/pwm/pwm-sun4i.c | 1 -
> >  1 file changed, 1 deletion(-)
> > 
> > diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c
> > index 6f5840a1a82d..53970d4ba695 100644
> > --- a/drivers/pwm/pwm-sun4i.c
> > +++ b/drivers/pwm/pwm-sun4i.c
> > @@ -156,7 +156,6 @@ static int sun4i_pwm_calculate(struct sun4i_pwm_chip *sun4i_pwm,
> >  	if (sun4i_pwm->data->has_prescaler_bypass) {
> >  		/* First, test without any prescaler when available */
> >  		prescaler = PWM_PRESCAL_MASK;
> > -		pval = 1;
> >  		/*
> >  		 * When not using any prescaler, the clock period in nanoseconds
> >  		 * is not an integer so round it half up instead of
> 
> Are you sure?  It looks used to me.

Ah.  Never mind.  My tree was out of date.

regards,
dan carpenter
Colin King Oct. 2, 2019, 1:30 p.m. UTC | #6
On 02/10/2019 14:29, Dan Carpenter wrote:
> On Wed, Oct 02, 2019 at 04:25:06PM +0300, Dan Carpenter wrote:
>> On Wed, Oct 02, 2019 at 11:08:44AM +0100, Colin King wrote:
>>> From: Colin Ian King <colin.king@canonical.com>
>>>
>>> Variable pval is being assigned a value that is never read. The
>>> assignment is redundant and hence can be removed.
>>>
>>> Addresses-Coverity: ("Unused value")
>>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>>> ---
>>>  drivers/pwm/pwm-sun4i.c | 1 -
>>>  1 file changed, 1 deletion(-)
>>>
>>> diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c
>>> index 6f5840a1a82d..53970d4ba695 100644
>>> --- a/drivers/pwm/pwm-sun4i.c
>>> +++ b/drivers/pwm/pwm-sun4i.c
>>> @@ -156,7 +156,6 @@ static int sun4i_pwm_calculate(struct sun4i_pwm_chip *sun4i_pwm,
>>>  	if (sun4i_pwm->data->has_prescaler_bypass) {
>>>  		/* First, test without any prescaler when available */
>>>  		prescaler = PWM_PRESCAL_MASK;
>>> -		pval = 1;
>>>  		/*
>>>  		 * When not using any prescaler, the clock period in nanoseconds
>>>  		 * is not an integer so round it half up instead of
>>
>> Are you sure?  It looks used to me.
> 
> Ah.  Never mind.  My tree was out of date.

No problem. I appreciated you eyeballing my fixes.
> 
> regards,
> dan carpenter
>

Patch
diff mbox series

diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c
index 6f5840a1a82d..53970d4ba695 100644
--- a/drivers/pwm/pwm-sun4i.c
+++ b/drivers/pwm/pwm-sun4i.c
@@ -156,7 +156,6 @@  static int sun4i_pwm_calculate(struct sun4i_pwm_chip *sun4i_pwm,
 	if (sun4i_pwm->data->has_prescaler_bypass) {
 		/* First, test without any prescaler when available */
 		prescaler = PWM_PRESCAL_MASK;
-		pval = 1;
 		/*
 		 * When not using any prescaler, the clock period in nanoseconds
 		 * is not an integer so round it half up instead of