]> Pileus Git - ~andy/linux/blobdiff - drivers/hid/hid-roccat.c
Merge branch 'can/at91_can-for-net-2.6' of git://git.pengutronix.de/git/mkl/linux-2.6
[~andy/linux] / drivers / hid / hid-roccat.c
index a9d9b29ff47f65347fcaa70db94d6ea41fcd490f..a14c579ea781950787365ea3d2d0218defde5ec8 100644 (file)
@@ -21,6 +21,8 @@
  * It is inspired by hidraw, but uses only one circular buffer for all readers.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/cdev.h>
 #include <linux/poll.h>
 #include <linux/sched.h>
@@ -65,7 +67,6 @@ struct roccat_reader {
 };
 
 static int roccat_major;
-static struct class *roccat_class;
 static struct cdev roccat_cdev;
 
 static struct roccat_device *devices[ROCCAT_MAX_DEVICES];
@@ -165,8 +166,7 @@ static int roccat_open(struct inode *inode, struct file *file)
        mutex_lock(&device->readers_lock);
 
        if (!device) {
-               printk(KERN_EMERG "roccat device with minor %d doesn't exist\n",
-                               minor);
+               pr_emerg("roccat device with minor %d doesn't exist\n", minor);
                error = -ENODEV;
                goto exit_err;
        }
@@ -214,8 +214,7 @@ static int roccat_release(struct inode *inode, struct file *file)
        device = devices[minor];
        if (!device) {
                mutex_unlock(&devices_lock);
-               printk(KERN_EMERG "roccat device with minor %d doesn't exist\n",
-                               minor);
+               pr_emerg("roccat device with minor %d doesn't exist\n", minor);
                return -ENODEV;
        }
 
@@ -289,12 +288,14 @@ EXPORT_SYMBOL_GPL(roccat_report_event);
 
 /*
  * roccat_connect() - create a char device for special event output
+ * @class: the class thats used to create the device. Meant to hold device
+ * specific sysfs attributes.
  * @hid: the hid device the char device should be connected to.
  *
  * Return value is minor device number in Range [0, ROCCAT_MAX_DEVICES] on
  * success, a negative error code on failure.
  */
-int roccat_connect(struct hid_device *hid)
+int roccat_connect(struct class *klass, struct hid_device *hid)
 {
        unsigned int minor;
        struct roccat_device *device;
@@ -320,7 +321,7 @@ int roccat_connect(struct hid_device *hid)
                return -EINVAL;
        }
 
-       device->dev = device_create(roccat_class, &hid->dev,
+       device->dev = device_create(klass, &hid->dev,
                        MKDEV(roccat_major, minor), NULL,
                        "%s%s%d", "roccat", hid->driver->name, minor);
 
@@ -361,7 +362,7 @@ void roccat_disconnect(int minor)
 
        device->exist = 0; /* TODO exist maybe not needed */
 
-       device_destroy(roccat_class, MKDEV(roccat_major, minor));
+       device_destroy(device->dev->class, MKDEV(roccat_major, minor));
 
        if (device->open) {
                hid_hw_close(device->hid);
@@ -392,14 +393,7 @@ static int __init roccat_init(void)
        roccat_major = MAJOR(dev_id);
 
        if (retval < 0) {
-               printk(KERN_WARNING "roccat: can't get major number\n");
-               return retval;
-       }
-
-       roccat_class = class_create(THIS_MODULE, "roccat");
-       if (IS_ERR(roccat_class)) {
-               retval = PTR_ERR(roccat_class);
-               unregister_chrdev_region(dev_id, ROCCAT_MAX_DEVICES);
+               pr_warn("can't get major number\n");
                return retval;
        }
 
@@ -414,7 +408,6 @@ static void __exit roccat_exit(void)
        dev_t dev_id = MKDEV(roccat_major, 0);
 
        cdev_del(&roccat_cdev);
-       class_destroy(roccat_class);
        unregister_chrdev_region(dev_id, ROCCAT_MAX_DEVICES);
 }