mirror of https://gitee.com/openkylin/linux.git
staging: comedi: gsc_hpdi: absorb setup_subdevices()
This function is only called by the (*auto_attach). Absorb it into that function to clarify the attach and remove the need for some of the forward declarations. For aesthetics, add some whitespace to the subdevice init. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
4ddc6ba41d
commit
7de0b0dfac
|
@ -53,10 +53,6 @@
|
||||||
#include "comedi_fc.h"
|
#include "comedi_fc.h"
|
||||||
|
|
||||||
static void abort_dma(struct comedi_device *dev, unsigned int channel);
|
static void abort_dma(struct comedi_device *dev, unsigned int channel);
|
||||||
static int hpdi_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
|
|
||||||
static int hpdi_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
|
|
||||||
struct comedi_cmd *cmd);
|
|
||||||
static int hpdi_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
|
|
||||||
static int dio_config_block_size(struct comedi_device *dev, unsigned int *data);
|
static int dio_config_block_size(struct comedi_device *dev, unsigned int *data);
|
||||||
|
|
||||||
#define TIMER_BASE 50 /* 20MHz master clock */
|
#define TIMER_BASE 50 /* 20MHz master clock */
|
||||||
|
@ -284,36 +280,6 @@ static void init_plx9080(struct comedi_device *dev)
|
||||||
writel(bits, plx_iobase + PLX_DMA0_MODE_REG);
|
writel(bits, plx_iobase + PLX_DMA0_MODE_REG);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate and initialize the subdevice structures.
|
|
||||||
*/
|
|
||||||
static int setup_subdevices(struct comedi_device *dev)
|
|
||||||
{
|
|
||||||
struct comedi_subdevice *s;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = comedi_alloc_subdevices(dev, 1);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
s = &dev->subdevices[0];
|
|
||||||
/* analog input subdevice */
|
|
||||||
dev->read_subdev = s;
|
|
||||||
/* dev->write_subdev = s; */
|
|
||||||
s->type = COMEDI_SUBD_DIO;
|
|
||||||
s->subdev_flags =
|
|
||||||
SDF_READABLE | SDF_WRITEABLE | SDF_LSAMPL | SDF_CMD_READ;
|
|
||||||
s->n_chan = 32;
|
|
||||||
s->len_chanlist = 32;
|
|
||||||
s->maxdata = 1;
|
|
||||||
s->range_table = &range_digital;
|
|
||||||
s->insn_config = dio_config_insn;
|
|
||||||
s->do_cmd = hpdi_cmd;
|
|
||||||
s->do_cmdtest = hpdi_cmd_test;
|
|
||||||
s->cancel = hpdi_cancel;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int init_hpdi(struct comedi_device *dev)
|
static int init_hpdi(struct comedi_device *dev)
|
||||||
{
|
{
|
||||||
struct hpdi_private *devpriv = dev->private;
|
struct hpdi_private *devpriv = dev->private;
|
||||||
|
@ -716,6 +682,7 @@ static int hpdi_auto_attach(struct comedi_device *dev,
|
||||||
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
|
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
|
||||||
const struct hpdi_board *thisboard;
|
const struct hpdi_board *thisboard;
|
||||||
struct hpdi_private *devpriv;
|
struct hpdi_private *devpriv;
|
||||||
|
struct comedi_subdevice *s;
|
||||||
int i;
|
int i;
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
|
@ -778,10 +745,25 @@ static int hpdi_auto_attach(struct comedi_device *dev,
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
retval = setup_subdevices(dev);
|
retval = comedi_alloc_subdevices(dev, 1);
|
||||||
if (retval < 0)
|
if (retval)
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
|
/* Digital I/O subdevice */
|
||||||
|
s = &dev->subdevices[0];
|
||||||
|
dev->read_subdev = s;
|
||||||
|
s->type = COMEDI_SUBD_DIO;
|
||||||
|
s->subdev_flags = SDF_READABLE | SDF_WRITEABLE | SDF_LSAMPL |
|
||||||
|
SDF_CMD_READ;
|
||||||
|
s->n_chan = 32;
|
||||||
|
s->len_chanlist = 32;
|
||||||
|
s->maxdata = 1;
|
||||||
|
s->range_table = &range_digital;
|
||||||
|
s->insn_config = dio_config_insn;
|
||||||
|
s->do_cmd = hpdi_cmd;
|
||||||
|
s->do_cmdtest = hpdi_cmd_test;
|
||||||
|
s->cancel = hpdi_cancel;
|
||||||
|
|
||||||
return init_hpdi(dev);
|
return init_hpdi(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue