From: H Hartley Sweeten Date: Thu, 5 Dec 2013 23:54:15 +0000 (-0700) Subject: staging: comedi: pcmuio: tidy up pcmuio_attach() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=fc5ba1bd717b1daad46bb990f86cb30b2f2e219e;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git staging: comedi: pcmuio: tidy up pcmuio_attach() Clean up the local variables, 'sdev_no' and 'asic' are both used in simple for () loops. Use the local variable 'i' for both cases. The 'n_subdevs' variable is only used in one place, just remove it. For aesthetics, add some whitespace to the subdevice init and reorder it to follow the more typical style in comedi drivers. Remove the unnecessary init of s->len_chanlist for subdevices that do not support async commands (interrupts). The core will default it to the correct value. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/staging/comedi/drivers/pcmuio.c index 32da92f45b40..edcac2679c40 100644 --- a/drivers/staging/comedi/drivers/pcmuio.c +++ b/drivers/staging/comedi/drivers/pcmuio.c @@ -591,8 +591,8 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it) const struct pcmuio_board *board = comedi_board(dev); struct comedi_subdevice *s; struct pcmuio_private *devpriv; - int sdev_no, n_subdevs, asic; int ret; + int i; ret = comedi_request_region(dev, it->options[0], board->num_asics * PCMUIO_ASIC_IOSIZE); @@ -603,8 +603,8 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (!devpriv) return -ENOMEM; - for (asic = 0; asic < PCMUIO_MAX_ASICS; ++asic) { - struct pcmuio_asic *chip = &devpriv->asics[asic]; + for (i = 0; i < PCMUIO_MAX_ASICS; ++i) { + struct pcmuio_asic *chip = &devpriv->asics[i]; spin_lock_init(&chip->pagelock); spin_lock_init(&chip->spinlock); @@ -633,34 +633,29 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it) } } - n_subdevs = board->num_asics * 2; - - ret = comedi_alloc_subdevices(dev, n_subdevs); + ret = comedi_alloc_subdevices(dev, board->num_asics * 2); if (ret) return ret; - for (sdev_no = 0; sdev_no < (int)dev->n_subdevices; ++sdev_no) { - s = &dev->subdevices[sdev_no]; - s->maxdata = 1; - s->range_table = &range_digital; - s->subdev_flags = SDF_READABLE | SDF_WRITABLE; - s->type = COMEDI_SUBD_DIO; - s->insn_bits = pcmuio_dio_insn_bits; - s->insn_config = pcmuio_dio_insn_config; - s->n_chan = 24; + for (i = 0; i < dev->n_subdevices; ++i) { + s = &dev->subdevices[i]; + s->type = COMEDI_SUBD_DIO; + s->subdev_flags = SDF_READABLE | SDF_WRITABLE; + s->n_chan = 24; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = pcmuio_dio_insn_bits; + s->insn_config = pcmuio_dio_insn_config; /* subdevices 0 and 2 can suppport interrupts */ - if ((sdev_no == 0 && dev->irq) || - (sdev_no == 2 && devpriv->irq2)) { + if ((i == 0 && dev->irq) || (i == 2 && devpriv->irq2)) { /* setup the interrupt subdevice */ dev->read_subdev = s; - s->subdev_flags |= SDF_CMD_READ; - s->cancel = pcmuio_cancel; - s->do_cmd = pcmuio_cmd; - s->do_cmdtest = pcmuio_cmdtest; - s->len_chanlist = s->n_chan; - } else { - s->len_chanlist = 1; + s->subdev_flags |= SDF_CMD_READ; + s->len_chanlist = s->n_chan; + s->cancel = pcmuio_cancel; + s->do_cmd = pcmuio_cmd; + s->do_cmdtest = pcmuio_cmdtest; } }