4 * Copyright (C) 2000 Ralph Metzler <ralph@convergence.de>
5 * & Marcus Metzler <marcus@convergence.de>
6 * for convergence integrated media GmbH
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 2.1
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
20 #define pr_fmt(fmt) "dvbdev: " fmt
22 #include <linux/types.h>
23 #include <linux/errno.h>
24 #include <linux/string.h>
25 #include <linux/module.h>
26 #include <linux/kernel.h>
27 #include <linux/init.h>
28 #include <linux/slab.h>
29 #include <linux/device.h>
31 #include <linux/cdev.h>
32 #include <linux/mutex.h>
35 /* Due to enum tuner_pad_index */
36 #include <media/tuner.h>
38 static DEFINE_MUTEX(dvbdev_mutex
);
39 static int dvbdev_debug
;
41 module_param(dvbdev_debug
, int, 0644);
42 MODULE_PARM_DESC(dvbdev_debug
, "Turn on/off device debugging (default:off).");
44 #define dprintk(fmt, arg...) do { \
46 printk(KERN_DEBUG pr_fmt("%s: " fmt), \
50 static LIST_HEAD(dvb_adapter_list
);
51 static DEFINE_MUTEX(dvbdev_register_lock
);
53 static const char * const dnames
[] = {
54 "video", "audio", "sec", "frontend", "demux", "dvr", "ca",
58 #ifdef CONFIG_DVB_DYNAMIC_MINORS
59 #define MAX_DVB_MINORS 256
60 #define DVB_MAX_IDS MAX_DVB_MINORS
63 #define nums2minor(num, type, id) ((num << 6) | (id << 4) | type)
64 #define MAX_DVB_MINORS (DVB_MAX_ADAPTERS*64)
67 static struct class *dvb_class
;
69 static struct dvb_device
*dvb_minors
[MAX_DVB_MINORS
];
70 static DECLARE_RWSEM(minor_rwsem
);
72 static int dvb_device_open(struct inode
*inode
, struct file
*file
)
74 struct dvb_device
*dvbdev
;
76 mutex_lock(&dvbdev_mutex
);
77 down_read(&minor_rwsem
);
78 dvbdev
= dvb_minors
[iminor(inode
)];
80 if (dvbdev
&& dvbdev
->fops
) {
82 const struct file_operations
*new_fops
;
84 new_fops
= fops_get(dvbdev
->fops
);
87 file
->private_data
= dvbdev
;
88 replace_fops(file
, new_fops
);
90 err
= file
->f_op
->open(inode
, file
);
91 up_read(&minor_rwsem
);
92 mutex_unlock(&dvbdev_mutex
);
96 up_read(&minor_rwsem
);
97 mutex_unlock(&dvbdev_mutex
);
102 static const struct file_operations dvb_device_fops
=
104 .owner
= THIS_MODULE
,
105 .open
= dvb_device_open
,
106 .llseek
= noop_llseek
,
109 static struct cdev dvb_device_cdev
;
111 int dvb_generic_open(struct inode
*inode
, struct file
*file
)
113 struct dvb_device
*dvbdev
= file
->private_data
;
121 if ((file
->f_flags
& O_ACCMODE
) == O_RDONLY
) {
122 if (!dvbdev
->readers
)
126 if (!dvbdev
->writers
)
134 EXPORT_SYMBOL(dvb_generic_open
);
137 int dvb_generic_release(struct inode
*inode
, struct file
*file
)
139 struct dvb_device
*dvbdev
= file
->private_data
;
144 if ((file
->f_flags
& O_ACCMODE
) == O_RDONLY
) {
153 EXPORT_SYMBOL(dvb_generic_release
);
156 long dvb_generic_ioctl(struct file
*file
,
157 unsigned int cmd
, unsigned long arg
)
159 struct dvb_device
*dvbdev
= file
->private_data
;
164 if (!dvbdev
->kernel_ioctl
)
167 return dvb_usercopy(file
, cmd
, arg
, dvbdev
->kernel_ioctl
);
169 EXPORT_SYMBOL(dvb_generic_ioctl
);
172 static int dvbdev_get_free_id (struct dvb_adapter
*adap
, int type
)
176 while (id
< DVB_MAX_IDS
) {
177 struct dvb_device
*dev
;
178 list_for_each_entry(dev
, &adap
->device_list
, list_head
)
179 if (dev
->type
== type
&& dev
->id
== id
)
188 static void dvb_media_device_free(struct dvb_device
*dvbdev
)
190 #if defined(CONFIG_MEDIA_CONTROLLER_DVB)
191 if (dvbdev
->entity
) {
192 media_device_unregister_entity(dvbdev
->entity
);
193 kfree(dvbdev
->entity
);
195 dvbdev
->entity
= NULL
;
199 if (dvbdev
->tsout_entity
) {
202 for (i
= 0; i
< dvbdev
->tsout_num_entities
; i
++) {
203 media_device_unregister_entity(&dvbdev
->tsout_entity
[i
]);
204 kfree(dvbdev
->tsout_entity
[i
].name
);
206 kfree(dvbdev
->tsout_entity
);
207 kfree(dvbdev
->tsout_pads
);
208 dvbdev
->tsout_entity
= NULL
;
209 dvbdev
->tsout_pads
= NULL
;
211 dvbdev
->tsout_num_entities
= 0;
214 if (dvbdev
->intf_devnode
) {
215 media_devnode_remove(dvbdev
->intf_devnode
);
216 dvbdev
->intf_devnode
= NULL
;
219 if (dvbdev
->adapter
->conn
) {
220 media_device_unregister_entity(dvbdev
->adapter
->conn
);
221 dvbdev
->adapter
->conn
= NULL
;
222 kfree(dvbdev
->adapter
->conn_pads
);
223 dvbdev
->adapter
->conn_pads
= NULL
;
228 #if defined(CONFIG_MEDIA_CONTROLLER_DVB)
229 static int dvb_create_tsout_entity(struct dvb_device
*dvbdev
,
230 const char *name
, int npads
)
234 dvbdev
->tsout_pads
= kcalloc(npads
, sizeof(*dvbdev
->tsout_pads
),
236 if (!dvbdev
->tsout_pads
)
239 dvbdev
->tsout_entity
= kcalloc(npads
, sizeof(*dvbdev
->tsout_entity
),
241 if (!dvbdev
->tsout_entity
)
244 dvbdev
->tsout_num_entities
= npads
;
246 for (i
= 0; i
< npads
; i
++) {
247 struct media_pad
*pads
= &dvbdev
->tsout_pads
[i
];
248 struct media_entity
*entity
= &dvbdev
->tsout_entity
[i
];
250 entity
->name
= kasprintf(GFP_KERNEL
, "%s #%d", name
, i
);
254 entity
->function
= MEDIA_ENT_F_IO_DTV
;
255 pads
->flags
= MEDIA_PAD_FL_SINK
;
257 ret
= media_entity_pads_init(entity
, 1, pads
);
261 ret
= media_device_register_entity(dvbdev
->adapter
->mdev
,
269 #define DEMUX_TSOUT "demux-tsout"
270 #define DVR_TSOUT "dvr-tsout"
272 static int dvb_create_media_entity(struct dvb_device
*dvbdev
,
273 int type
, int demux_sink_pads
)
278 case DVB_DEVICE_FRONTEND
:
282 ret
= dvb_create_tsout_entity(dvbdev
, DVR_TSOUT
,
285 case DVB_DEVICE_DEMUX
:
286 npads
= 1 + demux_sink_pads
;
287 ret
= dvb_create_tsout_entity(dvbdev
, DEMUX_TSOUT
,
297 * We should be creating entities for the MPE/ULE
298 * decapsulation hardware (or software implementation).
300 * However, the number of for the MPE/ULE decaps may not be
301 * fixed. As we don't have yet dynamic support for PADs at
302 * the Media Controller, let's not create the decap
310 dvbdev
->entity
= kzalloc(sizeof(*dvbdev
->entity
), GFP_KERNEL
);
314 dvbdev
->entity
->name
= dvbdev
->name
;
317 dvbdev
->pads
= kcalloc(npads
, sizeof(*dvbdev
->pads
),
324 case DVB_DEVICE_FRONTEND
:
325 dvbdev
->entity
->function
= MEDIA_ENT_F_DTV_DEMOD
;
326 dvbdev
->pads
[0].flags
= MEDIA_PAD_FL_SINK
;
327 dvbdev
->pads
[1].flags
= MEDIA_PAD_FL_SOURCE
;
329 case DVB_DEVICE_DEMUX
:
330 dvbdev
->entity
->function
= MEDIA_ENT_F_TS_DEMUX
;
331 dvbdev
->pads
[0].flags
= MEDIA_PAD_FL_SINK
;
332 for (i
= 1; i
< npads
; i
++)
333 dvbdev
->pads
[i
].flags
= MEDIA_PAD_FL_SOURCE
;
336 dvbdev
->entity
->function
= MEDIA_ENT_F_DTV_CA
;
337 dvbdev
->pads
[0].flags
= MEDIA_PAD_FL_SINK
;
338 dvbdev
->pads
[1].flags
= MEDIA_PAD_FL_SOURCE
;
341 /* Should never happen, as the first switch prevents it */
342 kfree(dvbdev
->entity
);
344 dvbdev
->entity
= NULL
;
350 ret
= media_entity_pads_init(dvbdev
->entity
, npads
, dvbdev
->pads
);
354 ret
= media_device_register_entity(dvbdev
->adapter
->mdev
,
359 pr_info("%s: media entity '%s' registered.\n",
360 __func__
, dvbdev
->entity
->name
);
366 static int dvb_register_media_device(struct dvb_device
*dvbdev
,
368 unsigned demux_sink_pads
)
370 #if defined(CONFIG_MEDIA_CONTROLLER_DVB)
371 struct media_link
*link
;
375 if (!dvbdev
->adapter
->mdev
)
378 ret
= dvb_create_media_entity(dvbdev
, type
, demux_sink_pads
);
383 case DVB_DEVICE_FRONTEND
:
384 intf_type
= MEDIA_INTF_T_DVB_FE
;
386 case DVB_DEVICE_DEMUX
:
387 intf_type
= MEDIA_INTF_T_DVB_DEMUX
;
390 intf_type
= MEDIA_INTF_T_DVB_DVR
;
393 intf_type
= MEDIA_INTF_T_DVB_CA
;
396 intf_type
= MEDIA_INTF_T_DVB_NET
;
402 dvbdev
->intf_devnode
= media_devnode_create(dvbdev
->adapter
->mdev
,
406 if (!dvbdev
->intf_devnode
)
410 * Create the "obvious" link, e. g. the ones that represent
411 * a direct association between an interface and an entity.
412 * Other links should be created elsewhere, like:
413 * DVB FE intf -> tuner
414 * DVB demux intf -> dvr
420 link
= media_create_intf_link(dvbdev
->entity
, &dvbdev
->intf_devnode
->intf
,
421 MEDIA_LNK_FL_ENABLED
);
428 int dvb_register_device(struct dvb_adapter
*adap
, struct dvb_device
**pdvbdev
,
429 const struct dvb_device
*template, void *priv
, int type
,
432 struct dvb_device
*dvbdev
;
433 struct file_operations
*dvbdevfops
;
434 struct device
*clsdev
;
438 mutex_lock(&dvbdev_register_lock
);
440 if ((id
= dvbdev_get_free_id (adap
, type
)) < 0){
441 mutex_unlock(&dvbdev_register_lock
);
443 pr_err("%s: couldn't find free device id\n", __func__
);
447 *pdvbdev
= dvbdev
= kzalloc(sizeof(*dvbdev
), GFP_KERNEL
);
450 mutex_unlock(&dvbdev_register_lock
);
454 dvbdevfops
= kzalloc(sizeof(struct file_operations
), GFP_KERNEL
);
458 mutex_unlock(&dvbdev_register_lock
);
462 memcpy(dvbdev
, template, sizeof(struct dvb_device
));
465 dvbdev
->adapter
= adap
;
467 dvbdev
->fops
= dvbdevfops
;
468 init_waitqueue_head (&dvbdev
->wait_queue
);
470 memcpy(dvbdevfops
, template->fops
, sizeof(struct file_operations
));
471 dvbdevfops
->owner
= adap
->module
;
473 list_add_tail (&dvbdev
->list_head
, &adap
->device_list
);
475 down_write(&minor_rwsem
);
476 #ifdef CONFIG_DVB_DYNAMIC_MINORS
477 for (minor
= 0; minor
< MAX_DVB_MINORS
; minor
++)
478 if (dvb_minors
[minor
] == NULL
)
481 if (minor
== MAX_DVB_MINORS
) {
484 up_write(&minor_rwsem
);
485 mutex_unlock(&dvbdev_register_lock
);
489 minor
= nums2minor(adap
->num
, type
, id
);
492 dvbdev
->minor
= minor
;
493 dvb_minors
[minor
] = dvbdev
;
494 up_write(&minor_rwsem
);
496 ret
= dvb_register_media_device(dvbdev
, type
, minor
, demux_sink_pads
);
498 pr_err("%s: dvb_register_media_device failed to create the mediagraph\n",
501 dvb_media_device_free(dvbdev
);
504 up_write(&minor_rwsem
);
505 mutex_unlock(&dvbdev_register_lock
);
509 mutex_unlock(&dvbdev_register_lock
);
511 clsdev
= device_create(dvb_class
, adap
->device
,
512 MKDEV(DVB_MAJOR
, minor
),
513 dvbdev
, "dvb%d.%s%d", adap
->num
, dnames
[type
], id
);
514 if (IS_ERR(clsdev
)) {
515 pr_err("%s: failed to create device dvb%d.%s%d (%ld)\n",
516 __func__
, adap
->num
, dnames
[type
], id
, PTR_ERR(clsdev
));
517 return PTR_ERR(clsdev
);
519 dprintk("DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n",
520 adap
->num
, dnames
[type
], id
, minor
, minor
);
524 EXPORT_SYMBOL(dvb_register_device
);
527 void dvb_remove_device(struct dvb_device
*dvbdev
)
532 down_write(&minor_rwsem
);
533 dvb_minors
[dvbdev
->minor
] = NULL
;
534 up_write(&minor_rwsem
);
536 dvb_media_device_free(dvbdev
);
538 device_destroy(dvb_class
, MKDEV(DVB_MAJOR
, dvbdev
->minor
));
540 list_del (&dvbdev
->list_head
);
542 EXPORT_SYMBOL(dvb_remove_device
);
545 void dvb_free_device(struct dvb_device
*dvbdev
)
550 kfree (dvbdev
->fops
);
553 EXPORT_SYMBOL(dvb_free_device
);
556 void dvb_unregister_device(struct dvb_device
*dvbdev
)
558 dvb_remove_device(dvbdev
);
559 dvb_free_device(dvbdev
);
561 EXPORT_SYMBOL(dvb_unregister_device
);
564 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
566 static int dvb_create_io_intf_links(struct dvb_adapter
*adap
,
567 struct media_interface
*intf
,
570 struct media_device
*mdev
= adap
->mdev
;
571 struct media_entity
*entity
;
572 struct media_link
*link
;
574 media_device_for_each_entity(entity
, mdev
) {
575 if (entity
->function
== MEDIA_ENT_F_IO_DTV
) {
576 if (strncmp(entity
->name
, name
, strlen(name
)))
578 link
= media_create_intf_link(entity
, intf
,
579 MEDIA_LNK_FL_ENABLED
);
587 int dvb_create_media_graph(struct dvb_adapter
*adap
,
588 bool create_rf_connector
)
590 struct media_device
*mdev
= adap
->mdev
;
591 struct media_entity
*entity
, *tuner
= NULL
, *demod
= NULL
, *conn
;
592 struct media_entity
*demux
= NULL
, *ca
= NULL
;
593 struct media_link
*link
;
594 struct media_interface
*intf
;
595 unsigned demux_pad
= 0;
596 unsigned dvr_pad
= 0;
597 unsigned ntuner
= 0, ndemod
= 0;
599 static const char *connector_name
= "Television";
604 media_device_for_each_entity(entity
, mdev
) {
605 switch (entity
->function
) {
606 case MEDIA_ENT_F_TUNER
:
610 case MEDIA_ENT_F_DTV_DEMOD
:
614 case MEDIA_ENT_F_TS_DEMUX
:
617 case MEDIA_ENT_F_DTV_CA
:
624 * Prepare to signalize to media_create_pad_links() that multiple
625 * entities of the same type exists and a 1:n or n:1 links need to be
627 * NOTE: if both tuner and demod have multiple instances, it is up
628 * to the caller driver to create such links.
635 if (create_rf_connector
) {
636 conn
= kzalloc(sizeof(*conn
), GFP_KERNEL
);
641 adap
->conn_pads
= kzalloc(sizeof(*adap
->conn_pads
), GFP_KERNEL
);
642 if (!adap
->conn_pads
)
645 conn
->flags
= MEDIA_ENT_FL_CONNECTOR
;
646 conn
->function
= MEDIA_ENT_F_CONN_RF
;
647 conn
->name
= connector_name
;
648 adap
->conn_pads
->flags
= MEDIA_PAD_FL_SOURCE
;
650 ret
= media_entity_pads_init(conn
, 1, adap
->conn_pads
);
654 ret
= media_device_register_entity(mdev
, conn
);
659 ret
= media_create_pad_links(mdev
,
662 MEDIA_ENT_F_DTV_DEMOD
,
664 MEDIA_LNK_FL_ENABLED
,
667 ret
= media_create_pad_links(mdev
,
671 tuner
, TUNER_PAD_RF_INPUT
,
672 MEDIA_LNK_FL_ENABLED
,
678 if (ntuner
&& ndemod
) {
679 ret
= media_create_pad_links(mdev
,
681 tuner
, TUNER_PAD_OUTPUT
,
682 MEDIA_ENT_F_DTV_DEMOD
,
683 demod
, 0, MEDIA_LNK_FL_ENABLED
,
689 if (ndemod
&& demux
) {
690 ret
= media_create_pad_links(mdev
,
691 MEDIA_ENT_F_DTV_DEMOD
,
693 MEDIA_ENT_F_TS_DEMUX
,
694 demux
, 0, MEDIA_LNK_FL_ENABLED
,
700 ret
= media_create_pad_link(demux
, 1, ca
,
701 0, MEDIA_LNK_FL_ENABLED
);
706 /* Create demux links for each ringbuffer/pad */
708 media_device_for_each_entity(entity
, mdev
) {
709 if (entity
->function
== MEDIA_ENT_F_IO_DTV
) {
710 if (!strncmp(entity
->name
, DVR_TSOUT
,
711 strlen(DVR_TSOUT
))) {
712 ret
= media_create_pad_link(demux
,
718 if (!strncmp(entity
->name
, DEMUX_TSOUT
,
719 strlen(DEMUX_TSOUT
))) {
720 ret
= media_create_pad_link(demux
,
730 /* Create interface links for FE->tuner, DVR->demux and CA->ca */
731 media_device_for_each_intf(intf
, mdev
) {
732 if (intf
->type
== MEDIA_INTF_T_DVB_CA
&& ca
) {
733 link
= media_create_intf_link(ca
, intf
,
734 MEDIA_LNK_FL_ENABLED
);
739 if (intf
->type
== MEDIA_INTF_T_DVB_FE
&& tuner
) {
740 link
= media_create_intf_link(tuner
, intf
,
741 MEDIA_LNK_FL_ENABLED
);
747 * Indirect link - let's not create yet, as we don't know how
748 * to handle indirect links, nor if this will
749 * actually be needed.
751 if (intf
->type
== MEDIA_INTF_T_DVB_DVR
&& demux
) {
752 link
= media_create_intf_link(demux
, intf
,
753 MEDIA_LNK_FL_ENABLED
);
758 if (intf
->type
== MEDIA_INTF_T_DVB_DVR
) {
759 ret
= dvb_create_io_intf_links(adap
, intf
, DVR_TSOUT
);
763 if (intf
->type
== MEDIA_INTF_T_DVB_DEMUX
) {
764 ret
= dvb_create_io_intf_links(adap
, intf
, DEMUX_TSOUT
);
771 EXPORT_SYMBOL_GPL(dvb_create_media_graph
);
774 static int dvbdev_check_free_adapter_num(int num
)
776 struct list_head
*entry
;
777 list_for_each(entry
, &dvb_adapter_list
) {
778 struct dvb_adapter
*adap
;
779 adap
= list_entry(entry
, struct dvb_adapter
, list_head
);
780 if (adap
->num
== num
)
786 static int dvbdev_get_free_adapter_num (void)
790 while (num
< DVB_MAX_ADAPTERS
) {
791 if (dvbdev_check_free_adapter_num(num
))
800 int dvb_register_adapter(struct dvb_adapter
*adap
, const char *name
,
801 struct module
*module
, struct device
*device
,
806 mutex_lock(&dvbdev_register_lock
);
808 for (i
= 0; i
< DVB_MAX_ADAPTERS
; ++i
) {
809 num
= adapter_nums
[i
];
810 if (num
>= 0 && num
< DVB_MAX_ADAPTERS
) {
811 /* use the one the driver asked for */
812 if (dvbdev_check_free_adapter_num(num
))
815 num
= dvbdev_get_free_adapter_num();
822 mutex_unlock(&dvbdev_register_lock
);
826 memset (adap
, 0, sizeof(struct dvb_adapter
));
827 INIT_LIST_HEAD (&adap
->device_list
);
829 pr_info("DVB: registering new adapter (%s)\n", name
);
833 adap
->module
= module
;
834 adap
->device
= device
;
835 adap
->mfe_shared
= 0;
836 adap
->mfe_dvbdev
= NULL
;
837 mutex_init (&adap
->mfe_lock
);
839 list_add_tail (&adap
->list_head
, &dvb_adapter_list
);
841 mutex_unlock(&dvbdev_register_lock
);
845 EXPORT_SYMBOL(dvb_register_adapter
);
848 int dvb_unregister_adapter(struct dvb_adapter
*adap
)
850 mutex_lock(&dvbdev_register_lock
);
851 list_del (&adap
->list_head
);
852 mutex_unlock(&dvbdev_register_lock
);
855 EXPORT_SYMBOL(dvb_unregister_adapter
);
857 /* if the miracle happens and "generic_usercopy()" is included into
858 the kernel, then this can vanish. please don't make the mistake and
859 define this as video_usercopy(). this will introduce a dependecy
860 to the v4l "videodev.o" module, which is unnecessary for some
861 cards (ie. the budget dvb-cards don't need the v4l module...) */
862 int dvb_usercopy(struct file
*file
,
863 unsigned int cmd
, unsigned long arg
,
864 int (*func
)(struct file
*file
,
865 unsigned int cmd
, void *arg
))
872 /* Copy arguments into temp kernel buffer */
873 switch (_IOC_DIR(cmd
)) {
876 * For this command, the pointer is actually an integer
881 case _IOC_READ
: /* some v4l ioctls are marked wrong ... */
883 case (_IOC_WRITE
| _IOC_READ
):
884 if (_IOC_SIZE(cmd
) <= sizeof(sbuf
)) {
887 /* too big to allocate from stack */
888 mbuf
= kmalloc(_IOC_SIZE(cmd
), GFP_KERNEL
);
895 if (copy_from_user(parg
, (void __user
*)arg
, _IOC_SIZE(cmd
)))
901 if ((err
= func(file
, cmd
, parg
)) == -ENOIOCTLCMD
)
907 /* Copy results into user buffer */
908 switch (_IOC_DIR(cmd
))
911 case (_IOC_WRITE
| _IOC_READ
):
912 if (copy_to_user((void __user
*)arg
, parg
, _IOC_SIZE(cmd
)))
922 static int dvb_uevent(struct device
*dev
, struct kobj_uevent_env
*env
)
924 struct dvb_device
*dvbdev
= dev_get_drvdata(dev
);
926 add_uevent_var(env
, "DVB_ADAPTER_NUM=%d", dvbdev
->adapter
->num
);
927 add_uevent_var(env
, "DVB_DEVICE_TYPE=%s", dnames
[dvbdev
->type
]);
928 add_uevent_var(env
, "DVB_DEVICE_NUM=%d", dvbdev
->id
);
932 static char *dvb_devnode(struct device
*dev
, umode_t
*mode
)
934 struct dvb_device
*dvbdev
= dev_get_drvdata(dev
);
936 return kasprintf(GFP_KERNEL
, "dvb/adapter%d/%s%d",
937 dvbdev
->adapter
->num
, dnames
[dvbdev
->type
], dvbdev
->id
);
941 static int __init
init_dvbdev(void)
944 dev_t dev
= MKDEV(DVB_MAJOR
, 0);
946 if ((retval
= register_chrdev_region(dev
, MAX_DVB_MINORS
, "DVB")) != 0) {
947 pr_err("dvb-core: unable to get major %d\n", DVB_MAJOR
);
951 cdev_init(&dvb_device_cdev
, &dvb_device_fops
);
952 if ((retval
= cdev_add(&dvb_device_cdev
, dev
, MAX_DVB_MINORS
)) != 0) {
953 pr_err("dvb-core: unable register character device\n");
957 dvb_class
= class_create(THIS_MODULE
, "dvb");
958 if (IS_ERR(dvb_class
)) {
959 retval
= PTR_ERR(dvb_class
);
962 dvb_class
->dev_uevent
= dvb_uevent
;
963 dvb_class
->devnode
= dvb_devnode
;
967 cdev_del(&dvb_device_cdev
);
968 unregister_chrdev_region(dev
, MAX_DVB_MINORS
);
973 static void __exit
exit_dvbdev(void)
975 class_destroy(dvb_class
);
976 cdev_del(&dvb_device_cdev
);
977 unregister_chrdev_region(MKDEV(DVB_MAJOR
, 0), MAX_DVB_MINORS
);
980 subsys_initcall(init_dvbdev
);
981 module_exit(exit_dvbdev
);
983 MODULE_DESCRIPTION("DVB Core Driver");
984 MODULE_AUTHOR("Marcus Metzler, Ralph Metzler, Holger Waechtler");
985 MODULE_LICENSE("GPL");