Skip to content

Commit

Permalink
staging: comedi: remove this_board macro in the pcl711 driver
Browse files Browse the repository at this point in the history
The 'this_board' macro depends on having a local variable with
a magic name. The CodingStyle document suggests not doing this
to avoid confusion. Remove the macro and use the comedi_board()
inline helper to get the dev->board_ptr information.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Jun 5, 2012
1 parent f21b15b commit 90d662e
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions drivers/staging/comedi/drivers/pcl711.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ struct pcl711_board {
const struct comedi_lrange *ai_range_type;
};

#define this_board ((const struct pcl711_board *)dev->board_ptr)

struct pcl711_private {

int board;
Expand All @@ -169,6 +167,7 @@ static irqreturn_t pcl711_interrupt(int irq, void *d)
int lo, hi;
int data;
struct comedi_device *dev = d;
const struct pcl711_board *board = comedi_board(dev);
struct comedi_subdevice *s = dev->subdevices + 0;

if (!dev->attached) {
Expand All @@ -184,7 +183,7 @@ static irqreturn_t pcl711_interrupt(int irq, void *d)

/* FIXME! Nothing else sets ntrig! */
if (!(--devpriv->ntrig)) {
if (this_board->is_8112)
if (board->is_8112)
outb(1, dev->iobase + PCL711_MODE);
else
outb(0, dev->iobase + PCL711_MODE);
Expand All @@ -197,13 +196,14 @@ static irqreturn_t pcl711_interrupt(int irq, void *d)

static void pcl711_set_changain(struct comedi_device *dev, int chan)
{
const struct pcl711_board *board = comedi_board(dev);
int chan_register;

outb(CR_RANGE(chan), dev->iobase + PCL711_GAIN);

chan_register = CR_CHAN(chan);

if (this_board->is_8112) {
if (board->is_8112) {

/*
* Set the correct channel. The two channel banks are switched
Expand All @@ -225,6 +225,7 @@ static void pcl711_set_changain(struct comedi_device *dev, int chan)
static int pcl711_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
const struct pcl711_board *board = comedi_board(dev);
int i, n;
int hi, lo;

Expand All @@ -237,7 +238,7 @@ static int pcl711_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
*/
outb(1, dev->iobase + PCL711_MODE);

if (!this_board->is_8112)
if (!board->is_8112)
outb(0, dev->iobase + PCL711_SOFTTRIG);

i = PCL711_TIMEOUT;
Expand Down Expand Up @@ -481,6 +482,7 @@ static int pcl711_do_insn_bits(struct comedi_device *dev,

static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
const struct pcl711_board *board = comedi_board(dev);
int ret;
unsigned long iobase;
unsigned int irq;
Expand All @@ -498,12 +500,11 @@ static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it)

/* there should be a sanity check here */

/* set up some name stuff */
dev->board_name = this_board->name;
dev->board_name = board->name;

/* grab our IRQ */
irq = it->options[1];
if (irq > this_board->maxirq) {
if (irq > board->maxirq) {
printk(KERN_ERR "irq out of range\n");
return -EINVAL;
}
Expand All @@ -529,10 +530,10 @@ static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* AI subdevice */
s->type = COMEDI_SUBD_AI;
s->subdev_flags = SDF_READABLE | SDF_GROUND;
s->n_chan = this_board->n_aichan;
s->n_chan = board->n_aichan;
s->maxdata = 0xfff;
s->len_chanlist = 1;
s->range_table = this_board->ai_range_type;
s->range_table = board->ai_range_type;
s->insn_read = pcl711_ai_insn;
if (irq) {
dev->read_subdev = s;
Expand All @@ -545,7 +546,7 @@ static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* AO subdevice */
s->type = COMEDI_SUBD_AO;
s->subdev_flags = SDF_WRITABLE;
s->n_chan = this_board->n_aochan;
s->n_chan = board->n_aochan;
s->maxdata = 0xfff;
s->len_chanlist = 1;
s->range_table = &range_bipolar5;
Expand Down Expand Up @@ -577,7 +578,7 @@ static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it)
this is the "base value" for the mode register, which is
used for the irq on the PCL711
*/
if (this_board->is_pcl711b)
if (board->is_pcl711b)
devpriv->mode = (dev->irq << 4);

/* clear DAC */
Expand Down

0 comments on commit 90d662e

Please sign in to comment.