From a2a04d4fa2cce64af813dcd2f42c3d1196ac35c2 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Mon, 5 Nov 2007 11:50:11 +0000 Subject: [PATCH] Inline fixes: define inline functions before calling them. Some versions of gcc treat it as an error. Others will ignore the inline in this case and compile in a function call. --- comedi/drivers/me4000.c | 16 ++---- comedi/drivers/ni_mio_common.c | 93 +++++++++++++++++----------------- 2 files changed, 51 insertions(+), 58 deletions(-) diff --git a/comedi/drivers/me4000.c b/comedi/drivers/me4000.c index ed7b34ae..aff64812 100644 --- a/comedi/drivers/me4000.c +++ b/comedi/drivers/me4000.c @@ -171,28 +171,22 @@ static int me4000_ao_insn_read(comedi_device * dev, /*----------------------------------------------------------------------------- Meilhaus inline functions ---------------------------------------------------------------------------*/ -static void inline me4000_outb(comedi_device * dev, unsigned char value, - unsigned long port); -static void inline me4000_outl(comedi_device * dev, unsigned long value, - unsigned long port); -static unsigned long inline me4000_inl(comedi_device * dev, unsigned long port); -static unsigned char inline me4000_inb(comedi_device * dev, unsigned long port); - -static void me4000_outb(comedi_device * dev, unsigned char value, + +static inline void me4000_outb(comedi_device * dev, unsigned char value, unsigned long port) { PORT_PDEBUG("--> 0x%02X port 0x%04lX\n", value, port); outb(value, port); } -static void me4000_outl(comedi_device * dev, unsigned long value, +static inline void me4000_outl(comedi_device * dev, unsigned long value, unsigned long port) { PORT_PDEBUG("--> 0x%08lX port 0x%04lX\n", value, port); outl(value, port); } -static unsigned long me4000_inl(comedi_device * dev, unsigned long port) +static inline unsigned long me4000_inl(comedi_device * dev, unsigned long port) { unsigned long value; value = inl(port); @@ -200,7 +194,7 @@ static unsigned long me4000_inl(comedi_device * dev, unsigned long port) return value; } -static unsigned char me4000_inb(comedi_device * dev, unsigned long port) +static inline unsigned char me4000_inb(comedi_device * dev, unsigned long port) { unsigned char value; value = inb(port); diff --git a/comedi/drivers/ni_mio_common.c b/comedi/drivers/ni_mio_common.c index 2276ffe6..e44488df 100644 --- a/comedi/drivers/ni_mio_common.c +++ b/comedi/drivers/ni_mio_common.c @@ -364,10 +364,54 @@ static void handle_b_interrupt(comedi_device * dev, unsigned short status, unsigned ao_mite_status); static void get_last_sample_611x(comedi_device * dev); static void get_last_sample_6143(comedi_device * dev); + +static inline void ni_set_bitfield(comedi_device * dev, int reg, + unsigned bit_mask, unsigned bit_values) +{ + unsigned long flags; + + comedi_spin_lock_irqsave(&devpriv->soft_reg_copy_lock, flags); + switch (reg) { + case Interrupt_A_Enable_Register: + devpriv->int_a_enable_reg &= ~bit_mask; + devpriv->int_a_enable_reg |= bit_values & bit_mask; + devpriv->stc_writew(dev, devpriv->int_a_enable_reg, + Interrupt_A_Enable_Register); + break; + case Interrupt_B_Enable_Register: + devpriv->int_b_enable_reg &= ~bit_mask; + devpriv->int_b_enable_reg |= bit_values & bit_mask; + devpriv->stc_writew(dev, devpriv->int_b_enable_reg, + Interrupt_B_Enable_Register); + break; + case IO_Bidirection_Pin_Register: + devpriv->io_bidirection_pin_reg &= ~bit_mask; + devpriv->io_bidirection_pin_reg |= bit_values & bit_mask; + devpriv->stc_writew(dev, devpriv->io_bidirection_pin_reg, + IO_Bidirection_Pin_Register); + break; + case AI_AO_Select: + devpriv->ai_ao_select_reg &= ~bit_mask; + devpriv->ai_ao_select_reg |= bit_values & bit_mask; + ni_writeb(devpriv->ai_ao_select_reg, AI_AO_Select); + break; + case G0_G1_Select: + devpriv->g0_g1_select_reg &= ~bit_mask; + devpriv->g0_g1_select_reg |= bit_values & bit_mask; + ni_writeb(devpriv->g0_g1_select_reg, G0_G1_Select); + break; + default: + rt_printk("Warning %s() called with invalid register\n", + __FUNCTION__); + rt_printk("reg is %d\n", reg); + break; + } + mmiowb(); + comedi_spin_unlock_irqrestore(&devpriv->soft_reg_copy_lock, flags); +} + #ifdef PCIDMA static int ni_ai_drain_dma(comedi_device * dev); -static inline void ni_set_bitfield(comedi_device * dev, int reg, - unsigned bit_mask, unsigned bit_values); /* DMA channel setup */ @@ -699,51 +743,6 @@ static inline unsigned short ni_ao_win_inw(comedi_device * dev, int addr) return data; } -static inline void ni_set_bitfield(comedi_device * dev, int reg, - unsigned bit_mask, unsigned bit_values) -{ - unsigned long flags; - - comedi_spin_lock_irqsave(&devpriv->soft_reg_copy_lock, flags); - switch (reg) { - case Interrupt_A_Enable_Register: - devpriv->int_a_enable_reg &= ~bit_mask; - devpriv->int_a_enable_reg |= bit_values & bit_mask; - devpriv->stc_writew(dev, devpriv->int_a_enable_reg, - Interrupt_A_Enable_Register); - break; - case Interrupt_B_Enable_Register: - devpriv->int_b_enable_reg &= ~bit_mask; - devpriv->int_b_enable_reg |= bit_values & bit_mask; - devpriv->stc_writew(dev, devpriv->int_b_enable_reg, - Interrupt_B_Enable_Register); - break; - case IO_Bidirection_Pin_Register: - devpriv->io_bidirection_pin_reg &= ~bit_mask; - devpriv->io_bidirection_pin_reg |= bit_values & bit_mask; - devpriv->stc_writew(dev, devpriv->io_bidirection_pin_reg, - IO_Bidirection_Pin_Register); - break; - case AI_AO_Select: - devpriv->ai_ao_select_reg &= ~bit_mask; - devpriv->ai_ao_select_reg |= bit_values & bit_mask; - ni_writeb(devpriv->ai_ao_select_reg, AI_AO_Select); - break; - case G0_G1_Select: - devpriv->g0_g1_select_reg &= ~bit_mask; - devpriv->g0_g1_select_reg |= bit_values & bit_mask; - ni_writeb(devpriv->g0_g1_select_reg, G0_G1_Select); - break; - default: - rt_printk("Warning %s() called with invalid register\n", - __FUNCTION__); - rt_printk("reg is %d\n", reg); - break; - } - mmiowb(); - comedi_spin_unlock_irqrestore(&devpriv->soft_reg_copy_lock, flags); -} - /* ni_set_bits( ) allows different parts of the ni_mio_common driver to * share registers (such as Interrupt_A_Register) without interfering with * each other. -- 2.26.2