aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/danube/files/drivers/char/danube_gpio.c
diff options
context:
space:
mode:
authorJohn Crispin <john@openwrt.org>2007-12-13 22:38:51 +0000
committerJohn Crispin <john@openwrt.org>2007-12-13 22:38:51 +0000
commitfe1ee2d5b953647832261fba5487921da5a1b9f7 (patch)
tree4a1029b891704594254d9b1fc3211433ad990b37 /target/linux/danube/files/drivers/char/danube_gpio.c
parentb81933c951855596309804b6730798deab503917 (diff)
downloadupstream-fe1ee2d5b953647832261fba5487921da5a1b9f7.tar.gz
upstream-fe1ee2d5b953647832261fba5487921da5a1b9f7.tar.bz2
upstream-fe1ee2d5b953647832261fba5487921da5a1b9f7.zip
danube gpio clean up
SVN-Revision: 9743
Diffstat (limited to 'target/linux/danube/files/drivers/char/danube_gpio.c')
-rw-r--r--target/linux/danube/files/drivers/char/danube_gpio.c127
1 files changed, 45 insertions, 82 deletions
diff --git a/target/linux/danube/files/drivers/char/danube_gpio.c b/target/linux/danube/files/drivers/char/danube_gpio.c
index df5cfe753e..f6f78adc13 100644
--- a/target/linux/danube/files/drivers/char/danube_gpio.c
+++ b/target/linux/danube/files/drivers/char/danube_gpio.c
@@ -29,13 +29,6 @@
#include <asm/danube/danube.h>
#include <asm/danube/danube_ioctl.h>
-
-#define PORT_IOC_CALL(ret,port,pin,func) \
- ret=danube_port_reserve_pin(port,pin,PORT_MODULE_ID); \
- if (ret == 0) ret=func(port,pin,PORT_MODULE_ID); \
- if (ret == 0) ret=danube_port_free_pin(port,pin,PORT_MODULE_ID);
-
-
#define MAX_PORTS 2
#define PINS_PER_PORT 16
@@ -310,7 +303,7 @@ danube_port_release (struct inode *inode, struct file *filelp)
static int
danube_port_ioctl (struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg)
+ unsigned int cmd, unsigned long arg)
{
int ret = 0;
volatile struct danube_port_ioctl_parm parm;
@@ -338,97 +331,67 @@ danube_port_ioctl (struct inode *inode, struct file *filp,
switch (cmd) {
case DANUBE_PORT_IOCOD:
- if (parm.value == 0x00) {
- PORT_IOC_CALL (ret, parm.port, parm.pin,
- danube_port_clear_open_drain);
- }
- else {
- PORT_IOC_CALL (ret, parm.port, parm.pin,
- danube_port_set_open_drain);
- }
+ if (parm.value == 0x00)
+ danube_port_clear_open_drain(parm.port, parm.pin);
+ else
+ danube_port_set_open_drain(parm.port, parm.pin);
break;
+
case DANUBE_PORT_IOCPUDSEL:
- if (parm.value == 0x00) {
- PORT_IOC_CALL (ret, parm.port, parm.pin,
- danube_port_clear_pudsel);
- }
- else {
- PORT_IOC_CALL (ret, parm.port, parm.pin,
- danube_port_set_pudsel);
- }
+ if (parm.value == 0x00)
+ danube_port_clear_pudsel(parm.port, parm.pin);
+ else
+ danube_port_set_pudsel(parm.port, parm.pin);
break;
+
case DANUBE_PORT_IOCPUDEN:
- if (parm.value == 0x00) {
- PORT_IOC_CALL (ret, parm.port, parm.pin,
- danube_port_clear_puden);
- }
- else {
- PORT_IOC_CALL (ret, parm.port, parm.pin,
- danube_port_set_puden);
- }
+ if (parm.value == 0x00)
+ danube_port_clear_puden(parm.port, parm.pin);
+ else
+ danube_port_set_puden(parm.port, parm.pin);
break;
+
case DANUBE_PORT_IOCSTOFF:
- if (parm.value == 0x00) {
- PORT_IOC_CALL (ret, parm.port, parm.pin,
- danube_port_clear_stoff);
- }
- else {
- PORT_IOC_CALL (ret, parm.port, parm.pin,
- danube_port_set_stoff);
- }
+ if (parm.value == 0x00)
+ danube_port_clear_stoff(parm.port, parm.pin);
+ else
+ danube_port_set_stoff(parm.port, parm.pin);
break;
+
case DANUBE_PORT_IOCDIR:
- if (parm.value == 0x00) {
- PORT_IOC_CALL (ret, parm.port, parm.pin,
- danube_port_set_dir_in);
- }
- else {
- PORT_IOC_CALL (ret, parm.port, parm.pin,
- danube_port_set_dir_out);
- }
+ if (parm.value == 0x00)
+ danube_port_set_dir_in(parm.port, parm.pin);
+ else
+ danube_port_set_dir_out(parm.port, parm.pin);
break;
+
case DANUBE_PORT_IOCOUTPUT:
- if (parm.value == 0x00) {
- PORT_IOC_CALL (ret, parm.port, parm.pin,
- danube_port_clear_output);
- }
- else {
- PORT_IOC_CALL (ret, parm.port, parm.pin,
- danube_port_set_output);
- }
+ if (parm.value == 0x00)
+ danube_port_clear_output(parm.port, parm.pin);
+ else
+ danube_port_set_output(parm.port, parm.pin);
break;
+
case DANUBE_PORT_IOCALTSEL0:
- if (parm.value == 0x00) {
- PORT_IOC_CALL (ret, parm.port, parm.pin,
- danube_port_clear_altsel0);
- }
- else {
- PORT_IOC_CALL (ret, parm.port, parm.pin,
- danube_port_set_altsel0);
- }
+ if (parm.value == 0x00)
+ danube_port_clear_altsel0(parm.port, parm.pin);
+ else
+ danube_port_set_altsel0(parm.port, parm.pin);
break;
+
case DANUBE_PORT_IOCALTSEL1:
- if (parm.value == 0x00) {
- PORT_IOC_CALL (ret, parm.port, parm.pin,
- danube_port_clear_altsel1);
- }
- else {
- PORT_IOC_CALL (ret, parm.port, parm.pin,
- danube_port_set_altsel1);
- }
+ if (parm.value == 0x00)
+ danube_port_clear_altsel1(parm.port, parm.pin);
+ else
+ danube_port_set_altsel1(parm.port, parm.pin);
break;
+
case DANUBE_PORT_IOCINPUT:
- ret = danube_port_reserve_pin (parm.port, parm.pin,
- PORT_MODULE_ID);
- if (ret == 0)
- parm.value =
- danube_port_get_input (parm.port, parm.pin,
- PORT_MODULE_ID);
- ret = danube_port_free_pin (parm.port, parm.pin,
- PORT_MODULE_ID);
- copy_to_user ((void *) arg, (void *) &parm,
- sizeof (struct danube_port_ioctl_parm));
+ parm.value = danube_port_get_input(parm.port, parm.pin);
+ copy_to_user((void*)arg, (void*)&parm,
+ sizeof(struct danube_port_ioctl_parm));
break;
+
default:
ret = -EINVAL;
}