diff options
author | Devin Heitmueller <dheitmueller@kernellabs.com> | 2009-11-19 23:15:54 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-02-26 13:10:43 -0500 |
commit | d68b687b1e322e7325b1458d799e8234997e4ccd (patch) | |
tree | 57b63b7f8ec2505582a944df31e6139f60c9265a /drivers/media/video/cx18/cx18-alsa-main.c | |
parent | 4a8cfe6a5c158133f57c2e8476f259366d4bdc4d (diff) |
V4L/DVB: cx18: rework cx18-alsa module loading to support automatic loading
Restructure the way the module gets loaded so that it gets loaded automatically
when cx18 is loaded, and make it work properly if there are multiple cards
present (since the old code would only take one opportunity to connect to cx18
instances when the module first loaded).
This work was sponsored by ONELAN Limited.
Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx18/cx18-alsa-main.c')
-rw-r--r-- | drivers/media/video/cx18/cx18-alsa-main.c | 38 |
1 files changed, 6 insertions, 32 deletions
diff --git a/drivers/media/video/cx18/cx18-alsa-main.c b/drivers/media/video/cx18/cx18-alsa-main.c index 3c339774522a..6433ff0ad859 100644 --- a/drivers/media/video/cx18/cx18-alsa-main.c +++ b/drivers/media/video/cx18/cx18-alsa-main.c | |||
@@ -190,11 +190,9 @@ err_exit: | |||
190 | return ret; | 190 | return ret; |
191 | } | 191 | } |
192 | 192 | ||
193 | static int __init cx18_alsa_init_callback(struct device *dev, void *data) | 193 | int cx18_alsa_load(struct cx18 *cx) |
194 | { | 194 | { |
195 | struct v4l2_device *v4l2_dev = dev_get_drvdata(dev); | 195 | struct v4l2_device *v4l2_dev = &cx->v4l2_dev; |
196 | int *count = data; | ||
197 | struct cx18 *cx; | ||
198 | struct cx18_stream *s; | 196 | struct cx18_stream *s; |
199 | 197 | ||
200 | if (v4l2_dev == NULL) { | 198 | if (v4l2_dev == NULL) { |
@@ -227,41 +225,16 @@ static int __init cx18_alsa_init_callback(struct device *dev, void *data) | |||
227 | __func__); | 225 | __func__); |
228 | } else { | 226 | } else { |
229 | CX18_DEBUG_ALSA_INFO("%s: created cx18 ALSA interface instance " | 227 | CX18_DEBUG_ALSA_INFO("%s: created cx18 ALSA interface instance " |
230 | "%d\n", __func__, *count); | 228 | "\n", __func__); |
231 | (*count)++; | ||
232 | } | 229 | } |
233 | return 0; | 230 | return 0; |
234 | } | 231 | } |
235 | 232 | ||
236 | static int __init cx18_alsa_init(void) | 233 | static int __init cx18_alsa_init(void) |
237 | { | 234 | { |
238 | struct device_driver *drv; | ||
239 | int count = 0; | ||
240 | int ret; | ||
241 | |||
242 | printk(KERN_INFO "cx18-alsa: module loading...\n"); | 235 | printk(KERN_INFO "cx18-alsa: module loading...\n"); |
243 | 236 | cx18_ext_init = &cx18_alsa_load; | |
244 | drv = driver_find("cx18", &pci_bus_type); | 237 | return 0; |
245 | if (drv == NULL) { | ||
246 | printk("cx18-alsa: drv was null\n"); | ||
247 | return -ENODEV; | ||
248 | } | ||
249 | ret = driver_for_each_device(drv, NULL, &count, | ||
250 | cx18_alsa_init_callback); | ||
251 | put_driver(drv); | ||
252 | |||
253 | if (count == 0) { | ||
254 | printk(KERN_ERR "cx18-alsa: no cx18 cards found with a PCM " | ||
255 | "capture stream allocated\n"); | ||
256 | ret = -ENODEV; | ||
257 | } else { | ||
258 | printk(KERN_INFO "cx18-alsa: ALSA interface(s) created for %d " | ||
259 | "cx18 card(s)\n", count); | ||
260 | ret = 0; | ||
261 | } | ||
262 | |||
263 | printk(KERN_INFO "cx18-alsa: module load complete\n"); | ||
264 | return ret; | ||
265 | } | 238 | } |
266 | 239 | ||
267 | static void snd_cx18_exit(struct snd_cx18_card *cxsc) | 240 | static void snd_cx18_exit(struct snd_cx18_card *cxsc) |
@@ -308,6 +281,7 @@ static void cx18_alsa_exit(void) | |||
308 | ret = driver_for_each_device(drv, NULL, NULL, cx18_alsa_exit_callback); | 281 | ret = driver_for_each_device(drv, NULL, NULL, cx18_alsa_exit_callback); |
309 | put_driver(drv); | 282 | put_driver(drv); |
310 | 283 | ||
284 | cx18_ext_init = NULL; | ||
311 | printk(KERN_INFO "cx18-alsa: module unload complete\n"); | 285 | printk(KERN_INFO "cx18-alsa: module unload complete\n"); |
312 | } | 286 | } |
313 | 287 | ||