Commit 6fe9bb67 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: jr3_pci: use comedi_alloc_spriv()

Use the helper function to allocate the subdevice private data. This
sets the s->private variable for us and allows the comedi core to
automatically kfree() the memory during the (*detach).
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 050389f5
...@@ -687,12 +687,10 @@ static int jr3_pci_auto_attach(struct comedi_device *dev, ...@@ -687,12 +687,10 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
s->n_chan = 8 * 7 + 2; s->n_chan = 8 * 7 + 2;
s->insn_read = jr3_pci_ai_insn_read; s->insn_read = jr3_pci_ai_insn_read;
p = kzalloc(sizeof(*p), GFP_KERNEL); p = comedi_alloc_spriv(s, sizeof(*p));
if (p) { if (p) {
int j; int j;
s->private = p;
p->channel = &devpriv->iobase->channel[i].data; p->channel = &devpriv->iobase->channel[i].data;
dev_dbg(dev->class_dev, "p->channel %p %p (%tx)\n", dev_dbg(dev->class_dev, "p->channel %p %p (%tx)\n",
p->channel, devpriv->iobase, p->channel, devpriv->iobase,
...@@ -780,16 +778,11 @@ static int jr3_pci_auto_attach(struct comedi_device *dev, ...@@ -780,16 +778,11 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
static void jr3_pci_detach(struct comedi_device *dev) static void jr3_pci_detach(struct comedi_device *dev)
{ {
int i;
struct jr3_pci_dev_private *devpriv = dev->private; struct jr3_pci_dev_private *devpriv = dev->private;
if (devpriv) { if (devpriv) {
del_timer_sync(&devpriv->timer); del_timer_sync(&devpriv->timer);
if (dev->subdevices) {
for (i = 0; i < devpriv->n_channels; i++)
kfree(dev->subdevices[i].private);
}
if (devpriv->iobase) if (devpriv->iobase)
iounmap(devpriv->iobase); iounmap(devpriv->iobase);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment