[linux-dvb] [patch 1/8] budget-ci IR: groundwork for following patches

David Härdeman david at hardeman.nu
Tue Oct 3 02:01:51 CEST 2006


This patch lays down some groundwork for later budget-ci patches. The bulk
of this consists of moving a few members into a new struct and renaming a
few of them.

It also allocates extra space for the device name (the "name" field in
/proc/bus/input/devices and in the relevant sysfs dir) to avoid truncation
and uses snprintf rather than sprintf in case the extra space shouldn't be
enough.

Taken from Darren Salt's dvb-ir patchset

Signed-off-by: Darren Salt <linux at youmustbejoking.demon.co.uk>
Signed-off-by: David Härdeman <david at hardeman.nu>


Index: v4l-dvb/linux/drivers/media/dvb/ttpci/budget-ci.c
===================================================================
--- v4l-dvb.orig/linux/drivers/media/dvb/ttpci/budget-ci.c	2006-10-02 18:59:39.000000000 +0200
+++ v4l-dvb/linux/drivers/media/dvb/ttpci/budget-ci.c	2006-10-02 18:59:42.000000000 +0200
@@ -65,15 +65,19 @@
 #define SLOTSTATUS_READY	8
 #define SLOTSTATUS_OCCUPIED	(SLOTSTATUS_PRESENT|SLOTSTATUS_RESET|SLOTSTATUS_READY)
 
+struct budget_ci_ir {
+	struct input_dev *dev;
+	struct tasklet_struct msp430_irq_tasklet;
+	char name[72]; /* 40 + 32 for (struct saa7146_dev).name */
+};
+
 struct budget_ci {
 	struct budget budget;
-	struct input_dev *input_dev;
-	struct tasklet_struct msp430_irq_tasklet;
 	struct tasklet_struct ciintf_irq_tasklet;
 	int slot_status;
 	int ci_irq;
 	struct dvb_ca_en50221 ca;
-	char ir_dev_name[50];
+	struct budget_ci_ir ir;
 	u8 tuner_pll_address; /* used for philips_tdm1316l configs */
 };
 
@@ -149,7 +153,7 @@
 static void msp430_ir_interrupt(unsigned long data)
 {
 	struct budget_ci *budget_ci = (struct budget_ci *) data;
-	struct input_dev *dev = budget_ci->input_dev;
+	struct input_dev *dev = budget_ci->ir.dev;
 	unsigned int code =
 		ttpci_budget_debiread(&budget_ci->budget, DEBINOSWAP, DEBIADDR_IR, 2, 1, 0) >> 8;
 
@@ -185,23 +189,23 @@
 static int msp430_ir_init(struct budget_ci *budget_ci)
 {
 	struct saa7146_dev *saa = budget_ci->budget.dev;
-	struct input_dev *input_dev;
+	struct input_dev *input_dev = budget_ci->ir.dev;
 	int i;
 
-	budget_ci->input_dev = input_dev = input_allocate_device();
+	budget_ci->ir.dev = input_dev = input_allocate_device();
 	if (!input_dev)
 		return -ENOMEM;
 
-	sprintf(budget_ci->ir_dev_name, "Budget-CI dvb ir receiver %s", saa->name);
-
-	input_dev->name = budget_ci->ir_dev_name;
+	snprintf(budget_ci->ir.name, sizeof(budget_ci->ir.name),
+		 "Budget-CI dvb ir receiver %s", saa->name);
+	input_dev->name = budget_ci->ir.name;
 
 	set_bit(EV_KEY, input_dev->evbit);
 	for (i = 0; i < ARRAY_SIZE(key_map); i++)
 		if (key_map[i])
 			set_bit(key_map[i], input_dev->keybit);
 
-	input_register_device(budget_ci->input_dev);
+	input_register_device(budget_ci->ir.dev);
 
 	input_dev->timer.function = msp430_ir_debounce;
 
@@ -214,7 +218,7 @@
 static void msp430_ir_deinit(struct budget_ci *budget_ci)
 {
 	struct saa7146_dev *saa = budget_ci->budget.dev;
-	struct input_dev *dev = budget_ci->input_dev;
+	struct input_dev *dev = budget_ci->ir.dev;
 
 	saa7146_write(saa, IER, saa7146_read(saa, IER) & ~MASK_06);
 	saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
@@ -533,7 +537,7 @@
 	dprintk(8, "dev: %p, budget_ci: %p\n", dev, budget_ci);
 
 	if (*isr & MASK_06)
-		tasklet_schedule(&budget_ci->msp430_irq_tasklet);
+		tasklet_schedule(&budget_ci->ir.msp430_irq_tasklet);
 
 	if (*isr & MASK_10)
 		ttpci_budget_irq10_handler(dev, isr);
@@ -1089,7 +1093,7 @@
 		return err;
 	}
 
-	tasklet_init(&budget_ci->msp430_irq_tasklet, msp430_ir_interrupt,
+	tasklet_init(&budget_ci->ir.msp430_irq_tasklet, msp430_ir_interrupt,
 		     (unsigned long) budget_ci);
 
 	msp430_ir_init(budget_ci);
@@ -1118,7 +1122,7 @@
 	}
 	err = ttpci_budget_deinit(&budget_ci->budget);
 
-	tasklet_kill(&budget_ci->msp430_irq_tasklet);
+	tasklet_kill(&budget_ci->ir.msp430_irq_tasklet);
 
 	msp430_ir_deinit(budget_ci);
 

--
David Härdeman




More information about the linux-dvb mailing list