staging: comedi: pcm3724: remove subdevice pointer math
Convert the comedi_subdevice access from pointer math to array access. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
9fab612335
commit
0a96639fe7
1 changed files with 17 additions and 9 deletions
|
@ -119,6 +119,8 @@ static int compute_buffer(int config, int devno, struct comedi_subdevice *s)
|
||||||
static void do_3724_config(struct comedi_device *dev,
|
static void do_3724_config(struct comedi_device *dev,
|
||||||
struct comedi_subdevice *s, int chanspec)
|
struct comedi_subdevice *s, int chanspec)
|
||||||
{
|
{
|
||||||
|
struct comedi_subdevice *s_dio1 = &dev->subdevices[0];
|
||||||
|
struct comedi_subdevice *s_dio2 = &dev->subdevices[1];
|
||||||
int config;
|
int config;
|
||||||
int buffer_config;
|
int buffer_config;
|
||||||
unsigned long port_8255_cfg;
|
unsigned long port_8255_cfg;
|
||||||
|
@ -136,10 +138,10 @@ static void do_3724_config(struct comedi_device *dev,
|
||||||
if (!(s->io_bits & 0xff0000))
|
if (!(s->io_bits & 0xff0000))
|
||||||
config |= CR_C_IO;
|
config |= CR_C_IO;
|
||||||
|
|
||||||
buffer_config = compute_buffer(0, 0, dev->subdevices);
|
buffer_config = compute_buffer(0, 0, s_dio1);
|
||||||
buffer_config = compute_buffer(buffer_config, 1, (dev->subdevices) + 1);
|
buffer_config = compute_buffer(buffer_config, 1, s_dio2);
|
||||||
|
|
||||||
if (s == dev->subdevices)
|
if (s == s_dio1)
|
||||||
port_8255_cfg = dev->iobase + _8255_CR;
|
port_8255_cfg = dev->iobase + _8255_CR;
|
||||||
else
|
else
|
||||||
port_8255_cfg = dev->iobase + SIZE_8255 + _8255_CR;
|
port_8255_cfg = dev->iobase + SIZE_8255 + _8255_CR;
|
||||||
|
@ -154,6 +156,7 @@ static void do_3724_config(struct comedi_device *dev,
|
||||||
static void enable_chan(struct comedi_device *dev, struct comedi_subdevice *s,
|
static void enable_chan(struct comedi_device *dev, struct comedi_subdevice *s,
|
||||||
int chanspec)
|
int chanspec)
|
||||||
{
|
{
|
||||||
|
struct comedi_subdevice *s_dio1 = &dev->subdevices[0];
|
||||||
unsigned int mask;
|
unsigned int mask;
|
||||||
int gatecfg;
|
int gatecfg;
|
||||||
struct priv_pcm3724 *priv;
|
struct priv_pcm3724 *priv;
|
||||||
|
@ -162,9 +165,9 @@ static void enable_chan(struct comedi_device *dev, struct comedi_subdevice *s,
|
||||||
priv = dev->private;
|
priv = dev->private;
|
||||||
|
|
||||||
mask = 1 << CR_CHAN(chanspec);
|
mask = 1 << CR_CHAN(chanspec);
|
||||||
if (s == dev->subdevices) /* subdev 0 */
|
if (s == s_dio1)
|
||||||
priv->dio_1 |= mask;
|
priv->dio_1 |= mask;
|
||||||
else /* subdev 1 */
|
else
|
||||||
priv->dio_2 |= mask;
|
priv->dio_2 |= mask;
|
||||||
|
|
||||||
if (priv->dio_1 & 0xff0000)
|
if (priv->dio_1 & 0xff0000)
|
||||||
|
@ -231,6 +234,7 @@ static int pcm3724_attach(struct comedi_device *dev,
|
||||||
struct comedi_devconfig *it)
|
struct comedi_devconfig *it)
|
||||||
{
|
{
|
||||||
const struct pcm3724_board *board = comedi_board(dev);
|
const struct pcm3724_board *board = comedi_board(dev);
|
||||||
|
struct comedi_subdevice *s;
|
||||||
unsigned long iobase;
|
unsigned long iobase;
|
||||||
unsigned int iorange;
|
unsigned int iorange;
|
||||||
int ret, i, n_subdevices;
|
int ret, i, n_subdevices;
|
||||||
|
@ -263,9 +267,10 @@ static int pcm3724_attach(struct comedi_device *dev,
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
for (i = 0; i < dev->n_subdevices; i++) {
|
for (i = 0; i < dev->n_subdevices; i++) {
|
||||||
subdev_8255_init(dev, dev->subdevices + i, subdev_8255_cb,
|
s = &dev->subdevices[i];
|
||||||
|
subdev_8255_init(dev, s, subdev_8255_cb,
|
||||||
(unsigned long)(dev->iobase + SIZE_8255 * i));
|
(unsigned long)(dev->iobase + SIZE_8255 * i));
|
||||||
((dev->subdevices) + i)->insn_config = subdev_3724_insn_config;
|
s->insn_config = subdev_3724_insn_config;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -273,11 +278,14 @@ static int pcm3724_attach(struct comedi_device *dev,
|
||||||
static void pcm3724_detach(struct comedi_device *dev)
|
static void pcm3724_detach(struct comedi_device *dev)
|
||||||
{
|
{
|
||||||
const struct pcm3724_board *board = comedi_board(dev);
|
const struct pcm3724_board *board = comedi_board(dev);
|
||||||
|
struct comedi_subdevice *s;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (dev->subdevices) {
|
if (dev->subdevices) {
|
||||||
for (i = 0; i < dev->n_subdevices; i++)
|
for (i = 0; i < dev->n_subdevices; i++) {
|
||||||
subdev_8255_cleanup(dev, dev->subdevices + i);
|
s = &dev->subdevices[i];
|
||||||
|
subdev_8255_cleanup(dev, s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (dev->iobase)
|
if (dev->iobase)
|
||||||
release_region(dev->iobase, board->io_range);
|
release_region(dev->iobase, board->io_range);
|
||||||
|
|
Loading…
Add table
Reference in a new issue