staging: comedi: poc: introduce struct poc_private
Wrap the private data used by this driver in a struct. This makes the use of that data clearer and gets rid of the need for the casts. 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>
This commit is contained in:
parent
8c12ec2616
commit
22201ceaeb
1 changed files with 13 additions and 4 deletions
|
@ -57,13 +57,18 @@ struct boarddef_struct {
|
||||||
const struct comedi_lrange *range;
|
const struct comedi_lrange *range;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct poc_private {
|
||||||
|
unsigned int ao_readback[32];
|
||||||
|
};
|
||||||
|
|
||||||
static int readback_insn(struct comedi_device *dev, struct comedi_subdevice *s,
|
static int readback_insn(struct comedi_device *dev, struct comedi_subdevice *s,
|
||||||
struct comedi_insn *insn, unsigned int *data)
|
struct comedi_insn *insn, unsigned int *data)
|
||||||
{
|
{
|
||||||
|
struct poc_private *devpriv = dev->private;
|
||||||
int chan;
|
int chan;
|
||||||
|
|
||||||
chan = CR_CHAN(insn->chanspec);
|
chan = CR_CHAN(insn->chanspec);
|
||||||
data[0] = ((unsigned int *)dev->private)[chan];
|
data[0] = devpriv->ao_readback[chan];
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -75,12 +80,13 @@ static int readback_insn(struct comedi_device *dev, struct comedi_subdevice *s,
|
||||||
static int dac02_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
|
static int dac02_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
|
||||||
struct comedi_insn *insn, unsigned int *data)
|
struct comedi_insn *insn, unsigned int *data)
|
||||||
{
|
{
|
||||||
|
struct poc_private *devpriv = dev->private;
|
||||||
int temp;
|
int temp;
|
||||||
int chan;
|
int chan;
|
||||||
int output;
|
int output;
|
||||||
|
|
||||||
chan = CR_CHAN(insn->chanspec);
|
chan = CR_CHAN(insn->chanspec);
|
||||||
((unsigned int *)dev->private)[chan] = data[0];
|
devpriv->ao_readback[chan] = data[0];
|
||||||
output = data[0];
|
output = data[0];
|
||||||
#ifdef wrong
|
#ifdef wrong
|
||||||
/* convert to complementary binary if range is bipolar */
|
/* convert to complementary binary if range is bipolar */
|
||||||
|
@ -131,6 +137,7 @@ static int pcl734_insn_bits(struct comedi_device *dev,
|
||||||
static int poc_attach(struct comedi_device *dev, struct comedi_devconfig *it)
|
static int poc_attach(struct comedi_device *dev, struct comedi_devconfig *it)
|
||||||
{
|
{
|
||||||
const struct boarddef_struct *board = comedi_board(dev);
|
const struct boarddef_struct *board = comedi_board(dev);
|
||||||
|
struct poc_private *devpriv;
|
||||||
struct comedi_subdevice *s;
|
struct comedi_subdevice *s;
|
||||||
unsigned long iobase;
|
unsigned long iobase;
|
||||||
unsigned int iosize;
|
unsigned int iosize;
|
||||||
|
@ -160,8 +167,10 @@ static int poc_attach(struct comedi_device *dev, struct comedi_devconfig *it)
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (alloc_private(dev, sizeof(unsigned int) * board->n_chan) < 0)
|
ret = alloc_private(dev, sizeof(*devpriv));
|
||||||
return -ENOMEM;
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
devpriv = dev->private;
|
||||||
|
|
||||||
/* analog output subdevice */
|
/* analog output subdevice */
|
||||||
s = &dev->subdevices[0];
|
s = &dev->subdevices[0];
|
||||||
|
|
Loading…
Add table
Reference in a new issue