diff options
author | Jim Cromie <jim.cromie@gmail.com> | 2006-07-10 04:45:37 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-07-10 13:24:26 -0700 |
commit | babcfade47371eea81fd7f24d892b5ff5b1786ea (patch) | |
tree | a0b5f1ce6d0ab758f78a35a1e8fd0ce07c8572f3 | |
parent | 27385085f19a9bc9b147905554e6e2509fdaceb2 (diff) | |
download | lwn-babcfade47371eea81fd7f24d892b5ff5b1786ea.tar.gz lwn-babcfade47371eea81fd7f24d892b5ff5b1786ea.zip |
[PATCH] pc8736x_gpio: fix re-modprobe errors: fix/finish cdev-init
- Switch from register_chrdev() to (register|alloc)_chrdev_region().
- use a cdev. This was intended for original patchset, but was
overlooked.
We use a single cdev for all pins (minor device-numbers), as gleaned
from cs5535_gpio, and in contrast to whats currently done in scx200_gpio
(which I'll fix soon)
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | drivers/char/pc8736x_gpio.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/char/pc8736x_gpio.c b/drivers/char/pc8736x_gpio.c index bfc45e0cc602..11bd78c80628 100644 --- a/drivers/char/pc8736x_gpio.c +++ b/drivers/char/pc8736x_gpio.c @@ -259,7 +259,8 @@ static struct cdev pc8736x_gpio_cdev; static int __init pc8736x_gpio_init(void) { - int rc = 0; + int rc; + dev_t devid; pdev = platform_device_alloc(DEVNAME, 0); if (!pdev) @@ -307,7 +308,14 @@ static int __init pc8736x_gpio_init(void) } dev_info(&pdev->dev, "GPIO ioport %x reserved\n", pc8736x_gpio_base); - rc = register_chrdev(major, DEVNAME, &pc8736x_gpio_fops); + if (major) { + devid = MKDEV(major, 0); + rc = register_chrdev_region(devid, PC8736X_GPIO_CT, DEVNAME); + } else { + rc = alloc_chrdev_region(&devid, 0, PC8736X_GPIO_CT, DEVNAME); + major = MAJOR(devid); + } + if (rc < 0) { dev_err(&pdev->dev, "register-chrdev failed: %d\n", rc); goto undo_request_region; @@ -318,6 +326,11 @@ static int __init pc8736x_gpio_init(void) } pc8736x_init_shadow(); + + /* ignore minor errs, and succeed */ + cdev_init(&pc8736x_gpio_cdev, &pc8736x_gpio_fops); + cdev_add(&pc8736x_gpio_cdev, devid, PC8736X_GPIO_CT); + return 0; undo_request_region: |