staging: comedi: ni_stc.h: tidy up AI_AO_Select register and bits

Rename the CamelCase and convert the enum into macros.

Tidy up the driver code to use the new macros.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
H Hartley Sweeten
2015-05-01 15:00:03 -07:00
committed by Greg Kroah-Hartman
parent 3446b08e83
commit a4b7ef9d8e
2 changed files with 18 additions and 23 deletions

View File

@@ -546,7 +546,7 @@ static inline void ni_set_bitfield(struct comedi_device *dev, int reg,
devpriv->io_bidirection_pin_reg |= bit_values & bit_mask;
ni_stc_writew(dev, devpriv->io_bidirection_pin_reg, reg);
break;
case AI_AO_Select:
case NI_E_DMA_AI_AO_SEL_REG:
devpriv->ai_ao_select_reg &= ~bit_mask;
devpriv->ai_ao_select_reg |= bit_values & bit_mask;
ni_writeb(dev, devpriv->ai_ao_select_reg, reg);
@@ -571,29 +571,25 @@ static inline void ni_set_bitfield(struct comedi_device *dev, int reg,
/* negative channel means no channel */
static inline void ni_set_ai_dma_channel(struct comedi_device *dev, int channel)
{
unsigned bitfield;
unsigned bits = 0;
if (channel >= 0)
bitfield =
(ni_stc_dma_channel_select_bitfield(channel) <<
AI_DMA_Select_Shift) & AI_DMA_Select_Mask;
else
bitfield = 0;
ni_set_bitfield(dev, AI_AO_Select, AI_DMA_Select_Mask, bitfield);
bits = ni_stc_dma_channel_select_bitfield(channel);
ni_set_bitfield(dev, NI_E_DMA_AI_AO_SEL_REG,
NI_E_DMA_AI_SEL_MASK, NI_E_DMA_AI_SEL(bits));
}
/* negative channel means no channel */
static inline void ni_set_ao_dma_channel(struct comedi_device *dev, int channel)
{
unsigned bitfield;
unsigned bits = 0;
if (channel >= 0)
bitfield =
(ni_stc_dma_channel_select_bitfield(channel) <<
AO_DMA_Select_Shift) & AO_DMA_Select_Mask;
else
bitfield = 0;
ni_set_bitfield(dev, AI_AO_Select, AO_DMA_Select_Mask, bitfield);
bits = ni_stc_dma_channel_select_bitfield(channel);
ni_set_bitfield(dev, NI_E_DMA_AI_AO_SEL_REG,
NI_E_DMA_AO_SEL_MASK, NI_E_DMA_AO_SEL(bits));
}
/* negative mite_channel means no channel */
@@ -5373,7 +5369,7 @@ static int ni_E_init(struct comedi_device *dev,
}
/* DMA setup */
ni_writeb(dev, devpriv->ai_ao_select_reg, AI_AO_Select);
ni_writeb(dev, devpriv->ai_ao_select_reg, NI_E_DMA_AI_AO_SEL_REG);
ni_writeb(dev, devpriv->g0_g1_select_reg, G0_G1_Select);
if (devpriv->is_6xxx) {

View File

@@ -571,6 +571,12 @@
#define NI_E_STATUS_AI_FIFO_LOWER_NE BIT(3)
#define NI_E_STATUS_PROMOUT BIT(0)
#define NI_E_DMA_AI_AO_SEL_REG 0x09 /* w8 */
#define NI_E_DMA_AI_SEL(x) (((x) & 0xf) << 0)
#define NI_E_DMA_AI_SEL_MASK NI_E_DMA_AI_SEL(0xf)
#define NI_E_DMA_AO_SEL(x) (((x) & 0xf) << 4)
#define NI_E_DMA_AO_SEL_MASK NI_E_DMA_AO_SEL(0xf)
#define NI_E_SERIAL_CMD_REG 0x0d /* w8 */
#define NI_E_SERIAL_CMD_DAC_LD(x) BIT(3 + (x))
#define NI_E_SERIAL_CMD_EEPROM_CS BIT(2)
@@ -582,13 +588,6 @@
#define NI_E_MISC_CMD_EXT_ATRIG NI_E_MISC_CMD_INTEXT_ATRIG(0)
#define NI_E_MISC_CMD_INT_ATRIG NI_E_MISC_CMD_INTEXT_ATRIG(1)
#define AI_AO_Select 0x09
enum AI_AO_Select_Bits {
AI_DMA_Select_Shift = 0,
AI_DMA_Select_Mask = 0xf,
AO_DMA_Select_Shift = 4,
AO_DMA_Select_Mask = 0xf << AO_DMA_Select_Shift
};
#define G0_G1_Select 0x0b
static inline unsigned ni_stc_dma_channel_select_bitfield(unsigned channel)
{