[PATCH 3/4] budget-ci: IR-related error-trapping and shutdown fixups and verbosity

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Report errors from input_register_device.

Don't try to unregister and shutdown the IR device if the input driver wasn't
initialised; also, shut it down a little earlier.

Signed-off-by: Darren Salt <linux@xxxxxxxxxxxxxxxxxxxxxxxxxxx>

diff --git a/linux/drivers/media/dvb/ttpci/budget-ci.c b/linux/drivers/media/dvb/ttpci/budget-ci.c
--- a/linux/drivers/media/dvb/ttpci/budget-ci.c	Wed Mar 22 13:45:34 2006
+++ b/linux/drivers/media/dvb/ttpci/budget-ci.c	Wed Mar 22 16:26:21 2006
@@ -191,6 +191,9 @@
 	struct saa7146_dev *saa = budget_ci->budget.dev;
 	struct input_dev *input_dev;
 	int i;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
+	int error;
+#endif
 
 	budget_ci->ir.dev = input_dev = input_allocate_device();
 	if (!input_dev)
@@ -225,7 +228,17 @@
 		if (key_map[i])
 			set_bit(key_map[i], input_dev->keybit);
 
-	input_register_device(budget_ci->ir.dev);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
+	error = input_register_device(input_dev);
+	if (error) {
+		input_free_device(input_dev);
+		budget_ci->ir.dev = NULL;
+		printk(KERN_ERR "budget_ci: could not init driver for IR device (code %d)\n", error);
+		return error;
+	}
+#else   
+	input_register_device(input_dev);
+#endif
 
 	input_dev->timer.function = msp430_ir_debounce;
 
@@ -243,10 +256,11 @@
 	saa7146_write(saa, IER, saa7146_read(saa, IER) & ~MASK_06);
 	saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
 
-	if (del_timer(&dev->timer))
-		input_event(dev, EV_KEY, key_map[dev->repeat_key], !!0);
-
-	input_unregister_device(dev);
+	if (dev) {
+		if (del_timer(&dev->timer))
+			input_event(dev, EV_KEY, key_map[dev->repeat_key], !!0);
+		input_unregister_device(dev);
+	}
 }
 
 static int ciintf_read_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address)
@@ -1035,7 +1049,7 @@
 	tasklet_init(&budget_ci->ir.msp430_irq_tasklet, msp430_ir_interrupt,
 		     (unsigned long) budget_ci);
 
-	msp430_ir_init(budget_ci);
+	budget_ci->budget.ir_present = !msp430_ir_init(budget_ci);
 
 	ciintf_init(budget_ci);
 
@@ -1053,13 +1067,15 @@
 
 	if (budget_ci->budget.ci_present)
 		ciintf_deinit(budget_ci);
+
+	if (budget_ci->budget.ir_present) {
+		tasklet_kill(&budget_ci->ir.msp430_irq_tasklet);
+		msp430_ir_deinit(budget_ci);
+	}
+
 	if (budget_ci->budget.dvb_frontend)
 		dvb_unregister_frontend(budget_ci->budget.dvb_frontend);
 	err = ttpci_budget_deinit(&budget_ci->budget);
-
-	tasklet_kill(&budget_ci->ir.msp430_irq_tasklet);
-
-	msp430_ir_deinit(budget_ci);
 
 	// disable frontend and CI interface
 	saa7146_setgpio(saa, 2, SAA7146_GPIO_INPUT);
diff --git a/linux/drivers/media/dvb/ttpci/budget.h b/linux/drivers/media/dvb/ttpci/budget.h
--- a/linux/drivers/media/dvb/ttpci/budget.h	Wed Mar 22 13:45:34 2006
+++ b/linux/drivers/media/dvb/ttpci/budget.h	Wed Mar 22 16:26:21 2006
@@ -67,8 +67,10 @@
 	struct semaphore pid_mutex;
 #endif
 
-	int ci_present;
 	int video_port;
+
+	u8 ci_present;
+	u8 ir_present;
 
 	u8 tsf;
 	u32 ttbp;

_______________________________________________

linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux