V4L/DVB (7140): constify function pointer tables
[deliverable/linux.git] / drivers / media / dvb / dvb-core / dvbdev.c
index a9fa3337dd81d653e20ae80c3acdb7235f2a37ab..ce5122e220f651ebd4853f368855d49195fd9f2b 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/module.h>
-#include <linux/moduleparam.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/slab.h>
@@ -59,18 +58,13 @@ static struct class *dvb_class;
 
 static struct dvb_device* dvbdev_find_device (int minor)
 {
-       struct list_head *entry;
+       struct dvb_adapter *adap;
 
-       list_for_each (entry, &dvb_adapter_list) {
-               struct list_head *entry0;
-               struct dvb_adapter *adap;
-               adap = list_entry (entry, struct dvb_adapter, list_head);
-               list_for_each (entry0, &adap->device_list) {
-                       struct dvb_device *dev;
-                       dev = list_entry (entry0, struct dvb_device, list_head);
+       list_for_each_entry(adap, &dvb_adapter_list, list_head) {
+               struct dvb_device *dev;
+               list_for_each_entry(dev, &adap->device_list, list_head)
                        if (nums2minor(adap->num, dev->type, dev->id) == minor)
                                return dev;
-               }
        }
 
        return NULL;
@@ -103,16 +97,13 @@ static int dvb_device_open(struct inode *inode, struct file *file)
 }
 
 
-static struct file_operations dvb_device_fops =
+static const struct file_operations dvb_device_fops =
 {
        .owner =        THIS_MODULE,
        .open =         dvb_device_open,
 };
 
-static struct cdev dvb_device_cdev = {
-       .kobj   = {.name = "dvb", },
-       .owner  =       THIS_MODULE,
-};
+static struct cdev dvb_device_cdev;
 
 int dvb_generic_open(struct inode *inode, struct file *file)
 {
@@ -180,13 +171,10 @@ static int dvbdev_get_free_id (struct dvb_adapter *adap, int type)
        u32 id = 0;
 
        while (id < DVB_MAX_IDS) {
-               struct list_head *entry;
-               list_for_each (entry, &adap->device_list) {
-                       struct dvb_device *dev;
-                       dev = list_entry (entry, struct dvb_device, list_head);
+               struct dvb_device *dev;
+               list_for_each_entry(dev, &adap->device_list, list_head)
                        if (dev->type == type && dev->id == id)
                                goto skip;
-               }
                return id;
 skip:
                id++;
@@ -200,7 +188,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
 {
        struct dvb_device *dvbdev;
        struct file_operations *dvbdevfops;
-       struct class_device *clsdev;
+       struct device *clsdev;
        int id;
 
        mutex_lock(&dvbdev_register_lock);
@@ -208,7 +196,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
        if ((id = dvbdev_get_free_id (adap, type)) < 0){
                mutex_unlock(&dvbdev_register_lock);
                *pdvbdev = NULL;
-               printk ("%s: could get find free device id...\n", __FUNCTION__);
+               printk(KERN_ERR "%s: couldn't find free device id\n", __FUNCTION__);
                return -ENFILE;
        }
 
@@ -242,17 +230,16 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
 
        mutex_unlock(&dvbdev_register_lock);
 
-       clsdev = class_device_create(dvb_class, NULL, MKDEV(DVB_MAJOR,
-                                    nums2minor(adap->num, type, id)),
-                                    adap->device, "dvb%d.%s%d", adap->num,
-                                    dnames[type], id);
+       clsdev = device_create(dvb_class, adap->device,
+                              MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)),
+                              "dvb%d.%s%d", adap->num, dnames[type], id);
        if (IS_ERR(clsdev)) {
                printk(KERN_ERR "%s: failed to create device dvb%d.%s%d (%ld)\n",
                       __FUNCTION__, adap->num, dnames[type], id, PTR_ERR(clsdev));
                return PTR_ERR(clsdev);
        }
 
-       dprintk("DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n",
+       dprintk(KERN_DEBUG "DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n",
                adap->num, dnames[type], id, nums2minor(adap->num, type, id),
                nums2minor(adap->num, type, id));
 
@@ -266,8 +253,8 @@ void dvb_unregister_device(struct dvb_device *dvbdev)
        if (!dvbdev)
                return;
 
-       class_device_destroy(dvb_class, MKDEV(DVB_MAJOR, nums2minor(dvbdev->adapter->num,
-                                       dvbdev->type, dvbdev->id)));
+       device_destroy(dvb_class, MKDEV(DVB_MAJOR, nums2minor(dvbdev->adapter->num,
+                      dvbdev->type, dvbdev->id)));
 
        list_del (&dvbdev->list_head);
        kfree (dvbdev->fops);
@@ -281,13 +268,10 @@ static int dvbdev_get_free_adapter_num (void)
        int num = 0;
 
        while (num < DVB_MAX_ADAPTERS) {
-               struct list_head *entry;
-               list_for_each (entry, &dvb_adapter_list) {
-                       struct dvb_adapter *adap;
-                       adap = list_entry (entry, struct dvb_adapter, list_head);
+               struct dvb_adapter *adap;
+               list_for_each_entry(adap, &dvb_adapter_list, list_head)
                        if (adap->num == num)
                                goto skip;
-               }
                return num;
 skip:
                num++;
@@ -311,7 +295,7 @@ int dvb_register_adapter(struct dvb_adapter *adap, const char *name, struct modu
        memset (adap, 0, sizeof(struct dvb_adapter));
        INIT_LIST_HEAD (&adap->device_list);
 
-       printk ("DVB: registering new adapter (%s).\n", name);
+       printk(KERN_INFO "DVB: registering new adapter (%s)\n", name);
 
        adap->num = num;
        adap->name = name;
@@ -407,13 +391,13 @@ static int __init init_dvbdev(void)
        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);
+               printk(KERN_ERR "dvb-core: unable to get major %d\n", DVB_MAJOR);
                return retval;
        }
 
        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);
+               printk(KERN_ERR "dvb-core: unable register character device\n");
                goto error;
        }
 
This page took 0.028393 seconds and 5 git commands to generate.