lkml.org 
[lkml]   [2005]   [Jan]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 3/4] support up to six DVB cards
- [DVB] core: add support for up to six DVB cards by using
32bit dev_t capabilities

Signed-off-by: Johannes Stezenbach <js@linuxtv.org>

--- linux-2.6.11-rc2-bk2/drivers/media/dvb/dvb-core/dvbdev.c 2004-12-24 22:34:26.000000000 +0100
+++ linux-2.6.11-rc2-bk2-dvb/drivers/media/dvb/dvb-core/dvbdev.c 2005-01-25 00:35:45.000000000 +0100
@@ -31,6 +31,8 @@
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/device.h>
+#include <linux/fs.h>
+#include <linux/cdev.h>

#include "dvbdev.h"

@@ -50,8 +52,9 @@ static const char * const dnames[] = {
};


-#define DVB_MAX_IDS 4
+#define DVB_MAX_IDS 6
#define nums2minor(num,type,id) ((num << 6) | (id << 4) | type)
+#define MAX_DVB_MINORS (DVB_MAX_IDS*64)

struct class_simple *dvb_class;
EXPORT_SYMBOL(dvb_class);
@@ -109,6 +112,11 @@ static struct file_operations dvb_device
};


+static struct cdev dvb_device_cdev = {
+ .kobj = {.name = "dvb", },
+ .owner = THIS_MODULE,
+};
+
int dvb_generic_open(struct inode *inode, struct file *file)
{
struct dvb_device *dvbdev = file->private_data;
@@ -400,25 +408,41 @@ out:
static int __init init_dvbdev(void)
{
int retval;
+ dev_t dev = MKDEV(DVB_MAJOR, 0);
+
+ if ((retval = register_chrdev_region(dev, MAX_DVB_MINORS, "DVB")) != 0) {
+ printk("dvb-core: unable to get major %d\n", DVB_MAJOR);
+ return retval;
+ }

- if ((retval = register_chrdev(DVB_MAJOR,"DVB", &dvb_device_fops)))
+ cdev_init(&dvb_device_cdev, &dvb_device_fops);
+ if ((retval = cdev_add(&dvb_device_cdev, dev, MAX_DVB_MINORS)) != 0) {
printk("dvb-core: unable to get major %d\n", DVB_MAJOR);
+ goto error;
+ }

devfs_mk_dir("dvb");

dvb_class = class_simple_create(THIS_MODULE, "dvb");
- if (IS_ERR(dvb_class))
- return PTR_ERR(dvb_class);
+ if (IS_ERR(dvb_class)) {
+ retval = PTR_ERR(dvb_class);
+ goto error;
+ }
+ return 0;

+error:
+ cdev_del(&dvb_device_cdev);
+ unregister_chrdev_region(dev, MAX_DVB_MINORS);
return retval;
}


static void __exit exit_dvbdev(void)
{
- unregister_chrdev(DVB_MAJOR, "DVB");
devfs_remove("dvb");
class_simple_destroy(dvb_class);
+ cdev_del(&dvb_device_cdev);
+ unregister_chrdev_region(MKDEV(DVB_MAJOR, 0), MAX_DVB_MINORS);
}

module_init(init_dvbdev);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:09    [W:1.298 / U:0.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site