aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH Hartley Sweeten <hartleys@visionengravers.com>2012-09-05 21:53:24 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-09-05 23:06:30 -0400
commit0a96639fe702a06ca428323a0cfcf7cabc26f6c7 (patch)
treecb3df8cd91429b77df5525e1273c6d42ed841dcf
parent9fab612335c0822e0e0a404fdd6d9222b3bfc800 (diff)
staging: comedi: pcm3724: remove subdevice pointer math
Convert the comedi_subdevice access from pointer math to array access. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/comedi/drivers/pcm3724.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/drivers/staging/comedi/drivers/pcm3724.c b/drivers/staging/comedi/drivers/pcm3724.c
index 62c22ccfb780..4102547dc6a8 100644
--- a/drivers/staging/comedi/drivers/pcm3724.c
+++ b/drivers/staging/comedi/drivers/pcm3724.c
@@ -119,6 +119,8 @@ static int compute_buffer(int config, int devno, struct comedi_subdevice *s)
119static void do_3724_config(struct comedi_device *dev, 119static void do_3724_config(struct comedi_device *dev,
120 struct comedi_subdevice *s, int chanspec) 120 struct comedi_subdevice *s, int chanspec)
121{ 121{
122 struct comedi_subdevice *s_dio1 = &dev->subdevices[0];
123 struct comedi_subdevice *s_dio2 = &dev->subdevices[1];
122 int config; 124 int config;
123 int buffer_config; 125 int buffer_config;
124 unsigned long port_8255_cfg; 126 unsigned long port_8255_cfg;
@@ -136,10 +138,10 @@ static void do_3724_config(struct comedi_device *dev,
136 if (!(s->io_bits & 0xff0000)) 138 if (!(s->io_bits & 0xff0000))
137 config |= CR_C_IO; 139 config |= CR_C_IO;
138 140
139 buffer_config = compute_buffer(0, 0, dev->subdevices); 141 buffer_config = compute_buffer(0, 0, s_dio1);
140 buffer_config = compute_buffer(buffer_config, 1, (dev->subdevices) + 1); 142 buffer_config = compute_buffer(buffer_config, 1, s_dio2);
141 143
142 if (s == dev->subdevices) 144 if (s == s_dio1)
143 port_8255_cfg = dev->iobase + _8255_CR; 145 port_8255_cfg = dev->iobase + _8255_CR;
144 else 146 else
145 port_8255_cfg = dev->iobase + SIZE_8255 + _8255_CR; 147 port_8255_cfg = dev->iobase + SIZE_8255 + _8255_CR;
@@ -154,6 +156,7 @@ static void do_3724_config(struct comedi_device *dev,
154static void enable_chan(struct comedi_device *dev, struct comedi_subdevice *s, 156static void enable_chan(struct comedi_device *dev, struct comedi_subdevice *s,
155 int chanspec) 157 int chanspec)
156{ 158{
159 struct comedi_subdevice *s_dio1 = &dev->subdevices[0];
157 unsigned int mask; 160 unsigned int mask;
158 int gatecfg; 161 int gatecfg;
159 struct priv_pcm3724 *priv; 162 struct priv_pcm3724 *priv;
@@ -162,9 +165,9 @@ static void enable_chan(struct comedi_device *dev, struct comedi_subdevice *s,
162 priv = dev->private; 165 priv = dev->private;
163 166
164 mask = 1 << CR_CHAN(chanspec); 167 mask = 1 << CR_CHAN(chanspec);
165 if (s == dev->subdevices) /* subdev 0 */ 168 if (s == s_dio1)
166 priv->dio_1 |= mask; 169 priv->dio_1 |= mask;
167 else /* subdev 1 */ 170 else
168 priv->dio_2 |= mask; 171 priv->dio_2 |= mask;
169 172
170 if (priv->dio_1 & 0xff0000) 173 if (priv->dio_1 & 0xff0000)
@@ -231,6 +234,7 @@ static int pcm3724_attach(struct comedi_device *dev,
231 struct comedi_devconfig *it) 234 struct comedi_devconfig *it)
232{ 235{
233 const struct pcm3724_board *board = comedi_board(dev); 236 const struct pcm3724_board *board = comedi_board(dev);
237 struct comedi_subdevice *s;
234 unsigned long iobase; 238 unsigned long iobase;
235 unsigned int iorange; 239 unsigned int iorange;
236 int ret, i, n_subdevices; 240 int ret, i, n_subdevices;
@@ -263,9 +267,10 @@ static int pcm3724_attach(struct comedi_device *dev,
263 return ret; 267 return ret;
264 268
265 for (i = 0; i < dev->n_subdevices; i++) { 269 for (i = 0; i < dev->n_subdevices; i++) {
266 subdev_8255_init(dev, dev->subdevices + i, subdev_8255_cb, 270 s = &dev->subdevices[i];
271 subdev_8255_init(dev, s, subdev_8255_cb,
267 (unsigned long)(dev->iobase + SIZE_8255 * i)); 272 (unsigned long)(dev->iobase + SIZE_8255 * i));
268 ((dev->subdevices) + i)->insn_config = subdev_3724_insn_config; 273 s->insn_config = subdev_3724_insn_config;
269 } 274 }
270 return 0; 275 return 0;
271} 276}
@@ -273,11 +278,14 @@ static int pcm3724_attach(struct comedi_device *dev,
273static void pcm3724_detach(struct comedi_device *dev) 278static void pcm3724_detach(struct comedi_device *dev)
274{ 279{
275 const struct pcm3724_board *board = comedi_board(dev); 280 const struct pcm3724_board *board = comedi_board(dev);
281 struct comedi_subdevice *s;
276 int i; 282 int i;
277 283
278 if (dev->subdevices) { 284 if (dev->subdevices) {
279 for (i = 0; i < dev->n_subdevices; i++) 285 for (i = 0; i < dev->n_subdevices; i++) {
280 subdev_8255_cleanup(dev, dev->subdevices + i); 286 s = &dev->subdevices[i];
287 subdev_8255_cleanup(dev, s);
288 }
281 } 289 }
282 if (dev->iobase) 290 if (dev->iobase)
283 release_region(dev->iobase, board->io_range); 291 release_region(dev->iobase, board->io_range);