diff options
author | H Hartley Sweeten <hartleys@visionengravers.com> | 2012-08-16 22:48:14 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-08-17 11:14:33 -0400 |
commit | fa090ab24bc8155ca8c4fbeafec0873da03f04bc (patch) | |
tree | fb6ce246dcfa9c74cf5f14338a06724360a825bb | |
parent | 2a4b0ba517bb30f764b22efa47f3ce937318b04e (diff) |
staging: comedi: cb_pcimdda: remove forward declarations
Move a couple of the functions in order to remove the need for
the forward declarations.
Also, remove the unnecessary comments.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/comedi/drivers/cb_pcimdda.c | 241 |
1 files changed, 94 insertions, 147 deletions
diff --git a/drivers/staging/comedi/drivers/cb_pcimdda.c b/drivers/staging/comedi/drivers/cb_pcimdda.c index 04b9995d1cf4..75e803a9f102 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdda.c +++ b/drivers/staging/comedi/drivers/cb_pcimdda.c | |||
@@ -149,141 +149,12 @@ struct board_private_struct { | |||
149 | 149 | ||
150 | }; | 150 | }; |
151 | 151 | ||
152 | static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, | ||
153 | struct comedi_insn *insn, unsigned int *data); | ||
154 | static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, | ||
155 | struct comedi_insn *insn, unsigned int *data); | ||
156 | |||
157 | /*--------------------------------------------------------------------------- | ||
158 | HELPER FUNCTION DECLARATIONS | ||
159 | -----------------------------------------------------------------------------*/ | ||
160 | |||
161 | /* returns a maxdata value for a given n_bits */ | 152 | /* returns a maxdata value for a given n_bits */ |
162 | static inline unsigned int figure_out_maxdata(int bits) | 153 | static inline unsigned int figure_out_maxdata(int bits) |
163 | { | 154 | { |
164 | return ((unsigned int)1 << bits) - 1; | 155 | return ((unsigned int)1 << bits) - 1; |
165 | } | 156 | } |
166 | 157 | ||
167 | /* | ||
168 | * Probes for a supported device. | ||
169 | * | ||
170 | * Prerequisite: private be allocated already inside dev | ||
171 | * | ||
172 | * If the device is found, it returns 0 and has the following side effects: | ||
173 | * | ||
174 | * o assigns a struct pci_dev * to dev->private->pci_dev | ||
175 | * o assigns a struct board * to dev->board_ptr | ||
176 | * o sets dev->private->registers | ||
177 | * o sets dev->private->dio_registers | ||
178 | * | ||
179 | * Otherwise, returns a -errno on error | ||
180 | */ | ||
181 | static int probe(struct comedi_device *dev, const struct comedi_devconfig *it); | ||
182 | |||
183 | /*--------------------------------------------------------------------------- | ||
184 | FUNCTION DEFINITIONS | ||
185 | -----------------------------------------------------------------------------*/ | ||
186 | |||
187 | /* | ||
188 | * Attach is called by the Comedi core to configure the driver | ||
189 | * for a particular board. If you specified a board_name array | ||
190 | * in the driver structure, dev->board_ptr contains that | ||
191 | * address. | ||
192 | */ | ||
193 | static int attach(struct comedi_device *dev, struct comedi_devconfig *it) | ||
194 | { | ||
195 | const struct board_struct *thisboard; | ||
196 | struct board_private_struct *devpriv; | ||
197 | struct comedi_subdevice *s; | ||
198 | int err; | ||
199 | |||
200 | err = alloc_private(dev, sizeof(*devpriv)); | ||
201 | if (err) | ||
202 | return err; | ||
203 | devpriv = dev->private; | ||
204 | |||
205 | /* | ||
206 | * If you can probe the device to determine what device in a series | ||
207 | * it is, this is the place to do it. Otherwise, dev->board_ptr | ||
208 | * should already be initialized. | ||
209 | */ | ||
210 | err = probe(dev, it); | ||
211 | if (err) | ||
212 | return err; | ||
213 | thisboard = comedi_board(dev); | ||
214 | |||
215 | /* Output some info */ | ||
216 | printk("comedi%d: %s: ", dev->minor, thisboard->name); | ||
217 | |||
218 | /* | ||
219 | * Initialize dev->board_name. Note that we can use the "thisboard" | ||
220 | * macro now, since we just initialized it in the last line. | ||
221 | */ | ||
222 | dev->board_name = thisboard->name; | ||
223 | |||
224 | err = comedi_alloc_subdevices(dev, 2); | ||
225 | if (err) | ||
226 | return err; | ||
227 | |||
228 | s = dev->subdevices + 0; | ||
229 | |||
230 | /* analog output subdevice */ | ||
231 | s->type = COMEDI_SUBD_AO; | ||
232 | s->subdev_flags = SDF_WRITABLE | SDF_READABLE; | ||
233 | s->n_chan = thisboard->ao_chans; | ||
234 | s->maxdata = figure_out_maxdata(thisboard->ao_bits); | ||
235 | /* this is hard-coded here */ | ||
236 | if (it->options[2]) | ||
237 | s->range_table = &range_bipolar10; | ||
238 | else | ||
239 | s->range_table = &range_bipolar5; | ||
240 | s->insn_write = &ao_winsn; | ||
241 | s->insn_read = &ao_rinsn; | ||
242 | |||
243 | s = dev->subdevices + 1; | ||
244 | /* digital i/o subdevice */ | ||
245 | if (thisboard->dio_chans) { | ||
246 | switch (thisboard->dio_method) { | ||
247 | case DIO_8255: | ||
248 | /* | ||
249 | * this is a straight 8255, so register us with | ||
250 | * the 8255 driver | ||
251 | */ | ||
252 | subdev_8255_init(dev, s, NULL, devpriv->dio_registers); | ||
253 | devpriv->attached_to_8255 = 1; | ||
254 | break; | ||
255 | case DIO_INTERNAL: | ||
256 | default: | ||
257 | printk("DIO_INTERNAL not implemented yet!\n"); | ||
258 | return -ENXIO; | ||
259 | break; | ||
260 | } | ||
261 | } else { | ||
262 | s->type = COMEDI_SUBD_UNUSED; | ||
263 | } | ||
264 | |||
265 | printk("attached\n"); | ||
266 | |||
267 | return 1; | ||
268 | } | ||
269 | |||
270 | static void detach(struct comedi_device *dev) | ||
271 | { | ||
272 | struct board_private_struct *devpriv = dev->private; | ||
273 | |||
274 | if (devpriv) { | ||
275 | if (dev->subdevices && devpriv->attached_to_8255) { | ||
276 | subdev_8255_cleanup(dev, dev->subdevices + 2); | ||
277 | devpriv->attached_to_8255 = 0; | ||
278 | } | ||
279 | if (devpriv->pci_dev) { | ||
280 | if (devpriv->registers) | ||
281 | comedi_pci_disable(devpriv->pci_dev); | ||
282 | pci_dev_put(devpriv->pci_dev); | ||
283 | } | ||
284 | } | ||
285 | } | ||
286 | |||
287 | static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, | 158 | static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, |
288 | struct comedi_insn *insn, unsigned int *data) | 159 | struct comedi_insn *insn, unsigned int *data) |
289 | { | 160 | { |
@@ -344,24 +215,6 @@ static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, | |||
344 | return i; | 215 | return i; |
345 | } | 216 | } |
346 | 217 | ||
347 | /*--------------------------------------------------------------------------- | ||
348 | HELPER FUNCTION DEFINITIONS | ||
349 | -----------------------------------------------------------------------------*/ | ||
350 | |||
351 | /* | ||
352 | * Probes for a supported device. | ||
353 | * | ||
354 | * Prerequisite: private be allocated already inside dev | ||
355 | * | ||
356 | * If the device is found, it returns 0 and has the following side effects: | ||
357 | * | ||
358 | * o assigns a struct pci_dev * to dev->private->pci_dev | ||
359 | * o assigns a struct board * to dev->board_ptr | ||
360 | * o sets dev->private->registers | ||
361 | * o sets dev->private->dio_registers | ||
362 | * | ||
363 | * Otherwise, returns a -errno on error | ||
364 | */ | ||
365 | static int probe(struct comedi_device *dev, const struct comedi_devconfig *it) | 218 | static int probe(struct comedi_device *dev, const struct comedi_devconfig *it) |
366 | { | 219 | { |
367 | const struct board_struct *thisboard; | 220 | const struct board_struct *thisboard; |
@@ -411,6 +264,100 @@ static int probe(struct comedi_device *dev, const struct comedi_devconfig *it) | |||
411 | return -ENODEV; | 264 | return -ENODEV; |
412 | } | 265 | } |
413 | 266 | ||
267 | static int attach(struct comedi_device *dev, struct comedi_devconfig *it) | ||
268 | { | ||
269 | const struct board_struct *thisboard; | ||
270 | struct board_private_struct *devpriv; | ||
271 | struct comedi_subdevice *s; | ||
272 | int err; | ||
273 | |||
274 | err = alloc_private(dev, sizeof(*devpriv)); | ||
275 | if (err) | ||
276 | return err; | ||
277 | devpriv = dev->private; | ||
278 | |||
279 | /* | ||
280 | * If you can probe the device to determine what device in a series | ||
281 | * it is, this is the place to do it. Otherwise, dev->board_ptr | ||
282 | * should already be initialized. | ||
283 | */ | ||
284 | err = probe(dev, it); | ||
285 | if (err) | ||
286 | return err; | ||
287 | thisboard = comedi_board(dev); | ||
288 | |||
289 | /* Output some info */ | ||
290 | printk("comedi%d: %s: ", dev->minor, thisboard->name); | ||
291 | |||
292 | /* | ||
293 | * Initialize dev->board_name. Note that we can use the "thisboard" | ||
294 | * macro now, since we just initialized it in the last line. | ||
295 | */ | ||
296 | dev->board_name = thisboard->name; | ||
297 | |||
298 | err = comedi_alloc_subdevices(dev, 2); | ||
299 | if (err) | ||
300 | return err; | ||
301 | |||
302 | s = dev->subdevices + 0; | ||
303 | |||
304 | /* analog output subdevice */ | ||
305 | s->type = COMEDI_SUBD_AO; | ||
306 | s->subdev_flags = SDF_WRITABLE | SDF_READABLE; | ||
307 | s->n_chan = thisboard->ao_chans; | ||
308 | s->maxdata = figure_out_maxdata(thisboard->ao_bits); | ||
309 | /* this is hard-coded here */ | ||
310 | if (it->options[2]) | ||
311 | s->range_table = &range_bipolar10; | ||
312 | else | ||
313 | s->range_table = &range_bipolar5; | ||
314 | s->insn_write = &ao_winsn; | ||
315 | s->insn_read = &ao_rinsn; | ||
316 | |||
317 | s = dev->subdevices + 1; | ||
318 | /* digital i/o subdevice */ | ||
319 | if (thisboard->dio_chans) { | ||
320 | switch (thisboard->dio_method) { | ||
321 | case DIO_8255: | ||
322 | /* | ||
323 | * this is a straight 8255, so register us with | ||
324 | * the 8255 driver | ||
325 | */ | ||
326 | subdev_8255_init(dev, s, NULL, devpriv->dio_registers); | ||
327 | devpriv->attached_to_8255 = 1; | ||
328 | break; | ||
329 | case DIO_INTERNAL: | ||
330 | default: | ||
331 | printk("DIO_INTERNAL not implemented yet!\n"); | ||
332 | return -ENXIO; | ||
333 | break; | ||
334 | } | ||
335 | } else { | ||
336 | s->type = COMEDI_SUBD_UNUSED; | ||
337 | } | ||
338 | |||
339 | printk("attached\n"); | ||
340 | |||
341 | return 1; | ||
342 | } | ||
343 | |||
344 | static void detach(struct comedi_device *dev) | ||
345 | { | ||
346 | struct board_private_struct *devpriv = dev->private; | ||
347 | |||
348 | if (devpriv) { | ||
349 | if (dev->subdevices && devpriv->attached_to_8255) { | ||
350 | subdev_8255_cleanup(dev, dev->subdevices + 2); | ||
351 | devpriv->attached_to_8255 = 0; | ||
352 | } | ||
353 | if (devpriv->pci_dev) { | ||
354 | if (devpriv->registers) | ||
355 | comedi_pci_disable(devpriv->pci_dev); | ||
356 | pci_dev_put(devpriv->pci_dev); | ||
357 | } | ||
358 | } | ||
359 | } | ||
360 | |||
414 | static struct comedi_driver cb_pcimdda_driver = { | 361 | static struct comedi_driver cb_pcimdda_driver = { |
415 | .driver_name = "cb_pcimdda", | 362 | .driver_name = "cb_pcimdda", |
416 | .module = THIS_MODULE, | 363 | .module = THIS_MODULE, |