diff options
author | Jim Cromie <jim.cromie@gmail.com> | 2006-07-14 03:24:16 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-07-15 00:53:53 -0400 |
commit | 635adb6cd25c8f816c9017a0a0349cd389eafcd3 (patch) | |
tree | 411268749d87ebebff2183990d776b4571c7e76a /drivers/char | |
parent | ae2d1f2f5b59d00b39283c52dc4ee675397bbacd (diff) |
[PATCH] scx200_gpio: use 1 cdev for N minors, not N for N
Remove the scx200_gpio's cdev-array & ksalloc, replacing it with a single
static struct cdev, which is sufficient for all the pins.
cdev_put is commented out since kernel wont link properly with it, and its
apparently not needed.
With these patches, this driver continues to work with Chris Boot's
leds_48xx driver.
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>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/scx200_gpio.c | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c index e7665c1ad134..dd1f997944e6 100644 --- a/drivers/char/scx200_gpio.c +++ b/drivers/char/scx200_gpio.c | |||
@@ -63,7 +63,6 @@ static int scx200_gpio_release(struct inode *inode, struct file *file) | |||
63 | return 0; | 63 | return 0; |
64 | } | 64 | } |
65 | 65 | ||
66 | |||
67 | static const struct file_operations scx200_gpio_fops = { | 66 | static const struct file_operations scx200_gpio_fops = { |
68 | .owner = THIS_MODULE, | 67 | .owner = THIS_MODULE, |
69 | .write = nsc_gpio_write, | 68 | .write = nsc_gpio_write, |
@@ -72,11 +71,11 @@ static const struct file_operations scx200_gpio_fops = { | |||
72 | .release = scx200_gpio_release, | 71 | .release = scx200_gpio_release, |
73 | }; | 72 | }; |
74 | 73 | ||
75 | struct cdev *scx200_devices; | 74 | struct cdev scx200_gpio_cdev; /* use 1 cdev for all pins */ |
76 | 75 | ||
77 | static int __init scx200_gpio_init(void) | 76 | static int __init scx200_gpio_init(void) |
78 | { | 77 | { |
79 | int rc, i; | 78 | int rc; |
80 | dev_t devid; | 79 | dev_t devid; |
81 | 80 | ||
82 | if (!scx200_gpio_present()) { | 81 | if (!scx200_gpio_present()) { |
@@ -107,25 +106,12 @@ static int __init scx200_gpio_init(void) | |||
107 | dev_err(&pdev->dev, "SCx200 chrdev_region err: %d\n", rc); | 106 | dev_err(&pdev->dev, "SCx200 chrdev_region err: %d\n", rc); |
108 | goto undo_platform_device_add; | 107 | goto undo_platform_device_add; |
109 | } | 108 | } |
110 | scx200_devices = kzalloc(MAX_PINS * sizeof(struct cdev), GFP_KERNEL); | 109 | |
111 | if (!scx200_devices) { | 110 | cdev_init(&scx200_gpio_cdev, &scx200_gpio_fops); |
112 | rc = -ENOMEM; | 111 | cdev_add(&scx200_gpio_cdev, devid, MAX_PINS); |
113 | goto undo_chrdev_region; | ||
114 | } | ||
115 | for (i = 0; i < MAX_PINS; i++) { | ||
116 | struct cdev *cdev = &scx200_devices[i]; | ||
117 | cdev_init(cdev, &scx200_gpio_fops); | ||
118 | cdev->owner = THIS_MODULE; | ||
119 | rc = cdev_add(cdev, MKDEV(major, i), 1); | ||
120 | /* tolerate 'minor' errors */ | ||
121 | if (rc) | ||
122 | dev_err(&pdev->dev, "Error %d on minor %d", rc, i); | ||
123 | } | ||
124 | 112 | ||
125 | return 0; /* succeed */ | 113 | return 0; /* succeed */ |
126 | 114 | ||
127 | undo_chrdev_region: | ||
128 | unregister_chrdev_region(devid, MAX_PINS); | ||
129 | undo_platform_device_add: | 115 | undo_platform_device_add: |
130 | platform_device_del(pdev); | 116 | platform_device_del(pdev); |
131 | undo_malloc: | 117 | undo_malloc: |
@@ -136,7 +122,9 @@ undo_malloc: | |||
136 | 122 | ||
137 | static void __exit scx200_gpio_cleanup(void) | 123 | static void __exit scx200_gpio_cleanup(void) |
138 | { | 124 | { |
139 | kfree(scx200_devices); | 125 | cdev_del(&scx200_gpio_cdev); |
126 | /* cdev_put(&scx200_gpio_cdev); */ | ||
127 | |||
140 | unregister_chrdev_region(MKDEV(major, 0), MAX_PINS); | 128 | unregister_chrdev_region(MKDEV(major, 0), MAX_PINS); |
141 | platform_device_unregister(pdev); | 129 | platform_device_unregister(pdev); |
142 | } | 130 | } |