diff mbox series

[v6,10/10] clocksource: timer-dm: Check prescaler value

Message ID 1514887799-24605-11-git-send-email-j-keerthy@ti.com
State Superseded
Headers show
Series omap: dmtimer: Move driver out of plat-omap | expand

Commit Message

J, KEERTHY Jan. 2, 2018, 10:09 a.m. UTC
From: Ladislav Michl <ladis@linux-mips.org>

Invalid prescaler value is silently ignored. Fix that
by returning -EINVAL in such case. As invalid value
disabled use of the prescaler, use -1 explicitely for
that purpose.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
---
 drivers/clocksource/timer-dm.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Ladislav Michl Jan. 4, 2018, 10:47 p.m. UTC | #1
On Tue, Jan 02, 2018 at 03:39:59PM +0530, Keerthy wrote:
> From: Ladislav Michl <ladis@linux-mips.org>
> 
> Invalid prescaler value is silently ignored. Fix that
> by returning -EINVAL in such case. As invalid value
> disabled use of the prescaler, use -1 explicitely for
> that purpose.
> 
> Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
> ---
>  drivers/clocksource/timer-dm.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/clocksource/timer-dm.c b/drivers/clocksource/timer-dm.c
> index 60db173..01a9cb0 100644
> --- a/drivers/clocksource/timer-dm.c
> +++ b/drivers/clocksource/timer-dm.c
> @@ -672,6 +672,9 @@ int omap_dm_timer_set_prescaler(struct omap_dm_timer *timer, int prescaler)
>  	if (prescaler >= 0x00 && prescaler <= 0x07) {
>  		l |= OMAP_TIMER_CTRL_PRE;
>  		l |= prescaler << 2;
> +	} else {
> +		if (prescaler != -1)
> +			return -EINVAL;

Argh... This is actually wrong, as it leaves timer enabled.
I suggest simply dropping this patch and I'll rethink whole
approach a bit later (and better).

>  	}
>  	omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l);
>  

Sorry for the noise,
	ladis
--
To unsubscribe from this list: send the line "unsubscribe linux-pwm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
J, KEERTHY Jan. 7, 2018, 3:56 p.m. UTC | #2
On 1/5/2018 4:17 AM, Ladislav Michl wrote:
> On Tue, Jan 02, 2018 at 03:39:59PM +0530, Keerthy wrote:
>> From: Ladislav Michl <ladis@linux-mips.org>
>>
>> Invalid prescaler value is silently ignored. Fix that
>> by returning -EINVAL in such case. As invalid value
>> disabled use of the prescaler, use -1 explicitely for
>> that purpose.
>>
>> Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
>> ---
>>   drivers/clocksource/timer-dm.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/clocksource/timer-dm.c b/drivers/clocksource/timer-dm.c
>> index 60db173..01a9cb0 100644
>> --- a/drivers/clocksource/timer-dm.c
>> +++ b/drivers/clocksource/timer-dm.c
>> @@ -672,6 +672,9 @@ int omap_dm_timer_set_prescaler(struct omap_dm_timer *timer, int prescaler)
>>   	if (prescaler >= 0x00 && prescaler <= 0x07) {
>>   		l |= OMAP_TIMER_CTRL_PRE;
>>   		l |= prescaler << 2;
>> +	} else {
>> +		if (prescaler != -1)
>> +			return -EINVAL;
> 
> Argh... This is actually wrong, as it leaves timer enabled.
> I suggest simply dropping this patch and I'll rethink whole
> approach a bit later (and better).

Okay. I hope the rest 9 patches work well for you.

> 
>>   	}
>>   	omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l);
>>   
> 
> Sorry for the noise,
> 	ladis
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-pwm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ladislav Michl Jan. 7, 2018, 7:26 p.m. UTC | #3
On Sun, Jan 07, 2018 at 09:26:44PM +0530, Keerthy wrote:
> On 1/5/2018 4:17 AM, Ladislav Michl wrote:
> > On Tue, Jan 02, 2018 at 03:39:59PM +0530, Keerthy wrote:
> > > From: Ladislav Michl <ladis@linux-mips.org>
> > > 
> > > Invalid prescaler value is silently ignored. Fix that
> > > by returning -EINVAL in such case. As invalid value
> > > disabled use of the prescaler, use -1 explicitely for
> > > that purpose.
> > > 
> > > Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
> > > ---
> > >   drivers/clocksource/timer-dm.c | 3 +++
> > >   1 file changed, 3 insertions(+)
> > > 
> > > diff --git a/drivers/clocksource/timer-dm.c b/drivers/clocksource/timer-dm.c
> > > index 60db173..01a9cb0 100644
> > > --- a/drivers/clocksource/timer-dm.c
> > > +++ b/drivers/clocksource/timer-dm.c
> > > @@ -672,6 +672,9 @@ int omap_dm_timer_set_prescaler(struct omap_dm_timer *timer, int prescaler)
> > >   	if (prescaler >= 0x00 && prescaler <= 0x07) {
> > >   		l |= OMAP_TIMER_CTRL_PRE;
> > >   		l |= prescaler << 2;
> > > +	} else {
> > > +		if (prescaler != -1)
> > > +			return -EINVAL;
> > 
> > Argh... This is actually wrong, as it leaves timer enabled.
> > I suggest simply dropping this patch and I'll rethink whole
> > approach a bit later (and better).
> 
> Okay. I hope the rest 9 patches work well for you.

Yes. I rebased event capture patches on top of this serie (based on
linux-next) and will post them during next week for review. Fixed
patch will be included (note, it is not really needed for your serie
as noone is calling this function).

> > 
> > >   	}
> > >   	omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l);
> > 
> > Sorry for the noise,
> > 	ladis
> > 
--
To unsubscribe from this list: send the line "unsubscribe linux-pwm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox series

Patch

diff --git a/drivers/clocksource/timer-dm.c b/drivers/clocksource/timer-dm.c
index 60db173..01a9cb0 100644
--- a/drivers/clocksource/timer-dm.c
+++ b/drivers/clocksource/timer-dm.c
@@ -672,6 +672,9 @@  int omap_dm_timer_set_prescaler(struct omap_dm_timer *timer, int prescaler)
 	if (prescaler >= 0x00 && prescaler <= 0x07) {
 		l |= OMAP_TIMER_CTRL_PRE;
 		l |= prescaler << 2;
+	} else {
+		if (prescaler != -1)
+			return -EINVAL;
 	}
 	omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l);