Commit 5c1eb3857a7fada597f6dc2746f5f700bdb780ee

Authored by H Hartley Sweeten
Committed by Greg Kroah-Hartman
1 parent 22d4b56f5b

staging: comedi: adq12b: remove devpriv macro

This macro relies on a local variable having a specific name.

Also, remove the kfree in the detach. The comedi core handles
the kfree of dev->private.

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>

Showing 1 changed file with 11 additions and 12 deletions Side-by-side Diff

drivers/staging/comedi/drivers/adq12b.c
... ... @@ -133,8 +133,6 @@
133 133 unsigned int digital_state;
134 134 };
135 135  
136   -#define devpriv ((struct adq12b_private *)dev->private)
137   -
138 136 /*
139 137 * "instructions" read/write data in "one-shot" or "software-triggered"
140 138 * mode.
... ... @@ -144,6 +142,7 @@
144 142 struct comedi_subdevice *s, struct comedi_insn *insn,
145 143 unsigned int *data)
146 144 {
  145 + struct adq12b_private *devpriv = dev->private;
147 146 int n, i;
148 147 int range, channel;
149 148 unsigned char hi, lo, status;
... ... @@ -200,6 +199,7 @@
200 199 struct comedi_subdevice *s,
201 200 struct comedi_insn *insn, unsigned int *data)
202 201 {
  202 + struct adq12b_private *devpriv = dev->private;
203 203 int channel;
204 204  
205 205 for (channel = 0; channel < 8; channel++)
... ... @@ -221,6 +221,7 @@
221 221 static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
222 222 {
223 223 const struct adq12b_board *board = comedi_board(dev);
  224 + struct adq12b_private *devpriv;
224 225 struct comedi_subdevice *s;
225 226 unsigned long iobase;
226 227 int unipolar, differential;
227 228  
228 229  
... ... @@ -252,19 +253,18 @@
252 253  
253 254 dev->board_name = board->name;
254 255  
255   -/*
256   - * Allocate the private structure area. alloc_private() is a
257   - * convenient macro defined in comedidev.h.
258   - */
259   - if (alloc_private(dev, sizeof(struct adq12b_private)) < 0)
260   - return -ENOMEM;
  256 + ret = alloc_private(dev, sizeof(*devpriv));
  257 + if (ret)
  258 + return ret;
  259 + devpriv = dev->private;
261 260  
262   -/* fill in devpriv structure */
263 261 devpriv->unipolar = unipolar;
264 262 devpriv->differential = differential;
265 263 devpriv->digital_state = 0;
266   -/* initialize channel and range to -1 so we make sure we always write
267   - at least once to the CTREG in the instruction */
  264 + /*
  265 + * initialize channel and range to -1 so we make sure we
  266 + * always write at least once to the CTREG in the instruction
  267 + */
268 268 devpriv->last_channel = -1;
269 269 devpriv->last_range = -1;
270 270  
... ... @@ -321,7 +321,6 @@
321 321 {
322 322 if (dev->iobase)
323 323 release_region(dev->iobase, ADQ12B_SIZE);
324   - kfree(devpriv);
325 324 }
326 325  
327 326 static const struct adq12b_board adq12b_boards[] = {