diff options
author | David Hardeman <david@hardeman.nu> | 2006-12-02 18:16:05 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-12-10 06:05:09 -0500 |
commit | dd2f398ccb73530a99582e972aa57e3ed2fd73c6 (patch) | |
tree | a5760a9e9a96a49ed50fa255e90700bf3ae39ca0 /drivers/media | |
parent | 5cfbacd0d3ee0c9f68e1ad3f24c4e1f879cc47a7 (diff) |
V4L/DVB (4875): budget-ci IR: groundwork for following patches
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@youmustbejoking.demon.co.uk>
Signed-off-by: David Hardeman <david@hardeman.nu>
Signed-off-by: Andrew de Quincey <adq_dvb@lidskialf.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/dvb/ttpci/budget-ci.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c index 25d0dfc1f585..2893e752745b 100644 --- a/drivers/media/dvb/ttpci/budget-ci.c +++ b/drivers/media/dvb/ttpci/budget-ci.c | |||
@@ -72,15 +72,19 @@ | |||
72 | #define SLOTSTATUS_READY 8 | 72 | #define SLOTSTATUS_READY 8 |
73 | #define SLOTSTATUS_OCCUPIED (SLOTSTATUS_PRESENT|SLOTSTATUS_RESET|SLOTSTATUS_READY) | 73 | #define SLOTSTATUS_OCCUPIED (SLOTSTATUS_PRESENT|SLOTSTATUS_RESET|SLOTSTATUS_READY) |
74 | 74 | ||
75 | struct budget_ci_ir { | ||
76 | struct input_dev *dev; | ||
77 | struct tasklet_struct msp430_irq_tasklet; | ||
78 | char name[72]; /* 40 + 32 for (struct saa7146_dev).name */ | ||
79 | }; | ||
80 | |||
75 | struct budget_ci { | 81 | struct budget_ci { |
76 | struct budget budget; | 82 | struct budget budget; |
77 | struct input_dev *input_dev; | ||
78 | struct tasklet_struct msp430_irq_tasklet; | ||
79 | struct tasklet_struct ciintf_irq_tasklet; | 83 | struct tasklet_struct ciintf_irq_tasklet; |
80 | int slot_status; | 84 | int slot_status; |
81 | int ci_irq; | 85 | int ci_irq; |
82 | struct dvb_ca_en50221 ca; | 86 | struct dvb_ca_en50221 ca; |
83 | char ir_dev_name[50]; | 87 | struct budget_ci_ir ir; |
84 | u8 tuner_pll_address; /* used for philips_tdm1316l configs */ | 88 | u8 tuner_pll_address; /* used for philips_tdm1316l configs */ |
85 | }; | 89 | }; |
86 | 90 | ||
@@ -156,7 +160,7 @@ static void msp430_ir_debounce(unsigned long data) | |||
156 | static void msp430_ir_interrupt(unsigned long data) | 160 | static void msp430_ir_interrupt(unsigned long data) |
157 | { | 161 | { |
158 | struct budget_ci *budget_ci = (struct budget_ci *) data; | 162 | struct budget_ci *budget_ci = (struct budget_ci *) data; |
159 | struct input_dev *dev = budget_ci->input_dev; | 163 | struct input_dev *dev = budget_ci->ir.dev; |
160 | unsigned int code = | 164 | unsigned int code = |
161 | ttpci_budget_debiread(&budget_ci->budget, DEBINOSWAP, DEBIADDR_IR, 2, 1, 0) >> 8; | 165 | ttpci_budget_debiread(&budget_ci->budget, DEBINOSWAP, DEBIADDR_IR, 2, 1, 0) >> 8; |
162 | 166 | ||
@@ -191,17 +195,17 @@ static void msp430_ir_interrupt(unsigned long data) | |||
191 | static int msp430_ir_init(struct budget_ci *budget_ci) | 195 | static int msp430_ir_init(struct budget_ci *budget_ci) |
192 | { | 196 | { |
193 | struct saa7146_dev *saa = budget_ci->budget.dev; | 197 | struct saa7146_dev *saa = budget_ci->budget.dev; |
194 | struct input_dev *input_dev; | 198 | struct input_dev *input_dev = budget_ci->ir.dev; |
195 | int i; | 199 | int i; |
196 | int err; | 200 | int err; |
197 | 201 | ||
198 | input_dev = input_allocate_device(); | 202 | budget_ci->ir.dev = input_dev = input_allocate_device(); |
199 | if (!input_dev) | 203 | if (!input_dev) |
200 | return -ENOMEM; | 204 | return -ENOMEM; |
201 | 205 | ||
202 | sprintf(budget_ci->ir_dev_name, "Budget-CI dvb ir receiver %s", saa->name); | 206 | snprintf(budget_ci->ir.name, sizeof(budget_ci->ir.name), |
203 | 207 | "Budget-CI dvb ir receiver %s", saa->name); | |
204 | input_dev->name = budget_ci->ir_dev_name; | 208 | input_dev->name = budget_ci->ir.name; |
205 | 209 | ||
206 | set_bit(EV_KEY, input_dev->evbit); | 210 | set_bit(EV_KEY, input_dev->evbit); |
207 | for (i = 0; i < ARRAY_SIZE(key_map); i++) | 211 | for (i = 0; i < ARRAY_SIZE(key_map); i++) |
@@ -214,9 +218,9 @@ static int msp430_ir_init(struct budget_ci *budget_ci) | |||
214 | return err; | 218 | return err; |
215 | } | 219 | } |
216 | 220 | ||
217 | input_dev->timer.function = msp430_ir_debounce; | 221 | input_register_device(budget_ci->ir.dev); |
218 | 222 | ||
219 | budget_ci->input_dev = input_dev; | 223 | input_dev->timer.function = msp430_ir_debounce; |
220 | 224 | ||
221 | saa7146_write(saa, IER, saa7146_read(saa, IER) | MASK_06); | 225 | saa7146_write(saa, IER, saa7146_read(saa, IER) | MASK_06); |
222 | saa7146_setgpio(saa, 3, SAA7146_GPIO_IRQHI); | 226 | saa7146_setgpio(saa, 3, SAA7146_GPIO_IRQHI); |
@@ -227,7 +231,7 @@ static int msp430_ir_init(struct budget_ci *budget_ci) | |||
227 | static void msp430_ir_deinit(struct budget_ci *budget_ci) | 231 | static void msp430_ir_deinit(struct budget_ci *budget_ci) |
228 | { | 232 | { |
229 | struct saa7146_dev *saa = budget_ci->budget.dev; | 233 | struct saa7146_dev *saa = budget_ci->budget.dev; |
230 | struct input_dev *dev = budget_ci->input_dev; | 234 | struct input_dev *dev = budget_ci->ir.dev; |
231 | 235 | ||
232 | saa7146_write(saa, IER, saa7146_read(saa, IER) & ~MASK_06); | 236 | saa7146_write(saa, IER, saa7146_read(saa, IER) & ~MASK_06); |
233 | saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT); | 237 | saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT); |
@@ -548,7 +552,7 @@ static void budget_ci_irq(struct saa7146_dev *dev, u32 * isr) | |||
548 | dprintk(8, "dev: %p, budget_ci: %p\n", dev, budget_ci); | 552 | dprintk(8, "dev: %p, budget_ci: %p\n", dev, budget_ci); |
549 | 553 | ||
550 | if (*isr & MASK_06) | 554 | if (*isr & MASK_06) |
551 | tasklet_schedule(&budget_ci->msp430_irq_tasklet); | 555 | tasklet_schedule(&budget_ci->ir.msp430_irq_tasklet); |
552 | 556 | ||
553 | if (*isr & MASK_10) | 557 | if (*isr & MASK_10) |
554 | ttpci_budget_irq10_handler(dev, isr); | 558 | ttpci_budget_irq10_handler(dev, isr); |
@@ -1105,7 +1109,7 @@ static int budget_ci_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio | |||
1105 | return err; | 1109 | return err; |
1106 | } | 1110 | } |
1107 | 1111 | ||
1108 | tasklet_init(&budget_ci->msp430_irq_tasklet, msp430_ir_interrupt, | 1112 | tasklet_init(&budget_ci->ir.msp430_irq_tasklet, msp430_ir_interrupt, |
1109 | (unsigned long) budget_ci); | 1113 | (unsigned long) budget_ci); |
1110 | 1114 | ||
1111 | msp430_ir_init(budget_ci); | 1115 | msp430_ir_init(budget_ci); |
@@ -1134,7 +1138,7 @@ static int budget_ci_detach(struct saa7146_dev *dev) | |||
1134 | } | 1138 | } |
1135 | err = ttpci_budget_deinit(&budget_ci->budget); | 1139 | err = ttpci_budget_deinit(&budget_ci->budget); |
1136 | 1140 | ||
1137 | tasklet_kill(&budget_ci->msp430_irq_tasklet); | 1141 | tasklet_kill(&budget_ci->ir.msp430_irq_tasklet); |
1138 | 1142 | ||
1139 | msp430_ir_deinit(budget_ci); | 1143 | msp430_ir_deinit(budget_ci); |
1140 | 1144 | ||