Re: [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]

 



Hmm. Slight breakage - msp430_ir_tasklet should be unconditionally
terminated. Fixed version attached.

-- 
| Darren Salt    | linux or ds at              | nr. Ashington, | Toon
| RISC OS, Linux | youmustbejoking,demon,co,uk | Northumberland | Army
| + Buy local produce. Try to walk or cycle. TRANSPORT CAUSES GLOBAL WARMING.

If you really want to know, you won't ask me.
budget-ci: IR-related error-trapping and shutdown fixups and verbosity
From: Darren Salt <linux@xxxxxxxxxxxxxxxxxxxxxxxxxxx>

Report errors from input_register_device, but don't try to unregister and
shutdown if the input driver wasn't initialised - failure here shouldn't be
considered to be a problem.

Shut down the IR device earlier in budget_ci_detach.

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,14 @@
 
 	if (budget_ci->budget.ci_present)
 		ciintf_deinit(budget_ci);
+
+	tasklet_kill(&budget_ci->ir.msp430_irq_tasklet);
+	if (budget_ci->budget.ir_present)
+		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;
 
 	u32 buffer_width;
 	u32 buffer_height;
_______________________________________________

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