[PATCH 01/42] staging: comedi: ni_660x: change IOConfigReg() into a macro

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 drivers/staging/comedi/drivers/ni_660x.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_660x.c b/drivers/staging/comedi/drivers/ni_660x.c
index 46647c6..10db2ff 100644
--- a/drivers/staging/comedi/drivers/ni_660x.c
+++ b/drivers/staging/comedi/drivers/ni_660x.c
@@ -156,13 +156,7 @@ enum ni_660x_register {
 	NI660X_NUM_REGS,
 };
 
-static inline unsigned IOConfigReg(unsigned pfi_channel)
-{
-	unsigned reg = NI660X_IO_CFG_0_1 + pfi_channel / 2;
-
-	BUG_ON(reg > NI660X_IO_CFG_38_39);
-	return reg;
-}
+#define NI660X_IO_CFG(x)	(NI660X_IO_CFG_0_1 + ((x) / 2))
 
 enum ni_660x_register_width {
 	DATA_1B,
@@ -893,7 +887,7 @@ static void init_tio_chip(struct comedi_device *dev, int chipset)
 			       devpriv->dma_configuration_soft_copies[chipset],
 			       NI660X_DMA_CFG);
 	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,
@@ -944,22 +938,22 @@ static void ni_660x_select_pfi_output(struct comedi_device *dev,
 	if (idle_chipset != active_chipset) {
 		idle_bits =
 		    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_bits(pfi_channel,
 					   pfi_output_select_high_Z);
 		ni_660x_write_register(dev, idle_chipset, idle_bits,
-				       IOConfigReg(pfi_channel));
+				       NI660X_IO_CFG(pfi_channel));
 	}
 
 	active_bits =
 	    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_bits(pfi_channel, output_select);
 	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,
@@ -1025,10 +1019,10 @@ static int ni_660x_dio_insn_config(struct comedi_device *dev,
 		break;
 
 	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_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;
 
 	default:
-- 
2.6.3

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux