Merge branch 'for-4.2' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
[firefly-linux-kernel-4.4.55.git] / drivers / staging / comedi / drivers / ni_mio_common.c
index 0651aed7f4db329351c113d5428d9e3e046d7bfe..6cc304a4c59bfca17a6055d99631424ebeafa09f 100644 (file)
@@ -367,19 +367,19 @@ static const struct mio_regmap m_series_stc_write_regmap[] = {
        [NISTC_AO_MODE3_REG]            = { 0x18c, 2 },
        [NISTC_RESET_REG]               = { 0x190, 2 },
        [NISTC_INTA_ENA_REG]            = { 0x192, 2 },
-       [Second_IRQ_A_Enable_Register]  = { 0, 0 }, /* E-Series only */
-       [Interrupt_B_Enable_Register]   = { 0x196, 2 },
-       [Second_IRQ_B_Enable_Register]  = { 0, 0 }, /* E-Series only */
-       [AI_Personal_Register]          = { 0x19a, 2 },
-       [AO_Personal_Register]          = { 0x19c, 2 },
-       [RTSI_Trig_A_Output_Register]   = { 0x19e, 2 },
-       [RTSI_Trig_B_Output_Register]   = { 0x1a0, 2 },
-       [RTSI_Board_Register]           = { 0, 0 }, /* Unknown */
-       [Configuration_Memory_Clear]    = { 0x1a4, 2 },
-       [ADC_FIFO_Clear]                = { 0x1a6, 2 },
-       [DAC_FIFO_Clear]                = { 0x1a8, 2 },
-       [AO_Output_Control_Register]    = { 0x1ac, 2 },
-       [AI_Mode_3_Register]            = { 0x1ae, 2 },
+       [NISTC_INTA2_ENA_REG]           = { 0, 0 }, /* E-Series only */
+       [NISTC_INTB_ENA_REG]            = { 0x196, 2 },
+       [NISTC_INTB2_ENA_REG]           = { 0, 0 }, /* E-Series only */
+       [NISTC_AI_PERSONAL_REG]         = { 0x19a, 2 },
+       [NISTC_AO_PERSONAL_REG]         = { 0x19c, 2 },
+       [NISTC_RTSI_TRIGA_OUT_REG]      = { 0x19e, 2 },
+       [NISTC_RTSI_TRIGB_OUT_REG]      = { 0x1a0, 2 },
+       [NISTC_RTSI_BOARD_REG]          = { 0, 0 }, /* Unknown */
+       [NISTC_CFG_MEM_CLR_REG]         = { 0x1a4, 2 },
+       [NISTC_ADC_FIFO_CLR_REG]        = { 0x1a6, 2 },
+       [NISTC_DAC_FIFO_CLR_REG]        = { 0x1a8, 2 },
+       [NISTC_AO_OUT_CTRL_REG]         = { 0x1ac, 2 },
+       [NISTC_AI_MODE3_REG]            = { 0x1ae, 2 },
 };
 
 static void m_series_stc_write(struct comedi_device *dev,
@@ -410,24 +410,24 @@ static void m_series_stc_write(struct comedi_device *dev,
 }
 
 static const struct mio_regmap m_series_stc_read_regmap[] = {
-       [AI_Status_1_Register]          = { 0x104, 2 },
-       [AO_Status_1_Register]          = { 0x106, 2 },
-       [G_Status_Register]             = { 0x108, 2 },
-       [AI_Status_2_Register]          = { 0, 0 }, /* Unknown */
-       [AO_Status_2_Register]          = { 0x10c, 2 },
-       [DIO_Parallel_Input_Register]   = { 0, 0 }, /* Unknown */
-       [G_HW_Save_Register(0)]         = { 0x110, 4 },
-       [G_HW_Save_Register(1)]         = { 0x114, 4 },
-       [G_Save_Register(0)]            = { 0x118, 4 },
-       [G_Save_Register(1)]            = { 0x11c, 4 },
-       [AO_UI_Save_Registers]          = { 0x120, 4 },
-       [AO_BC_Save_Registers]          = { 0x124, 4 },
-       [AO_UC_Save_Registers]          = { 0x128, 4 },
-       [Joint_Status_1_Register]       = { 0x136, 2 },
-       [DIO_Serial_Input_Register]     = { 0x009, 1 },
-       [Joint_Status_2_Register]       = { 0x13a, 2 },
-       [AI_SI_Save_Registers]          = { 0x180, 4 },
-       [AI_SC_Save_Registers]          = { 0x184, 4 },
+       [NISTC_AI_STATUS1_REG]          = { 0x104, 2 },
+       [NISTC_AO_STATUS1_REG]          = { 0x106, 2 },
+       [NISTC_G01_STATUS_REG]          = { 0x108, 2 },
+       [NISTC_AI_STATUS2_REG]          = { 0, 0 }, /* Unknown */
+       [NISTC_AO_STATUS2_REG]          = { 0x10c, 2 },
+       [NISTC_DIO_IN_REG]              = { 0, 0 }, /* Unknown */
+       [NISTC_G0_HW_SAVE_REG]          = { 0x110, 4 },
+       [NISTC_G1_HW_SAVE_REG]          = { 0x114, 4 },
+       [NISTC_G0_SAVE_REG]             = { 0x118, 4 },
+       [NISTC_G1_SAVE_REG]             = { 0x11c, 4 },
+       [NISTC_AO_UI_SAVE_REG]          = { 0x120, 4 },
+       [NISTC_AO_BC_SAVE_REG]          = { 0x124, 4 },
+       [NISTC_AO_UC_SAVE_REG]          = { 0x128, 4 },
+       [NISTC_STATUS1_REG]             = { 0x136, 2 },
+       [NISTC_DIO_SERIAL_IN_REG]       = { 0x009, 1 },
+       [NISTC_STATUS2_REG]             = { 0x13a, 2 },
+       [NISTC_AI_SI_SAVE_REG]          = { 0x180, 4 },
+       [NISTC_AI_SC_SAVE_REG]          = { 0x184, 4 },
 };
 
 static unsigned int m_series_stc_read(struct comedi_device *dev,
@@ -469,8 +469,8 @@ static void ni_stc_writew(struct comedi_device *dev, uint16_t data, int reg)
                if (!devpriv->mite && reg < 8) {
                        ni_writew(dev, data, reg * 2);
                } else {
-                       ni_writew(dev, reg, Window_Address);
-                       ni_writew(dev, data, Window_Data);
+                       ni_writew(dev, reg, NI_E_STC_WINDOW_ADDR_REG);
+                       ni_writew(dev, data, NI_E_STC_WINDOW_DATA_REG);
                }
                spin_unlock_irqrestore(&devpriv->window_lock, flags);
        }
@@ -501,8 +501,8 @@ static uint16_t ni_stc_readw(struct comedi_device *dev, int reg)
                if (!devpriv->mite && reg < 8) {
                        val = ni_readw(dev, reg * 2);
                } else {
-                       ni_writew(dev, reg, Window_Address);
-                       val = ni_readw(dev, Window_Data);
+                       ni_writew(dev, reg, NI_E_STC_WINDOW_ADDR_REG);
+                       val = ni_readw(dev, NI_E_STC_WINDOW_DATA_REG);
                }
                spin_unlock_irqrestore(&devpriv->window_lock, flags);
        }
@@ -536,7 +536,7 @@ static inline void ni_set_bitfield(struct comedi_device *dev, int reg,
                devpriv->int_a_enable_reg |= bit_values & bit_mask;
                ni_stc_writew(dev, devpriv->int_a_enable_reg, reg);
                break;
-       case Interrupt_B_Enable_Register:
+       case NISTC_INTB_ENA_REG:
                devpriv->int_b_enable_reg &= ~bit_mask;
                devpriv->int_b_enable_reg |= bit_values & bit_mask;
                ni_stc_writew(dev, devpriv->int_b_enable_reg, reg);
@@ -546,12 +546,12 @@ 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);
                break;
-       case G0_G1_Select:
+       case NI_E_DMA_G0_G1_SEL_REG:
                devpriv->g0_g1_select_reg &= ~bit_mask;
                devpriv->g0_g1_select_reg |= bit_values & bit_mask;
                ni_writeb(dev, devpriv->g0_g1_select_reg, reg);
@@ -567,48 +567,55 @@ static inline void ni_set_bitfield(struct comedi_device *dev, int reg,
 
 #ifdef PCIDMA
 /* DMA channel setup */
+static inline unsigned ni_stc_dma_channel_select_bitfield(unsigned channel)
+{
+       if (channel < 4)
+               return 1 << channel;
+       if (channel == 4)
+               return 0x3;
+       if (channel == 5)
+               return 0x5;
+       BUG();
+       return 0;
+}
 
 /* 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 */
+/* negative channel means no channel */
 static inline void ni_set_gpct_dma_channel(struct comedi_device *dev,
                                           unsigned gpct_index,
-                                          int mite_channel)
+                                          int channel)
 {
-       unsigned bitfield;
+       unsigned bits = 0;
 
-       if (mite_channel >= 0)
-               bitfield = GPCT_DMA_Select_Bits(gpct_index, mite_channel);
-       else
-               bitfield = 0;
-       ni_set_bitfield(dev, G0_G1_Select, GPCT_DMA_Select_Mask(gpct_index),
-                       bitfield);
+       if (channel >= 0)
+               bits = ni_stc_dma_channel_select_bitfield(channel);
+
+       ni_set_bitfield(dev, NI_E_DMA_G0_G1_SEL_REG,
+                       NI_E_DMA_G0_G1_SEL_MASK(gpct_index),
+                       NI_E_DMA_G0_G1_SEL(gpct_index, bits));
 }
 
 /* negative mite_channel means no channel */
@@ -686,7 +693,6 @@ static int ni_request_gpct_mite_channel(struct comedi_device *dev,
        unsigned long flags;
        struct mite_channel *mite_chan;
 
-       BUG_ON(gpct_index >= NUM_GPCT);
        spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
        BUG_ON(devpriv->counter_dev->counters[gpct_index].mite_chan);
        mite_chan =
@@ -770,7 +776,6 @@ static void ni_release_gpct_mite_channel(struct comedi_device *dev,
        struct ni_private *devpriv = dev->private;
        unsigned long flags;
 
-       BUG_ON(gpct_index >= NUM_GPCT);
        spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
        if (devpriv->counter_dev->counters[gpct_index].mite_chan) {
                struct mite_channel *mite_chan =
@@ -818,13 +823,13 @@ static void ni_e_series_enable_second_irq(struct comedi_device *dev,
         * dma requests for their counters
         */
        if (gpct_index == 0) {
-               reg = Second_IRQ_A_Enable_Register;
+               reg = NISTC_INTA2_ENA_REG;
                if (enable)
-                       val = G0_Gate_Second_Irq_Enable;
+                       val = NISTC_INTA_ENA_G0_GATE;
        } else {
-               reg = Second_IRQ_B_Enable_Register;
+               reg = NISTC_INTB2_ENA_REG;
                if (enable)
-                       val = G1_Gate_Second_Irq_Enable;
+                       val = NISTC_INTB_ENA_G1_GATE;
        }
        ni_stc_writew(dev, val, reg);
 }
@@ -838,18 +843,18 @@ static void ni_clear_ai_fifo(struct comedi_device *dev)
 
        if (devpriv->is_6143) {
                /*  Flush the 6143 data FIFO */
-               ni_writel(dev, 0x10, AIFIFO_Control_6143);
-               ni_writel(dev, 0x00, AIFIFO_Control_6143);
+               ni_writel(dev, 0x10, NI6143_AI_FIFO_CTRL_REG);
+               ni_writel(dev, 0x00, NI6143_AI_FIFO_CTRL_REG);
                /*  Wait for complete */
                for (i = 0; i < timeout; i++) {
-                       if (!(ni_readl(dev, AIFIFO_Status_6143) & 0x10))
+                       if (!(ni_readl(dev, NI6143_AI_FIFO_STATUS_REG) & 0x10))
                                break;
                        udelay(1);
                }
                if (i == timeout)
                        dev_err(dev->class_dev, "FIFO flush timeout\n");
        } else {
-               ni_stc_writew(dev, 1, ADC_FIFO_Clear);
+               ni_stc_writew(dev, 1, NISTC_ADC_FIFO_CLR_REG);
                if (devpriv->is_625x) {
                        ni_writeb(dev, 0, NI_M_STATIC_AI_CTRL_REG(0));
                        ni_writeb(dev, 1, NI_M_STATIC_AI_CTRL_REG(0));
@@ -874,8 +879,8 @@ static inline void ni_ao_win_outw(struct comedi_device *dev, uint16_t data,
        unsigned long flags;
 
        spin_lock_irqsave(&devpriv->window_lock, flags);
-       ni_writew(dev, addr, AO_Window_Address_611x);
-       ni_writew(dev, data, AO_Window_Data_611x);
+       ni_writew(dev, addr, NI611X_AO_WINDOW_ADDR_REG);
+       ni_writew(dev, data, NI611X_AO_WINDOW_DATA_REG);
        spin_unlock_irqrestore(&devpriv->window_lock, flags);
 }
 
@@ -886,8 +891,8 @@ static inline void ni_ao_win_outl(struct comedi_device *dev, uint32_t data,
        unsigned long flags;
 
        spin_lock_irqsave(&devpriv->window_lock, flags);
-       ni_writew(dev, addr, AO_Window_Address_611x);
-       ni_writel(dev, data, AO_Window_Data_611x);
+       ni_writew(dev, addr, NI611X_AO_WINDOW_ADDR_REG);
+       ni_writel(dev, data, NI611X_AO_WINDOW_DATA_REG);
        spin_unlock_irqrestore(&devpriv->window_lock, flags);
 }
 
@@ -898,8 +903,8 @@ static inline unsigned short ni_ao_win_inw(struct comedi_device *dev, int addr)
        unsigned short data;
 
        spin_lock_irqsave(&devpriv->window_lock, flags);
-       ni_writew(dev, addr, AO_Window_Address_611x);
-       data = ni_readw(dev, AO_Window_Data_611x);
+       ni_writew(dev, addr, NI611X_AO_WINDOW_ADDR_REG);
+       data = ni_readw(dev, NI611X_AO_WINDOW_DATA_REG);
        spin_unlock_irqrestore(&devpriv->window_lock, flags);
        return data;
 }
@@ -950,8 +955,8 @@ static int ni_ai_drain_dma(struct comedi_device *dev)
        spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
        if (devpriv->ai_mite_chan) {
                for (i = 0; i < timeout; i++) {
-                       if ((ni_stc_readw(dev, AI_Status_1_Register) &
-                            AI_FIFO_Empty_St)
+                       if ((ni_stc_readw(dev, NISTC_AI_STATUS1_REG) &
+                            NISTC_AI_STATUS1_FIFO_E)
                            && mite_bytes_in_transit(devpriv->ai_mite_chan) ==
                            0)
                                break;
@@ -962,7 +967,7 @@ static int ni_ai_drain_dma(struct comedi_device *dev)
                        dev_err(dev->class_dev,
                                "mite_bytes_in_transit=%i, AI_Status1_Register=0x%x\n",
                                mite_bytes_in_transit(devpriv->ai_mite_chan),
-                               ni_stc_readw(dev, AI_Status_1_Register));
+                               ni_stc_readw(dev, NISTC_AI_STATUS1_REG));
                        retval = -1;
                }
        }
@@ -994,8 +999,8 @@ static int ni_ao_wait_for_dma_load(struct comedi_device *dev)
        for (i = 0; i < timeout; i++) {
                unsigned short b_status;
 
-               b_status = ni_stc_readw(dev, AO_Status_1_Register);
-               if (b_status & AO_FIFO_Half_Full_St)
+               b_status = ni_stc_readw(dev, NISTC_AO_STATUS1_REG);
+               if (b_status & NISTC_AO_STATUS1_FIFO_HF)
                        break;
                /* if we poll too often, the pci bus activity seems
                   to slow the dma transfer down */
@@ -1030,9 +1035,9 @@ static void ni_ao_fifo_load(struct comedi_device *dev,
                                i++;
                                packed_data |= (d << 16) & 0xffff0000;
                        }
-                       ni_writel(dev, packed_data, DAC_FIFO_Data_611x);
+                       ni_writel(dev, packed_data, NI611X_AO_FIFO_DATA_REG);
                } else {
-                       ni_writew(dev, d, DAC_FIFO_Data);
+                       ni_writew(dev, d, NI_E_AO_FIFO_DATA_REG);
                }
        }
 }
@@ -1084,9 +1089,9 @@ static int ni_ao_prep_fifo(struct comedi_device *dev,
        unsigned int nsamples;
 
        /* reset fifo */
-       ni_stc_writew(dev, 1, DAC_FIFO_Clear);
+       ni_stc_writew(dev, 1, NISTC_DAC_FIFO_CLR_REG);
        if (devpriv->is_6xxx)
-               ni_ao_win_outl(dev, 0x6, AO_FIFO_Offset_Load_611x);
+               ni_ao_win_outl(dev, 0x6, NI611X_AO_FIFO_OFFSET_LOAD_REG);
 
        /* load some data */
        nbytes = comedi_buf_read_n_available(s);
@@ -1113,7 +1118,7 @@ static void ni_ai_fifo_read(struct comedi_device *dev,
 
        if (devpriv->is_611x) {
                for (i = 0; i < n / 2; i++) {
-                       dl = ni_readl(dev, ADC_FIFO_Data_611x);
+                       dl = ni_readl(dev, NI611X_AI_FIFO_DATA_REG);
                        /* This may get the hi/lo data in the wrong order */
                        data = (dl >> 16) & 0xffff;
                        comedi_buf_write_samples(s, &data, 1);
@@ -1122,14 +1127,14 @@ static void ni_ai_fifo_read(struct comedi_device *dev,
                }
                /* Check if there's a single sample stuck in the FIFO */
                if (n % 2) {
-                       dl = ni_readl(dev, ADC_FIFO_Data_611x);
+                       dl = ni_readl(dev, NI611X_AI_FIFO_DATA_REG);
                        data = dl & 0xffff;
                        comedi_buf_write_samples(s, &data, 1);
                }
        } else if (devpriv->is_6143) {
                /*  This just reads the FIFO assuming the data is present, no checks on the FIFO status are performed */
                for (i = 0; i < n / 2; i++) {
-                       dl = ni_readl(dev, AIFIFO_Data_6143);
+                       dl = ni_readl(dev, NI6143_AI_FIFO_DATA_REG);
 
                        data = (dl >> 16) & 0xffff;
                        comedi_buf_write_samples(s, &data, 1);
@@ -1139,8 +1144,8 @@ static void ni_ai_fifo_read(struct comedi_device *dev,
                if (n % 2) {
                        /* Assume there is a single sample stuck in the FIFO */
                        /* Get stranded sample into FIFO */
-                       ni_writel(dev, 0x01, AIFIFO_Control_6143);
-                       dl = ni_readl(dev, AIFIFO_Data_6143);
+                       ni_writel(dev, 0x01, NI6143_AI_FIFO_CTRL_REG);
+                       dl = ni_readl(dev, NI6143_AI_FIFO_DATA_REG);
                        data = (dl >> 16) & 0xffff;
                        comedi_buf_write_samples(s, &data, 1);
                }
@@ -1154,7 +1159,7 @@ static void ni_ai_fifo_read(struct comedi_device *dev,
                }
                for (i = 0; i < n; i++) {
                        devpriv->ai_fifo_buffer[i] =
-                           ni_readw(dev, ADC_FIFO_Data_Register);
+                           ni_readw(dev, NI_E_AI_FIFO_DATA_REG);
                }
                comedi_buf_write_samples(s, devpriv->ai_fifo_buffer, n);
        }
@@ -1185,9 +1190,9 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev)
        int i;
 
        if (devpriv->is_611x) {
-               while ((ni_stc_readw(dev, AI_Status_1_Register) &
-                       AI_FIFO_Empty_St) == 0) {
-                       dl = ni_readl(dev, ADC_FIFO_Data_611x);
+               while ((ni_stc_readw(dev, NISTC_AI_STATUS1_REG) &
+                       NISTC_AI_STATUS1_FIFO_E) == 0) {
+                       dl = ni_readl(dev, NI611X_AI_FIFO_DATA_REG);
 
                        /* This may get the hi/lo data in the wrong order */
                        data = dl >> 16;
@@ -1197,8 +1202,8 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev)
                }
        } else if (devpriv->is_6143) {
                i = 0;
-               while (ni_readl(dev, AIFIFO_Status_6143) & 0x04) {
-                       dl = ni_readl(dev, AIFIFO_Data_6143);
+               while (ni_readl(dev, NI6143_AI_FIFO_STATUS_REG) & 0x04) {
+                       dl = ni_readl(dev, NI6143_AI_FIFO_DATA_REG);
 
                        /* This may get the hi/lo data in the wrong order */
                        data = dl >> 16;
@@ -1208,29 +1213,29 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev)
                        i += 2;
                }
                /*  Check if stranded sample is present */
-               if (ni_readl(dev, AIFIFO_Status_6143) & 0x01) {
+               if (ni_readl(dev, NI6143_AI_FIFO_STATUS_REG) & 0x01) {
                        /* Get stranded sample into FIFO */
-                       ni_writel(dev, 0x01, AIFIFO_Control_6143);
-                       dl = ni_readl(dev, AIFIFO_Data_6143);
+                       ni_writel(dev, 0x01, NI6143_AI_FIFO_CTRL_REG);
+                       dl = ni_readl(dev, NI6143_AI_FIFO_DATA_REG);
                        data = (dl >> 16) & 0xffff;
                        comedi_buf_write_samples(s, &data, 1);
                }
 
        } else {
-               fifo_empty = ni_stc_readw(dev, AI_Status_1_Register) &
-                            AI_FIFO_Empty_St;
+               fifo_empty = ni_stc_readw(dev, NISTC_AI_STATUS1_REG) &
+                            NISTC_AI_STATUS1_FIFO_E;
                while (fifo_empty == 0) {
                        for (i = 0;
                             i <
                             sizeof(devpriv->ai_fifo_buffer) /
                             sizeof(devpriv->ai_fifo_buffer[0]); i++) {
                                fifo_empty = ni_stc_readw(dev,
-                                                         AI_Status_1_Register) &
-                                               AI_FIFO_Empty_St;
+                                                         NISTC_AI_STATUS1_REG) &
+                                               NISTC_AI_STATUS1_FIFO_E;
                                if (fifo_empty)
                                        break;
                                devpriv->ai_fifo_buffer[i] =
-                                   ni_readw(dev, ADC_FIFO_Data_Register);
+                                   ni_readw(dev, NI_E_AI_FIFO_DATA_REG);
                        }
                        comedi_buf_write_samples(s, devpriv->ai_fifo_buffer, i);
                }
@@ -1248,8 +1253,8 @@ static void get_last_sample_611x(struct comedi_device *dev)
                return;
 
        /* Check if there's a single sample stuck in the FIFO */
-       if (ni_readb(dev, XXX_Status) & 0x80) {
-               dl = ni_readl(dev, ADC_FIFO_Data_611x);
+       if (ni_readb(dev, NI_E_STATUS_REG) & 0x80) {
+               dl = ni_readl(dev, NI611X_AI_FIFO_DATA_REG);
                data = dl & 0xffff;
                comedi_buf_write_samples(s, &data, 1);
        }
@@ -1266,10 +1271,10 @@ static void get_last_sample_6143(struct comedi_device *dev)
                return;
 
        /* Check if there's a single sample stuck in the FIFO */
-       if (ni_readl(dev, AIFIFO_Status_6143) & 0x01) {
+       if (ni_readl(dev, NI6143_AI_FIFO_STATUS_REG) & 0x01) {
                /* Get stranded sample into FIFO */
-               ni_writel(dev, 0x01, AIFIFO_Control_6143);
-               dl = ni_readl(dev, AIFIFO_Data_6143);
+               ni_writel(dev, 0x01, NI6143_AI_FIFO_CTRL_REG);
+               dl = ni_readl(dev, NI6143_AI_FIFO_DATA_REG);
 
                /* This may get the hi/lo data in the wrong order */
                data = (dl >> 16) & 0xffff;
@@ -1335,13 +1340,13 @@ static void ack_a_interrupt(struct comedi_device *dev, unsigned short a_status)
 {
        unsigned short ack = 0;
 
-       if (a_status & AI_SC_TC_St)
+       if (a_status & NISTC_AI_STATUS1_SC_TC)
                ack |= NISTC_INTA_ACK_AI_SC_TC;
-       if (a_status & AI_START1_St)
+       if (a_status & NISTC_AI_STATUS1_START1)
                ack |= NISTC_INTA_ACK_AI_START1;
-       if (a_status & AI_START_St)
+       if (a_status & NISTC_AI_STATUS1_START)
                ack |= NISTC_INTA_ACK_AI_START;
-       if (a_status & AI_STOP_St)
+       if (a_status & NISTC_AI_STATUS1_STOP)
                ack |= NISTC_INTA_ACK_AI_STOP;
        if (ack)
                ni_stc_writew(dev, ack, NISTC_INTA_ACK_REG);
@@ -1373,8 +1378,8 @@ static void handle_a_interrupt(struct comedi_device *dev, unsigned short status,
 #endif
 
        /* test for all uncommon interrupt events at the same time */
-       if (status & (AI_Overrun_St | AI_Overflow_St | AI_SC_TC_Error_St |
-                     AI_SC_TC_St | AI_START1_St)) {
+       if (status & (NISTC_AI_STATUS1_ERR |
+                     NISTC_AI_STATUS1_SC_TC | NISTC_AI_STATUS1_START1)) {
                if (status == 0xffff) {
                        dev_err(dev->class_dev, "Card removed?\n");
                        /* we probably aren't even running a command now,
@@ -1385,41 +1390,40 @@ static void handle_a_interrupt(struct comedi_device *dev, unsigned short status,
                        }
                        return;
                }
-               if (status & (AI_Overrun_St | AI_Overflow_St |
-                             AI_SC_TC_Error_St)) {
+               if (status & NISTC_AI_STATUS1_ERR) {
                        dev_err(dev->class_dev, "ai error a_status=%04x\n",
                                status);
 
                        shutdown_ai_command(dev);
 
                        s->async->events |= COMEDI_CB_ERROR;
-                       if (status & (AI_Overrun_St | AI_Overflow_St))
+                       if (status & NISTC_AI_STATUS1_OVER)
                                s->async->events |= COMEDI_CB_OVERFLOW;
 
                        comedi_handle_events(dev, s);
                        return;
                }
-               if (status & AI_SC_TC_St) {
+               if (status & NISTC_AI_STATUS1_SC_TC) {
                        if (cmd->stop_src == TRIG_COUNT)
                                shutdown_ai_command(dev);
                }
        }
 #ifndef PCIDMA
-       if (status & AI_FIFO_Half_Full_St) {
+       if (status & NISTC_AI_STATUS1_FIFO_HF) {
                int i;
                static const int timeout = 10;
                /* pcmcia cards (at least 6036) seem to stop producing interrupts if we
                 *fail to get the fifo less than half full, so loop to be sure.*/
                for (i = 0; i < timeout; ++i) {
                        ni_handle_fifo_half_full(dev);
-                       if ((ni_stc_readw(dev, AI_Status_1_Register) &
-                            AI_FIFO_Half_Full_St) == 0)
+                       if ((ni_stc_readw(dev, NISTC_AI_STATUS1_REG) &
+                            NISTC_AI_STATUS1_FIFO_HF) == 0)
                                break;
                }
        }
 #endif /*  !PCIDMA */
 
-       if ((status & AI_STOP_St))
+       if (status & NISTC_AI_STATUS1_STOP)
                ni_handle_eos(dev, s);
 
        comedi_handle_events(dev, s);
@@ -1429,19 +1433,19 @@ static void ack_b_interrupt(struct comedi_device *dev, unsigned short b_status)
 {
        unsigned short ack = 0;
 
-       if (b_status & AO_BC_TC_St)
+       if (b_status & NISTC_AO_STATUS1_BC_TC)
                ack |= NISTC_INTB_ACK_AO_BC_TC;
-       if (b_status & AO_Overrun_St)
+       if (b_status & NISTC_AO_STATUS1_OVERRUN)
                ack |= NISTC_INTB_ACK_AO_ERR;
-       if (b_status & AO_START_St)
+       if (b_status & NISTC_AO_STATUS1_START)
                ack |= NISTC_INTB_ACK_AO_START;
-       if (b_status & AO_START1_St)
+       if (b_status & NISTC_AO_STATUS1_START1)
                ack |= NISTC_INTB_ACK_AO_START1;
-       if (b_status & AO_UC_TC_St)
+       if (b_status & NISTC_AO_STATUS1_UC_TC)
                ack |= NISTC_INTB_ACK_AO_UC_TC;
-       if (b_status & AO_UI2_TC_St)
+       if (b_status & NISTC_AO_STATUS1_UI2_TC)
                ack |= NISTC_INTB_ACK_AO_UI2_TC;
-       if (b_status & AO_UPDATE_St)
+       if (b_status & NISTC_AO_STATUS1_UPDATE)
                ack |= NISTC_INTB_ACK_AO_UPDATE;
        if (ack)
                ni_stc_writew(dev, ack, NISTC_INTB_ACK_REG);
@@ -1473,26 +1477,26 @@ static void handle_b_interrupt(struct comedi_device *dev,
 
        if (b_status == 0xffff)
                return;
-       if (b_status & AO_Overrun_St) {
+       if (b_status & NISTC_AO_STATUS1_OVERRUN) {
                dev_err(dev->class_dev,
                        "AO FIFO underrun status=0x%04x status2=0x%04x\n",
-                       b_status, ni_stc_readw(dev, AO_Status_2_Register));
+                       b_status, ni_stc_readw(dev, NISTC_AO_STATUS2_REG));
                s->async->events |= COMEDI_CB_OVERFLOW;
        }
 
-       if (b_status & AO_BC_TC_St)
+       if (b_status & NISTC_AO_STATUS1_BC_TC)
                s->async->events |= COMEDI_CB_EOA;
 
 #ifndef PCIDMA
-       if (b_status & AO_FIFO_Request_St) {
+       if (b_status & NISTC_AO_STATUS1_FIFO_REQ) {
                int ret;
 
                ret = ni_ao_fifo_half_empty(dev, s);
                if (!ret) {
                        dev_err(dev->class_dev, "AO buffer underrun\n");
-                       ni_set_bits(dev, Interrupt_B_Enable_Register,
-                                   AO_FIFO_Interrupt_Enable |
-                                   AO_Error_Interrupt_Enable, 0);
+                       ni_set_bits(dev, NISTC_INTB_ENA_REG,
+                                   NISTC_INTB_ENA_AO_FIFO |
+                                   NISTC_INTB_ENA_AO_ERR, 0);
                        s->async->events |= COMEDI_CB_OVERFLOW;
                }
        }
@@ -1608,6 +1612,7 @@ static int ni_ao_setup_MITE_dma(struct comedi_device *dev)
 static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s)
 {
        struct ni_private *devpriv = dev->private;
+       unsigned ai_personal;
        unsigned ai_out_ctrl;
 
        ni_release_ai_mite_channel(dev);
@@ -1620,7 +1625,7 @@ static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s)
        ni_clear_ai_fifo(dev);
 
        if (!devpriv->is_6143)
-               ni_writeb(dev, 0, Misc_Command);
+               ni_writeb(dev, NI_E_MISC_CMD_EXT_ATRIG, NI_E_MISC_CMD_REG);
 
        ni_stc_writew(dev, NISTC_AI_CMD1_DISARM, NISTC_AI_CMD1_REG);
        ni_stc_writew(dev, NISTC_AI_MODE1_START_STOP |
@@ -1629,45 +1634,36 @@ static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s)
                      NISTC_AI_MODE1_REG);
        ni_stc_writew(dev, 0, NISTC_AI_MODE2_REG);
        /* generate FIFO interrupts on non-empty */
-       ni_stc_writew(dev, (0 << 6) | 0x0000, AI_Mode_3_Register);
+       ni_stc_writew(dev, NISTC_AI_MODE3_FIFO_MODE_NE,
+                     NISTC_AI_MODE3_REG);
 
+       ai_personal = NISTC_AI_PERSONAL_SHIFTIN_PW |
+                     NISTC_AI_PERSONAL_SOC_POLARITY |
+                     NISTC_AI_PERSONAL_LOCALMUX_CLK_PW;
        ai_out_ctrl = NISTC_AI_OUT_CTRL_SCAN_IN_PROG_SEL(3) |
                      NISTC_AI_OUT_CTRL_EXTMUX_CLK_SEL(0) |
                      NISTC_AI_OUT_CTRL_LOCALMUX_CLK_SEL(2) |
                      NISTC_AI_OUT_CTRL_SC_TC_SEL(3);
        if (devpriv->is_611x) {
-               ni_stc_writew(dev,
-                             AI_SHIFTIN_Pulse_Width |
-                             AI_SOC_Polarity |
-                             AI_LOCALMUX_CLK_Pulse_Width,
-                             AI_Personal_Register);
                ai_out_ctrl |= NISTC_AI_OUT_CTRL_CONVERT_HIGH;
        } else if (devpriv->is_6143) {
-               ni_stc_writew(dev, AI_SHIFTIN_Pulse_Width |
-                                  AI_SOC_Polarity |
-                                  AI_LOCALMUX_CLK_Pulse_Width,
-                             AI_Personal_Register);
                ai_out_ctrl |= NISTC_AI_OUT_CTRL_CONVERT_LOW;
        } else {
-               ni_stc_writew(dev,
-                             AI_SHIFTIN_Pulse_Width |
-                             AI_SOC_Polarity |
-                             AI_CONVERT_Pulse_Width |
-                             AI_LOCALMUX_CLK_Pulse_Width,
-                             AI_Personal_Register);
+               ai_personal |= NISTC_AI_PERSONAL_CONVERT_PW;
                if (devpriv->is_622x)
                        ai_out_ctrl |= NISTC_AI_OUT_CTRL_CONVERT_HIGH;
                else
                        ai_out_ctrl |= NISTC_AI_OUT_CTRL_CONVERT_LOW;
        }
+       ni_stc_writew(dev, ai_personal, NISTC_AI_PERSONAL_REG);
        ni_stc_writew(dev, ai_out_ctrl, NISTC_AI_OUT_CTRL_REG);
 
        /* the following registers should not be changed, because there
         * are no backup registers in devpriv.  If you want to change
         * any of these, add a backup register and other appropriate code:
         *      NISTC_AI_MODE1_REG
-        *      AI_Mode_3_Register
-        *      AI_Personal_Register
+        *      NISTC_AI_MODE3_REG
+        *      NISTC_AI_PERSONAL_REG
         *      NISTC_AI_OUT_CTRL_REG
         */
 
@@ -1703,9 +1699,9 @@ static void ni_prime_channelgain_list(struct comedi_device *dev)
 
        ni_stc_writew(dev, NISTC_AI_CMD1_CONVERT_PULSE, NISTC_AI_CMD1_REG);
        for (i = 0; i < NI_TIMEOUT; ++i) {
-               if (!(ni_stc_readw(dev, AI_Status_1_Register) &
-                     AI_FIFO_Empty_St)) {
-                       ni_stc_writew(dev, 1, ADC_FIFO_Clear);
+               if (!(ni_stc_readw(dev, NISTC_AI_STATUS1_REG) &
+                     NISTC_AI_STATUS1_FIFO_E)) {
+                       ni_stc_writew(dev, 1, NISTC_ADC_FIFO_CLR_REG);
                        return;
                }
                udelay(1);
@@ -1724,7 +1720,7 @@ static void ni_m_series_load_channelgain_list(struct comedi_device *dev,
        unsigned int dither;
        unsigned range_code;
 
-       ni_stc_writew(dev, 1, Configuration_Memory_Clear);
+       ni_stc_writew(dev, 1, NISTC_CFG_MEM_CLR_REG);
 
        if ((list[0] & CR_ALT_SOURCE)) {
                unsigned bypass_bits;
@@ -1839,7 +1835,7 @@ static void ni_load_channelgain_list(struct comedi_device *dev,
                devpriv->changain_state = 0;
        }
 
-       ni_stc_writew(dev, 1, Configuration_Memory_Clear);
+       ni_stc_writew(dev, 1, NISTC_CFG_MEM_CLR_REG);
 
        /*  Set up Calibration mode if required */
        if (devpriv->is_6143) {
@@ -1847,20 +1843,20 @@ static void ni_load_channelgain_list(struct comedi_device *dev,
                    && !devpriv->ai_calib_source_enabled) {
                        /*  Strobe Relay enable bit */
                        ni_writew(dev, devpriv->ai_calib_source |
-                                      Calibration_Channel_6143_RelayOn,
-                                 Calibration_Channel_6143);
+                                      NI6143_CALIB_CHAN_RELAY_ON,
+                                 NI6143_CALIB_CHAN_REG);
                        ni_writew(dev, devpriv->ai_calib_source,
-                                 Calibration_Channel_6143);
+                                 NI6143_CALIB_CHAN_REG);
                        devpriv->ai_calib_source_enabled = 1;
                        msleep_interruptible(100);      /*  Allow relays to change */
                } else if (!(list[0] & CR_ALT_SOURCE)
                           && devpriv->ai_calib_source_enabled) {
                        /*  Strobe Relay disable bit */
                        ni_writew(dev, devpriv->ai_calib_source |
-                                      Calibration_Channel_6143_RelayOff,
-                                 Calibration_Channel_6143);
+                                      NI6143_CALIB_CHAN_RELAY_OFF,
+                                 NI6143_CALIB_CHAN_REG);
                        ni_writew(dev, devpriv->ai_calib_source,
-                                 Calibration_Channel_6143);
+                                 NI6143_CALIB_CHAN_REG);
                        devpriv->ai_calib_source_enabled = 0;
                        msleep_interruptible(100);      /*  Allow relays to change */
                }
@@ -1886,7 +1882,7 @@ static void ni_load_channelgain_list(struct comedi_device *dev,
                if ((list[i] & CR_ALT_SOURCE)) {
                        if (devpriv->is_611x)
                                ni_writew(dev, CR_CHAN(list[i]) & 0x0003,
-                                         Calibration_Channel_Select_611x);
+                                         NI611X_CALIB_CHAN_SEL_REG);
                } else {
                        if (devpriv->is_611x)
                                aref = AREF_DIFF;
@@ -1894,30 +1890,31 @@ static void ni_load_channelgain_list(struct comedi_device *dev,
                                aref = AREF_OTHER;
                        switch (aref) {
                        case AREF_DIFF:
-                               hi |= AI_DIFFERENTIAL;
+                               hi |= NI_E_AI_CFG_HI_TYPE_DIFF;
                                break;
                        case AREF_COMMON:
-                               hi |= AI_COMMON;
+                               hi |= NI_E_AI_CFG_HI_TYPE_COMMON;
                                break;
                        case AREF_GROUND:
-                               hi |= AI_GROUND;
+                               hi |= NI_E_AI_CFG_HI_TYPE_GROUND;
                                break;
                        case AREF_OTHER:
                                break;
                        }
                }
-               hi |= AI_CONFIG_CHANNEL(chan);
+               hi |= NI_E_AI_CFG_HI_CHAN(chan);
 
-               ni_writew(dev, hi, Configuration_Memory_High);
+               ni_writew(dev, hi, NI_E_AI_CFG_HI_REG);
 
                if (!devpriv->is_6143) {
-                       lo = range;
+                       lo = NI_E_AI_CFG_LO_GAIN(range);
+
                        if (i == n_chan - 1)
-                               lo |= AI_LAST_CHANNEL;
+                               lo |= NI_E_AI_CFG_LO_LAST_CHAN;
                        if (dither)
-                               lo |= AI_DITHER;
+                               lo |= NI_E_AI_CFG_LO_DITHER;
 
-                       ni_writew(dev, lo, Configuration_Memory_Low);
+                       ni_writew(dev, lo, NI_E_AI_CFG_LO_REG);
                }
        }
 
@@ -1955,15 +1952,17 @@ static int ni_ai_insn_read(struct comedi_device *dev,
                        /* The 611x has screwy 32-bit FIFOs. */
                        d = 0;
                        for (i = 0; i < NI_TIMEOUT; i++) {
-                               if (ni_readb(dev, XXX_Status) & 0x80) {
-                                       d = ni_readl(dev, ADC_FIFO_Data_611x);
+                               if (ni_readb(dev, NI_E_STATUS_REG) & 0x80) {
+                                       d = ni_readl(dev,
+                                                    NI611X_AI_FIFO_DATA_REG);
                                        d >>= 16;
                                        d &= 0xffff;
                                        break;
                                }
-                               if (!(ni_stc_readw(dev, AI_Status_1_Register) &
-                                     AI_FIFO_Empty_St)) {
-                                       d = ni_readl(dev, ADC_FIFO_Data_611x);
+                               if (!(ni_stc_readw(dev, NISTC_AI_STATUS1_REG) &
+                                     NISTC_AI_STATUS1_FIFO_E)) {
+                                       d = ni_readl(dev,
+                                                    NI611X_AI_FIFO_DATA_REG);
                                        d &= 0xffff;
                                        break;
                                }
@@ -1983,11 +1982,13 @@ static int ni_ai_insn_read(struct comedi_device *dev,
                        /* The 6143 has 32-bit FIFOs. You need to strobe a bit to move a single 16bit stranded sample into the FIFO */
                        dl = 0;
                        for (i = 0; i < NI_TIMEOUT; i++) {
-                               if (ni_readl(dev, AIFIFO_Status_6143) & 0x01) {
+                               if (ni_readl(dev, NI6143_AI_FIFO_STATUS_REG) &
+                                   0x01) {
                                        /* Get stranded sample into FIFO */
                                        ni_writel(dev, 0x01,
-                                                 AIFIFO_Control_6143);
-                                       dl = ni_readl(dev, AIFIFO_Data_6143);
+                                                 NI6143_AI_FIFO_CTRL_REG);
+                                       dl = ni_readl(dev,
+                                                     NI6143_AI_FIFO_DATA_REG);
                                        break;
                                }
                        }
@@ -2002,8 +2003,8 @@ static int ni_ai_insn_read(struct comedi_device *dev,
                        ni_stc_writew(dev, NISTC_AI_CMD1_CONVERT_PULSE,
                                      NISTC_AI_CMD1_REG);
                        for (i = 0; i < NI_TIMEOUT; i++) {
-                               if (!(ni_stc_readw(dev, AI_Status_1_Register) &
-                                     AI_FIFO_Empty_St))
+                               if (!(ni_stc_readw(dev, NISTC_AI_STATUS1_REG) &
+                                     NISTC_AI_STATUS1_FIFO_E))
                                        break;
                        }
                        if (i == NI_TIMEOUT) {
@@ -2015,7 +2016,7 @@ static int ni_ai_insn_read(struct comedi_device *dev,
                                dl &= mask;
                                data[n] = dl;
                        } else {
-                               d = ni_readw(dev, ADC_FIFO_Data_Register);
+                               d = ni_readw(dev, NI_E_AI_FIFO_DATA_REG);
                                d += signbits;  /* subtle: needs to be short addition */
                                data[n] = d;
                        }
@@ -2267,8 +2268,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        case TRIG_INT:
        case TRIG_NOW:
                ai_trig |= NISTC_AI_TRIG_START1_EDGE |
-                          NISTC_AI_TRIG_START1_SEL(0),
-                          NISTC_AI_TRIG_SEL_REG;
+                          NISTC_AI_TRIG_START1_SEL(0);
                break;
        case TRIG_EXT:
                ai_trig |= NISTC_AI_TRIG_START1_SEL(CR_CHAN(cmd->start_arg) +
@@ -2344,7 +2344,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        case TRIG_TIMER:
                /*
                 * stop bits for non 611x boards
-                * AI_SI_Special_Trigger_Delay=0
+                * NISTC_AI_MODE3_SI_TRIG_DELAY=0
                 * NISTC_AI_MODE2_PRE_TRIGGER=0
                 * NISTC_AI_START_STOP_REG:
                 * NISTC_AI_START_POLARITY=0    (?) rising edge
@@ -2441,25 +2441,25 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
                case AIMODE_HALF_FULL:
                        /*generate FIFO interrupts and DMA requests on half-full */
 #ifdef PCIDMA
-                       ni_stc_writew(dev, AI_FIFO_Mode_HF_to_E,
-                                     AI_Mode_3_Register);
+                       ni_stc_writew(dev, NISTC_AI_MODE3_FIFO_MODE_HF_E,
+                                     NISTC_AI_MODE3_REG);
 #else
-                       ni_stc_writew(dev, AI_FIFO_Mode_HF,
-                                     AI_Mode_3_Register);
+                       ni_stc_writew(dev, NISTC_AI_MODE3_FIFO_MODE_HF,
+                                     NISTC_AI_MODE3_REG);
 #endif
                        break;
                case AIMODE_SAMPLE:
                        /*generate FIFO interrupts on non-empty */
-                       ni_stc_writew(dev, AI_FIFO_Mode_NE,
-                                     AI_Mode_3_Register);
+                       ni_stc_writew(dev, NISTC_AI_MODE3_FIFO_MODE_NE,
+                                     NISTC_AI_MODE3_REG);
                        break;
                case AIMODE_SCAN:
 #ifdef PCIDMA
-                       ni_stc_writew(dev, AI_FIFO_Mode_NE,
-                                     AI_Mode_3_Register);
+                       ni_stc_writew(dev, NISTC_AI_MODE3_FIFO_MODE_NE,
+                                     NISTC_AI_MODE3_REG);
 #else
-                       ni_stc_writew(dev, AI_FIFO_Mode_HF,
-                                     AI_Mode_3_Register);
+                       ni_stc_writew(dev, NISTC_AI_MODE3_FIFO_MODE_HF,
+                                     NISTC_AI_MODE3_REG);
 #endif
                        interrupt_a_enable |= NISTC_INTA_ENA_AI_STOP;
                        break;
@@ -2542,7 +2542,7 @@ static int ni_ai_insn_config(struct comedi_device *dev,
                        calib_source = data[1] & 0xf;
 
                        devpriv->ai_calib_source = calib_source;
-                       ni_writew(dev, calib_source, Calibration_Channel_6143);
+                       ni_writew(dev, calib_source, NI6143_CALIB_CHAN_REG);
                } else {
                        unsigned int calib_source;
                        unsigned int calib_source_adjust;
@@ -2555,7 +2555,7 @@ static int ni_ai_insn_config(struct comedi_device *dev,
                        devpriv->ai_calib_source = calib_source;
                        if (devpriv->is_611x) {
                                ni_writeb(dev, calib_source_adjust,
-                                         Cal_Gain_Select_611x);
+                                         NI611X_CAL_GAIN_SEL_REG);
                        }
                }
                return 2;
@@ -2683,27 +2683,27 @@ static int ni_old_ao_config_chanlist(struct comedi_device *dev,
        for (i = 0; i < n_chans; i++) {
                chan = CR_CHAN(chanspec[i]);
                range = CR_RANGE(chanspec[i]);
-               conf = AO_Channel(chan);
+               conf = NI_E_AO_DACSEL(chan);
 
                if (comedi_range_is_bipolar(s, range)) {
-                       conf |= AO_Bipolar;
+                       conf |= NI_E_AO_CFG_BIP;
                        invert = (s->maxdata + 1) >> 1;
                } else {
                        invert = 0;
                }
                if (comedi_range_is_external(s, range))
-                       conf |= AO_Ext_Ref;
+                       conf |= NI_E_AO_EXT_REF;
 
                /* not all boards can deglitch, but this shouldn't hurt */
                if (chanspec[i] & CR_DEGLITCH)
-                       conf |= AO_Deglitch;
+                       conf |= NI_E_AO_DEGLITCH;
 
                /* analog reference */
                /* AREF_OTHER connects AO ground to AI ground, i think */
-               conf |= (CR_AREF(chanspec[i]) ==
-                        AREF_OTHER) ? AO_Ground_Ref : 0;
+               if (CR_AREF(chanspec[i]) == AREF_OTHER)
+                       conf |= NI_E_AO_GROUND_REF;
 
-               ni_writew(dev, conf, AO_Configuration);
+               ni_writew(dev, conf, NI_E_AO_CFG_REG);
                devpriv->ao_conf[chan] = conf;
        }
        return invert;
@@ -2735,13 +2735,13 @@ static int ni_ao_insn_write(struct comedi_device *dev,
        int i;
 
        if (devpriv->is_6xxx) {
-               ni_ao_win_outw(dev, 1 << chan, AO_Immediate_671x);
+               ni_ao_win_outw(dev, 1 << chan, NI671X_AO_IMMEDIATE_REG);
 
-               reg = DACx_Direct_Data_671x(chan);
+               reg = NI671X_DAC_DIRECT_DATA_REG(chan);
        } else if (devpriv->is_m_series) {
                reg = NI_M_DAC_DIRECT_DATA_REG(chan);
        } else {
-               reg = (chan) ? DAC1_Direct_Data : DAC0_Direct_Data;
+               reg = NI_E_DAC_DIRECT_DATA_REG(chan);
        }
 
        ni_ao_config_chanlist(dev, s, &insn->chanspec, 1, 0);
@@ -2831,13 +2831,13 @@ static int ni_ao_inttrig(struct comedi_device *dev,
           multiple times) */
        s->async->inttrig = NULL;
 
-       ni_set_bits(dev, Interrupt_B_Enable_Register,
-                   AO_FIFO_Interrupt_Enable | AO_Error_Interrupt_Enable, 0);
-       interrupt_b_bits = AO_Error_Interrupt_Enable;
+       ni_set_bits(dev, NISTC_INTB_ENA_REG,
+                   NISTC_INTB_ENA_AO_FIFO | NISTC_INTB_ENA_AO_ERR, 0);
+       interrupt_b_bits = NISTC_INTB_ENA_AO_ERR;
 #ifdef PCIDMA
-       ni_stc_writew(dev, 1, DAC_FIFO_Clear);
+       ni_stc_writew(dev, 1, NISTC_DAC_FIFO_CLR_REG);
        if (devpriv->is_6xxx)
-               ni_ao_win_outl(dev, 0x6, AO_FIFO_Offset_Load_611x);
+               ni_ao_win_outl(dev, 0x6, NI611X_AO_FIFO_OFFSET_LOAD_REG);
        ret = ni_ao_setup_MITE_dma(dev);
        if (ret)
                return ret;
@@ -2849,7 +2849,7 @@ static int ni_ao_inttrig(struct comedi_device *dev,
        if (ret == 0)
                return -EPIPE;
 
-       interrupt_b_bits |= AO_FIFO_Interrupt_Enable;
+       interrupt_b_bits |= NISTC_INTB_ENA_AO_FIFO;
 #endif
 
        ni_stc_writew(dev, devpriv->ao_mode3 | NISTC_AO_MODE3_NOT_AN_UPDATE,
@@ -2858,8 +2858,8 @@ static int ni_ao_inttrig(struct comedi_device *dev,
        /* wait for DACs to be loaded */
        for (i = 0; i < timeout; i++) {
                udelay(1);
-               if ((ni_stc_readw(dev, Joint_Status_2_Register) &
-                    AO_TMRDACWRs_In_Progress_St) == 0)
+               if ((ni_stc_readw(dev, NISTC_STATUS2_REG) &
+                    NISTC_STATUS2_AO_TMRDACWRS_IN_PROGRESS) == 0)
                        break;
        }
        if (i == timeout) {
@@ -2873,7 +2873,7 @@ static int ni_ao_inttrig(struct comedi_device *dev,
         */
        ni_stc_writew(dev, NISTC_INTB_ACK_AO_ERR, NISTC_INTB_ACK_REG);
 
-       ni_set_bits(dev, Interrupt_B_Enable_Register, interrupt_b_bits, 1);
+       ni_set_bits(dev, NISTC_INTB_ENA_REG, interrupt_b_bits, 1);
 
        ni_stc_writew(dev, NISTC_AO_CMD1_UI_ARM |
                           NISTC_AO_CMD1_UC_ARM |
@@ -2909,7 +2909,8 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        ni_stc_writew(dev, NISTC_AO_CMD1_DISARM, NISTC_AO_CMD1_REG);
 
        if (devpriv->is_6xxx) {
-               ni_ao_win_outw(dev, CLEAR_WG, AO_Misc_611x);
+               ni_ao_win_outw(dev, NI611X_AO_MISC_CLEAR_WG,
+                              NI611X_AO_MISC_REG);
 
                bits = 0;
                for (i = 0; i < cmd->chanlist_len; i++) {
@@ -2917,9 +2918,9 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 
                        chan = CR_CHAN(cmd->chanlist[i]);
                        bits |= 1 << chan;
-                       ni_ao_win_outw(dev, chan, AO_Waveform_Generation_611x);
+                       ni_ao_win_outw(dev, chan, NI611X_AO_WAVEFORM_GEN_REG);
                }
-               ni_ao_win_outw(dev, bits, AO_Timed_611x);
+               ni_ao_win_outw(dev, bits, NI611X_AO_TIMED_REG);
        }
 
        ni_ao_config_chanlist(dev, s, cmd->chanlist, cmd->chanlist_len, 1);
@@ -3037,21 +3038,21 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        if (cmd->scan_end_arg > 1) {
                devpriv->ao_mode1 |= NISTC_AO_MODE1_MULTI_CHAN;
                ni_stc_writew(dev,
-                             AO_Number_Of_Channels(cmd->scan_end_arg - 1) |
-                             AO_UPDATE_Output_Select(AO_Update_Output_High_Z),
-                             AO_Output_Control_Register);
+                             NISTC_AO_OUT_CTRL_CHANS(cmd->scan_end_arg - 1) |
+                             NISTC_AO_OUT_CTRL_UPDATE_SEL_HIGHZ,
+                             NISTC_AO_OUT_CTRL_REG);
        } else {
                unsigned bits;
 
                devpriv->ao_mode1 &= ~NISTC_AO_MODE1_MULTI_CHAN;
-               bits = AO_UPDATE_Output_Select(AO_Update_Output_High_Z);
+               bits = NISTC_AO_OUT_CTRL_UPDATE_SEL_HIGHZ;
                if (devpriv->is_m_series || devpriv->is_6xxx) {
-                       bits |= AO_Number_Of_Channels(0);
+                       bits |= NISTC_AO_OUT_CTRL_CHANS(0);
                } else {
                        bits |=
-                           AO_Number_Of_Channels(CR_CHAN(cmd->chanlist[0]));
+                           NISTC_AO_OUT_CTRL_CHANS(CR_CHAN(cmd->chanlist[0]));
                }
-               ni_stc_writew(dev, bits, AO_Output_Control_Register);
+               ni_stc_writew(dev, bits, NISTC_AO_OUT_CTRL_REG);
        }
        ni_stc_writew(dev, devpriv->ao_mode1, NISTC_AO_MODE1_REG);
 
@@ -3071,19 +3072,22 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        devpriv->ao_mode2 &= ~NISTC_AO_MODE2_FIFO_REXMIT_ENA;
        ni_stc_writew(dev, devpriv->ao_mode2, NISTC_AO_MODE2_REG);
 
-       bits = AO_BC_Source_Select | AO_UPDATE_Pulse_Width |
-           AO_TMRDACWR_Pulse_Width;
+       bits = NISTC_AO_PERSONAL_BC_SRC_SEL |
+              NISTC_AO_PERSONAL_UPDATE_PW |
+              NISTC_AO_PERSONAL_TMRDACWR_PW;
        if (board->ao_fifo_depth)
-               bits |= AO_FIFO_Enable;
+               bits |= NISTC_AO_PERSONAL_FIFO_ENA;
        else
-               bits |= AO_DMA_PIO_Control;
+               bits |= NISTC_AO_PERSONAL_DMA_PIO_CTRL;
 #if 0
-       /* F Hess: windows driver does not set AO_Number_Of_DAC_Packages bit for 6281,
-          verified with bus analyzer. */
+       /*
+        * F Hess: windows driver does not set NISTC_AO_PERSONAL_NUM_DAC bit
+        * for 6281, verified with bus analyzer.
+        */
        if (devpriv->is_m_series)
-               bits |= AO_Number_Of_DAC_Packages;
+               bits |= NISTC_AO_PERSONAL_NUM_DAC;
 #endif
-       ni_stc_writew(dev, bits, AO_Personal_Register);
+       ni_stc_writew(dev, bits, NISTC_AO_PERSONAL_REG);
        /*  enable sending of ao dma requests */
        ni_stc_writew(dev, NISTC_AO_START_AOFREQ_ENA, NISTC_AO_START_SEL_REG);
 
@@ -3092,8 +3096,8 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        if (cmd->stop_src == TRIG_COUNT) {
                ni_stc_writew(dev, NISTC_INTB_ACK_AO_BC_TC,
                              NISTC_INTB_ACK_REG);
-               ni_set_bits(dev, Interrupt_B_Enable_Register,
-                           AO_BC_TC_Interrupt_Enable, 1);
+               ni_set_bits(dev, NISTC_INTB_ENA_REG,
+                           NISTC_INTB_ENA_AO_BC_TC, 1);
        }
 
        s->async->inttrig = ni_ao_inttrig;
@@ -3192,12 +3196,14 @@ static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s)
 
        ni_stc_writew(dev, NISTC_RESET_AO_CFG_START, NISTC_RESET_REG);
        ni_stc_writew(dev, NISTC_AO_CMD1_DISARM, NISTC_AO_CMD1_REG);
-       ni_set_bits(dev, Interrupt_B_Enable_Register, ~0, 0);
-       ni_stc_writew(dev, AO_BC_Source_Select, AO_Personal_Register);
+       ni_set_bits(dev, NISTC_INTB_ENA_REG, ~0, 0);
+       ni_stc_writew(dev, NISTC_AO_PERSONAL_BC_SRC_SEL, NISTC_AO_PERSONAL_REG);
        ni_stc_writew(dev, NISTC_INTB_ACK_AO_ALL, NISTC_INTB_ACK_REG);
-       ni_stc_writew(dev, AO_BC_Source_Select | AO_UPDATE_Pulse_Width |
-                     AO_TMRDACWR_Pulse_Width, AO_Personal_Register);
-       ni_stc_writew(dev, 0, AO_Output_Control_Register);
+       ni_stc_writew(dev, NISTC_AO_PERSONAL_BC_SRC_SEL |
+                          NISTC_AO_PERSONAL_UPDATE_PW |
+                          NISTC_AO_PERSONAL_TMRDACWR_PW,
+                     NISTC_AO_PERSONAL_REG);
+       ni_stc_writew(dev, 0, NISTC_AO_OUT_CTRL_REG);
        ni_stc_writew(dev, 0, NISTC_AO_START_SEL_REG);
        devpriv->ao_cmd1 = 0;
        ni_stc_writew(dev, devpriv->ao_cmd1, NISTC_AO_CMD1_REG);
@@ -3221,8 +3227,9 @@ static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s)
 
                for (i = 0; i < s->n_chan; ++i)
                        immediate_bits |= 1 << i;
-               ni_ao_win_outw(dev, immediate_bits, AO_Immediate_671x);
-               ni_ao_win_outw(dev, CLEAR_WG, AO_Misc_611x);
+               ni_ao_win_outw(dev, immediate_bits, NI671X_AO_IMMEDIATE_REG);
+               ni_ao_win_outw(dev, NI611X_AO_MISC_CLEAR_WG,
+                              NI611X_AO_MISC_REG);
        }
        ni_stc_writew(dev, NISTC_RESET_AO_CFG_END, NISTC_RESET_REG);
 
@@ -3268,7 +3275,7 @@ static int ni_dio_insn_bits(struct comedi_device *dev,
                ni_stc_writew(dev, devpriv->dio_output, NISTC_DIO_OUT_REG);
        }
 
-       data[1] = ni_stc_readw(dev, DIO_Parallel_Input_Register);
+       data[1] = ni_stc_readw(dev, NISTC_DIO_IN_REG);
 
        return insn->n;
 }
@@ -3526,8 +3533,8 @@ static int ni_serial_hw_readwrite8(struct comedi_device *dev,
        devpriv->dio_output |= NISTC_DIO_OUT_SERIAL(data_out);
        ni_stc_writew(dev, devpriv->dio_output, NISTC_DIO_OUT_REG);
 
-       status1 = ni_stc_readw(dev, Joint_Status_1_Register);
-       if (status1 & DIO_Serial_IO_In_Progress_St) {
+       status1 = ni_stc_readw(dev, NISTC_STATUS1_REG);
+       if (status1 & NISTC_STATUS1_SERIO_IN_PROG) {
                err = -EBUSY;
                goto Error;
        }
@@ -3537,8 +3544,8 @@ static int ni_serial_hw_readwrite8(struct comedi_device *dev,
        devpriv->dio_control &= ~NISTC_DIO_CTRL_HW_SER_START;
 
        /* Wait until STC says we're done, but don't loop infinitely. */
-       while ((status1 = ni_stc_readw(dev, Joint_Status_1_Register)) &
-              DIO_Serial_IO_In_Progress_St) {
+       while ((status1 = ni_stc_readw(dev, NISTC_STATUS1_REG)) &
+              NISTC_STATUS1_SERIO_IN_PROG) {
                /* Delay one bit per loop */
                udelay((devpriv->serial_interval_ns + 999) / 1000);
                if (--count < 0) {
@@ -3549,12 +3556,14 @@ static int ni_serial_hw_readwrite8(struct comedi_device *dev,
                }
        }
 
-       /* Delay for last bit. This delay is absolutely necessary, because
-          DIO_Serial_IO_In_Progress_St goes high one bit too early. */
+       /*
+        * Delay for last bit. This delay is absolutely necessary, because
+        * NISTC_STATUS1_SERIO_IN_PROG goes high one bit too early.
+        */
        udelay((devpriv->serial_interval_ns + 999) / 1000);
 
        if (data_in)
-               *data_in = ni_stc_readw(dev, DIO_Serial_Input_Register);
+               *data_in = ni_stc_readw(dev, NISTC_DIO_SERIAL_IN_REG);
 
 Error:
        ni_stc_writew(dev, devpriv->dio_control, NISTC_DIO_CTRL_REG);
@@ -3595,8 +3604,7 @@ static int ni_serial_sw_readwrite8(struct comedi_device *dev,
                udelay((devpriv->serial_interval_ns + 999) / 2000);
 
                /* Input current bit */
-               if (ni_stc_readw(dev, DIO_Parallel_Input_Register) &
-                   NISTC_DIO_SDIN)
+               if (ni_stc_readw(dev, NISTC_DIO_IN_REG) & NISTC_DIO_SDIN)
                        input |= mask;
        }
 
@@ -3700,10 +3708,10 @@ static void init_ao_67xx(struct comedi_device *dev, struct comedi_subdevice *s)
        int i;
 
        for (i = 0; i < s->n_chan; i++) {
-               ni_ao_win_outw(dev, AO_Channel(i) | 0x0,
-                              AO_Configuration_2_67xx);
+               ni_ao_win_outw(dev, NI_E_AO_DACSEL(i) | 0x0,
+                              NI67XX_AO_CFG2_REG);
        }
-       ni_ao_win_outw(dev, 0x0, AO_Later_Single_Point_Updates);
+       ni_ao_win_outw(dev, 0x0, NI67XX_AO_SP_UPDATES_REG);
 }
 
 static const struct mio_regmap ni_gpct_to_stc_regmap[] = {
@@ -3711,10 +3719,10 @@ static const struct mio_regmap ni_gpct_to_stc_regmap[] = {
        [NITIO_G1_AUTO_INC]     = { NISTC_G1_AUTOINC_REG, 2 },
        [NITIO_G0_CMD]          = { NISTC_G0_CMD_REG, 2 },
        [NITIO_G1_CMD]          = { NISTC_G1_CMD_REG, 2 },
-       [NITIO_G0_HW_SAVE]      = { G_HW_Save_Register(0), 4 },
-       [NITIO_G1_HW_SAVE]      = { G_HW_Save_Register(1), 4 },
-       [NITIO_G0_SW_SAVE]      = { G_Save_Register(0), 4 },
-       [NITIO_G1_SW_SAVE]      = { G_Save_Register(1), 4 },
+       [NITIO_G0_HW_SAVE]      = { NISTC_G0_HW_SAVE_REG, 4 },
+       [NITIO_G1_HW_SAVE]      = { NISTC_G1_HW_SAVE_REG, 4 },
+       [NITIO_G0_SW_SAVE]      = { NISTC_G0_SAVE_REG, 4 },
+       [NITIO_G1_SW_SAVE]      = { NISTC_G1_SAVE_REG, 4 },
        [NITIO_G0_MODE]         = { NISTC_G0_MODE_REG, 2 },
        [NITIO_G1_MODE]         = { NISTC_G1_MODE_REG, 2 },
        [NITIO_G0_LOADA]        = { NISTC_G0_LOADA_REG, 4 },
@@ -3727,10 +3735,10 @@ static const struct mio_regmap ni_gpct_to_stc_regmap[] = {
        [NITIO_G1_CNT_MODE]     = { 0x1b2, 2 }, /* M-Series only */
        [NITIO_G0_GATE2]        = { 0x1b4, 2 }, /* M-Series only */
        [NITIO_G1_GATE2]        = { 0x1b6, 2 }, /* M-Series only */
-       [NITIO_G01_STATUS]      = { G_Status_Register, 2 },
+       [NITIO_G01_STATUS]      = { NISTC_G01_STATUS_REG, 2 },
        [NITIO_G01_RESET]       = { NISTC_RESET_REG, 2 },
-       [NITIO_G01_STATUS1]     = { Joint_Status_1_Register, 2 },
-       [NITIO_G01_STATUS2]     = { Joint_Status_2_Register, 2 },
+       [NITIO_G01_STATUS1]     = { NISTC_STATUS1_REG, 2 },
+       [NITIO_G01_STATUS2]     = { NISTC_STATUS2_REG, 2 },
        [NITIO_G0_DMA_CFG]      = { 0x1b8, 2 }, /* M-Series only */
        [NITIO_G1_DMA_CFG]      = { 0x1ba, 2 }, /* M-Series only */
        [NITIO_G0_DMA_STATUS]   = { 0x1b8, 2 }, /* M-Series only */
@@ -3739,10 +3747,10 @@ static const struct mio_regmap ni_gpct_to_stc_regmap[] = {
        [NITIO_G1_ABZ]          = { 0x1c2, 2 }, /* M-Series only */
        [NITIO_G0_INT_ACK]      = { NISTC_INTA_ACK_REG, 2 },
        [NITIO_G1_INT_ACK]      = { NISTC_INTB_ACK_REG, 2 },
-       [NITIO_G0_STATUS]       = { AI_Status_1_Register, 2 },
-       [NITIO_G1_STATUS]       = { AO_Status_1_Register, 2 },
+       [NITIO_G0_STATUS]       = { NISTC_AI_STATUS1_REG, 2 },
+       [NITIO_G1_STATUS]       = { NISTC_AO_STATUS1_REG, 2 },
        [NITIO_G0_INT_ENA]      = { NISTC_INTA_ENA_REG, 2 },
-       [NITIO_G1_INT_ENA]      = { Interrupt_B_Enable_Register, 2 },
+       [NITIO_G1_INT_ENA]      = { NISTC_INTB_ENA_REG, 2 },
 };
 
 static unsigned int ni_gpct_to_stc_register(struct comedi_device *dev,
@@ -3753,7 +3761,7 @@ static unsigned int ni_gpct_to_stc_register(struct comedi_device *dev,
        if (reg < ARRAY_SIZE(ni_gpct_to_stc_regmap)) {
                regmap = &ni_gpct_to_stc_regmap[reg];
        } else {
-               dev_warn(dev->class_dev,"%s: unhandled register 0x%x\n",
+               dev_warn(dev->class_dev, "%s: unhandled register=0x%x\n",
                         __func__, reg);
                return 0;
        }
@@ -3769,7 +3777,7 @@ static void ni_gpct_write_register(struct ni_gpct *counter, unsigned bits,
        static const unsigned gpct_interrupt_a_enable_mask =
            NISTC_INTA_ENA_G0_GATE | NISTC_INTA_ENA_G0_TC;
        static const unsigned gpct_interrupt_b_enable_mask =
-           G1_Gate_Interrupt_Enable | G1_TC_Interrupt_Enable;
+           NISTC_INTB_ENA_G1_GATE | NISTC_INTB_ENA_G1_TC;
 
        if (stc_register == 0)
                return;
@@ -4050,9 +4058,9 @@ static int ni_6143_pwm_config(struct comedi_device *dev,
                        data[4] = down_count * devpriv->clock_ns;
                        return -EAGAIN;
                }
-               ni_writel(dev, up_count, Calibration_HighTime_6143);
+               ni_writel(dev, up_count, NI6143_CALIB_HI_TIME_REG);
                devpriv->pwm_up_count = up_count;
-               ni_writel(dev, down_count, Calibration_LowTime_6143);
+               ni_writel(dev, down_count, NI6143_CALIB_LO_TIME_REG);
                devpriv->pwm_down_count = down_count;
                return 5;
        case INSN_CONFIG_GET_PWM_OUTPUT:
@@ -4132,6 +4140,7 @@ static void ni_write_caldac(struct comedi_device *dev, int addr, int val)
        const struct ni_board_struct *board = dev->board_ptr;
        struct ni_private *devpriv = dev->private;
        unsigned int loadbit = 0, bits = 0, bit, bitstring = 0;
+       unsigned int cmd;
        int i;
        int type;
 
@@ -4145,7 +4154,7 @@ static void ni_write_caldac(struct comedi_device *dev, int addr, int val)
                        break;
                if (addr < caldacs[type].n_chans) {
                        bits = caldacs[type].packbits(addr, val, &bitstring);
-                       loadbit = SerDacLd(i);
+                       loadbit = NI_E_SERIAL_CMD_DAC_LD(i);
                        break;
                }
                addr -= caldacs[type].n_chans;
@@ -4156,15 +4165,15 @@ static void ni_write_caldac(struct comedi_device *dev, int addr, int val)
                return;
 
        for (bit = 1 << (bits - 1); bit; bit >>= 1) {
-               ni_writeb(dev, ((bit & bitstring) ? 0x02 : 0), Serial_Command);
+               cmd = (bit & bitstring) ? NI_E_SERIAL_CMD_SDATA : 0;
+               ni_writeb(dev, cmd, NI_E_SERIAL_CMD_REG);
                udelay(1);
-               ni_writeb(dev, 1 | ((bit & bitstring) ? 0x02 : 0),
-                         Serial_Command);
+               ni_writeb(dev, NI_E_SERIAL_CMD_SCLK | cmd, NI_E_SERIAL_CMD_REG);
                udelay(1);
        }
-       ni_writeb(dev, loadbit, Serial_Command);
+       ni_writeb(dev, loadbit, NI_E_SERIAL_CMD_REG);
        udelay(1);
-       ni_writeb(dev, 0, Serial_Command);
+       ni_writeb(dev, 0, NI_E_SERIAL_CMD_REG);
 }
 
 static int ni_calib_insn_write(struct comedi_device *dev,
@@ -4246,24 +4255,30 @@ static void caldac_setup(struct comedi_device *dev, struct comedi_subdevice *s)
 
 static int ni_read_eeprom(struct comedi_device *dev, int addr)
 {
+       unsigned int cmd = NI_E_SERIAL_CMD_EEPROM_CS;
        int bit;
        int bitstring;
 
        bitstring = 0x0300 | ((addr & 0x100) << 3) | (addr & 0xff);
-       ni_writeb(dev, 0x04, Serial_Command);
+       ni_writeb(dev, cmd, NI_E_SERIAL_CMD_REG);
        for (bit = 0x8000; bit; bit >>= 1) {
-               ni_writeb(dev, 0x04 | ((bit & bitstring) ? 0x02 : 0),
-                         Serial_Command);
-               ni_writeb(dev, 0x05 | ((bit & bitstring) ? 0x02 : 0),
-                         Serial_Command);
+               if (bit & bitstring)
+                       cmd |= NI_E_SERIAL_CMD_SDATA;
+               else
+                       cmd &= ~NI_E_SERIAL_CMD_SDATA;
+
+               ni_writeb(dev, cmd, NI_E_SERIAL_CMD_REG);
+               ni_writeb(dev, NI_E_SERIAL_CMD_SCLK | cmd, NI_E_SERIAL_CMD_REG);
        }
+       cmd = NI_E_SERIAL_CMD_EEPROM_CS;
        bitstring = 0;
        for (bit = 0x80; bit; bit >>= 1) {
-               ni_writeb(dev, 0x04, Serial_Command);
-               ni_writeb(dev, 0x05, Serial_Command);
-               bitstring |= ((ni_readb(dev, XXX_Status) & PROMOUT) ? bit : 0);
+               ni_writeb(dev, cmd, NI_E_SERIAL_CMD_REG);
+               ni_writeb(dev, NI_E_SERIAL_CMD_SCLK | cmd, NI_E_SERIAL_CMD_REG);
+               if (ni_readb(dev, NI_E_STATUS_REG) & NI_E_STATUS_PROMOUT)
+                       bitstring |= bit;
        }
-       ni_writeb(dev, 0x00, Serial_Command);
+       ni_writeb(dev, 0, NI_E_SERIAL_CMD_REG);
 
        return bitstring;
 }
@@ -4458,8 +4473,8 @@ static int cs5529_wait_for_idle(struct comedi_device *dev)
        int i;
 
        for (i = 0; i < timeout; i++) {
-               status = ni_ao_win_inw(dev, CAL_ADC_Status_67xx);
-               if ((status & CSS_ADC_BUSY) == 0)
+               status = ni_ao_win_inw(dev, NI67XX_CAL_STATUS_REG);
+               if ((status & NI67XX_CAL_STATUS_BUSY) == 0)
                        break;
                set_current_state(TASK_INTERRUPTIBLE);
                if (schedule_timeout(1))
@@ -4477,13 +4492,14 @@ static void cs5529_command(struct comedi_device *dev, unsigned short value)
        static const int timeout = 100;
        int i;
 
-       ni_ao_win_outw(dev, value, CAL_ADC_Command_67xx);
+       ni_ao_win_outw(dev, value, NI67XX_CAL_CMD_REG);
        /* give time for command to start being serially clocked into cs5529.
-        * this insures that the CSS_ADC_BUSY bit will get properly
+        * this insures that the NI67XX_CAL_STATUS_BUSY bit will get properly
         * set before we exit this function.
         */
        for (i = 0; i < timeout; i++) {
-               if ((ni_ao_win_inw(dev, CAL_ADC_Status_67xx) & CSS_ADC_BUSY))
+               if (ni_ao_win_inw(dev, NI67XX_CAL_STATUS_REG) &
+                   NI67XX_CAL_STATUS_BUSY)
                        break;
                udelay(1);
        }
@@ -4498,25 +4514,25 @@ static int cs5529_do_conversion(struct comedi_device *dev,
        int retval;
        unsigned short status;
 
-       cs5529_command(dev, CSCMD_COMMAND | CSCMD_SINGLE_CONVERSION);
+       cs5529_command(dev, CS5529_CMD_CB | CS5529_CMD_SINGLE_CONV);
        retval = cs5529_wait_for_idle(dev);
        if (retval) {
                dev_err(dev->class_dev,
                        "timeout or signal in cs5529_do_conversion()\n");
                return -ETIME;
        }
-       status = ni_ao_win_inw(dev, CAL_ADC_Status_67xx);
-       if (status & CSS_OSC_DETECT) {
+       status = ni_ao_win_inw(dev, NI67XX_CAL_STATUS_REG);
+       if (status & NI67XX_CAL_STATUS_OSC_DETECT) {
                dev_err(dev->class_dev,
                        "cs5529 conversion error, status CSS_OSC_DETECT\n");
                return -EIO;
        }
-       if (status & CSS_OVERRANGE) {
+       if (status & NI67XX_CAL_STATUS_OVERRANGE) {
                dev_err(dev->class_dev,
                        "cs5529 conversion error, overrange (ignoring)\n");
        }
        if (data) {
-               *data = ni_ao_win_inw(dev, CAL_ADC_Data_67xx);
+               *data = ni_ao_win_inw(dev, NI67XX_CAL_DATA_REG);
                /* cs5529 returns 16 bit signed data in bipolar mode */
                *data ^= (1 << 15);
        }
@@ -4540,7 +4556,7 @@ static int cs5529_ai_insn_read(struct comedi_device *dev,
                channel_select = INTERNAL_REF;
        else
                channel_select = CR_CHAN(insn->chanspec);
-       ni_ao_win_outw(dev, channel_select, AO_Calibration_Channel_Select_67xx);
+       ni_ao_win_outw(dev, channel_select, NI67XX_AO_CAL_CHAN_SEL_REG);
 
        for (n = 0; n < insn->n; n++) {
                retval = cs5529_do_conversion(dev, &sample);
@@ -4554,12 +4570,10 @@ static int cs5529_ai_insn_read(struct comedi_device *dev,
 static void cs5529_config_write(struct comedi_device *dev, unsigned int value,
                                unsigned int reg_select_bits)
 {
-       ni_ao_win_outw(dev, ((value >> 16) & 0xff),
-                      CAL_ADC_Config_Data_High_Word_67xx);
-       ni_ao_win_outw(dev, (value & 0xffff),
-                      CAL_ADC_Config_Data_Low_Word_67xx);
-       reg_select_bits &= CSCMD_REGISTER_SELECT_MASK;
-       cs5529_command(dev, CSCMD_COMMAND | reg_select_bits);
+       ni_ao_win_outw(dev, (value >> 16) & 0xff, NI67XX_CAL_CFG_HI_REG);
+       ni_ao_win_outw(dev, value & 0xffff, NI67XX_CAL_CFG_LO_REG);
+       reg_select_bits &= CS5529_CMD_REG_MASK;
+       cs5529_command(dev, CS5529_CMD_CB | reg_select_bits);
        if (cs5529_wait_for_idle(dev))
                dev_err(dev->class_dev,
                        "timeout or signal in %s\n", __func__);
@@ -4567,20 +4581,20 @@ static void cs5529_config_write(struct comedi_device *dev, unsigned int value,
 
 static int init_cs5529(struct comedi_device *dev)
 {
-       unsigned int config_bits =
-           CSCFG_PORT_MODE | CSCFG_WORD_RATE_2180_CYCLES;
+       unsigned int config_bits = CS5529_CFG_PORT_FLAG |
+                                  CS5529_CFG_WORD_RATE_2180;
 
 #if 1
        /* do self-calibration */
-       cs5529_config_write(dev, config_bits | CSCFG_SELF_CAL_OFFSET_GAIN,
-                           CSCMD_CONFIG_REGISTER);
+       cs5529_config_write(dev, config_bits | CS5529_CFG_CALIB_BOTH_SELF,
+                           CS5529_CFG_REG);
        /* need to force a conversion for calibration to run */
        cs5529_do_conversion(dev, NULL);
 #else
        /* force gain calibration to 1 */
-       cs5529_config_write(dev, 0x400000, CSCMD_GAIN_REGISTER);
-       cs5529_config_write(dev, config_bits | CSCFG_SELF_CAL_OFFSET,
-                           CSCMD_CONFIG_REGISTER);
+       cs5529_config_write(dev, 0x400000, CS5529_GAIN_REG);
+       cs5529_config_write(dev, config_bits | CS5529_CFG_CALIB_OFFSET_SELF,
+                           CS5529_CFG_REG);
        if (cs5529_wait_for_idle(dev))
                dev_err(dev->class_dev,
                        "timeout or signal in %s\n", __func__);
@@ -4795,24 +4809,22 @@ static int ni_valid_rtsi_output_source(struct comedi_device *dev,
 }
 
 static int ni_set_rtsi_routing(struct comedi_device *dev,
-                              unsigned chan, unsigned source)
+                              unsigned chan, unsigned src)
 {
        struct ni_private *devpriv = dev->private;
 
-       if (ni_valid_rtsi_output_source(dev, chan, source) == 0)
+       if (ni_valid_rtsi_output_source(dev, chan, src) == 0)
                return -EINVAL;
        if (chan < 4) {
-               devpriv->rtsi_trig_a_output_reg &= ~RTSI_Trig_Output_Mask(chan);
-               devpriv->rtsi_trig_a_output_reg |=
-                   RTSI_Trig_Output_Bits(chan, source);
+               devpriv->rtsi_trig_a_output_reg &= ~NISTC_RTSI_TRIG_MASK(chan);
+               devpriv->rtsi_trig_a_output_reg |= NISTC_RTSI_TRIG(chan, src);
                ni_stc_writew(dev, devpriv->rtsi_trig_a_output_reg,
-                             RTSI_Trig_A_Output_Register);
+                             NISTC_RTSI_TRIGA_OUT_REG);
        } else if (chan < 8) {
-               devpriv->rtsi_trig_b_output_reg &= ~RTSI_Trig_Output_Mask(chan);
-               devpriv->rtsi_trig_b_output_reg |=
-                   RTSI_Trig_Output_Bits(chan, source);
+               devpriv->rtsi_trig_b_output_reg &= ~NISTC_RTSI_TRIG_MASK(chan);
+               devpriv->rtsi_trig_b_output_reg |= NISTC_RTSI_TRIG(chan, src);
                ni_stc_writew(dev, devpriv->rtsi_trig_b_output_reg,
-                             RTSI_Trig_B_Output_Register);
+                             NISTC_RTSI_TRIGB_OUT_REG);
        }
        return 2;
 }
@@ -4822,11 +4834,11 @@ static unsigned ni_get_rtsi_routing(struct comedi_device *dev, unsigned chan)
        struct ni_private *devpriv = dev->private;
 
        if (chan < 4) {
-               return RTSI_Trig_Output_Source(chan,
-                                              devpriv->rtsi_trig_a_output_reg);
+               return NISTC_RTSI_TRIG_TO_SRC(chan,
+                                             devpriv->rtsi_trig_a_output_reg);
        } else if (chan < NISTC_RTSI_TRIG_NUM_CHAN(devpriv->is_m_series)) {
-               return RTSI_Trig_Output_Source(chan,
-                                              devpriv->rtsi_trig_b_output_reg);
+               return NISTC_RTSI_TRIG_TO_SRC(chan,
+                                             devpriv->rtsi_trig_b_output_reg);
        } else {
                if (chan == NISTC_RTSI_TRIG_OLD_CLK_CHAN)
                        return NI_RTSI_OUTPUT_RTSI_OSC;
@@ -4925,31 +4937,26 @@ static void ni_rtsi_init(struct comedi_device *dev)
                dev_err(dev->class_dev, "ni_set_master_clock failed, bug?\n");
        /*  default internal lines routing to RTSI bus lines */
        devpriv->rtsi_trig_a_output_reg =
-           RTSI_Trig_Output_Bits(0,
-                                 NI_RTSI_OUTPUT_ADR_START1) |
-           RTSI_Trig_Output_Bits(1,
-                                 NI_RTSI_OUTPUT_ADR_START2) |
-           RTSI_Trig_Output_Bits(2,
-                                 NI_RTSI_OUTPUT_SCLKG) |
-           RTSI_Trig_Output_Bits(3, NI_RTSI_OUTPUT_DACUPDN);
+           NISTC_RTSI_TRIG(0, NI_RTSI_OUTPUT_ADR_START1) |
+           NISTC_RTSI_TRIG(1, NI_RTSI_OUTPUT_ADR_START2) |
+           NISTC_RTSI_TRIG(2, NI_RTSI_OUTPUT_SCLKG) |
+           NISTC_RTSI_TRIG(3, NI_RTSI_OUTPUT_DACUPDN);
        ni_stc_writew(dev, devpriv->rtsi_trig_a_output_reg,
-                     RTSI_Trig_A_Output_Register);
+                     NISTC_RTSI_TRIGA_OUT_REG);
        devpriv->rtsi_trig_b_output_reg =
-           RTSI_Trig_Output_Bits(4,
-                                 NI_RTSI_OUTPUT_DA_START1) |
-           RTSI_Trig_Output_Bits(5,
-                                 NI_RTSI_OUTPUT_G_SRC0) |
-           RTSI_Trig_Output_Bits(6, NI_RTSI_OUTPUT_G_GATE0);
+           NISTC_RTSI_TRIG(4, NI_RTSI_OUTPUT_DA_START1) |
+           NISTC_RTSI_TRIG(5, NI_RTSI_OUTPUT_G_SRC0) |
+           NISTC_RTSI_TRIG(6, NI_RTSI_OUTPUT_G_GATE0);
        if (devpriv->is_m_series)
                devpriv->rtsi_trig_b_output_reg |=
-                   RTSI_Trig_Output_Bits(7, NI_RTSI_OUTPUT_RTSI_OSC);
+                   NISTC_RTSI_TRIG(7, NI_RTSI_OUTPUT_RTSI_OSC);
        ni_stc_writew(dev, devpriv->rtsi_trig_b_output_reg,
-                     RTSI_Trig_B_Output_Register);
+                     NISTC_RTSI_TRIGB_OUT_REG);
 
-/*
-* Sets the source and direction of the 4 on board lines
-* ni_stc_writew(dev, 0x0000, RTSI_Board_Register);
-*/
+       /*
+        * Sets the source and direction of the 4 on board lines
+        * ni_stc_writew(dev, 0, NISTC_RTSI_BOARD_REG);
+        */
 }
 
 #ifdef PCIDMA
@@ -5002,8 +5009,8 @@ static irqreturn_t ni_E_interrupt(int irq, void *d)
 
        /*  lock to avoid race with comedi_poll */
        spin_lock_irqsave(&dev->spinlock, flags);
-       a_status = ni_stc_readw(dev, AI_Status_1_Register);
-       b_status = ni_stc_readw(dev, AO_Status_1_Register);
+       a_status = ni_stc_readw(dev, NISTC_AI_STATUS1_REG);
+       b_status = ni_stc_readw(dev, NISTC_AO_STATUS1_REG);
 #ifdef PCIDMA
        if (mite) {
                struct ni_private *devpriv = dev->private;
@@ -5031,9 +5038,9 @@ static irqreturn_t ni_E_interrupt(int irq, void *d)
 #endif
        ack_a_interrupt(dev, a_status);
        ack_b_interrupt(dev, b_status);
-       if ((a_status & Interrupt_A_St) || (ai_mite_status & CHSR_INT))
+       if ((a_status & NISTC_AI_STATUS1_INTA) || (ai_mite_status & CHSR_INT))
                handle_a_interrupt(dev, a_status, ai_mite_status);
-       if ((b_status & Interrupt_B_St) || (ao_mite_status & CHSR_INT))
+       if ((b_status & NISTC_AO_STATUS1_INTB) || (ao_mite_status & CHSR_INT))
                handle_b_interrupt(dev, b_status, ao_mite_status);
        handle_gpct_interrupt(dev, 0);
        handle_gpct_interrupt(dev, 1);
@@ -5207,7 +5214,8 @@ static int ni_E_init(struct comedi_device *dev,
        /* 8255 device */
        s = &dev->subdevices[NI_8255_DIO_SUBDEV];
        if (board->has_8255) {
-               ret = subdev_8255_init(dev, s, ni_8255_callback, Port_A);
+               ret = subdev_8255_init(dev, s, ni_8255_callback,
+                                      NI_E_8255_BASE);
                if (ret)
                        return ret;
        } else {
@@ -5376,11 +5384,11 @@ 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->g0_g1_select_reg, G0_G1_Select);
+       ni_writeb(dev, devpriv->ai_ao_select_reg, NI_E_DMA_AI_AO_SEL_REG);
+       ni_writeb(dev, devpriv->g0_g1_select_reg, NI_E_DMA_G0_G1_SEL_REG);
 
        if (devpriv->is_6xxx) {
-               ni_writeb(dev, 0, Magic_611x);
+               ni_writeb(dev, 0, NI611X_MAGIC_REG);
        } else if (devpriv->is_m_series) {
                int channel;