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 #define pr_fmt(fmt) "dvbdev: " fmt
26 #include <linux/types.h>
27 #include <linux/errno.h>
28 #include <linux/string.h>
29 #include <linux/module.h>
30 #include <linux/kernel.h>
31 #include <linux/init.h>
32 #include <linux/slab.h>
33 #include <linux/device.h>
35 #include <linux/cdev.h>
36 #include <linux/mutex.h>
39 /* Due to enum tuner_pad_index */
40 #include <media/tuner.h>
42 static DEFINE_MUTEX(dvbdev_mutex
);
43 static int dvbdev_debug
;
45 module_param(dvbdev_debug
, int, 0644);
46 MODULE_PARM_DESC(dvbdev_debug
, "Turn on/off device debugging (default:off).");
48 #define dprintk(fmt, arg...) do { \
50 printk(KERN_DEBUG pr_fmt("%s: " fmt), \
54 static LIST_HEAD(dvb_adapter_list
);
55 static DEFINE_MUTEX(dvbdev_register_lock
);
57 static const char * const dnames
[] = {
58 "video", "audio", "sec", "frontend", "demux", "dvr", "ca",
62 #ifdef CONFIG_DVB_DYNAMIC_MINORS
63 #define MAX_DVB_MINORS 256
64 #define DVB_MAX_IDS MAX_DVB_MINORS
67 #define nums2minor(num, type, id) ((num << 6) | (id << 4) | type)
68 #define MAX_DVB_MINORS (DVB_MAX_ADAPTERS*64)
71 static struct class *dvb_class
;
73 static struct dvb_device
*dvb_minors
[MAX_DVB_MINORS
];
74 static DECLARE_RWSEM(minor_rwsem
);
76 static int dvb_device_open(struct inode
*inode
, struct file
*file
)
78 struct dvb_device
*dvbdev
;
80 mutex_lock(&dvbdev_mutex
);
81 down_read(&minor_rwsem
);
82 dvbdev
= dvb_minors
[iminor(inode
)];
84 if (dvbdev
&& dvbdev
->fops
) {
86 const struct file_operations
*new_fops
;
88 new_fops
= fops_get(dvbdev
->fops
);
91 file
->private_data
= dvbdev
;
92 replace_fops(file
, new_fops
);
94 err
= file
->f_op
->open(inode
, file
);
95 up_read(&minor_rwsem
);
96 mutex_unlock(&dvbdev_mutex
);
100 up_read(&minor_rwsem
);
101 mutex_unlock(&dvbdev_mutex
);
106 static const struct file_operations dvb_device_fops
=
108 .owner
= THIS_MODULE
,
109 .open
= dvb_device_open
,
110 .llseek
= noop_llseek
,
113 static struct cdev dvb_device_cdev
;
115 int dvb_generic_open(struct inode
*inode
, struct file
*file
)
117 struct dvb_device
*dvbdev
= file
->private_data
;
125 if ((file
->f_flags
& O_ACCMODE
) == O_RDONLY
) {
126 if (!dvbdev
->readers
)
130 if (!dvbdev
->writers
)
138 EXPORT_SYMBOL(dvb_generic_open
);
141 int dvb_generic_release(struct inode
*inode
, struct file
*file
)
143 struct dvb_device
*dvbdev
= file
->private_data
;
148 if ((file
->f_flags
& O_ACCMODE
) == O_RDONLY
) {
157 EXPORT_SYMBOL(dvb_generic_release
);
160 long dvb_generic_ioctl(struct file
*file
,
161 unsigned int cmd
, unsigned long arg
)
163 struct dvb_device
*dvbdev
= file
->private_data
;
168 if (!dvbdev
->kernel_ioctl
)
171 return dvb_usercopy(file
, cmd
, arg
, dvbdev
->kernel_ioctl
);
173 EXPORT_SYMBOL(dvb_generic_ioctl
);
176 static int dvbdev_get_free_id (struct dvb_adapter
*adap
, int type
)
180 while (id
< DVB_MAX_IDS
) {
181 struct dvb_device
*dev
;
182 list_for_each_entry(dev
, &adap
->device_list
, list_head
)
183 if (dev
->type
== type
&& dev
->id
== id
)
192 static void dvb_media_device_free(struct dvb_device
*dvbdev
)
194 #if defined(CONFIG_MEDIA_CONTROLLER_DVB)
195 if (dvbdev
->entity
) {
196 media_device_unregister_entity(dvbdev
->entity
);
197 kfree(dvbdev
->entity
);
199 dvbdev
->entity
= NULL
;
203 if (dvbdev
->tsout_entity
) {
206 for (i
= 0; i
< dvbdev
->tsout_num_entities
; i
++) {
207 media_device_unregister_entity(&dvbdev
->tsout_entity
[i
]);
208 kfree(dvbdev
->tsout_entity
[i
].name
);
210 kfree(dvbdev
->tsout_entity
);
211 kfree(dvbdev
->tsout_pads
);
212 dvbdev
->tsout_entity
= NULL
;
213 dvbdev
->tsout_pads
= NULL
;
215 dvbdev
->tsout_num_entities
= 0;
218 if (dvbdev
->intf_devnode
) {
219 media_devnode_remove(dvbdev
->intf_devnode
);
220 dvbdev
->intf_devnode
= NULL
;
223 if (dvbdev
->adapter
->conn
) {
224 media_device_unregister_entity(dvbdev
->adapter
->conn
);
225 dvbdev
->adapter
->conn
= NULL
;
226 kfree(dvbdev
->adapter
->conn_pads
);
227 dvbdev
->adapter
->conn_pads
= NULL
;
232 #if defined(CONFIG_MEDIA_CONTROLLER_DVB)
233 static int dvb_create_tsout_entity(struct dvb_device
*dvbdev
,
234 const char *name
, int npads
)
238 dvbdev
->tsout_pads
= kcalloc(npads
, sizeof(*dvbdev
->tsout_pads
),
240 if (!dvbdev
->tsout_pads
)
243 dvbdev
->tsout_entity
= kcalloc(npads
, sizeof(*dvbdev
->tsout_entity
),
245 if (!dvbdev
->tsout_entity
)
248 dvbdev
->tsout_num_entities
= npads
;
250 for (i
= 0; i
< npads
; i
++) {
251 struct media_pad
*pads
= &dvbdev
->tsout_pads
[i
];
252 struct media_entity
*entity
= &dvbdev
->tsout_entity
[i
];
254 entity
->name
= kasprintf(GFP_KERNEL
, "%s #%d", name
, i
);
258 entity
->function
= MEDIA_ENT_F_IO_DTV
;
259 pads
->flags
= MEDIA_PAD_FL_SINK
;
261 ret
= media_entity_pads_init(entity
, 1, pads
);
265 ret
= media_device_register_entity(dvbdev
->adapter
->mdev
,
273 #define DEMUX_TSOUT "demux-tsout"
274 #define DVR_TSOUT "dvr-tsout"
276 static int dvb_create_media_entity(struct dvb_device
*dvbdev
,
277 int type
, int demux_sink_pads
)
282 case DVB_DEVICE_FRONTEND
:
286 ret
= dvb_create_tsout_entity(dvbdev
, DVR_TSOUT
,
289 case DVB_DEVICE_DEMUX
:
290 npads
= 1 + demux_sink_pads
;
291 ret
= dvb_create_tsout_entity(dvbdev
, DEMUX_TSOUT
,
301 * We should be creating entities for the MPE/ULE
302 * decapsulation hardware (or software implementation).
304 * However, the number of for the MPE/ULE decaps may not be
305 * fixed. As we don't have yet dynamic support for PADs at
306 * the Media Controller, let's not create the decap
314 dvbdev
->entity
= kzalloc(sizeof(*dvbdev
->entity
), GFP_KERNEL
);
318 dvbdev
->entity
->name
= dvbdev
->name
;
321 dvbdev
->pads
= kcalloc(npads
, sizeof(*dvbdev
->pads
),
328 case DVB_DEVICE_FRONTEND
:
329 dvbdev
->entity
->function
= MEDIA_ENT_F_DTV_DEMOD
;
330 dvbdev
->pads
[0].flags
= MEDIA_PAD_FL_SINK
;
331 dvbdev
->pads
[1].flags
= MEDIA_PAD_FL_SOURCE
;
333 case DVB_DEVICE_DEMUX
:
334 dvbdev
->entity
->function
= MEDIA_ENT_F_TS_DEMUX
;
335 dvbdev
->pads
[0].flags
= MEDIA_PAD_FL_SINK
;
336 for (i
= 1; i
< npads
; i
++)
337 dvbdev
->pads
[i
].flags
= MEDIA_PAD_FL_SOURCE
;
340 dvbdev
->entity
->function
= MEDIA_ENT_F_DTV_CA
;
341 dvbdev
->pads
[0].flags
= MEDIA_PAD_FL_SINK
;
342 dvbdev
->pads
[1].flags
= MEDIA_PAD_FL_SOURCE
;
345 /* Should never happen, as the first switch prevents it */
346 kfree(dvbdev
->entity
);
348 dvbdev
->entity
= NULL
;
354 ret
= media_entity_pads_init(dvbdev
->entity
, npads
, dvbdev
->pads
);
358 ret
= media_device_register_entity(dvbdev
->adapter
->mdev
,
363 pr_info("%s: media entity '%s' registered.\n",
364 __func__
, dvbdev
->entity
->name
);
370 static int dvb_register_media_device(struct dvb_device
*dvbdev
,
372 unsigned demux_sink_pads
)
374 #if defined(CONFIG_MEDIA_CONTROLLER_DVB)
375 struct media_link
*link
;
379 if (!dvbdev
->adapter
->mdev
)
382 ret
= dvb_create_media_entity(dvbdev
, type
, demux_sink_pads
);
387 case DVB_DEVICE_FRONTEND
:
388 intf_type
= MEDIA_INTF_T_DVB_FE
;
390 case DVB_DEVICE_DEMUX
:
391 intf_type
= MEDIA_INTF_T_DVB_DEMUX
;
394 intf_type
= MEDIA_INTF_T_DVB_DVR
;
397 intf_type
= MEDIA_INTF_T_DVB_CA
;
400 intf_type
= MEDIA_INTF_T_DVB_NET
;
406 dvbdev
->intf_devnode
= media_devnode_create(dvbdev
->adapter
->mdev
,
410 if (!dvbdev
->intf_devnode
)
414 * Create the "obvious" link, e. g. the ones that represent
415 * a direct association between an interface and an entity.
416 * Other links should be created elsewhere, like:
417 * DVB FE intf -> tuner
418 * DVB demux intf -> dvr
424 link
= media_create_intf_link(dvbdev
->entity
, &dvbdev
->intf_devnode
->intf
,
425 MEDIA_LNK_FL_ENABLED
);
432 int dvb_register_device(struct dvb_adapter
*adap
, struct dvb_device
**pdvbdev
,
433 const struct dvb_device
*template, void *priv
, int type
,
436 struct dvb_device
*dvbdev
;
437 struct file_operations
*dvbdevfops
;
438 struct device
*clsdev
;
442 mutex_lock(&dvbdev_register_lock
);
444 if ((id
= dvbdev_get_free_id (adap
, type
)) < 0){
445 mutex_unlock(&dvbdev_register_lock
);
447 pr_err("%s: couldn't find free device id\n", __func__
);
451 *pdvbdev
= dvbdev
= kzalloc(sizeof(*dvbdev
), GFP_KERNEL
);
454 mutex_unlock(&dvbdev_register_lock
);
458 dvbdevfops
= kzalloc(sizeof(struct file_operations
), GFP_KERNEL
);
462 mutex_unlock(&dvbdev_register_lock
);
466 memcpy(dvbdev
, template, sizeof(struct dvb_device
));
469 dvbdev
->adapter
= adap
;
471 dvbdev
->fops
= dvbdevfops
;
472 init_waitqueue_head (&dvbdev
->wait_queue
);
474 memcpy(dvbdevfops
, template->fops
, sizeof(struct file_operations
));
475 dvbdevfops
->owner
= adap
->module
;
477 list_add_tail (&dvbdev
->list_head
, &adap
->device_list
);
479 down_write(&minor_rwsem
);
480 #ifdef CONFIG_DVB_DYNAMIC_MINORS
481 for (minor
= 0; minor
< MAX_DVB_MINORS
; minor
++)
482 if (dvb_minors
[minor
] == NULL
)
485 if (minor
== MAX_DVB_MINORS
) {
488 up_write(&minor_rwsem
);
489 mutex_unlock(&dvbdev_register_lock
);
493 minor
= nums2minor(adap
->num
, type
, id
);
496 dvbdev
->minor
= minor
;
497 dvb_minors
[minor
] = dvbdev
;
498 up_write(&minor_rwsem
);
500 ret
= dvb_register_media_device(dvbdev
, type
, minor
, demux_sink_pads
);
502 pr_err("%s: dvb_register_media_device failed to create the mediagraph\n",
505 dvb_media_device_free(dvbdev
);
508 up_write(&minor_rwsem
);
509 mutex_unlock(&dvbdev_register_lock
);
513 mutex_unlock(&dvbdev_register_lock
);
515 clsdev
= device_create(dvb_class
, adap
->device
,
516 MKDEV(DVB_MAJOR
, minor
),
517 dvbdev
, "dvb%d.%s%d", adap
->num
, dnames
[type
], id
);
518 if (IS_ERR(clsdev
)) {
519 pr_err("%s: failed to create device dvb%d.%s%d (%ld)\n",
520 __func__
, adap
->num
, dnames
[type
], id
, PTR_ERR(clsdev
));
521 return PTR_ERR(clsdev
);
523 dprintk("DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n",
524 adap
->num
, dnames
[type
], id
, minor
, minor
);
528 EXPORT_SYMBOL(dvb_register_device
);
531 void dvb_remove_device(struct dvb_device
*dvbdev
)
536 down_write(&minor_rwsem
);
537 dvb_minors
[dvbdev
->minor
] = NULL
;
538 up_write(&minor_rwsem
);
540 dvb_media_device_free(dvbdev
);
542 device_destroy(dvb_class
, MKDEV(DVB_MAJOR
, dvbdev
->minor
));
544 list_del (&dvbdev
->list_head
);
546 EXPORT_SYMBOL(dvb_remove_device
);
549 void dvb_free_device(struct dvb_device
*dvbdev
)
554 kfree (dvbdev
->fops
);
557 EXPORT_SYMBOL(dvb_free_device
);
560 void dvb_unregister_device(struct dvb_device
*dvbdev
)
562 dvb_remove_device(dvbdev
);
563 dvb_free_device(dvbdev
);
565 EXPORT_SYMBOL(dvb_unregister_device
);
568 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
570 static int dvb_create_io_intf_links(struct dvb_adapter
*adap
,
571 struct media_interface
*intf
,
574 struct media_device
*mdev
= adap
->mdev
;
575 struct media_entity
*entity
;
576 struct media_link
*link
;
578 media_device_for_each_entity(entity
, mdev
) {
579 if (entity
->function
== MEDIA_ENT_F_IO_DTV
) {
580 if (strncmp(entity
->name
, name
, strlen(name
)))
582 link
= media_create_intf_link(entity
, intf
,
583 MEDIA_LNK_FL_ENABLED
);
591 int dvb_create_media_graph(struct dvb_adapter
*adap
,
592 bool create_rf_connector
)
594 struct media_device
*mdev
= adap
->mdev
;
595 struct media_entity
*entity
, *tuner
= NULL
, *demod
= NULL
, *conn
;
596 struct media_entity
*demux
= NULL
, *ca
= NULL
;
597 struct media_link
*link
;
598 struct media_interface
*intf
;
599 unsigned demux_pad
= 0;
600 unsigned dvr_pad
= 0;
601 unsigned ntuner
= 0, ndemod
= 0;
603 static const char *connector_name
= "Television";
608 media_device_for_each_entity(entity
, mdev
) {
609 switch (entity
->function
) {
610 case MEDIA_ENT_F_TUNER
:
614 case MEDIA_ENT_F_DTV_DEMOD
:
618 case MEDIA_ENT_F_TS_DEMUX
:
621 case MEDIA_ENT_F_DTV_CA
:
628 * Prepare to signalize to media_create_pad_links() that multiple
629 * entities of the same type exists and a 1:n or n:1 links need to be
631 * NOTE: if both tuner and demod have multiple instances, it is up
632 * to the caller driver to create such links.
639 if (create_rf_connector
) {
640 conn
= kzalloc(sizeof(*conn
), GFP_KERNEL
);
645 adap
->conn_pads
= kzalloc(sizeof(*adap
->conn_pads
), GFP_KERNEL
);
646 if (!adap
->conn_pads
)
649 conn
->flags
= MEDIA_ENT_FL_CONNECTOR
;
650 conn
->function
= MEDIA_ENT_F_CONN_RF
;
651 conn
->name
= connector_name
;
652 adap
->conn_pads
->flags
= MEDIA_PAD_FL_SOURCE
;
654 ret
= media_entity_pads_init(conn
, 1, adap
->conn_pads
);
658 ret
= media_device_register_entity(mdev
, conn
);
663 ret
= media_create_pad_links(mdev
,
666 MEDIA_ENT_F_DTV_DEMOD
,
668 MEDIA_LNK_FL_ENABLED
,
671 ret
= media_create_pad_links(mdev
,
675 tuner
, TUNER_PAD_RF_INPUT
,
676 MEDIA_LNK_FL_ENABLED
,
682 if (ntuner
&& ndemod
) {
683 ret
= media_create_pad_links(mdev
,
685 tuner
, TUNER_PAD_OUTPUT
,
686 MEDIA_ENT_F_DTV_DEMOD
,
687 demod
, 0, MEDIA_LNK_FL_ENABLED
,
693 if (ndemod
&& demux
) {
694 ret
= media_create_pad_links(mdev
,
695 MEDIA_ENT_F_DTV_DEMOD
,
697 MEDIA_ENT_F_TS_DEMUX
,
698 demux
, 0, MEDIA_LNK_FL_ENABLED
,
704 ret
= media_create_pad_link(demux
, 1, ca
,
705 0, MEDIA_LNK_FL_ENABLED
);
710 /* Create demux links for each ringbuffer/pad */
712 media_device_for_each_entity(entity
, mdev
) {
713 if (entity
->function
== MEDIA_ENT_F_IO_DTV
) {
714 if (!strncmp(entity
->name
, DVR_TSOUT
,
715 strlen(DVR_TSOUT
))) {
716 ret
= media_create_pad_link(demux
,
722 if (!strncmp(entity
->name
, DEMUX_TSOUT
,
723 strlen(DEMUX_TSOUT
))) {
724 ret
= media_create_pad_link(demux
,
734 /* Create interface links for FE->tuner, DVR->demux and CA->ca */
735 media_device_for_each_intf(intf
, mdev
) {
736 if (intf
->type
== MEDIA_INTF_T_DVB_CA
&& ca
) {
737 link
= media_create_intf_link(ca
, intf
,
738 MEDIA_LNK_FL_ENABLED
);
743 if (intf
->type
== MEDIA_INTF_T_DVB_FE
&& tuner
) {
744 link
= media_create_intf_link(tuner
, intf
,
745 MEDIA_LNK_FL_ENABLED
);
751 * Indirect link - let's not create yet, as we don't know how
752 * to handle indirect links, nor if this will
753 * actually be needed.
755 if (intf
->type
== MEDIA_INTF_T_DVB_DVR
&& demux
) {
756 link
= media_create_intf_link(demux
, intf
,
757 MEDIA_LNK_FL_ENABLED
);
762 if (intf
->type
== MEDIA_INTF_T_DVB_DVR
) {
763 ret
= dvb_create_io_intf_links(adap
, intf
, DVR_TSOUT
);
767 if (intf
->type
== MEDIA_INTF_T_DVB_DEMUX
) {
768 ret
= dvb_create_io_intf_links(adap
, intf
, DEMUX_TSOUT
);
775 EXPORT_SYMBOL_GPL(dvb_create_media_graph
);
778 static int dvbdev_check_free_adapter_num(int num
)
780 struct list_head
*entry
;
781 list_for_each(entry
, &dvb_adapter_list
) {
782 struct dvb_adapter
*adap
;
783 adap
= list_entry(entry
, struct dvb_adapter
, list_head
);
784 if (adap
->num
== num
)
790 static int dvbdev_get_free_adapter_num (void)
794 while (num
< DVB_MAX_ADAPTERS
) {
795 if (dvbdev_check_free_adapter_num(num
))
804 int dvb_register_adapter(struct dvb_adapter
*adap
, const char *name
,
805 struct module
*module
, struct device
*device
,
810 mutex_lock(&dvbdev_register_lock
);
812 for (i
= 0; i
< DVB_MAX_ADAPTERS
; ++i
) {
813 num
= adapter_nums
[i
];
814 if (num
>= 0 && num
< DVB_MAX_ADAPTERS
) {
815 /* use the one the driver asked for */
816 if (dvbdev_check_free_adapter_num(num
))
819 num
= dvbdev_get_free_adapter_num();
826 mutex_unlock(&dvbdev_register_lock
);
830 memset (adap
, 0, sizeof(struct dvb_adapter
));
831 INIT_LIST_HEAD (&adap
->device_list
);
833 pr_info("DVB: registering new adapter (%s)\n", name
);
837 adap
->module
= module
;
838 adap
->device
= device
;
839 adap
->mfe_shared
= 0;
840 adap
->mfe_dvbdev
= NULL
;
841 mutex_init (&adap
->mfe_lock
);
843 list_add_tail (&adap
->list_head
, &dvb_adapter_list
);
845 mutex_unlock(&dvbdev_register_lock
);
849 EXPORT_SYMBOL(dvb_register_adapter
);
852 int dvb_unregister_adapter(struct dvb_adapter
*adap
)
854 mutex_lock(&dvbdev_register_lock
);
855 list_del (&adap
->list_head
);
856 mutex_unlock(&dvbdev_register_lock
);
859 EXPORT_SYMBOL(dvb_unregister_adapter
);
861 /* if the miracle happens and "generic_usercopy()" is included into
862 the kernel, then this can vanish. please don't make the mistake and
863 define this as video_usercopy(). this will introduce a dependecy
864 to the v4l "videodev.o" module, which is unnecessary for some
865 cards (ie. the budget dvb-cards don't need the v4l module...) */
866 int dvb_usercopy(struct file
*file
,
867 unsigned int cmd
, unsigned long arg
,
868 int (*func
)(struct file
*file
,
869 unsigned int cmd
, void *arg
))
876 /* Copy arguments into temp kernel buffer */
877 switch (_IOC_DIR(cmd
)) {
880 * For this command, the pointer is actually an integer
885 case _IOC_READ
: /* some v4l ioctls are marked wrong ... */
887 case (_IOC_WRITE
| _IOC_READ
):
888 if (_IOC_SIZE(cmd
) <= sizeof(sbuf
)) {
891 /* too big to allocate from stack */
892 mbuf
= kmalloc(_IOC_SIZE(cmd
), GFP_KERNEL
);
899 if (copy_from_user(parg
, (void __user
*)arg
, _IOC_SIZE(cmd
)))
905 if ((err
= func(file
, cmd
, parg
)) == -ENOIOCTLCMD
)
911 /* Copy results into user buffer */
912 switch (_IOC_DIR(cmd
))
915 case (_IOC_WRITE
| _IOC_READ
):
916 if (copy_to_user((void __user
*)arg
, parg
, _IOC_SIZE(cmd
)))
926 static int dvb_uevent(struct device
*dev
, struct kobj_uevent_env
*env
)
928 struct dvb_device
*dvbdev
= dev_get_drvdata(dev
);
930 add_uevent_var(env
, "DVB_ADAPTER_NUM=%d", dvbdev
->adapter
->num
);
931 add_uevent_var(env
, "DVB_DEVICE_TYPE=%s", dnames
[dvbdev
->type
]);
932 add_uevent_var(env
, "DVB_DEVICE_NUM=%d", dvbdev
->id
);
936 static char *dvb_devnode(struct device
*dev
, umode_t
*mode
)
938 struct dvb_device
*dvbdev
= dev_get_drvdata(dev
);
940 return kasprintf(GFP_KERNEL
, "dvb/adapter%d/%s%d",
941 dvbdev
->adapter
->num
, dnames
[dvbdev
->type
], dvbdev
->id
);
945 static int __init
init_dvbdev(void)
948 dev_t dev
= MKDEV(DVB_MAJOR
, 0);
950 if ((retval
= register_chrdev_region(dev
, MAX_DVB_MINORS
, "DVB")) != 0) {
951 pr_err("dvb-core: unable to get major %d\n", DVB_MAJOR
);
955 cdev_init(&dvb_device_cdev
, &dvb_device_fops
);
956 if ((retval
= cdev_add(&dvb_device_cdev
, dev
, MAX_DVB_MINORS
)) != 0) {
957 pr_err("dvb-core: unable register character device\n");
961 dvb_class
= class_create(THIS_MODULE
, "dvb");
962 if (IS_ERR(dvb_class
)) {
963 retval
= PTR_ERR(dvb_class
);
966 dvb_class
->dev_uevent
= dvb_uevent
;
967 dvb_class
->devnode
= dvb_devnode
;
971 cdev_del(&dvb_device_cdev
);
972 unregister_chrdev_region(dev
, MAX_DVB_MINORS
);
977 static void __exit
exit_dvbdev(void)
979 class_destroy(dvb_class
);
980 cdev_del(&dvb_device_cdev
);
981 unregister_chrdev_region(MKDEV(DVB_MAJOR
, 0), MAX_DVB_MINORS
);
984 subsys_initcall(init_dvbdev
);
985 module_exit(exit_dvbdev
);
987 MODULE_DESCRIPTION("DVB Core Driver");
988 MODULE_AUTHOR("Marcus Metzler, Ralph Metzler, Holger Waechtler");
989 MODULE_LICENSE("GPL");