Commit 050389f5 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: jr3_pci: tidy up subdevice init

For aesthetics, use a pointer to the comedi_subdevice instead of
accessing the dev->subdevices array directly.

Move the local variable for the subdevice private data so that
this function does not declare the variable twice.

Change the kzalloc for the subdevice private data to remove the
sizeof(struct foo).
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 c6cd0eef
...@@ -627,10 +627,12 @@ static void jr3_pci_poll_dev(unsigned long data) ...@@ -627,10 +627,12 @@ static void jr3_pci_poll_dev(unsigned long data)
static int jr3_pci_auto_attach(struct comedi_device *dev, static int jr3_pci_auto_attach(struct comedi_device *dev,
unsigned long context_unused) unsigned long context_unused)
{ {
int result;
struct pci_dev *pcidev = comedi_to_pci_dev(dev); struct pci_dev *pcidev = comedi_to_pci_dev(dev);
int i;
struct jr3_pci_dev_private *devpriv; struct jr3_pci_dev_private *devpriv;
struct jr3_pci_subdev_private *p;
struct comedi_subdevice *s;
int result;
int i;
if (sizeof(struct jr3_channel) != 0xc00) { if (sizeof(struct jr3_channel) != 0xc00) {
dev_err(dev->class_dev, dev_err(dev->class_dev,
...@@ -679,18 +681,18 @@ static int jr3_pci_auto_attach(struct comedi_device *dev, ...@@ -679,18 +681,18 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
dev->open = jr3_pci_open; dev->open = jr3_pci_open;
for (i = 0; i < devpriv->n_channels; i++) { for (i = 0; i < devpriv->n_channels; i++) {
dev->subdevices[i].type = COMEDI_SUBD_AI; s = &dev->subdevices[i];
dev->subdevices[i].subdev_flags = SDF_READABLE | SDF_GROUND; s->type = COMEDI_SUBD_AI;
dev->subdevices[i].n_chan = 8 * 7 + 2; s->subdev_flags = SDF_READABLE | SDF_GROUND;
dev->subdevices[i].insn_read = jr3_pci_ai_insn_read; s->n_chan = 8 * 7 + 2;
dev->subdevices[i].private = s->insn_read = jr3_pci_ai_insn_read;
kzalloc(sizeof(struct jr3_pci_subdev_private),
GFP_KERNEL); p = kzalloc(sizeof(*p), GFP_KERNEL);
if (dev->subdevices[i].private) { if (p) {
struct jr3_pci_subdev_private *p;
int j; int j;
p = dev->subdevices[i].private; 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,
...@@ -721,11 +723,10 @@ static int jr3_pci_auto_attach(struct comedi_device *dev, ...@@ -721,11 +723,10 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
p->maxdata_list[56] = 0xffff; p->maxdata_list[56] = 0xffff;
p->maxdata_list[57] = 0xffff; p->maxdata_list[57] = 0xffff;
/* Channel specific range and maxdata */ /* Channel specific range and maxdata */
dev->subdevices[i].range_table = NULL; s->range_table = NULL;
dev->subdevices[i].range_table_list = s->range_table_list = p->range_table_list;
p->range_table_list; s->maxdata = 0;
dev->subdevices[i].maxdata = 0; s->maxdata_list = p->maxdata_list;
dev->subdevices[i].maxdata_list = p->maxdata_list;
} }
} }
...@@ -762,7 +763,8 @@ static int jr3_pci_auto_attach(struct comedi_device *dev, ...@@ -762,7 +763,8 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
/* Start card timer */ /* Start card timer */
for (i = 0; i < devpriv->n_channels; i++) { for (i = 0; i < devpriv->n_channels; i++) {
struct jr3_pci_subdev_private *p = dev->subdevices[i].private; s = &dev->subdevices[i];
p = s->private;
p->next_time_min = jiffies + msecs_to_jiffies(500); p->next_time_min = jiffies + msecs_to_jiffies(500);
p->next_time_max = jiffies + msecs_to_jiffies(2000); p->next_time_max = jiffies + msecs_to_jiffies(2000);
......
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