Commit 6bd65164 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: adv_pci1710: remove devpriv and this_board macros

These macros rely on a local variable having a specific name. Remove
them and use the comedi_board() helper to get the this_board pointer.
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 f5f9a3ff
...@@ -269,9 +269,6 @@ struct pci1710_private { ...@@ -269,9 +269,6 @@ struct pci1710_private {
* internal state */ * internal state */
}; };
#define devpriv ((struct pci1710_private *)dev->private)
#define this_board ((const struct boardtype *)dev->board_ptr)
/* /*
============================================================================== ==============================================================================
*/ */
...@@ -304,8 +301,10 @@ static int pci171x_insn_read_ai(struct comedi_device *dev, ...@@ -304,8 +301,10 @@ static int pci171x_insn_read_ai(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
struct pci1710_private *devpriv = dev->private;
int n, timeout; int n, timeout;
#ifdef PCI171x_PARANOIDCHECK #ifdef PCI171x_PARANOIDCHECK
const struct boardtype *this_board = comedi_board(dev);
unsigned int idata; unsigned int idata;
#endif #endif
...@@ -359,6 +358,7 @@ static int pci171x_insn_write_ao(struct comedi_device *dev, ...@@ -359,6 +358,7 @@ static int pci171x_insn_write_ao(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
struct pci1710_private *devpriv = dev->private;
int n, chan, range, ofs; int n, chan, range, ofs;
chan = CR_CHAN(insn->chanspec); chan = CR_CHAN(insn->chanspec);
...@@ -391,6 +391,7 @@ static int pci171x_insn_read_ao(struct comedi_device *dev, ...@@ -391,6 +391,7 @@ static int pci171x_insn_read_ao(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
struct pci1710_private *devpriv = dev->private;
int n, chan; int n, chan;
chan = CR_CHAN(insn->chanspec); chan = CR_CHAN(insn->chanspec);
...@@ -461,6 +462,7 @@ static int pci171x_insn_counter_write(struct comedi_device *dev, ...@@ -461,6 +462,7 @@ static int pci171x_insn_counter_write(struct comedi_device *dev,
struct comedi_insn *insn, struct comedi_insn *insn,
unsigned int *data) unsigned int *data)
{ {
struct pci1710_private *devpriv = dev->private;
uint msb, lsb, ccntrl, status; uint msb, lsb, ccntrl, status;
lsb = data[0] & 0x00FF; lsb = data[0] & 0x00FF;
...@@ -492,6 +494,7 @@ static int pci171x_insn_counter_config(struct comedi_device *dev, ...@@ -492,6 +494,7 @@ static int pci171x_insn_counter_config(struct comedi_device *dev,
{ {
#ifdef unused #ifdef unused
/* This doesn't work like a normal Comedi counter config */ /* This doesn't work like a normal Comedi counter config */
struct pci1710_private *devpriv = dev->private;
uint ccntrl = 0; uint ccntrl = 0;
devpriv->cnt0_write_wait = data[0] & 0x20; devpriv->cnt0_write_wait = data[0] & 0x20;
...@@ -527,6 +530,7 @@ static int pci1720_insn_write_ao(struct comedi_device *dev, ...@@ -527,6 +530,7 @@ static int pci1720_insn_write_ao(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
struct pci1710_private *devpriv = dev->private;
int n, rangereg, chan; int n, rangereg, chan;
chan = CR_CHAN(insn->chanspec); chan = CR_CHAN(insn->chanspec);
...@@ -553,9 +557,11 @@ static int pci1720_insn_write_ao(struct comedi_device *dev, ...@@ -553,9 +557,11 @@ static int pci1720_insn_write_ao(struct comedi_device *dev,
static void interrupt_pci1710_every_sample(void *d) static void interrupt_pci1710_every_sample(void *d)
{ {
struct comedi_device *dev = d; struct comedi_device *dev = d;
struct pci1710_private *devpriv = dev->private;
struct comedi_subdevice *s = dev->subdevices + 0; struct comedi_subdevice *s = dev->subdevices + 0;
int m; int m;
#ifdef PCI171x_PARANOIDCHECK #ifdef PCI171x_PARANOIDCHECK
const struct boardtype *this_board = comedi_board(dev);
short sampl; short sampl;
#endif #endif
...@@ -633,8 +639,10 @@ static void interrupt_pci1710_every_sample(void *d) ...@@ -633,8 +639,10 @@ static void interrupt_pci1710_every_sample(void *d)
static int move_block_from_fifo(struct comedi_device *dev, static int move_block_from_fifo(struct comedi_device *dev,
struct comedi_subdevice *s, int n, int turn) struct comedi_subdevice *s, int n, int turn)
{ {
struct pci1710_private *devpriv = dev->private;
int i, j; int i, j;
#ifdef PCI171x_PARANOIDCHECK #ifdef PCI171x_PARANOIDCHECK
const struct boardtype *this_board = comedi_board(dev);
int sampl; int sampl;
#endif #endif
...@@ -677,6 +685,8 @@ static int move_block_from_fifo(struct comedi_device *dev, ...@@ -677,6 +685,8 @@ static int move_block_from_fifo(struct comedi_device *dev,
static void interrupt_pci1710_half_fifo(void *d) static void interrupt_pci1710_half_fifo(void *d)
{ {
struct comedi_device *dev = d; struct comedi_device *dev = d;
const struct boardtype *this_board = comedi_board(dev);
struct pci1710_private *devpriv = dev->private;
struct comedi_subdevice *s = dev->subdevices + 0; struct comedi_subdevice *s = dev->subdevices + 0;
int m, samplesinbuf; int m, samplesinbuf;
...@@ -731,6 +741,7 @@ static void interrupt_pci1710_half_fifo(void *d) ...@@ -731,6 +741,7 @@ static void interrupt_pci1710_half_fifo(void *d)
static irqreturn_t interrupt_service_pci1710(int irq, void *d) static irqreturn_t interrupt_service_pci1710(int irq, void *d)
{ {
struct comedi_device *dev = d; struct comedi_device *dev = d;
struct pci1710_private *devpriv = dev->private;
if (!dev->attached) /* is device attached? */ if (!dev->attached) /* is device attached? */
return IRQ_NONE; /* no, exit */ return IRQ_NONE; /* no, exit */
...@@ -766,6 +777,8 @@ static irqreturn_t interrupt_service_pci1710(int irq, void *d) ...@@ -766,6 +777,8 @@ static irqreturn_t interrupt_service_pci1710(int irq, void *d)
static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev, static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev,
struct comedi_subdevice *s) struct comedi_subdevice *s)
{ {
const struct boardtype *this_board = comedi_board(dev);
struct pci1710_private *devpriv = dev->private;
unsigned int divisor1 = 0, divisor2 = 0; unsigned int divisor1 = 0, divisor2 = 0;
unsigned int seglen; unsigned int seglen;
...@@ -846,6 +859,8 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev, ...@@ -846,6 +859,8 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_cmd *cmd) struct comedi_cmd *cmd)
{ {
const struct boardtype *this_board = comedi_board(dev);
struct pci1710_private *devpriv = dev->private;
int err = 0; int err = 0;
int tmp; int tmp;
unsigned int divisor1 = 0, divisor2 = 0; unsigned int divisor1 = 0, divisor2 = 0;
...@@ -981,6 +996,7 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev, ...@@ -981,6 +996,7 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev,
*/ */
static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{ {
struct pci1710_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd; struct comedi_cmd *cmd = &s->async->cmd;
devpriv->ai_n_chan = cmd->chanlist_len; devpriv->ai_n_chan = cmd->chanlist_len;
...@@ -1075,6 +1091,8 @@ static void setup_channel_list(struct comedi_device *dev, ...@@ -1075,6 +1091,8 @@ static void setup_channel_list(struct comedi_device *dev,
unsigned int *chanlist, unsigned int n_chan, unsigned int *chanlist, unsigned int n_chan,
unsigned int seglen) unsigned int seglen)
{ {
const struct boardtype *this_board = comedi_board(dev);
struct pci1710_private *devpriv = dev->private;
unsigned int i, range, chanprog; unsigned int i, range, chanprog;
devpriv->act_chanlist_len = seglen; devpriv->act_chanlist_len = seglen;
...@@ -1128,6 +1146,9 @@ static void start_pacer(struct comedi_device *dev, int mode, ...@@ -1128,6 +1146,9 @@ static void start_pacer(struct comedi_device *dev, int mode,
static int pci171x_ai_cancel(struct comedi_device *dev, static int pci171x_ai_cancel(struct comedi_device *dev,
struct comedi_subdevice *s) struct comedi_subdevice *s)
{ {
const struct boardtype *this_board = comedi_board(dev);
struct pci1710_private *devpriv = dev->private;
switch (this_board->cardtype) { switch (this_board->cardtype) {
default: default:
devpriv->CntrlReg &= Control_CNT0; devpriv->CntrlReg &= Control_CNT0;
...@@ -1154,6 +1175,9 @@ static int pci171x_ai_cancel(struct comedi_device *dev, ...@@ -1154,6 +1175,9 @@ static int pci171x_ai_cancel(struct comedi_device *dev,
*/ */
static int pci171x_reset(struct comedi_device *dev) static int pci171x_reset(struct comedi_device *dev)
{ {
const struct boardtype *this_board = comedi_board(dev);
struct pci1710_private *devpriv = dev->private;
outw(0x30, dev->iobase + PCI171x_CNTCTRL); outw(0x30, dev->iobase + PCI171x_CNTCTRL);
devpriv->CntrlReg = Control_SW | Control_CNT0; /* Software trigger, CNT0=external */ devpriv->CntrlReg = Control_SW | Control_CNT0; /* Software trigger, CNT0=external */
outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL); /* reset any operations */ outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL); /* reset any operations */
...@@ -1182,6 +1206,8 @@ static int pci171x_reset(struct comedi_device *dev) ...@@ -1182,6 +1206,8 @@ static int pci171x_reset(struct comedi_device *dev)
*/ */
static int pci1720_reset(struct comedi_device *dev) static int pci1720_reset(struct comedi_device *dev)
{ {
struct pci1710_private *devpriv = dev->private;
outb(Syncont_SC0, dev->iobase + PCI1720_SYNCONT); /* set synchronous output mode */ outb(Syncont_SC0, dev->iobase + PCI1720_SYNCONT); /* set synchronous output mode */
devpriv->da_ranges = 0xAA; devpriv->da_ranges = 0xAA;
outb(devpriv->da_ranges, dev->iobase + PCI1720_RANGE); /* set all ranges to +/-5V */ outb(devpriv->da_ranges, dev->iobase + PCI1720_RANGE); /* set all ranges to +/-5V */
...@@ -1202,6 +1228,8 @@ static int pci1720_reset(struct comedi_device *dev) ...@@ -1202,6 +1228,8 @@ static int pci1720_reset(struct comedi_device *dev)
*/ */
static int pci1710_reset(struct comedi_device *dev) static int pci1710_reset(struct comedi_device *dev)
{ {
const struct boardtype *this_board = comedi_board(dev);
switch (this_board->cardtype) { switch (this_board->cardtype) {
case TYPE_PCI1720: case TYPE_PCI1720:
return pci1720_reset(dev); return pci1720_reset(dev);
...@@ -1213,6 +1241,7 @@ static int pci1710_reset(struct comedi_device *dev) ...@@ -1213,6 +1241,7 @@ static int pci1710_reset(struct comedi_device *dev)
static struct pci_dev *pci1710_find_pci_dev(struct comedi_device *dev, static struct pci_dev *pci1710_find_pci_dev(struct comedi_device *dev,
struct comedi_devconfig *it) struct comedi_devconfig *it)
{ {
const struct boardtype *this_board = comedi_board(dev);
struct pci_dev *pcidev = NULL; struct pci_dev *pcidev = NULL;
int bus = it->options[0]; int bus = it->options[0];
int slot = it->options[1]; int slot = it->options[1];
...@@ -1252,6 +1281,8 @@ static struct pci_dev *pci1710_find_pci_dev(struct comedi_device *dev, ...@@ -1252,6 +1281,8 @@ static struct pci_dev *pci1710_find_pci_dev(struct comedi_device *dev,
static int pci1710_attach(struct comedi_device *dev, static int pci1710_attach(struct comedi_device *dev,
struct comedi_devconfig *it) struct comedi_devconfig *it)
{ {
const struct boardtype *this_board;
struct pci1710_private *devpriv;
struct pci_dev *pcidev; struct pci_dev *pcidev;
struct comedi_subdevice *s; struct comedi_subdevice *s;
int ret, subdev, n_subdevices; int ret, subdev, n_subdevices;
...@@ -1259,14 +1290,16 @@ static int pci1710_attach(struct comedi_device *dev, ...@@ -1259,14 +1290,16 @@ static int pci1710_attach(struct comedi_device *dev,
dev_info(dev->class_dev, DRV_NAME ": attach\n"); dev_info(dev->class_dev, DRV_NAME ": attach\n");
ret = alloc_private(dev, sizeof(struct pci1710_private)); ret = alloc_private(dev, sizeof(*devpriv));
if (ret < 0) if (ret < 0)
return -ENOMEM; return -ENOMEM;
devpriv = dev->private;
pcidev = pci1710_find_pci_dev(dev, it); pcidev = pci1710_find_pci_dev(dev, it);
if (!pcidev) if (!pcidev)
return -EIO; return -EIO;
comedi_set_hw_dev(dev, &pcidev->dev); comedi_set_hw_dev(dev, &pcidev->dev);
this_board = comedi_board(dev);
ret = comedi_pci_enable(pcidev, DRV_NAME); ret = comedi_pci_enable(pcidev, DRV_NAME);
if (ret) if (ret)
...@@ -1408,9 +1441,10 @@ static int pci1710_attach(struct comedi_device *dev, ...@@ -1408,9 +1441,10 @@ static int pci1710_attach(struct comedi_device *dev,
static void pci1710_detach(struct comedi_device *dev) static void pci1710_detach(struct comedi_device *dev)
{ {
struct pci1710_private *devpriv = dev->private;
struct pci_dev *pcidev = comedi_to_pci_dev(dev); struct pci_dev *pcidev = comedi_to_pci_dev(dev);
if (dev->private) { if (devpriv) {
if (devpriv->valid) if (devpriv->valid)
pci1710_reset(dev); pci1710_reset(dev);
if (dev->irq) if (dev->irq)
......
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