Skip to content

Commit

Permalink
staging: comedi: cb_pcidas: remove thisboard and devpriv macros
Browse files Browse the repository at this point in the history
The 'thisboard' and 'devpriv' macros rely on a local variable having
a specific name and yield pointers derived from that local variable.
Replace the macros with local variables where used. use the
comedi_board() helper to get the 'thisboard' pointer.

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 Jul 6, 2012
1 parent 536af69 commit 82d8c74
Showing 1 changed file with 46 additions and 12 deletions.
58 changes: 46 additions & 12 deletions drivers/staging/comedi/drivers/cb_pcidas.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,11 +404,6 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = {
},
};

/*
* Useful for shorthand access to the particular board structure
*/
#define thisboard ((const struct cb_pcidas_board *)dev->board_ptr)

/* this structure is for data unique to this hardware driver. If
several hardware drivers keep similar information in this structure,
feel free to suggest moving the variable to the struct comedi_device struct. */
Expand Down Expand Up @@ -441,14 +436,10 @@ struct cb_pcidas_private {
unsigned int calibration_source;
};

/*
* most drivers define the following macro to make it easy to
* access the private structure.
*/
#define devpriv ((struct cb_pcidas_private *)dev->private)

static inline unsigned int cal_enable_bits(struct comedi_device *dev)
{
struct cb_pcidas_private *devpriv = dev->private;

return CAL_EN_BIT | CAL_SRC_BITS(devpriv->calibration_source);
}

Expand All @@ -460,6 +451,7 @@ static int cb_pcidas_ai_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
struct cb_pcidas_private *devpriv = dev->private;
int n, i;
unsigned int bits;
static const int timeout = 10000;
Expand Down Expand Up @@ -512,6 +504,7 @@ static int cb_pcidas_ai_rinsn(struct comedi_device *dev,
static int ai_config_calibration_source(struct comedi_device *dev,
unsigned int *data)
{
struct cb_pcidas_private *devpriv = dev->private;
static const int num_calibration_sources = 8;
unsigned int source = data[1];

Expand Down Expand Up @@ -548,6 +541,7 @@ static int cb_pcidas_ao_nofifo_winsn(struct comedi_device *dev,
struct comedi_insn *insn,
unsigned int *data)
{
struct cb_pcidas_private *devpriv = dev->private;
int channel;
unsigned long flags;

Expand All @@ -574,6 +568,7 @@ static int cb_pcidas_ao_fifo_winsn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
struct cb_pcidas_private *devpriv = dev->private;
int channel;
unsigned long flags;

Expand Down Expand Up @@ -609,6 +604,8 @@ static int cb_pcidas_ao_readback_insn(struct comedi_device *dev,
struct comedi_insn *insn,
unsigned int *data)
{
struct cb_pcidas_private *devpriv = dev->private;

data[0] = devpriv->ao_value[CR_CHAN(insn->chanspec)];

return 1;
Expand All @@ -632,6 +629,7 @@ static int wait_for_nvram_ready(unsigned long s5933_base_addr)
static int nvram_read(struct comedi_device *dev, unsigned int address,
uint8_t *data)
{
struct cb_pcidas_private *devpriv = dev->private;
unsigned long iobase = devpriv->s5933_config;

if (wait_for_nvram_ready(iobase) < 0)
Expand Down Expand Up @@ -674,6 +672,7 @@ static void write_calibration_bitstream(struct comedi_device *dev,
unsigned int bitstream,
unsigned int bitstream_length)
{
struct cb_pcidas_private *devpriv = dev->private;
static const int write_delay = 1;
unsigned int bit;

Expand All @@ -690,6 +689,7 @@ static void write_calibration_bitstream(struct comedi_device *dev,
static int caldac_8800_write(struct comedi_device *dev, unsigned int address,
uint8_t value)
{
struct cb_pcidas_private *devpriv = dev->private;
static const int num_caldac_channels = 8;
static const int bitstream_length = 11;
unsigned int bitstream = ((address & 0x7) << 8) | value;
Expand Down Expand Up @@ -730,6 +730,8 @@ static int caldac_read_insn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
struct cb_pcidas_private *devpriv = dev->private;

data[0] = devpriv->caldac_value[CR_CHAN(insn->chanspec)];

return 1;
Expand All @@ -738,6 +740,8 @@ static int caldac_read_insn(struct comedi_device *dev,
/* 1602/16 pregain offset */
static int dac08_write(struct comedi_device *dev, unsigned int value)
{
struct cb_pcidas_private *devpriv = dev->private;

if (devpriv->dac08_value == value)
return 1;

Expand Down Expand Up @@ -767,13 +771,16 @@ static int dac08_read_insn(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data)
{
struct cb_pcidas_private *devpriv = dev->private;

data[0] = devpriv->dac08_value;

return 1;
}

static int trimpot_7376_write(struct comedi_device *dev, uint8_t value)
{
struct cb_pcidas_private *devpriv = dev->private;
static const int bitstream_length = 7;
unsigned int bitstream = value & 0x7f;
unsigned int register_bits;
Expand All @@ -798,6 +805,7 @@ static int trimpot_7376_write(struct comedi_device *dev, uint8_t value)
static int trimpot_8402_write(struct comedi_device *dev, unsigned int channel,
uint8_t value)
{
struct cb_pcidas_private *devpriv = dev->private;
static const int bitstream_length = 10;
unsigned int bitstream = ((channel & 0x3) << 8) | (value & 0xff);
unsigned int register_bits;
Expand All @@ -819,6 +827,9 @@ static int trimpot_8402_write(struct comedi_device *dev, unsigned int channel,
static int cb_pcidas_trimpot_write(struct comedi_device *dev,
unsigned int channel, unsigned int value)
{
const struct cb_pcidas_board *thisboard = comedi_board(dev);
struct cb_pcidas_private *devpriv = dev->private;

if (devpriv->trimpot_value[channel] == value)
return 1;

Expand Down Expand Up @@ -852,6 +863,7 @@ static int trimpot_read_insn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
struct cb_pcidas_private *devpriv = dev->private;
unsigned int channel = CR_CHAN(insn->chanspec);

data[0] = devpriv->trimpot_value[channel];
Expand All @@ -863,6 +875,8 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_cmd *cmd)
{
const struct cb_pcidas_board *thisboard = comedi_board(dev);
struct cb_pcidas_private *devpriv = dev->private;
int err = 0;
int tmp;
int i, gain, start_chan;
Expand Down Expand Up @@ -1039,6 +1053,8 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev,
static void cb_pcidas_load_counters(struct comedi_device *dev, unsigned int *ns,
int rounding_flags)
{
struct cb_pcidas_private *devpriv = dev->private;

i8253_cascade_ns_to_timer_2div(TIMER_BASE, &(devpriv->divisor1),
&(devpriv->divisor2), ns,
rounding_flags & TRIG_ROUND_MASK);
Expand All @@ -1053,6 +1069,8 @@ static void cb_pcidas_load_counters(struct comedi_device *dev, unsigned int *ns,
static int cb_pcidas_ai_cmd(struct comedi_device *dev,
struct comedi_subdevice *s)
{
const struct cb_pcidas_board *thisboard = comedi_board(dev);
struct cb_pcidas_private *devpriv = dev->private;
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
unsigned int bits;
Expand Down Expand Up @@ -1147,6 +1165,8 @@ static int cb_pcidas_ao_cmdtest(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_cmd *cmd)
{
const struct cb_pcidas_board *thisboard = comedi_board(dev);
struct cb_pcidas_private *devpriv = dev->private;
int err = 0;
int tmp;

Expand Down Expand Up @@ -1263,6 +1283,7 @@ static int cb_pcidas_ao_cmdtest(struct comedi_device *dev,
static int cb_pcidas_cancel(struct comedi_device *dev,
struct comedi_subdevice *s)
{
struct cb_pcidas_private *devpriv = dev->private;
unsigned long flags;

spin_lock_irqsave(&dev->spinlock, flags);
Expand All @@ -1283,6 +1304,8 @@ static int cb_pcidas_ao_inttrig(struct comedi_device *dev,
struct comedi_subdevice *s,
unsigned int trig_num)
{
const struct cb_pcidas_board *thisboard = comedi_board(dev);
struct cb_pcidas_private *devpriv = dev->private;
unsigned int num_bytes, num_points = thisboard->fifo_size;
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &s->async->cmd;
Expand Down Expand Up @@ -1332,6 +1355,7 @@ static int cb_pcidas_ao_inttrig(struct comedi_device *dev,
static int cb_pcidas_ao_cmd(struct comedi_device *dev,
struct comedi_subdevice *s)
{
struct cb_pcidas_private *devpriv = dev->private;
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
unsigned int i;
Expand Down Expand Up @@ -1399,6 +1423,7 @@ static int cb_pcidas_ao_cmd(struct comedi_device *dev,
static int cb_pcidas_ao_cancel(struct comedi_device *dev,
struct comedi_subdevice *s)
{
struct cb_pcidas_private *devpriv = dev->private;
unsigned long flags;

spin_lock_irqsave(&dev->spinlock, flags);
Expand All @@ -1416,6 +1441,8 @@ static int cb_pcidas_ao_cancel(struct comedi_device *dev,

static void handle_ao_interrupt(struct comedi_device *dev, unsigned int status)
{
const struct cb_pcidas_board *thisboard = comedi_board(dev);
struct cb_pcidas_private *devpriv = dev->private;
struct comedi_subdevice *s = dev->write_subdev;
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
Expand Down Expand Up @@ -1472,6 +1499,8 @@ static void handle_ao_interrupt(struct comedi_device *dev, unsigned int status)
static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
{
struct comedi_device *dev = (struct comedi_device *)d;
const struct cb_pcidas_board *thisboard = comedi_board(dev);
struct cb_pcidas_private *devpriv = dev->private;
struct comedi_subdevice *s = dev->read_subdev;
struct comedi_async *async;
int status, s5933_status;
Expand Down Expand Up @@ -1582,6 +1611,8 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
static int cb_pcidas_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
const struct cb_pcidas_board *thisboard;
struct cb_pcidas_private *devpriv;
struct comedi_subdevice *s;
struct pci_dev *pcidev = NULL;
int index;
Expand All @@ -1593,6 +1624,7 @@ static int cb_pcidas_attach(struct comedi_device *dev,
*/
if (alloc_private(dev, sizeof(struct cb_pcidas_private)) < 0)
return -ENOMEM;
devpriv = dev->private;

/*
* Probe the device to determine what device in the series it is.
Expand Down Expand Up @@ -1625,7 +1657,7 @@ static int cb_pcidas_attach(struct comedi_device *dev,
return -EIO;

found:

thisboard = comedi_board(dev);
dev_dbg(dev->class_dev, "Found %s on bus %i, slot %i\n",
cb_pcidas_boards[index].name, pcidev->bus->number,
PCI_SLOT(pcidev->devfn));
Expand Down Expand Up @@ -1781,6 +1813,8 @@ static int cb_pcidas_attach(struct comedi_device *dev,

static void cb_pcidas_detach(struct comedi_device *dev)
{
struct cb_pcidas_private *devpriv = dev->private;

if (devpriv) {
if (devpriv->s5933_config) {
outl(INTCSR_INBOX_INTR_STATUS,
Expand Down

0 comments on commit 82d8c74

Please sign in to comment.