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.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include <linux/types.h>
25 #include <linux/errno.h>
26 #include <linux/string.h>
27 #include <linux/module.h>
28 #include <linux/kernel.h>
29 #include <linux/init.h>
30 #include <linux/slab.h>
31 #include <linux/device.h>
33 #include <linux/cdev.h>
34 #include <linux/mutex.h>
37 /* Due to enum tuner_pad_index */
38 #include <media/tuner.h>
40 static DEFINE_MUTEX(dvbdev_mutex
);
41 static int dvbdev_debug
;
43 module_param(dvbdev_debug
, int, 0644);
44 MODULE_PARM_DESC(dvbdev_debug
, "Turn on/off device debugging (default:off).");
46 #define dprintk if (dvbdev_debug) printk
48 static LIST_HEAD(dvb_adapter_list
);
49 static DEFINE_MUTEX(dvbdev_register_lock
);
51 static const char * const dnames
[] = {
52 "video", "audio", "sec", "frontend", "demux", "dvr", "ca",
56 #ifdef CONFIG_DVB_DYNAMIC_MINORS
57 #define MAX_DVB_MINORS 256
58 #define DVB_MAX_IDS MAX_DVB_MINORS
61 #define nums2minor(num, type, id) ((num << 6) | (id << 4) | type)
62 #define MAX_DVB_MINORS (DVB_MAX_ADAPTERS*64)
65 static struct class *dvb_class
;
67 static struct dvb_device
*dvb_minors
[MAX_DVB_MINORS
];
68 static DECLARE_RWSEM(minor_rwsem
);
70 static int dvb_device_open(struct inode
*inode
, struct file
*file
)
72 struct dvb_device
*dvbdev
;
74 mutex_lock(&dvbdev_mutex
);
75 down_read(&minor_rwsem
);
76 dvbdev
= dvb_minors
[iminor(inode
)];
78 if (dvbdev
&& dvbdev
->fops
) {
80 const struct file_operations
*new_fops
;
82 new_fops
= fops_get(dvbdev
->fops
);
85 file
->private_data
= dvbdev
;
86 replace_fops(file
, new_fops
);
88 err
= file
->f_op
->open(inode
, file
);
89 up_read(&minor_rwsem
);
90 mutex_unlock(&dvbdev_mutex
);
94 up_read(&minor_rwsem
);
95 mutex_unlock(&dvbdev_mutex
);
100 static const struct file_operations dvb_device_fops
=
102 .owner
= THIS_MODULE
,
103 .open
= dvb_device_open
,
104 .llseek
= noop_llseek
,
107 static struct cdev dvb_device_cdev
;
109 int dvb_generic_open(struct inode
*inode
, struct file
*file
)
111 struct dvb_device
*dvbdev
= file
->private_data
;
119 if ((file
->f_flags
& O_ACCMODE
) == O_RDONLY
) {
120 if (!dvbdev
->readers
)
124 if (!dvbdev
->writers
)
132 EXPORT_SYMBOL(dvb_generic_open
);
135 int dvb_generic_release(struct inode
*inode
, struct file
*file
)
137 struct dvb_device
*dvbdev
= file
->private_data
;
142 if ((file
->f_flags
& O_ACCMODE
) == O_RDONLY
) {
151 EXPORT_SYMBOL(dvb_generic_release
);
154 long dvb_generic_ioctl(struct file
*file
,
155 unsigned int cmd
, unsigned long arg
)
157 struct dvb_device
*dvbdev
= file
->private_data
;
162 if (!dvbdev
->kernel_ioctl
)
165 return dvb_usercopy(file
, cmd
, arg
, dvbdev
->kernel_ioctl
);
167 EXPORT_SYMBOL(dvb_generic_ioctl
);
170 static int dvbdev_get_free_id (struct dvb_adapter
*adap
, int type
)
174 while (id
< DVB_MAX_IDS
) {
175 struct dvb_device
*dev
;
176 list_for_each_entry(dev
, &adap
->device_list
, list_head
)
177 if (dev
->type
== type
&& dev
->id
== id
)
186 static void dvb_media_device_free(struct dvb_device
*dvbdev
)
188 #if defined(CONFIG_MEDIA_CONTROLLER_DVB)
189 if (dvbdev
->entity
) {
190 media_device_unregister_entity(dvbdev
->entity
);
191 kfree(dvbdev
->entity
);
193 dvbdev
->entity
= NULL
;
197 if (dvbdev
->tsout_entity
) {
200 for (i
= 0; i
< dvbdev
->tsout_num_entities
; i
++) {
201 media_device_unregister_entity(&dvbdev
->tsout_entity
[i
]);
202 kfree(dvbdev
->tsout_entity
[i
].name
);
204 kfree(dvbdev
->tsout_entity
);
205 kfree(dvbdev
->tsout_pads
);
206 dvbdev
->tsout_entity
= NULL
;
207 dvbdev
->tsout_pads
= NULL
;
209 dvbdev
->tsout_num_entities
= 0;
212 if (dvbdev
->intf_devnode
) {
213 media_devnode_remove(dvbdev
->intf_devnode
);
214 dvbdev
->intf_devnode
= NULL
;
217 if (dvbdev
->adapter
->conn
) {
218 media_device_unregister_entity(dvbdev
->adapter
->conn
);
219 dvbdev
->adapter
->conn
= NULL
;
220 kfree(dvbdev
->adapter
->conn_pads
);
221 dvbdev
->adapter
->conn_pads
= NULL
;
226 #if defined(CONFIG_MEDIA_CONTROLLER_DVB)
227 static int dvb_create_tsout_entity(struct dvb_device
*dvbdev
,
228 const char *name
, int npads
)
232 dvbdev
->tsout_pads
= kcalloc(npads
, sizeof(*dvbdev
->tsout_pads
),
234 if (!dvbdev
->tsout_pads
)
237 dvbdev
->tsout_entity
= kcalloc(npads
, sizeof(*dvbdev
->tsout_entity
),
239 if (!dvbdev
->tsout_entity
)
242 dvbdev
->tsout_num_entities
= npads
;
244 for (i
= 0; i
< npads
; i
++) {
245 struct media_pad
*pads
= &dvbdev
->tsout_pads
[i
];
246 struct media_entity
*entity
= &dvbdev
->tsout_entity
[i
];
248 entity
->name
= kasprintf(GFP_KERNEL
, "%s #%d", name
, i
);
252 entity
->function
= MEDIA_ENT_F_IO_DTV
;
253 pads
->flags
= MEDIA_PAD_FL_SINK
;
255 ret
= media_entity_pads_init(entity
, 1, pads
);
259 ret
= media_device_register_entity(dvbdev
->adapter
->mdev
,
267 #define DEMUX_TSOUT "demux-tsout"
268 #define DVR_TSOUT "dvr-tsout"
270 static int dvb_create_media_entity(struct dvb_device
*dvbdev
,
271 int type
, int demux_sink_pads
)
276 case DVB_DEVICE_FRONTEND
:
280 ret
= dvb_create_tsout_entity(dvbdev
, DVR_TSOUT
,
283 case DVB_DEVICE_DEMUX
:
284 npads
= 1 + demux_sink_pads
;
285 ret
= dvb_create_tsout_entity(dvbdev
, DEMUX_TSOUT
,
295 * We should be creating entities for the MPE/ULE
296 * decapsulation hardware (or software implementation).
298 * However, the number of for the MPE/ULE decaps may not be
299 * fixed. As we don't have yet dynamic support for PADs at
300 * the Media Controller, let's not create the decap
308 dvbdev
->entity
= kzalloc(sizeof(*dvbdev
->entity
), GFP_KERNEL
);
312 dvbdev
->entity
->name
= dvbdev
->name
;
315 dvbdev
->pads
= kcalloc(npads
, sizeof(*dvbdev
->pads
),
322 case DVB_DEVICE_FRONTEND
:
323 dvbdev
->entity
->function
= MEDIA_ENT_F_DTV_DEMOD
;
324 dvbdev
->pads
[0].flags
= MEDIA_PAD_FL_SINK
;
325 dvbdev
->pads
[1].flags
= MEDIA_PAD_FL_SOURCE
;
327 case DVB_DEVICE_DEMUX
:
328 dvbdev
->entity
->function
= MEDIA_ENT_F_TS_DEMUX
;
329 dvbdev
->pads
[0].flags
= MEDIA_PAD_FL_SINK
;
330 for (i
= 1; i
< npads
; i
++)
331 dvbdev
->pads
[i
].flags
= MEDIA_PAD_FL_SOURCE
;
334 dvbdev
->entity
->function
= MEDIA_ENT_F_DTV_CA
;
335 dvbdev
->pads
[0].flags
= MEDIA_PAD_FL_SINK
;
336 dvbdev
->pads
[1].flags
= MEDIA_PAD_FL_SOURCE
;
339 /* Should never happen, as the first switch prevents it */
340 kfree(dvbdev
->entity
);
342 dvbdev
->entity
= NULL
;
348 ret
= media_entity_pads_init(dvbdev
->entity
, npads
, dvbdev
->pads
);
352 ret
= media_device_register_entity(dvbdev
->adapter
->mdev
,
357 printk(KERN_DEBUG
"%s: media entity '%s' registered.\n",
358 __func__
, dvbdev
->entity
->name
);
364 static int dvb_register_media_device(struct dvb_device
*dvbdev
,
366 unsigned demux_sink_pads
)
368 #if defined(CONFIG_MEDIA_CONTROLLER_DVB)
369 struct media_link
*link
;
373 if (!dvbdev
->adapter
->mdev
)
376 ret
= dvb_create_media_entity(dvbdev
, type
, demux_sink_pads
);
381 case DVB_DEVICE_FRONTEND
:
382 intf_type
= MEDIA_INTF_T_DVB_FE
;
384 case DVB_DEVICE_DEMUX
:
385 intf_type
= MEDIA_INTF_T_DVB_DEMUX
;
388 intf_type
= MEDIA_INTF_T_DVB_DVR
;
391 intf_type
= MEDIA_INTF_T_DVB_CA
;
394 intf_type
= MEDIA_INTF_T_DVB_NET
;
400 dvbdev
->intf_devnode
= media_devnode_create(dvbdev
->adapter
->mdev
,
404 if (!dvbdev
->intf_devnode
)
408 * Create the "obvious" link, e. g. the ones that represent
409 * a direct association between an interface and an entity.
410 * Other links should be created elsewhere, like:
411 * DVB FE intf -> tuner
412 * DVB demux intf -> dvr
418 link
= media_create_intf_link(dvbdev
->entity
, &dvbdev
->intf_devnode
->intf
,
419 MEDIA_LNK_FL_ENABLED
);
426 int dvb_register_device(struct dvb_adapter
*adap
, struct dvb_device
**pdvbdev
,
427 const struct dvb_device
*template, void *priv
, int type
,
430 struct dvb_device
*dvbdev
;
431 struct file_operations
*dvbdevfops
;
432 struct device
*clsdev
;
436 mutex_lock(&dvbdev_register_lock
);
438 if ((id
= dvbdev_get_free_id (adap
, type
)) < 0){
439 mutex_unlock(&dvbdev_register_lock
);
441 printk(KERN_ERR
"%s: couldn't find free device id\n", __func__
);
445 *pdvbdev
= dvbdev
= kzalloc(sizeof(*dvbdev
), GFP_KERNEL
);
448 mutex_unlock(&dvbdev_register_lock
);
452 dvbdevfops
= kzalloc(sizeof(struct file_operations
), GFP_KERNEL
);
456 mutex_unlock(&dvbdev_register_lock
);
460 memcpy(dvbdev
, template, sizeof(struct dvb_device
));
463 dvbdev
->adapter
= adap
;
465 dvbdev
->fops
= dvbdevfops
;
466 init_waitqueue_head (&dvbdev
->wait_queue
);
468 memcpy(dvbdevfops
, template->fops
, sizeof(struct file_operations
));
469 dvbdevfops
->owner
= adap
->module
;
471 list_add_tail (&dvbdev
->list_head
, &adap
->device_list
);
473 down_write(&minor_rwsem
);
474 #ifdef CONFIG_DVB_DYNAMIC_MINORS
475 for (minor
= 0; minor
< MAX_DVB_MINORS
; minor
++)
476 if (dvb_minors
[minor
] == NULL
)
479 if (minor
== MAX_DVB_MINORS
) {
482 up_write(&minor_rwsem
);
483 mutex_unlock(&dvbdev_register_lock
);
487 minor
= nums2minor(adap
->num
, type
, id
);
490 dvbdev
->minor
= minor
;
491 dvb_minors
[minor
] = dvbdev
;
492 up_write(&minor_rwsem
);
494 ret
= dvb_register_media_device(dvbdev
, type
, minor
, demux_sink_pads
);
497 "%s: dvb_register_media_device failed to create the mediagraph\n",
500 dvb_media_device_free(dvbdev
);
503 up_write(&minor_rwsem
);
504 mutex_unlock(&dvbdev_register_lock
);
508 mutex_unlock(&dvbdev_register_lock
);
510 clsdev
= device_create(dvb_class
, adap
->device
,
511 MKDEV(DVB_MAJOR
, minor
),
512 dvbdev
, "dvb%d.%s%d", adap
->num
, dnames
[type
], id
);
513 if (IS_ERR(clsdev
)) {
514 printk(KERN_ERR
"%s: failed to create device dvb%d.%s%d (%ld)\n",
515 __func__
, adap
->num
, dnames
[type
], id
, PTR_ERR(clsdev
));
516 return PTR_ERR(clsdev
);
518 dprintk(KERN_DEBUG
"DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n",
519 adap
->num
, dnames
[type
], id
, minor
, minor
);
523 EXPORT_SYMBOL(dvb_register_device
);
526 void dvb_unregister_device(struct dvb_device
*dvbdev
)
531 down_write(&minor_rwsem
);
532 dvb_minors
[dvbdev
->minor
] = NULL
;
533 up_write(&minor_rwsem
);
535 dvb_media_device_free(dvbdev
);
537 device_destroy(dvb_class
, MKDEV(DVB_MAJOR
, dvbdev
->minor
));
539 list_del (&dvbdev
->list_head
);
540 kfree (dvbdev
->fops
);
543 EXPORT_SYMBOL(dvb_unregister_device
);
546 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
548 static int dvb_create_io_intf_links(struct dvb_adapter
*adap
,
549 struct media_interface
*intf
,
552 struct media_device
*mdev
= adap
->mdev
;
553 struct media_entity
*entity
;
554 struct media_link
*link
;
556 media_device_for_each_entity(entity
, mdev
) {
557 if (entity
->function
== MEDIA_ENT_F_IO_DTV
) {
558 if (strncmp(entity
->name
, name
, strlen(name
)))
560 link
= media_create_intf_link(entity
, intf
,
561 MEDIA_LNK_FL_ENABLED
);
569 int dvb_create_media_graph(struct dvb_adapter
*adap
,
570 bool create_rf_connector
)
572 struct media_device
*mdev
= adap
->mdev
;
573 struct media_entity
*entity
, *tuner
= NULL
, *demod
= NULL
, *conn
;
574 struct media_entity
*demux
= NULL
, *ca
= NULL
;
575 struct media_link
*link
;
576 struct media_interface
*intf
;
577 unsigned demux_pad
= 0;
578 unsigned dvr_pad
= 0;
579 unsigned ntuner
= 0, ndemod
= 0;
581 static const char *connector_name
= "Television";
586 media_device_for_each_entity(entity
, mdev
) {
587 switch (entity
->function
) {
588 case MEDIA_ENT_F_TUNER
:
592 case MEDIA_ENT_F_DTV_DEMOD
:
596 case MEDIA_ENT_F_TS_DEMUX
:
599 case MEDIA_ENT_F_DTV_CA
:
606 * Prepare to signalize to media_create_pad_links() that multiple
607 * entities of the same type exists and a 1:n or n:1 links need to be
609 * NOTE: if both tuner and demod have multiple instances, it is up
610 * to the caller driver to create such links.
617 if (create_rf_connector
) {
618 conn
= kzalloc(sizeof(*conn
), GFP_KERNEL
);
623 adap
->conn_pads
= kzalloc(sizeof(*adap
->conn_pads
), GFP_KERNEL
);
624 if (!adap
->conn_pads
)
627 conn
->flags
= MEDIA_ENT_FL_CONNECTOR
;
628 conn
->function
= MEDIA_ENT_F_CONN_RF
;
629 conn
->name
= connector_name
;
630 adap
->conn_pads
->flags
= MEDIA_PAD_FL_SOURCE
;
632 ret
= media_entity_pads_init(conn
, 1, adap
->conn_pads
);
636 ret
= media_device_register_entity(mdev
, conn
);
641 ret
= media_create_pad_links(mdev
,
644 MEDIA_ENT_F_DTV_DEMOD
,
646 MEDIA_LNK_FL_ENABLED
,
649 ret
= media_create_pad_links(mdev
,
653 tuner
, TUNER_PAD_RF_INPUT
,
654 MEDIA_LNK_FL_ENABLED
,
660 if (ntuner
&& ndemod
) {
661 ret
= media_create_pad_links(mdev
,
663 tuner
, TUNER_PAD_OUTPUT
,
664 MEDIA_ENT_F_DTV_DEMOD
,
665 demod
, 0, MEDIA_LNK_FL_ENABLED
,
671 if (ndemod
&& demux
) {
672 ret
= media_create_pad_links(mdev
,
673 MEDIA_ENT_F_DTV_DEMOD
,
675 MEDIA_ENT_F_TS_DEMUX
,
676 demux
, 0, MEDIA_LNK_FL_ENABLED
,
682 ret
= media_create_pad_link(demux
, 1, ca
,
683 0, MEDIA_LNK_FL_ENABLED
);
688 /* Create demux links for each ringbuffer/pad */
690 media_device_for_each_entity(entity
, mdev
) {
691 if (entity
->function
== MEDIA_ENT_F_IO_DTV
) {
692 if (!strncmp(entity
->name
, DVR_TSOUT
,
693 strlen(DVR_TSOUT
))) {
694 ret
= media_create_pad_link(demux
,
700 if (!strncmp(entity
->name
, DEMUX_TSOUT
,
701 strlen(DEMUX_TSOUT
))) {
702 ret
= media_create_pad_link(demux
,
712 /* Create interface links for FE->tuner, DVR->demux and CA->ca */
713 media_device_for_each_intf(intf
, mdev
) {
714 if (intf
->type
== MEDIA_INTF_T_DVB_CA
&& ca
) {
715 link
= media_create_intf_link(ca
, intf
,
716 MEDIA_LNK_FL_ENABLED
);
721 if (intf
->type
== MEDIA_INTF_T_DVB_FE
&& tuner
) {
722 link
= media_create_intf_link(tuner
, intf
,
723 MEDIA_LNK_FL_ENABLED
);
729 * Indirect link - let's not create yet, as we don't know how
730 * to handle indirect links, nor if this will
731 * actually be needed.
733 if (intf
->type
== MEDIA_INTF_T_DVB_DVR
&& demux
) {
734 link
= media_create_intf_link(demux
, intf
,
735 MEDIA_LNK_FL_ENABLED
);
740 if (intf
->type
== MEDIA_INTF_T_DVB_DVR
) {
741 ret
= dvb_create_io_intf_links(adap
, intf
, DVR_TSOUT
);
745 if (intf
->type
== MEDIA_INTF_T_DVB_DEMUX
) {
746 ret
= dvb_create_io_intf_links(adap
, intf
, DEMUX_TSOUT
);
753 EXPORT_SYMBOL_GPL(dvb_create_media_graph
);
756 static int dvbdev_check_free_adapter_num(int num
)
758 struct list_head
*entry
;
759 list_for_each(entry
, &dvb_adapter_list
) {
760 struct dvb_adapter
*adap
;
761 adap
= list_entry(entry
, struct dvb_adapter
, list_head
);
762 if (adap
->num
== num
)
768 static int dvbdev_get_free_adapter_num (void)
772 while (num
< DVB_MAX_ADAPTERS
) {
773 if (dvbdev_check_free_adapter_num(num
))
782 int dvb_register_adapter(struct dvb_adapter
*adap
, const char *name
,
783 struct module
*module
, struct device
*device
,
788 mutex_lock(&dvbdev_register_lock
);
790 for (i
= 0; i
< DVB_MAX_ADAPTERS
; ++i
) {
791 num
= adapter_nums
[i
];
792 if (num
>= 0 && num
< DVB_MAX_ADAPTERS
) {
793 /* use the one the driver asked for */
794 if (dvbdev_check_free_adapter_num(num
))
797 num
= dvbdev_get_free_adapter_num();
804 mutex_unlock(&dvbdev_register_lock
);
808 memset (adap
, 0, sizeof(struct dvb_adapter
));
809 INIT_LIST_HEAD (&adap
->device_list
);
811 printk(KERN_INFO
"DVB: registering new adapter (%s)\n", name
);
815 adap
->module
= module
;
816 adap
->device
= device
;
817 adap
->mfe_shared
= 0;
818 adap
->mfe_dvbdev
= NULL
;
819 mutex_init (&adap
->mfe_lock
);
821 list_add_tail (&adap
->list_head
, &dvb_adapter_list
);
823 mutex_unlock(&dvbdev_register_lock
);
827 EXPORT_SYMBOL(dvb_register_adapter
);
830 int dvb_unregister_adapter(struct dvb_adapter
*adap
)
832 mutex_lock(&dvbdev_register_lock
);
833 list_del (&adap
->list_head
);
834 mutex_unlock(&dvbdev_register_lock
);
837 EXPORT_SYMBOL(dvb_unregister_adapter
);
839 /* if the miracle happens and "generic_usercopy()" is included into
840 the kernel, then this can vanish. please don't make the mistake and
841 define this as video_usercopy(). this will introduce a dependecy
842 to the v4l "videodev.o" module, which is unnecessary for some
843 cards (ie. the budget dvb-cards don't need the v4l module...) */
844 int dvb_usercopy(struct file
*file
,
845 unsigned int cmd
, unsigned long arg
,
846 int (*func
)(struct file
*file
,
847 unsigned int cmd
, void *arg
))
854 /* Copy arguments into temp kernel buffer */
855 switch (_IOC_DIR(cmd
)) {
858 * For this command, the pointer is actually an integer
863 case _IOC_READ
: /* some v4l ioctls are marked wrong ... */
865 case (_IOC_WRITE
| _IOC_READ
):
866 if (_IOC_SIZE(cmd
) <= sizeof(sbuf
)) {
869 /* too big to allocate from stack */
870 mbuf
= kmalloc(_IOC_SIZE(cmd
), GFP_KERNEL
);
877 if (copy_from_user(parg
, (void __user
*)arg
, _IOC_SIZE(cmd
)))
883 if ((err
= func(file
, cmd
, parg
)) == -ENOIOCTLCMD
)
889 /* Copy results into user buffer */
890 switch (_IOC_DIR(cmd
))
893 case (_IOC_WRITE
| _IOC_READ
):
894 if (copy_to_user((void __user
*)arg
, parg
, _IOC_SIZE(cmd
)))
904 static int dvb_uevent(struct device
*dev
, struct kobj_uevent_env
*env
)
906 struct dvb_device
*dvbdev
= dev_get_drvdata(dev
);
908 add_uevent_var(env
, "DVB_ADAPTER_NUM=%d", dvbdev
->adapter
->num
);
909 add_uevent_var(env
, "DVB_DEVICE_TYPE=%s", dnames
[dvbdev
->type
]);
910 add_uevent_var(env
, "DVB_DEVICE_NUM=%d", dvbdev
->id
);
914 static char *dvb_devnode(struct device
*dev
, umode_t
*mode
)
916 struct dvb_device
*dvbdev
= dev_get_drvdata(dev
);
918 return kasprintf(GFP_KERNEL
, "dvb/adapter%d/%s%d",
919 dvbdev
->adapter
->num
, dnames
[dvbdev
->type
], dvbdev
->id
);
923 static int __init
init_dvbdev(void)
926 dev_t dev
= MKDEV(DVB_MAJOR
, 0);
928 if ((retval
= register_chrdev_region(dev
, MAX_DVB_MINORS
, "DVB")) != 0) {
929 printk(KERN_ERR
"dvb-core: unable to get major %d\n", DVB_MAJOR
);
933 cdev_init(&dvb_device_cdev
, &dvb_device_fops
);
934 if ((retval
= cdev_add(&dvb_device_cdev
, dev
, MAX_DVB_MINORS
)) != 0) {
935 printk(KERN_ERR
"dvb-core: unable register character device\n");
939 dvb_class
= class_create(THIS_MODULE
, "dvb");
940 if (IS_ERR(dvb_class
)) {
941 retval
= PTR_ERR(dvb_class
);
944 dvb_class
->dev_uevent
= dvb_uevent
;
945 dvb_class
->devnode
= dvb_devnode
;
949 cdev_del(&dvb_device_cdev
);
950 unregister_chrdev_region(dev
, MAX_DVB_MINORS
);
955 static void __exit
exit_dvbdev(void)
957 class_destroy(dvb_class
);
958 cdev_del(&dvb_device_cdev
);
959 unregister_chrdev_region(MKDEV(DVB_MAJOR
, 0), MAX_DVB_MINORS
);
962 subsys_initcall(init_dvbdev
);
963 module_exit(exit_dvbdev
);
965 MODULE_DESCRIPTION("DVB Core Driver");
966 MODULE_AUTHOR("Marcus Metzler, Ralph Metzler, Holger Waechtler");
967 MODULE_LICENSE("GPL");