diff options
Diffstat (limited to 'drivers/media/video/bt8xx/bttv-driver.c')
-rw-r--r-- | drivers/media/video/bt8xx/bttv-driver.c | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c index ccf6aa6a975b..826ca60b42e6 100644 --- a/drivers/media/video/bt8xx/bttv-driver.c +++ b/drivers/media/video/bt8xx/bttv-driver.c | |||
@@ -58,7 +58,7 @@ | |||
58 | 58 | ||
59 | 59 | ||
60 | unsigned int bttv_num; /* number of Bt848s in use */ | 60 | unsigned int bttv_num; /* number of Bt848s in use */ |
61 | struct bttv bttvs[BTTV_MAX]; | 61 | struct bttv *bttvs[BTTV_MAX]; |
62 | 62 | ||
63 | unsigned int bttv_debug; | 63 | unsigned int bttv_debug; |
64 | unsigned int bttv_verbose = 1; | 64 | unsigned int bttv_verbose = 1; |
@@ -3217,29 +3217,19 @@ err: | |||
3217 | static int bttv_open(struct file *file) | 3217 | static int bttv_open(struct file *file) |
3218 | { | 3218 | { |
3219 | int minor = video_devdata(file)->minor; | 3219 | int minor = video_devdata(file)->minor; |
3220 | struct bttv *btv = NULL; | 3220 | struct bttv *btv = video_drvdata(file); |
3221 | struct bttv_fh *fh; | 3221 | struct bttv_fh *fh; |
3222 | enum v4l2_buf_type type = 0; | 3222 | enum v4l2_buf_type type = 0; |
3223 | unsigned int i; | ||
3224 | 3223 | ||
3225 | dprintk(KERN_DEBUG "bttv: open minor=%d\n",minor); | 3224 | dprintk(KERN_DEBUG "bttv: open minor=%d\n",minor); |
3226 | 3225 | ||
3227 | lock_kernel(); | 3226 | lock_kernel(); |
3228 | for (i = 0; i < bttv_num; i++) { | 3227 | if (btv->video_dev->minor == minor) { |
3229 | if (bttvs[i].video_dev && | 3228 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
3230 | bttvs[i].video_dev->minor == minor) { | 3229 | } else if (btv->vbi_dev->minor == minor) { |
3231 | btv = &bttvs[i]; | 3230 | type = V4L2_BUF_TYPE_VBI_CAPTURE; |
3232 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 3231 | } else { |
3233 | break; | 3232 | WARN_ON(1); |
3234 | } | ||
3235 | if (bttvs[i].vbi_dev && | ||
3236 | bttvs[i].vbi_dev->minor == minor) { | ||
3237 | btv = &bttvs[i]; | ||
3238 | type = V4L2_BUF_TYPE_VBI_CAPTURE; | ||
3239 | break; | ||
3240 | } | ||
3241 | } | ||
3242 | if (NULL == btv) { | ||
3243 | unlock_kernel(); | 3233 | unlock_kernel(); |
3244 | return -ENODEV; | 3234 | return -ENODEV; |
3245 | } | 3235 | } |
@@ -3429,20 +3419,14 @@ static struct video_device bttv_video_template = { | |||
3429 | static int radio_open(struct file *file) | 3419 | static int radio_open(struct file *file) |
3430 | { | 3420 | { |
3431 | int minor = video_devdata(file)->minor; | 3421 | int minor = video_devdata(file)->minor; |
3432 | struct bttv *btv = NULL; | 3422 | struct bttv *btv = video_drvdata(file); |
3433 | struct bttv_fh *fh; | 3423 | struct bttv_fh *fh; |
3434 | unsigned int i; | ||
3435 | 3424 | ||
3436 | dprintk("bttv: open minor=%d\n",minor); | 3425 | dprintk("bttv: open minor=%d\n",minor); |
3437 | 3426 | ||
3438 | lock_kernel(); | 3427 | lock_kernel(); |
3439 | for (i = 0; i < bttv_num; i++) { | 3428 | WARN_ON(btv->radio_dev && btv->radio_dev->minor != minor); |
3440 | if (bttvs[i].radio_dev && bttvs[i].radio_dev->minor == minor) { | 3429 | if (!btv->radio_dev || btv->radio_dev->minor != minor) { |
3441 | btv = &bttvs[i]; | ||
3442 | break; | ||
3443 | } | ||
3444 | } | ||
3445 | if (NULL == btv) { | ||
3446 | unlock_kernel(); | 3430 | unlock_kernel(); |
3447 | return -ENODEV; | 3431 | return -ENODEV; |
3448 | } | 3432 | } |
@@ -4203,6 +4187,7 @@ static struct video_device *vdev_init(struct bttv *btv, | |||
4203 | vfd->parent = &btv->c.pci->dev; | 4187 | vfd->parent = &btv->c.pci->dev; |
4204 | vfd->release = video_device_release; | 4188 | vfd->release = video_device_release; |
4205 | vfd->debug = bttv_debug; | 4189 | vfd->debug = bttv_debug; |
4190 | video_set_drvdata(vfd, btv); | ||
4206 | snprintf(vfd->name, sizeof(vfd->name), "BT%d%s %s (%s)", | 4191 | snprintf(vfd->name, sizeof(vfd->name), "BT%d%s %s (%s)", |
4207 | btv->id, (btv->id==848 && btv->revision==0x12) ? "A" : "", | 4192 | btv->id, (btv->id==848 && btv->revision==0x12) ? "A" : "", |
4208 | type_name, bttv_tvcards[btv->c.type].name); | 4193 | type_name, bttv_tvcards[btv->c.type].name); |
@@ -4312,8 +4297,7 @@ static int __devinit bttv_probe(struct pci_dev *dev, | |||
4312 | if (bttv_num == BTTV_MAX) | 4297 | if (bttv_num == BTTV_MAX) |
4313 | return -ENOMEM; | 4298 | return -ENOMEM; |
4314 | printk(KERN_INFO "bttv: Bt8xx card found (%d).\n", bttv_num); | 4299 | printk(KERN_INFO "bttv: Bt8xx card found (%d).\n", bttv_num); |
4315 | btv=&bttvs[bttv_num]; | 4300 | bttvs[bttv_num] = btv = kzalloc(sizeof(*btv), GFP_KERNEL); |
4316 | memset(btv,0,sizeof(*btv)); | ||
4317 | btv->c.nr = bttv_num; | 4301 | btv->c.nr = bttv_num; |
4318 | sprintf(btv->c.name,"bttv%d",btv->c.nr); | 4302 | sprintf(btv->c.name,"bttv%d",btv->c.nr); |
4319 | 4303 | ||
@@ -4517,6 +4501,9 @@ static void __devexit bttv_remove(struct pci_dev *pci_dev) | |||
4517 | pci_resource_len(btv->c.pci,0)); | 4501 | pci_resource_len(btv->c.pci,0)); |
4518 | 4502 | ||
4519 | pci_set_drvdata(pci_dev, NULL); | 4503 | pci_set_drvdata(pci_dev, NULL); |
4504 | bttvs[btv->c.nr] = NULL; | ||
4505 | kfree(btv); | ||
4506 | |||
4520 | return; | 4507 | return; |
4521 | } | 4508 | } |
4522 | 4509 | ||