diff options
author | H Hartley Sweeten <hartleys@visionengravers.com> | 2012-06-22 19:28:33 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-06-22 23:55:07 -0400 |
commit | 1de02225358988e8fd48d1dc3fd12336bbae258a (patch) | |
tree | ffcc61017f8731faded894cd375ac0683a2a1e51 /drivers | |
parent | 54be9353682914693074078d203407806f8f3f34 (diff) |
staging: comedi: ni_daq_700: remove the CALLBACK_* code
This driver was originally copied from the 8255 driver. The 8255
uses a callback function to handle the io operations to the device.
In this driver, the callback adds unneeded complexity.
The CALLBACK_ARG for this driver is always 'dev->iobase' and the
CALLBACK_FUNC is always 'subdev_700_cb'.
The callback function is also overly complex for this driver.
It takes a 'dir' parameter to determine if the io is a write or
read, a 'port' parameter that is not used, a 'data' parameter
that is only used for writes, and an 'arg' which is the iobase
of the device.
Unwind all of it and just put the outb()/inb() call in the code
where needed.
This allows getting rid of the private data completely. Refactor
the code based on it's removal.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/comedi/drivers/ni_daq_700.c | 46 |
1 files changed, 2 insertions, 44 deletions
diff --git a/drivers/staging/comedi/drivers/ni_daq_700.c b/drivers/staging/comedi/drivers/ni_daq_700.c index 525f076c9a6d..59f7632351e0 100644 --- a/drivers/staging/comedi/drivers/ni_daq_700.c +++ b/drivers/staging/comedi/drivers/ni_daq_700.c | |||
@@ -66,28 +66,6 @@ struct dio700_board { | |||
66 | #define DIO_W 0x04 | 66 | #define DIO_W 0x04 |
67 | #define DIO_R 0x05 | 67 | #define DIO_R 0x05 |
68 | 68 | ||
69 | struct subdev_700_struct { | ||
70 | unsigned long cb_arg; | ||
71 | int (*cb_func) (int, int, int, unsigned long); | ||
72 | }; | ||
73 | |||
74 | #define CALLBACK_ARG (((struct subdev_700_struct *)s->private)->cb_arg) | ||
75 | #define CALLBACK_FUNC (((struct subdev_700_struct *)s->private)->cb_func) | ||
76 | #define subdevpriv ((struct subdev_700_struct *)s->private) | ||
77 | |||
78 | static int subdev_700_cb(int dir, int port, int data, unsigned long arg) | ||
79 | { | ||
80 | /* port is always A for output and B for input (8255 emu) */ | ||
81 | unsigned long iobase = arg; | ||
82 | |||
83 | if (dir) { | ||
84 | outb(data, iobase + DIO_W); | ||
85 | return 0; | ||
86 | } else { | ||
87 | return inb(iobase + DIO_R); | ||
88 | } | ||
89 | } | ||
90 | |||
91 | static int subdev_700_insn(struct comedi_device *dev, | 69 | static int subdev_700_insn(struct comedi_device *dev, |
92 | struct comedi_subdevice *s, struct comedi_insn *insn, | 70 | struct comedi_subdevice *s, struct comedi_insn *insn, |
93 | unsigned int *data) | 71 | unsigned int *data) |
@@ -97,12 +75,11 @@ static int subdev_700_insn(struct comedi_device *dev, | |||
97 | s->state |= (data[0] & data[1]); | 75 | s->state |= (data[0] & data[1]); |
98 | 76 | ||
99 | if (data[0] & 0xff) | 77 | if (data[0] & 0xff) |
100 | CALLBACK_FUNC(1, _700_DATA, s->state & 0xff, | 78 | outb(s->state & 0xff, dev->iobase + DIO_W); |
101 | CALLBACK_ARG); | ||
102 | } | 79 | } |
103 | 80 | ||
104 | data[1] = s->state & 0xff; | 81 | data[1] = s->state & 0xff; |
105 | data[1] |= CALLBACK_FUNC(0, _700_DATA, 0, CALLBACK_ARG) << 8; | 82 | data[1] |= inb(dev->iobase + DIO_R); |
106 | 83 | ||
107 | return insn->n; | 84 | return insn->n; |
108 | } | 85 | } |
@@ -142,16 +119,6 @@ static int subdev_700_init(struct comedi_device *dev, | |||
142 | s->range_table = &range_digital; | 119 | s->range_table = &range_digital; |
143 | s->maxdata = 1; | 120 | s->maxdata = 1; |
144 | 121 | ||
145 | s->private = kmalloc(sizeof(struct subdev_700_struct), GFP_KERNEL); | ||
146 | if (!s->private) | ||
147 | return -ENOMEM; | ||
148 | |||
149 | CALLBACK_ARG = arg; | ||
150 | if (cb == NULL) | ||
151 | CALLBACK_FUNC = subdev_700_cb; | ||
152 | else | ||
153 | CALLBACK_FUNC = cb; | ||
154 | |||
155 | s->insn_bits = subdev_700_insn; | 122 | s->insn_bits = subdev_700_insn; |
156 | s->insn_config = subdev_700_insn_config; | 123 | s->insn_config = subdev_700_insn_config; |
157 | 124 | ||
@@ -161,13 +128,6 @@ static int subdev_700_init(struct comedi_device *dev, | |||
161 | return 0; | 128 | return 0; |
162 | } | 129 | } |
163 | 130 | ||
164 | static void subdev_700_cleanup(struct comedi_device *dev, | ||
165 | struct comedi_subdevice *s) | ||
166 | { | ||
167 | if (s->private) | ||
168 | kfree(s->private); | ||
169 | } | ||
170 | |||
171 | static int dio700_attach(struct comedi_device *dev, struct comedi_devconfig *it) | 131 | static int dio700_attach(struct comedi_device *dev, struct comedi_devconfig *it) |
172 | { | 132 | { |
173 | const struct dio700_board *thisboard = comedi_board(dev); | 133 | const struct dio700_board *thisboard = comedi_board(dev); |
@@ -224,8 +184,6 @@ static int dio700_attach(struct comedi_device *dev, struct comedi_devconfig *it) | |||
224 | 184 | ||
225 | static void dio700_detach(struct comedi_device *dev) | 185 | static void dio700_detach(struct comedi_device *dev) |
226 | { | 186 | { |
227 | if (dev->subdevices) | ||
228 | subdev_700_cleanup(dev, dev->subdevices + 0); | ||
229 | if (dev->irq) | 187 | if (dev->irq) |
230 | free_irq(dev->irq, dev); | 188 | free_irq(dev->irq, dev); |
231 | }; | 189 | }; |