Merge rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[pandora-kernel.git] / drivers / char / scx200_gpio.c
index e7665c1..b956c7b 100644 (file)
@@ -35,23 +35,21 @@ MODULE_PARM_DESC(major, "Major device number");
 
 #define MAX_PINS 32            /* 64 later, when known ok */
 
-struct nsc_gpio_ops scx200_access = {
+struct nsc_gpio_ops scx200_gpio_ops = {
        .owner          = THIS_MODULE,
        .gpio_config    = scx200_gpio_configure,
        .gpio_dump      = nsc_gpio_dump,
        .gpio_get       = scx200_gpio_get,
        .gpio_set       = scx200_gpio_set,
-       .gpio_set_high  = scx200_gpio_set_high,
-       .gpio_set_low   = scx200_gpio_set_low,
        .gpio_change    = scx200_gpio_change,
        .gpio_current   = scx200_gpio_current
 };
-EXPORT_SYMBOL(scx200_access);
+EXPORT_SYMBOL(scx200_gpio_ops);
 
 static int scx200_gpio_open(struct inode *inode, struct file *file)
 {
        unsigned m = iminor(inode);
-       file->private_data = &scx200_access;
+       file->private_data = &scx200_gpio_ops;
 
        if (m >= MAX_PINS)
                return -EINVAL;
@@ -63,8 +61,7 @@ static int scx200_gpio_release(struct inode *inode, struct file *file)
        return 0;
 }
 
-
-static const struct file_operations scx200_gpio_fops = {
+static const struct file_operations scx200_gpio_fileops = {
        .owner   = THIS_MODULE,
        .write   = nsc_gpio_write,
        .read    = nsc_gpio_read,
@@ -72,11 +69,11 @@ static const struct file_operations scx200_gpio_fops = {
        .release = scx200_gpio_release,
 };
 
-struct cdev *scx200_devices;
+struct cdev scx200_gpio_cdev;  /* use 1 cdev for all pins */
 
 static int __init scx200_gpio_init(void)
 {
-       int rc, i;
+       int rc;
        dev_t devid;
 
        if (!scx200_gpio_present()) {
@@ -94,7 +91,7 @@ static int __init scx200_gpio_init(void)
                goto undo_malloc;
 
        /* nsc_gpio uses dev_dbg(), so needs this */
-       scx200_access.dev = &pdev->dev;
+       scx200_gpio_ops.dev = &pdev->dev;
 
        if (major) {
                devid = MKDEV(major, 0);
@@ -107,25 +104,12 @@ static int __init scx200_gpio_init(void)
                dev_err(&pdev->dev, "SCx200 chrdev_region err: %d\n", rc);
                goto undo_platform_device_add;
        }
-       scx200_devices = kzalloc(MAX_PINS * sizeof(struct cdev), GFP_KERNEL);
-       if (!scx200_devices) {
-               rc = -ENOMEM;
-               goto undo_chrdev_region;
-       }
-       for (i = 0; i < MAX_PINS; i++) {
-               struct cdev *cdev = &scx200_devices[i];
-               cdev_init(cdev, &scx200_gpio_fops);
-               cdev->owner = THIS_MODULE;
-               rc = cdev_add(cdev, MKDEV(major, i), 1);
-               /* tolerate 'minor' errors */
-               if (rc)
-                       dev_err(&pdev->dev, "Error %d on minor %d", rc, i);
-       }
+
+       cdev_init(&scx200_gpio_cdev, &scx200_gpio_fileops);
+       cdev_add(&scx200_gpio_cdev, devid, MAX_PINS);
 
        return 0; /* succeed */
 
-undo_chrdev_region:
-       unregister_chrdev_region(devid, MAX_PINS);
 undo_platform_device_add:
        platform_device_del(pdev);
 undo_malloc:
@@ -136,7 +120,9 @@ undo_malloc:
 
 static void __exit scx200_gpio_cleanup(void)
 {
-       kfree(scx200_devices);
+       cdev_del(&scx200_gpio_cdev);
+       /* cdev_put(&scx200_gpio_cdev); */
+
        unregister_chrdev_region(MKDEV(major, 0), MAX_PINS);
        platform_device_unregister(pdev);
 }