aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/ttpci/budget-ci.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor@insightbb.com>2006-11-20 08:23:04 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-12-10 06:04:52 -0500
commitb07b4783fb30dee8c542fc76ed8993108d46d6aa (patch)
tree0e57cc5887511b31e964299820a7adf37e6e45ae /drivers/media/dvb/ttpci/budget-ci.c
parentff67c614e23bf5a3c16968e2c42ab442121c4beb (diff)
V4L/DVB (4854): Handle errors from input_register_device()
Also sprinkled some input_sync() throughout the code. Acked-by: Ricardo Cerqueira <v4l@cerqueira.org> Acked-by: Oliver Endriss <o.endriss@gmx.de> Acked-by: Andrew de Quincey <adq_dvb@lidskialf.net> Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb/ttpci/budget-ci.c')
-rw-r--r--drivers/media/dvb/ttpci/budget-ci.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c
index cd5ec489af1c..25d0dfc1f585 100644
--- a/drivers/media/dvb/ttpci/budget-ci.c
+++ b/drivers/media/dvb/ttpci/budget-ci.c
@@ -143,14 +143,14 @@ static void msp430_ir_debounce(unsigned long data)
143 struct input_dev *dev = (struct input_dev *) data; 143 struct input_dev *dev = (struct input_dev *) data;
144 144
145 if (dev->rep[0] == 0 || dev->rep[0] == ~0) { 145 if (dev->rep[0] == 0 || dev->rep[0] == ~0) {
146 input_event(dev, EV_KEY, key_map[dev->repeat_key], !!0); 146 input_event(dev, EV_KEY, key_map[dev->repeat_key], 0);
147 return; 147 } else {
148 dev->rep[0] = 0;
149 dev->timer.expires = jiffies + HZ * 350 / 1000;
150 add_timer(&dev->timer);
151 input_event(dev, EV_KEY, key_map[dev->repeat_key], 2); /* REPEAT */
148 } 152 }
149 153 input_sync(dev);
150 dev->rep[0] = 0;
151 dev->timer.expires = jiffies + HZ * 350 / 1000;
152 add_timer(&dev->timer);
153 input_event(dev, EV_KEY, key_map[dev->repeat_key], 2); /* REPEAT */
154} 154}
155 155
156static void msp430_ir_interrupt(unsigned long data) 156static void msp430_ir_interrupt(unsigned long data)
@@ -169,7 +169,7 @@ static void msp430_ir_interrupt(unsigned long data)
169 return; 169 return;
170 } 170 }
171 del_timer(&dev->timer); 171 del_timer(&dev->timer);
172 input_event(dev, EV_KEY, key_map[dev->repeat_key], !!0); 172 input_event(dev, EV_KEY, key_map[dev->repeat_key], 0);
173 } 173 }
174 174
175 if (!key_map[code]) { 175 if (!key_map[code]) {
@@ -177,15 +177,14 @@ static void msp430_ir_interrupt(unsigned long data)
177 return; 177 return;
178 } 178 }
179 179
180 input_event(dev, EV_KEY, key_map[code], 1);
181 input_sync(dev);
182
180 /* initialize debounce and repeat */ 183 /* initialize debounce and repeat */
181 dev->repeat_key = code; 184 dev->repeat_key = code;
182 /* Zenith remote _always_ sends 2 sequences */ 185 /* Zenith remote _always_ sends 2 sequences */
183 dev->rep[0] = ~0; 186 dev->rep[0] = ~0;
184 /* 350 milliseconds */ 187 mod_timer(&dev->timer, jiffies + msecs_to_jiffies(350));
185 dev->timer.expires = jiffies + HZ * 350 / 1000;
186 /* MAKE */
187 input_event(dev, EV_KEY, key_map[code], !0);
188 add_timer(&dev->timer);
189 } 188 }
190} 189}
191 190
@@ -194,8 +193,9 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
194 struct saa7146_dev *saa = budget_ci->budget.dev; 193 struct saa7146_dev *saa = budget_ci->budget.dev;
195 struct input_dev *input_dev; 194 struct input_dev *input_dev;
196 int i; 195 int i;
196 int err;
197 197
198 budget_ci->input_dev = input_dev = input_allocate_device(); 198 input_dev = input_allocate_device();
199 if (!input_dev) 199 if (!input_dev)
200 return -ENOMEM; 200 return -ENOMEM;
201 201
@@ -208,10 +208,16 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
208 if (key_map[i]) 208 if (key_map[i])
209 set_bit(key_map[i], input_dev->keybit); 209 set_bit(key_map[i], input_dev->keybit);
210 210
211 input_register_device(budget_ci->input_dev); 211 err = input_register_device(input_dev);
212 if (err) {
213 input_free_device(input_dev);
214 return err;
215 }
212 216
213 input_dev->timer.function = msp430_ir_debounce; 217 input_dev->timer.function = msp430_ir_debounce;
214 218
219 budget_ci->input_dev = input_dev;
220
215 saa7146_write(saa, IER, saa7146_read(saa, IER) | MASK_06); 221 saa7146_write(saa, IER, saa7146_read(saa, IER) | MASK_06);
216 saa7146_setgpio(saa, 3, SAA7146_GPIO_IRQHI); 222 saa7146_setgpio(saa, 3, SAA7146_GPIO_IRQHI);
217 223
@@ -226,8 +232,10 @@ static void msp430_ir_deinit(struct budget_ci *budget_ci)
226 saa7146_write(saa, IER, saa7146_read(saa, IER) & ~MASK_06); 232 saa7146_write(saa, IER, saa7146_read(saa, IER) & ~MASK_06);
227 saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT); 233 saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
228 234
229 if (del_timer(&dev->timer)) 235 if (del_timer(&dev->timer)) {
230 input_event(dev, EV_KEY, key_map[dev->repeat_key], !!0); 236 input_event(dev, EV_KEY, key_map[dev->repeat_key], 0);
237 input_sync(dev);
238 }
231 239
232 input_unregister_device(dev); 240 input_unregister_device(dev);
233} 241}