diff options
author | H Hartley Sweeten <hartleys@visionengravers.com> | 2012-08-16 22:47:51 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-08-17 11:14:32 -0400 |
commit | 2a4b0ba517bb30f764b22efa47f3ce937318b04e (patch) | |
tree | 2ca624aa9b5c6d2754a285b4643da81edcb0f3a0 | |
parent | aeb0ca6e72740f562b6eff5fa59a88107a8af8c9 (diff) |
staging: comedi: cb_pcimdda: remove thisboard and devpriv macros
These macros rely on a local variable having a specific name.
Remove them and use the comedi_board() helper to get the thisboard
pointer.
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 | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/drivers/staging/comedi/drivers/cb_pcimdda.c b/drivers/staging/comedi/drivers/cb_pcimdda.c index 04a9d5b95803..04b9995d1cf4 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdda.c +++ b/drivers/staging/comedi/drivers/cb_pcimdda.c | |||
@@ -131,11 +131,6 @@ static const struct board_struct boards[] = { | |||
131 | }; | 131 | }; |
132 | 132 | ||
133 | /* | 133 | /* |
134 | * Useful for shorthand access to the particular board structure | ||
135 | */ | ||
136 | #define thisboard ((const struct board_struct *)dev->board_ptr) | ||
137 | |||
138 | /* | ||
139 | * this structure is for data unique to this hardware driver. If | 134 | * this structure is for data unique to this hardware driver. If |
140 | * several hardware drivers keep similar information in this structure, | 135 | * several hardware drivers keep similar information in this structure, |
141 | * feel free to suggest moving the variable to the struct comedi_device | 136 | * feel free to suggest moving the variable to the struct comedi_device |
@@ -154,12 +149,6 @@ struct board_private_struct { | |||
154 | 149 | ||
155 | }; | 150 | }; |
156 | 151 | ||
157 | /* | ||
158 | * most drivers define the following macro to make it easy to | ||
159 | * access the private structure. | ||
160 | */ | ||
161 | #define devpriv ((struct board_private_struct *)dev->private) | ||
162 | |||
163 | static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, | 152 | static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, |
164 | struct comedi_insn *insn, unsigned int *data); | 153 | struct comedi_insn *insn, unsigned int *data); |
165 | static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, | 154 | static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, |
@@ -203,17 +192,15 @@ static int probe(struct comedi_device *dev, const struct comedi_devconfig *it); | |||
203 | */ | 192 | */ |
204 | static int attach(struct comedi_device *dev, struct comedi_devconfig *it) | 193 | static int attach(struct comedi_device *dev, struct comedi_devconfig *it) |
205 | { | 194 | { |
195 | const struct board_struct *thisboard; | ||
196 | struct board_private_struct *devpriv; | ||
206 | struct comedi_subdevice *s; | 197 | struct comedi_subdevice *s; |
207 | int err; | 198 | int err; |
208 | 199 | ||
209 | /* | 200 | err = alloc_private(dev, sizeof(*devpriv)); |
210 | * Allocate the private structure area. alloc_private() is a | 201 | if (err) |
211 | * convenient macro defined in comedidev.h. | 202 | return err; |
212 | * if this function fails (returns negative) then the private area is | 203 | devpriv = dev->private; |
213 | * kfree'd by comedi | ||
214 | */ | ||
215 | if (alloc_private(dev, sizeof(struct board_private_struct)) < 0) | ||
216 | return -ENOMEM; | ||
217 | 204 | ||
218 | /* | 205 | /* |
219 | * If you can probe the device to determine what device in a series | 206 | * If you can probe the device to determine what device in a series |
@@ -223,6 +210,7 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it) | |||
223 | err = probe(dev, it); | 210 | err = probe(dev, it); |
224 | if (err) | 211 | if (err) |
225 | return err; | 212 | return err; |
213 | thisboard = comedi_board(dev); | ||
226 | 214 | ||
227 | /* Output some info */ | 215 | /* Output some info */ |
228 | printk("comedi%d: %s: ", dev->minor, thisboard->name); | 216 | printk("comedi%d: %s: ", dev->minor, thisboard->name); |
@@ -281,6 +269,8 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it) | |||
281 | 269 | ||
282 | static void detach(struct comedi_device *dev) | 270 | static void detach(struct comedi_device *dev) |
283 | { | 271 | { |
272 | struct board_private_struct *devpriv = dev->private; | ||
273 | |||
284 | if (devpriv) { | 274 | if (devpriv) { |
285 | if (dev->subdevices && devpriv->attached_to_8255) { | 275 | if (dev->subdevices && devpriv->attached_to_8255) { |
286 | subdev_8255_cleanup(dev, dev->subdevices + 2); | 276 | subdev_8255_cleanup(dev, dev->subdevices + 2); |
@@ -297,6 +287,7 @@ static void detach(struct comedi_device *dev) | |||
297 | static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, | 287 | static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, |
298 | struct comedi_insn *insn, unsigned int *data) | 288 | struct comedi_insn *insn, unsigned int *data) |
299 | { | 289 | { |
290 | struct board_private_struct *devpriv = dev->private; | ||
300 | int i; | 291 | int i; |
301 | int chan = CR_CHAN(insn->chanspec); | 292 | int chan = CR_CHAN(insn->chanspec); |
302 | unsigned long offset = devpriv->registers + chan * 2; | 293 | unsigned long offset = devpriv->registers + chan * 2; |
@@ -336,6 +327,7 @@ static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, | |||
336 | static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, | 327 | static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, |
337 | struct comedi_insn *insn, unsigned int *data) | 328 | struct comedi_insn *insn, unsigned int *data) |
338 | { | 329 | { |
330 | struct board_private_struct *devpriv = dev->private; | ||
339 | int i; | 331 | int i; |
340 | int chan = CR_CHAN(insn->chanspec); | 332 | int chan = CR_CHAN(insn->chanspec); |
341 | 333 | ||
@@ -372,6 +364,8 @@ static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, | |||
372 | */ | 364 | */ |
373 | static int probe(struct comedi_device *dev, const struct comedi_devconfig *it) | 365 | static int probe(struct comedi_device *dev, const struct comedi_devconfig *it) |
374 | { | 366 | { |
367 | const struct board_struct *thisboard; | ||
368 | struct board_private_struct *devpriv = dev->private; | ||
375 | struct pci_dev *pcidev = NULL; | 369 | struct pci_dev *pcidev = NULL; |
376 | int index; | 370 | int index; |
377 | unsigned long registers; | 371 | unsigned long registers; |
@@ -396,6 +390,7 @@ static int probe(struct comedi_device *dev, const struct comedi_devconfig *it) | |||
396 | 390 | ||
397 | devpriv->pci_dev = pcidev; | 391 | devpriv->pci_dev = pcidev; |
398 | dev->board_ptr = boards + index; | 392 | dev->board_ptr = boards + index; |
393 | thisboard = comedi_board(dev); | ||
399 | if (comedi_pci_enable(pcidev, thisboard->name)) { | 394 | if (comedi_pci_enable(pcidev, thisboard->name)) { |
400 | printk | 395 | printk |
401 | ("cb_pcimdda: Failed to enable PCI device and request regions\n"); | 396 | ("cb_pcimdda: Failed to enable PCI device and request regions\n"); |