Skip to content

Commit c3b605d

Browse files
committed
Save in desc->pulses the pulses value * 2 to count only the pulse
and not the toggle status change.
1 parent 4fcbfc8 commit c3b605d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

soft_pwm.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ static ssize_t pwm_store(
105105
}else if(strcmp(attr->attr.name, "period")==0){
106106
desc->period = (unsigned int)value;
107107
}else if(strcmp(attr->attr.name, "pulses")==0){
108+
if (value>0)
109+
desc->pulses = (unsigned int)value*2;
110+
else
108111
desc->pulses = (unsigned int)value;
109112
}
110113
desc->next_tick = ktime_get();
@@ -305,7 +308,7 @@ static int __init soft_pwm_init(void){
305308
struct timespec tp;
306309

307310
int status;
308-
printk(KERN_INFO "SoftPWM v0.1-acme initializing.\n");
311+
printk(KERN_INFO "SoftPWM v0.2-acme initializing.\n");
309312

310313
hrtimer_get_res(CLOCK_MONOTONIC, &tp);
311314
printk(KERN_INFO "Clock resolution is %ldns\n", tp.tv_nsec);

0 commit comments

Comments
 (0)