diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-07 10:43:43 +0000 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-07 10:43:43 +0000 |
commit | c698fbc627c51ba8ad0e434848499cb4412072da (patch) | |
tree | a266d31e4f91cd5a98ba209b55e21825e6a51f80 | |
parent | bf6a78d38280357d2cbb3d3e84ec17f52dae1370 (diff) | |
download | mediapointer-dvb-s2-c698fbc627c51ba8ad0e434848499cb4412072da.tar.gz mediapointer-dvb-s2-c698fbc627c51ba8ad0e434848499cb4412072da.tar.bz2 |
ir-kbd-i2c: Prevent general protection fault on rmmod
From: Jean Delvare <khali@linux-fr.org>
The removal of the timer which polls the infrared input is racy.
Replacing the timer with a delayed work solves the problem.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | linux/drivers/media/video/ir-kbd-i2c.c | 22 | ||||
-rw-r--r-- | linux/include/media/ir-kbd-i2c.h | 3 |
2 files changed, 7 insertions, 18 deletions
diff --git a/linux/drivers/media/video/ir-kbd-i2c.c b/linux/drivers/media/video/ir-kbd-i2c.c index a99aea49a..a0b78706d 100644 --- a/linux/drivers/media/video/ir-kbd-i2c.c +++ b/linux/drivers/media/video/ir-kbd-i2c.c @@ -280,12 +280,6 @@ static void ir_key_poll(struct IR_i2c *ir) } } -static void ir_timer(unsigned long data) -{ - struct IR_i2c *ir = (struct IR_i2c*)data; - schedule_work(&ir->work); -} - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) static void ir_work(void *data) #else @@ -295,7 +289,7 @@ static void ir_work(struct work_struct *work) #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) struct IR_i2c *ir = data; #else - struct IR_i2c *ir = container_of(work, struct IR_i2c, work); + struct IR_i2c *ir = container_of(work, struct IR_i2c, work.work); #endif int polling_interval = 100; @@ -305,7 +299,7 @@ static void ir_work(struct work_struct *work) polling_interval = 50; ir_key_poll(ir); - mod_timer(&ir->timer, jiffies + msecs_to_jiffies(polling_interval)); + schedule_delayed_work(&ir->work, msecs_to_jiffies(polling_interval)); } /* ----------------------------------------------------------------------- */ @@ -462,14 +456,11 @@ static int ir_attach(struct i2c_adapter *adap, int addr, /* start polling via eventd */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) - INIT_WORK(&ir->work, ir_work, ir); + INIT_DELAYED_WORK(&ir->work, ir_work, ir); #else - INIT_WORK(&ir->work, ir_work); + INIT_DELAYED_WORK(&ir->work, ir_work); #endif - init_timer(&ir->timer); - ir->timer.function = ir_timer; - ir->timer.data = (unsigned long)ir; - schedule_work(&ir->work); + schedule_delayed_work(&ir->work, 0); return 0; @@ -486,8 +477,7 @@ static int ir_detach(struct i2c_client *client) struct IR_i2c *ir = i2c_get_clientdata(client); /* kill outstanding polls */ - del_timer_sync(&ir->timer); - flush_scheduled_work(); + cancel_delayed_work_sync(&ir->work); /* unregister devices */ input_unregister_device(ir->input); diff --git a/linux/include/media/ir-kbd-i2c.h b/linux/include/media/ir-kbd-i2c.h index 00fa57eb9..07963d705 100644 --- a/linux/include/media/ir-kbd-i2c.h +++ b/linux/include/media/ir-kbd-i2c.h @@ -14,8 +14,7 @@ struct IR_i2c { /* Used to avoid fast repeating */ unsigned char old; - struct work_struct work; - struct timer_list timer; + struct delayed_work work; char phys[32]; int (*get_key)(struct IR_i2c*, u32*, u32*); }; |