Skip to content

Commit

Permalink
staging: comedi: dt2801: remove 'boardtype' macro
Browse files Browse the repository at this point in the history
The 'boardtype' macro relies on a local variable having a specific
name and yields a struct derived from that local variable.

Replace the macro with local variables and use the comedi_board()
helper to get the struct as a pointer. Use pointer access when
using the variable.

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>
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Apr 8, 2013
1 parent 3cb65d4 commit 23e79f8
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions drivers/staging/comedi/drivers/dt2801.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,6 @@ static const struct dt2801_board boardtypes[] = {
.dabits = 12},
};

#define boardtype (*(const struct dt2801_board *)dev->board_ptr)

struct dt2801_private {

const struct comedi_lrange *dac_range_types[2];
Expand Down Expand Up @@ -592,6 +590,7 @@ static int dt2801_dio_insn_config(struct comedi_device *dev,
*/
static int dt2801_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
const struct dt2801_board *board = comedi_board(dev);
struct dt2801_private *devpriv;
struct comedi_subdevice *s;
unsigned long iobase;
Expand Down Expand Up @@ -624,7 +623,8 @@ static int dt2801_attach(struct comedi_device *dev, struct comedi_devconfig *it)

havetype:
dev->board_ptr = boardtypes + type;
printk("dt2801: %s at port 0x%lx", boardtype.name, iobase);
board = comedi_board(dev);
printk("dt2801: %s at port 0x%lx", board->name, iobase);

n_ai_chans = probe_number_of_ai_chans(dev);
printk(" (ai channels = %d)\n", n_ai_chans);
Expand All @@ -638,7 +638,7 @@ static int dt2801_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return -ENOMEM;
dev->private = devpriv;

dev->board_name = boardtype.name;
dev->board_name = board->name;

s = &dev->subdevices[0];
/* ai subdevice */
Expand All @@ -648,20 +648,20 @@ static int dt2801_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->n_chan = n_ai_chans;
#else
if (it->options[2])
s->n_chan = boardtype.ad_chan;
s->n_chan = board->ad_chan;
else
s->n_chan = boardtype.ad_chan / 2;
s->n_chan = board->ad_chan / 2;
#endif
s->maxdata = (1 << boardtype.adbits) - 1;
s->range_table = ai_range_lkup(boardtype.adrangetype, it->options[3]);
s->maxdata = (1 << board->adbits) - 1;
s->range_table = ai_range_lkup(board->adrangetype, it->options[3]);
s->insn_read = dt2801_ai_insn_read;

s = &dev->subdevices[1];
/* ao subdevice */
s->type = COMEDI_SUBD_AO;
s->subdev_flags = SDF_WRITABLE;
s->n_chan = 2;
s->maxdata = (1 << boardtype.dabits) - 1;
s->maxdata = (1 << board->dabits) - 1;
s->range_table_list = devpriv->dac_range_types;
devpriv->dac_range_types[0] = dac_range_lkup(it->options[4]);
devpriv->dac_range_types[1] = dac_range_lkup(it->options[5]);
Expand Down

0 comments on commit 23e79f8

Please sign in to comment.