aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorJim Cromie <jim.cromie@gmail.com>2006-06-27 05:54:23 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-27 20:32:43 -0400
commitf31000e573da052b6b8bcc21faff520b4e2eda7a (patch)
tree670d5e6e00da615f70d99a950cfe7b8603edad26 /drivers/char
parent58b087cda1e9e46c7061c2282f92bd8e1970bfe7 (diff)
[PATCH] chardev: GPIO for SCx200 & PC-8736x: use dev_dbg in common module
Use of dev_dbg() and friends is considered good practice. dev_dbg() needs a struct device *devp, but nsc_gpio is only a helper module, so it doesnt have/need its own. To provide devp to the user-modules (scx200 & pc8736x _gpio), we add it to the vtable, and set it during init. Also squeeze nsc_gpio_dump()'s format a little. [ 199.259879] pc8736x_gpio.0: io09: 0x0044 TS OD PUE EDGE LO DEBOUNCE 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/nsc_gpio.c45
-rw-r--r--drivers/char/pc8736x_gpio.c3
-rw-r--r--drivers/char/scx200_gpio.c11
3 files changed, 29 insertions, 30 deletions
diff --git a/drivers/char/nsc_gpio.c b/drivers/char/nsc_gpio.c
index 929d68486c1a..d0b5d65a73fb 100644
--- a/drivers/char/nsc_gpio.c
+++ b/drivers/char/nsc_gpio.c
@@ -14,22 +14,27 @@
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/nsc_gpio.h> 16#include <linux/nsc_gpio.h>
17#include <linux/platform_device.h>
17#include <asm/uaccess.h> 18#include <asm/uaccess.h>
18#include <asm/io.h> 19#include <asm/io.h>
19 20
20#define NAME "nsc_gpio" 21#define NAME "nsc_gpio"
21 22
22void nsc_gpio_dump(unsigned index, u32 config) 23void nsc_gpio_dump(struct nsc_gpio_ops *amp, unsigned index)
23{ 24{
24 printk(KERN_INFO NAME ": GPIO-%02u: 0x%08lx %s %s %s %s %s %s %s\n", 25 /* retrieve current config w/o changing it */
25 index, (unsigned long)config, 26 u32 config = amp->gpio_config(index, ~0, 0);
26 (config & 1) ? "OE" : "TS", /* output-enabled/tristate */ 27
27 (config & 2) ? "PP" : "OD", /* push pull / open drain */ 28 /* user requested via 'v' command, so its INFO */
28 (config & 4) ? "PUE" : "PUD", /* pull up enabled/disabled */ 29 dev_info(amp->dev, "io%02u: 0x%04x %s %s %s %s %s %s %s\n",
29 (config & 8) ? "LOCKED" : "", /* locked / unlocked */ 30 index, config,
30 (config & 16) ? "LEVEL" : "EDGE",/* level/edge input */ 31 (config & 1) ? "OE" : "TS", /* output-enabled/tristate */
31 (config & 32) ? "HI" : "LO", /* trigger on rise/fall edge */ 32 (config & 2) ? "PP" : "OD", /* push pull / open drain */
32 (config & 64) ? "DEBOUNCE" : ""); /* debounce */ 33 (config & 4) ? "PUE" : "PUD", /* pull up enabled/disabled */
34 (config & 8) ? "LOCKED" : "", /* locked / unlocked */
35 (config & 16) ? "LEVEL" : "EDGE",/* level/edge input */
36 (config & 32) ? "HI" : "LO", /* trigger on rise/fall edge */
37 (config & 64) ? "DEBOUNCE" : ""); /* debounce */
33} 38}
34 39
35ssize_t nsc_gpio_write(struct file *file, const char __user *data, 40ssize_t nsc_gpio_write(struct file *file, const char __user *data,
@@ -37,6 +42,7 @@ ssize_t nsc_gpio_write(struct file *file, const char __user *data,
37{ 42{
38 unsigned m = iminor(file->f_dentry->d_inode); 43 unsigned m = iminor(file->f_dentry->d_inode);
39 struct nsc_gpio_ops *amp = file->private_data; 44 struct nsc_gpio_ops *amp = file->private_data;
45 struct device *dev = amp->dev;
40 size_t i; 46 size_t i;
41 int err = 0; 47 int err = 0;
42 48
@@ -52,42 +58,41 @@ ssize_t nsc_gpio_write(struct file *file, const char __user *data,
52 amp->gpio_set(m, 1); 58 amp->gpio_set(m, 1);
53 break; 59 break;
54 case 'O': 60 case 'O':
55 printk(KERN_INFO NAME ": GPIO%d output enabled\n", m); 61 dev_dbg(dev, "GPIO%d output enabled\n", m);
56 amp->gpio_config(m, ~1, 1); 62 amp->gpio_config(m, ~1, 1);
57 break; 63 break;
58 case 'o': 64 case 'o':
59 printk(KERN_INFO NAME ": GPIO%d output disabled\n", m); 65 dev_dbg(dev, "GPIO%d output disabled\n", m);
60 amp->gpio_config(m, ~1, 0); 66 amp->gpio_config(m, ~1, 0);
61 break; 67 break;
62 case 'T': 68 case 'T':
63 printk(KERN_INFO NAME ": GPIO%d output is push pull\n", 69 dev_dbg(dev, "GPIO%d output is push pull\n",
64 m); 70 m);
65 amp->gpio_config(m, ~2, 2); 71 amp->gpio_config(m, ~2, 2);
66 break; 72 break;
67 case 't': 73 case 't':
68 printk(KERN_INFO NAME ": GPIO%d output is open drain\n", 74 dev_dbg(dev, "GPIO%d output is open drain\n",
69 m); 75 m);
70 amp->gpio_config(m, ~2, 0); 76 amp->gpio_config(m, ~2, 0);
71 break; 77 break;
72 case 'P': 78 case 'P':
73 printk(KERN_INFO NAME ": GPIO%d pull up enabled\n", m); 79 dev_dbg(dev, "GPIO%d pull up enabled\n", m);
74 amp->gpio_config(m, ~4, 4); 80 amp->gpio_config(m, ~4, 4);
75 break; 81 break;
76 case 'p': 82 case 'p':
77 printk(KERN_INFO NAME ": GPIO%d pull up disabled\n", m); 83 dev_dbg(dev, "GPIO%d pull up disabled\n", m);
78 amp->gpio_config(m, ~4, 0); 84 amp->gpio_config(m, ~4, 0);
79 break; 85 break;
80 case 'v': 86 case 'v':
81 /* View Current pin settings */ 87 /* View Current pin settings */
82 amp->gpio_dump(m); 88 amp->gpio_dump(amp, m);
83 break; 89 break;
84 case '\n': 90 case '\n':
85 /* end of settings string, do nothing */ 91 /* end of settings string, do nothing */
86 break; 92 break;
87 default: 93 default:
88 printk(KERN_ERR NAME 94 dev_err(dev, "io%2d bad setting: chr<0x%2x>\n",
89 ": GPIO-%2d bad setting: chr<0x%2x>\n", m, 95 m, (int)c);
90 (int)c);
91 err++; 96 err++;
92 } 97 }
93 } 98 }
diff --git a/drivers/char/pc8736x_gpio.c b/drivers/char/pc8736x_gpio.c
index b16fbef816c2..48ff1fc8b06d 100644
--- a/drivers/char/pc8736x_gpio.c
+++ b/drivers/char/pc8736x_gpio.c
@@ -207,8 +207,6 @@ static void pc8736x_gpio_change(unsigned index)
207 pc8736x_gpio_set(index, !pc8736x_gpio_get(index)); 207 pc8736x_gpio_set(index, !pc8736x_gpio_get(index));
208} 208}
209 209
210extern void nsc_gpio_dump(unsigned iminor);
211
212static struct nsc_gpio_ops pc8736x_access = { 210static struct nsc_gpio_ops pc8736x_access = {
213 .owner = THIS_MODULE, 211 .owner = THIS_MODULE,
214 .gpio_config = pc8736x_gpio_configure, 212 .gpio_config = pc8736x_gpio_configure,
@@ -260,6 +258,7 @@ static int __init pc8736x_gpio_init(void)
260 dev_err(&pdev->dev, "no device found\n"); 258 dev_err(&pdev->dev, "no device found\n");
261 goto undo_platform_dev_add; 259 goto undo_platform_dev_add;
262 } 260 }
261 pc8736x_access.dev = &pdev->dev;
263 262
264 /* Verify that chip and it's GPIO unit are both enabled. 263 /* Verify that chip and it's GPIO unit are both enabled.
265 My BIOS does this, so I take minimum action here 264 My BIOS does this, so I take minimum action here
diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c
index 442367b3f5dc..5a280a330401 100644
--- a/drivers/char/scx200_gpio.c
+++ b/drivers/char/scx200_gpio.c
@@ -35,14 +35,6 @@ static int major = 0; /* default to dynamic major */
35module_param(major, int, 0); 35module_param(major, int, 0);
36MODULE_PARM_DESC(major, "Major device number"); 36MODULE_PARM_DESC(major, "Major device number");
37 37
38extern void nsc_gpio_dump(unsigned index);
39
40extern ssize_t nsc_gpio_write(struct file *file, const char __user *data,
41 size_t len, loff_t *ppos);
42
43extern ssize_t nsc_gpio_read(struct file *file, char __user *buf,
44 size_t len, loff_t *ppos);
45
46struct nsc_gpio_ops scx200_access = { 38struct nsc_gpio_ops scx200_access = {
47 .owner = THIS_MODULE, 39 .owner = THIS_MODULE,
48 .gpio_config = scx200_gpio_configure, 40 .gpio_config = scx200_gpio_configure,
@@ -101,6 +93,9 @@ static int __init scx200_gpio_init(void)
101 if (rc) 93 if (rc)
102 goto undo_malloc; 94 goto undo_malloc;
103 95
96 /* nsc_gpio uses dev_dbg(), so needs this */
97 scx200_access.dev = &pdev->dev;
98
104 if (major) 99 if (major)
105 rc = register_chrdev_region(dev, num_pins, "scx200_gpio"); 100 rc = register_chrdev_region(dev, num_pins, "scx200_gpio");
106 else { 101 else {