Commit 22acd860 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: ni_660x: change IOConfigReg() into a macro

The BUG_ON() in this function is unnecessary. The 'pfi_channel' will
always be in range of the subdevice 'n_chan' (NUM_PFI_CHANNELS) which
will return a valid 'reg'.

Convert the inline function into a simple macro.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8dc5fb4e
...@@ -156,13 +156,7 @@ enum ni_660x_register { ...@@ -156,13 +156,7 @@ enum ni_660x_register {
NI660X_NUM_REGS, NI660X_NUM_REGS,
}; };
static inline unsigned IOConfigReg(unsigned pfi_channel) #define NI660X_IO_CFG(x) (NI660X_IO_CFG_0_1 + ((x) / 2))
{
unsigned reg = NI660X_IO_CFG_0_1 + pfi_channel / 2;
BUG_ON(reg > NI660X_IO_CFG_38_39);
return reg;
}
enum ni_660x_register_width { enum ni_660x_register_width {
DATA_1B, DATA_1B,
...@@ -893,7 +887,7 @@ static void init_tio_chip(struct comedi_device *dev, int chipset) ...@@ -893,7 +887,7 @@ static void init_tio_chip(struct comedi_device *dev, int chipset)
devpriv->dma_configuration_soft_copies[chipset], devpriv->dma_configuration_soft_copies[chipset],
NI660X_DMA_CFG); NI660X_DMA_CFG);
for (i = 0; i < NUM_PFI_CHANNELS; ++i) for (i = 0; i < NUM_PFI_CHANNELS; ++i)
ni_660x_write_register(dev, chipset, 0, IOConfigReg(i)); ni_660x_write_register(dev, chipset, 0, NI660X_IO_CFG(i));
} }
static int ni_660x_dio_insn_bits(struct comedi_device *dev, static int ni_660x_dio_insn_bits(struct comedi_device *dev,
...@@ -944,22 +938,22 @@ static void ni_660x_select_pfi_output(struct comedi_device *dev, ...@@ -944,22 +938,22 @@ static void ni_660x_select_pfi_output(struct comedi_device *dev,
if (idle_chipset != active_chipset) { if (idle_chipset != active_chipset) {
idle_bits = idle_bits =
ni_660x_read_register(dev, idle_chipset, ni_660x_read_register(dev, idle_chipset,
IOConfigReg(pfi_channel)); NI660X_IO_CFG(pfi_channel));
idle_bits &= ~pfi_output_select_mask(pfi_channel); idle_bits &= ~pfi_output_select_mask(pfi_channel);
idle_bits |= idle_bits |=
pfi_output_select_bits(pfi_channel, pfi_output_select_bits(pfi_channel,
pfi_output_select_high_Z); pfi_output_select_high_Z);
ni_660x_write_register(dev, idle_chipset, idle_bits, ni_660x_write_register(dev, idle_chipset, idle_bits,
IOConfigReg(pfi_channel)); NI660X_IO_CFG(pfi_channel));
} }
active_bits = active_bits =
ni_660x_read_register(dev, active_chipset, ni_660x_read_register(dev, active_chipset,
IOConfigReg(pfi_channel)); NI660X_IO_CFG(pfi_channel));
active_bits &= ~pfi_output_select_mask(pfi_channel); active_bits &= ~pfi_output_select_mask(pfi_channel);
active_bits |= pfi_output_select_bits(pfi_channel, output_select); active_bits |= pfi_output_select_bits(pfi_channel, output_select);
ni_660x_write_register(dev, active_chipset, active_bits, ni_660x_write_register(dev, active_chipset, active_bits,
IOConfigReg(pfi_channel)); NI660X_IO_CFG(pfi_channel));
} }
static int ni_660x_set_pfi_routing(struct comedi_device *dev, unsigned chan, static int ni_660x_set_pfi_routing(struct comedi_device *dev, unsigned chan,
...@@ -1025,10 +1019,10 @@ static int ni_660x_dio_insn_config(struct comedi_device *dev, ...@@ -1025,10 +1019,10 @@ static int ni_660x_dio_insn_config(struct comedi_device *dev,
break; break;
case INSN_CONFIG_FILTER: case INSN_CONFIG_FILTER:
val = ni_660x_read_register(dev, 0, IOConfigReg(chan)); val = ni_660x_read_register(dev, 0, NI660X_IO_CFG(chan));
val &= ~pfi_input_select_mask(chan); val &= ~pfi_input_select_mask(chan);
val |= pfi_input_select_bits(chan, data[1]); val |= pfi_input_select_bits(chan, data[1]);
ni_660x_write_register(dev, 0, val, IOConfigReg(chan)); ni_660x_write_register(dev, 0, val, NI660X_IO_CFG(chan));
break; break;
default: default:
......
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