[PATCH 090/107] staging: comedi: ni_stc.h: tidy up 8255 register defines

2015-05-01 Thread H Hartley Sweeten
Only the 'Port_A' define is used. Rename the CamelCase and remove the
unused defines.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c |  3 ++-
 drivers/staging/comedi/drivers/ni_stc.h| 10 ++
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index 06c491d..202957c 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -5204,7 +5204,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 {
diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index 9cea344..3bf73a7 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -582,14 +582,6 @@
 #define NI_E_MISC_CMD_EXT_ATRIGNI_E_MISC_CMD_INTEXT_ATRIG(0)
 #define NI_E_MISC_CMD_INT_ATRIGNI_E_MISC_CMD_INTEXT_ATRIG(1)
 
-#define Port_A 0x19
-#define Port_B 0x1b
-#define Port_C 0x1d
-#define Configuration  0x1f
-#define Strobes0x01
-#define Channel_A_Mode 0x03
-#define Channel_B_Mode 0x05
-#define Channel_C_Mode 0x07
 #define AI_AO_Select   0x09
 enum AI_AO_Select_Bits {
AI_DMA_Select_Shift = 0,
@@ -643,6 +635,8 @@ static inline unsigned int AI_CONFIG_CHANNEL(unsigned int 
channel)
return channel  0x3f;
 }
 
+#define NI_E_8255_BASE 0x19/* rw8 */
+
 #define ADC_FIFO_Data_Register 0x1c
 
 #define AO_Configuration   0x16
-- 
2.3.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 106/107] staging: comedi: ni_stc.h: tidy up the windowed_regs_67xx_61xx

2015-05-01 Thread H Hartley Sweeten
Rename the CamelCase. For aesthetics, convert the enum into defines.
Use the BIT() macro to define the bits.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 51 +
 drivers/staging/comedi/drivers/ni_stc.h| 53 ++
 2 files changed, 47 insertions(+), 57 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index 33f01e1..c741dde 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -1091,7 +1091,7 @@ static int ni_ao_prep_fifo(struct comedi_device *dev,
/* reset fifo */
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);
@@ -2736,9 +2736,9 @@ 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 {
@@ -2838,7 +2838,7 @@ static int ni_ao_inttrig(struct comedi_device *dev,
 #ifdef PCIDMA
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;
@@ -2910,7 +2910,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++) {
@@ -2918,9 +2919,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);
@@ -3227,8 +3228,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);
 
@@ -3708,9 +3710,9 @@ static void init_ao_67xx(struct comedi_device *dev, 
struct comedi_subdevice *s)
 
for (i = 0; i  s-n_chan; i++) {
ni_ao_win_outw(dev, NI_E_AO_DACSEL(i) | 0x0,
-  AO_Configuration_2_67xx);
+  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[] = {
@@ -4472,8 +4474,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))
@@ -4491,13 +4493,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 

[PATCH 081/107] staging: comedi: ni_stc.h: tidy up Joint_Status_1_Register

2015-05-01 Thread H Hartley Sweeten
Rename the CamelCase. Use the BIT() macro to define the bits.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 18 ++
 drivers/staging/comedi/drivers/ni_stc.h|  6 +++---
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index b194d15..9051477 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -423,7 +423,7 @@ static const struct mio_regmap m_series_stc_read_regmap[] = 
{
[NISTC_AO_UI_SAVE_REG]  = { 0x120, 4 },
[NISTC_AO_BC_SAVE_REG]  = { 0x124, 4 },
[NISTC_AO_UC_SAVE_REG]  = { 0x128, 4 },
-   [Joint_Status_1_Register]   = { 0x136, 2 },
+   [NISTC_STATUS1_REG] = { 0x136, 2 },
[DIO_Serial_Input_Register] = { 0x009, 1 },
[Joint_Status_2_Register]   = { 0x13a, 2 },
[AI_SI_Save_Registers]  = { 0x180, 4 },
@@ -3522,8 +3522,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;
}
@@ -3533,8 +3533,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) {
@@ -3545,8 +3545,10 @@ 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)
@@ -3724,7 +3726,7 @@ static const struct mio_regmap ni_gpct_to_stc_regmap[] = {
[NITIO_G1_GATE2]= { 0x1b6, 2 }, /* M-Series only */
[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_STATUS1] = { NISTC_STATUS1_REG, 2 },
[NITIO_G01_STATUS2] = { Joint_Status_2_Register, 2 },
[NITIO_G0_DMA_CFG]  = { 0x1b8, 2 }, /* M-Series only */
[NITIO_G1_DMA_CFG]  = { 0x1ba, 2 }, /* M-Series only */
diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index af07e4c..2d7f342 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -550,12 +550,12 @@
 #define NISTC_AO_BC_SAVE_REG   18
 #define NISTC_AO_UC_SAVE_REG   20
 
+#define NISTC_STATUS1_REG  27
+#define NISTC_STATUS1_SERIO_IN_PROGBIT(12)
+
 #define AI_SI_Save_Registers   64
 #define AI_SC_Save_Registers   66
 
-#define Joint_Status_1_Register 27
-#define DIO_Serial_IO_In_Progress_St_bit12
-
 #define DIO_Serial_Input_Register   28
 #define Joint_Status_2_Register 29
 enum Joint_Status_2_Bits {
-- 
2.3.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 059/107] staging: comedi: ni_stc.h: tidy up AO_Mode_3_Register and bits

2015-05-01 Thread H Hartley Sweeten
Rename the CamelCase. Use the BIT() macro to define the bits.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 20 ++--
 drivers/staging/comedi/drivers/ni_stc.h| 22 +++---
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index 2c85b57..a417ab4 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -364,7 +364,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] 
= {
[NISTC_AO_TRIG_SEL_REG] = { 0x186, 2 },
[NISTC_G0_AUTOINC_REG]  = { 0x188, 2 },
[NISTC_G1_AUTOINC_REG]  = { 0x18a, 2 },
-   [AO_Mode_3_Register]= { 0x18c, 2 },
+   [NISTC_AO_MODE3_REG]= { 0x18c, 2 },
[Joint_Reset_Register]  = { 0x190, 2 },
[Interrupt_A_Enable_Register]   = { 0x192, 2 },
[Second_IRQ_A_Enable_Register]  = { 0, 0 }, /* E-Series only */
@@ -2857,9 +2857,9 @@ static int ni_ao_inttrig(struct comedi_device *dev,
interrupt_b_bits |= AO_FIFO_Interrupt_Enable;
 #endif
 
-   ni_stc_writew(dev, devpriv-ao_mode3 | AO_Not_An_UPDATE,
- AO_Mode_3_Register);
-   ni_stc_writew(dev, devpriv-ao_mode3, AO_Mode_3_Register);
+   ni_stc_writew(dev, devpriv-ao_mode3 | NISTC_AO_MODE3_NOT_AN_UPDATE,
+ NISTC_AO_MODE3_REG);
+   ni_stc_writew(dev, devpriv-ao_mode3, NISTC_AO_MODE3_REG);
/* wait for DACs to be loaded */
for (i = 0; i  timeout; i++) {
udelay(1);
@@ -2967,8 +2967,8 @@ static int ni_ao_cmd(struct comedi_device *dev, struct 
comedi_subdevice *s)
devpriv-ao_trigger_select = val;
ni_stc_writew(dev, devpriv-ao_trigger_select, NISTC_AO_TRIG_SEL_REG);
 
-   devpriv-ao_mode3 = ~AO_Trigger_Length;
-   ni_stc_writew(dev, devpriv-ao_mode3, AO_Mode_3_Register);
+   devpriv-ao_mode3 = ~NISTC_AO_MODE3_TRIG_LEN;
+   ni_stc_writew(dev, devpriv-ao_mode3, NISTC_AO_MODE3_REG);
 
ni_stc_writew(dev, devpriv-ao_mode1, NISTC_AO_MODE1_REG);
devpriv-ao_mode2 = ~NISTC_AO_MODE2_BC_INIT_LOAD_SRC;
@@ -3064,8 +3064,8 @@ static int ni_ao_cmd(struct comedi_device *dev, struct 
comedi_subdevice *s)
   NISTC_AO_CMD1_DAC0_UPDATE_MODE,
  NISTC_AO_CMD1_REG);
 
-   devpriv-ao_mode3 |= AO_Stop_On_Overrun_Error;
-   ni_stc_writew(dev, devpriv-ao_mode3, AO_Mode_3_Register);
+   devpriv-ao_mode3 |= NISTC_AO_MODE3_STOP_ON_OVERRUN_ERR;
+   ni_stc_writew(dev, devpriv-ao_mode3, NISTC_AO_MODE3_REG);
 
devpriv-ao_mode2 = ~NISTC_AO_MODE2_FIFO_MODE_MASK;
 #ifdef PCIDMA
@@ -3213,10 +3213,10 @@ static int ni_ao_reset(struct comedi_device *dev, 
struct comedi_subdevice *s)
devpriv-ao_mode2 = 0;
ni_stc_writew(dev, devpriv-ao_mode2, NISTC_AO_MODE2_REG);
if (devpriv-is_m_series)
-   devpriv-ao_mode3 = AO_Last_Gate_Disable;
+   devpriv-ao_mode3 = NISTC_AO_MODE3_LAST_GATE_DISABLE;
else
devpriv-ao_mode3 = 0;
-   ni_stc_writew(dev, devpriv-ao_mode3, AO_Mode_3_Register);
+   ni_stc_writew(dev, devpriv-ao_mode3, NISTC_AO_MODE3_REG);
devpriv-ao_trigger_select = 0;
ni_stc_writew(dev, devpriv-ao_trigger_select,
  NISTC_AO_TRIG_SEL_REG);
diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index f63f290..69bfdc0 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -362,6 +362,17 @@
 #define NISTC_G0_AUTOINC_REG   68
 #define NISTC_G1_AUTOINC_REG   69
 
+#define NISTC_AO_MODE3_REG 70
+#define NISTC_AO_MODE3_UI2_SW_NEXT_TC  BIT(13)
+#define NISTC_AO_MODE3_UC_SW_EVERY_BC_TC   BIT(12)
+#define NISTC_AO_MODE3_TRIG_LENBIT(11)
+#define NISTC_AO_MODE3_STOP_ON_OVERRUN_ERR BIT(5)
+#define NISTC_AO_MODE3_STOP_ON_BC_TC_TRIG_ERR  BIT(4)
+#define NISTC_AO_MODE3_STOP_ON_BC_TC_ERR   BIT(3)
+#define NISTC_AO_MODE3_NOT_AN_UPDATE   BIT(2)
+#define NISTC_AO_MODE3_SW_GATE BIT(1)
+#define NISTC_AO_MODE3_LAST_GATE_DISABLE   BIT(0)  /* M-Series only */
+
 #define AI_Status_1_Register   2
 #define Interrupt_A_St 0x8000
 #define AI_FIFO_Full_St0x4000
@@ -420,17 +431,6 @@ enum Joint_Status_2_Bits {
 #define AO_BC_Save_Registers   18
 #define AO_UC_Save_Registers   20
 
-#define AO_Mode_3_Register 70
-#define AO_UI2_Switch_Load_Next_TC _bit13
-#define AO_UC_Switch_Load_Every_BC_TC  _bit12
-#define AO_Trigger_Length  

[PATCH 078/107] staging: comedi: ni_stc.h: tidy up G_HW_Save_Register

2015-05-01 Thread H Hartley Sweeten
Rename the CamelCase and define the G0 and G1 registers to add clarity
to the mio_regmap tables.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 8 
 drivers/staging/comedi/drivers/ni_stc.h| 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index ea30689..f0f449c 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -416,8 +416,8 @@ static const struct mio_regmap m_series_stc_read_regmap[] = 
{
[NISTC_AI_STATUS2_REG]  = { 0, 0 }, /* Unknown */
[NISTC_AO_STATUS2_REG]  = { 0x10c, 2 },
[NISTC_DIO_IN_REG]  = { 0, 0 }, /* Unknown */
-   [G_HW_Save_Register(0)] = { 0x110, 4 },
-   [G_HW_Save_Register(1)] = { 0x114, 4 },
+   [NISTC_G0_HW_SAVE_REG]  = { 0x110, 4 },
+   [NISTC_G1_HW_SAVE_REG]  = { 0x114, 4 },
[G_Save_Register(0)]= { 0x118, 4 },
[G_Save_Register(1)]= { 0x11c, 4 },
[AO_UI_Save_Registers]  = { 0x120, 4 },
@@ -3706,8 +3706,8 @@ 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_HW_SAVE]  = { NISTC_G0_HW_SAVE_REG, 4 },
+   [NITIO_G1_HW_SAVE]  = { NISTC_G1_HW_SAVE_REG, 4 },
[NITIO_G0_SW_SAVE]  = { G_Save_Register(0), 4 },
[NITIO_G1_SW_SAVE]  = { G_Save_Register(1), 4 },
[NITIO_G0_MODE] = { NISTC_G0_MODE_REG, 2 },
diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index 5be6a950..0b4dcc4 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -540,6 +540,9 @@
 
 #define NISTC_DIO_IN_REG   7
 
+#define NISTC_G0_HW_SAVE_REG   8
+#define NISTC_G1_HW_SAVE_REG   10
+
 #define AI_SI_Save_Registers   64
 #define AI_SC_Save_Registers   66
 
@@ -556,9 +559,6 @@ enum Joint_Status_2_Bits {
 #define AO_BC_Save_Registers   18
 #define AO_UC_Save_Registers   20
 
-#define G_HW_Save_Register(a)  (8+(a)*2)
-#define G_HW_Save_Register_High(a) (8+(a)*2)
-#define G_HW_Save_Register_Low(a)  (9+(a)*2)
 #define G_Save_Register(a) (12+(a)*2)
 #define G_Save_Register_High(a)(12+(a)*2)
 #define G_Save_Register_Low(a) (13+(a)*2)
-- 
2.3.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 083/107] staging: comedi: ni_stc.h: tidy up Joint_Status_2_Register and bits

2015-05-01 Thread H Hartley Sweeten
Rename the CamelCase. Use the BIT() macro to define the bits.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 8 
 drivers/staging/comedi/drivers/ni_stc.h| 8 +++-
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index cb4aed1..17646a2 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -425,7 +425,7 @@ static const struct mio_regmap m_series_stc_read_regmap[] = 
{
[NISTC_AO_UC_SAVE_REG]  = { 0x128, 4 },
[NISTC_STATUS1_REG] = { 0x136, 2 },
[NISTC_DIO_SERIAL_IN_REG]   = { 0x009, 1 },
-   [Joint_Status_2_Register]   = { 0x13a, 2 },
+   [NISTC_STATUS2_REG] = { 0x13a, 2 },
[AI_SI_Save_Registers]  = { 0x180, 4 },
[AI_SC_Save_Registers]  = { 0x184, 4 },
 };
@@ -2849,8 +2849,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) {
@@ -3727,7 +3727,7 @@ static const struct mio_regmap ni_gpct_to_stc_regmap[] = {
[NITIO_G01_STATUS]  = { NISTC_G01_STATUS_REG, 2 },
[NITIO_G01_RESET]   = { NISTC_RESET_REG, 2 },
[NITIO_G01_STATUS1] = { NISTC_STATUS1_REG, 2 },
-   [NITIO_G01_STATUS2] = { Joint_Status_2_Register, 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 */
diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index 509578c..cd4cf98 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -555,14 +555,12 @@
 
 #define NISTC_DIO_SERIAL_IN_REG28
 
+#define NISTC_STATUS2_REG  29
+#define NISTC_STATUS2_AO_TMRDACWRS_IN_PROGRESS BIT(5)
+
 #define AI_SI_Save_Registers   64
 #define AI_SC_Save_Registers   66
 
-#define Joint_Status_2_Register 29
-enum Joint_Status_2_Bits {
-   AO_TMRDACWRs_In_Progress_St = 0x20,
-};
-
 /* command register */
 #define G_Disarm_Copy  _bit15  /* strobe */
 #define G_Save_Trace_Copy  _bit14
-- 
2.3.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 089/107] staging: comedi: ni_stc.h: tidy up Misc_Command register and bits

2015-05-01 Thread H Hartley Sweeten
Rename the CamelCase. Use the BIT() macro to define the bits.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 2 +-
 drivers/staging/comedi/drivers/ni_stc.h| 6 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index 2f7d64d..06c491d 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -1620,7 +1620,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 |
diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index ffd435c..9cea344 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -577,7 +577,11 @@
 #define NI_E_SERIAL_CMD_SDATA  BIT(1)
 #define NI_E_SERIAL_CMD_SCLK   BIT(0)
 
-#define Misc_Command   0x0f
+#define NI_E_MISC_CMD_REG  0x0f/* w8 */
+#define NI_E_MISC_CMD_INTEXT_ATRIG(x)  (((x)  0x1)  7)
+#define NI_E_MISC_CMD_EXT_ATRIGNI_E_MISC_CMD_INTEXT_ATRIG(0)
+#define NI_E_MISC_CMD_INT_ATRIGNI_E_MISC_CMD_INTEXT_ATRIG(1)
+
 #define Port_A 0x19
 #define Port_B 0x1b
 #define Port_C 0x1d
-- 
2.3.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 095/107] staging: comedi: ni_stc.h: tidy up DAC_FIFO_Data register

2015-05-01 Thread H Hartley Sweeten
Rename the CamelCase.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 2 +-
 drivers/staging/comedi/drivers/ni_stc.h| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index 39e680e..b9e35ea 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -1032,7 +1032,7 @@ static void ni_ao_fifo_load(struct comedi_device *dev,
}
ni_writel(dev, packed_data, DAC_FIFO_Data_611x);
} else {
-   ni_writew(dev, d, DAC_FIFO_Data);
+   ni_writew(dev, d, NI_E_AO_FIFO_DATA_REG);
}
}
 }
diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index 486e6a0..2afa701 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -642,7 +642,7 @@ static inline unsigned GPCT_DMA_Select_Mask(unsigned 
gpct_index)
 
 #define NI_E_AI_FIFO_DATA_REG  0x1c/* r16 */
 
-#define DAC_FIFO_Data  0x1e
+#define NI_E_AO_FIFO_DATA_REG  0x1e/* w16 */
 #define DAC0_Direct_Data   0x18
 #define DAC1_Direct_Data   0x1a
 
-- 
2.3.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 075/107] staging: comedi: ni_stc.h: tidy up AI_Status_2_Register

2015-05-01 Thread H Hartley Sweeten
Rename the CamelCase.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 2 +-
 drivers/staging/comedi/drivers/ni_stc.h| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index a71a697..7b57937 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -413,7 +413,7 @@ static const struct mio_regmap m_series_stc_read_regmap[] = 
{
[NISTC_AI_STATUS1_REG]  = { 0x104, 2 },
[NISTC_AO_STATUS1_REG]  = { 0x106, 2 },
[NISTC_G01_STATUS_REG]  = { 0x108, 2 },
-   [AI_Status_2_Register]  = { 0, 0 }, /* Unknown */
+   [NISTC_AI_STATUS2_REG]  = { 0, 0 }, /* Unknown */
[AO_Status_2_Register]  = { 0x10c, 2 },
[DIO_Parallel_Input_Register]   = { 0, 0 }, /* Unknown */
[G_HW_Save_Register(0)] = { 0x110, 4 },
diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index 5950bab..2f72c47e 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -534,7 +534,7 @@
 
 #define NISTC_G01_STATUS_REG   4
 
-#define AI_Status_2_Register   5
+#define NISTC_AI_STATUS2_REG   5
 
 #define AO_Status_2_Register   6
 
-- 
2.3.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 085/107] staging: comedi: ni_stc.h: remove unused GPCT register bit defines

2015-05-01 Thread H Hartley Sweeten
The bit defines in this header for the GPCT registers are not used. The ones
in ni_tio_internal.h are used instead. Remove them from this header.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_stc.h | 68 -
 1 file changed, 68 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index da44951..45d8414 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -561,74 +561,6 @@
 #define NISTC_AI_SI_SAVE_REG   64
 #define NISTC_AI_SC_SAVE_REG   66
 
-/* command register */
-#define G_Disarm_Copy  _bit15  /* strobe */
-#define G_Save_Trace_Copy  _bit14
-#define G_Arm_Copy _bit13  /* strobe */
-#define G_Bank_Switch_Start_bit10  /* strobe */
-#define G_Little_Big_Endian_bit9
-#define G_Synchronized_Gate_bit8
-#define G_Write_Switch _bit7
-#define G_Up_Down(a)   (((a)0x03)5)
-#define G_Disarm   _bit4   /* strobe */
-#define G_Analog_Trigger_Reset _bit3   /* strobe */
-#define G_Save_Trace   _bit1
-#define G_Arm  _bit0   /* strobe */
-
-/*channel agnostic names for the command register #defines */
-#define G_Bank_Switch_Enable   _bit12
-#define G_Bank_Switch_Mode _bit11
-#define G_Load _bit2   /* strobe */
-
-/* input select register */
-#define G_Gate_Select(a)   (((a)0x1f)7)
-#define G_Source_Select(a) (((a)0x1f)2)
-#define G_Write_Acknowledges_Irq   _bit1
-#define G_Read_Acknowledges_Irq_bit0
-
-/* same input select register, but with channel agnostic names */
-#define G_Source_Polarity  _bit15
-#define G_Output_Polarity  _bit14
-#define G_OR_Gate  _bit13
-#define G_Gate_Select_Load_Source  _bit12
-
-/* mode register */
-#define G_Loading_On_TC_bit12
-#define G_Output_Mode(a)   (((a)0x03)8)
-#define G_Trigger_Mode_For_Edge_Gate(a)(((a)0x03)3)
-#define G_Gating_Mode(a)   (((a)0x03)0)
-
-/* same input mode register, but with channel agnostic names */
-#define G_Load_Source_Select   _bit7
-#define G_Reload_Source_Switching  _bit15
-#define G_Loading_On_Gate  _bit14
-#define G_Gate_Polarity_bit13
-
-#define G_Counting_Once(a) (((a)0x03)10)
-#define G_Stop_Mode(a) (((a)0x03)5)
-#define G_Gate_On_Both_Edges   _bit2
-
-/* G_Status_Register */
-#define G1_Gate_Error_St   _bit15
-#define G0_Gate_Error_St   _bit14
-#define G1_TC_Error_St _bit13
-#define G0_TC_Error_St _bit12
-#define G1_No_Load_Between_Gates_St_bit11
-#define G0_No_Load_Between_Gates_St_bit10
-#define G1_Armed_St_bit9
-#define G0_Armed_St_bit8
-#define G1_Stale_Data_St   _bit7
-#define G0_Stale_Data_St   _bit6
-#define G1_Next_Load_Source_St _bit5
-#define G0_Next_Load_Source_St _bit4
-#define G1_Counting_St _bit3
-#define G0_Counting_St _bit2
-#define G1_Save_St _bit1
-#define G0_Save_St _bit0
-
-/* general purpose counter timer */
-#define G_Autoincrement(a)  ((a)0)
-
 /* Additional windowed registers unique to E series */
 
 /* 16 bit registers shadowed from DAQ-STC */
-- 
2.3.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 091/107] staging: comedi: ni_stc.h: tidy up ADC_FIFO_Data_Register

2015-05-01 Thread H Hartley Sweeten
Rename the CamelCase.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 6 +++---
 drivers/staging/comedi/drivers/ni_stc.h| 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index 202957c..74817f8 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -1154,7 +1154,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);
}
@@ -1230,7 +1230,7 @@ static void ni_handle_fifo_dregs(struct comedi_device 
*dev)
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);
}
@@ -2006,7 +2006,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;
}
diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index 3bf73a7..ea5999c 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -637,7 +637,7 @@ static inline unsigned int AI_CONFIG_CHANNEL(unsigned int 
channel)
 
 #define NI_E_8255_BASE 0x19/* rw8 */
 
-#define ADC_FIFO_Data_Register 0x1c
+#define NI_E_AI_FIFO_DATA_REG  0x1c/* r16 */
 
 #define AO_Configuration   0x16
 #define AO_Bipolar _bit0
-- 
2.3.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 087/107] staging: comedi: ni_stc.h: tidy up XXX_Status register and bits

2015-05-01 Thread H Hartley Sweeten
Rename the CamelCase. Use the BIT() macro to define the bits.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c |  7 ---
 drivers/staging/comedi/drivers/ni_stc.h| 10 +++---
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index 518c033..b4a8a4c 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -1248,7 +1248,7 @@ 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) {
+   if (ni_readb(dev, NI_E_STATUS_REG)  0x80) {
dl = ni_readl(dev, ADC_FIFO_Data_611x);
data = dl  0x;
comedi_buf_write_samples(s, data, 1);
@@ -1946,7 +1946,7 @@ 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) {
+   if (ni_readb(dev, NI_E_STATUS_REG)  0x80) {
d = ni_readl(dev, ADC_FIFO_Data_611x);
d = 16;
d = 0x;
@@ -4258,7 +4258,8 @@ static int ni_read_eeprom(struct comedi_device *dev, int 
addr)
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);
+   if (ni_readb(dev, NI_E_STATUS_REG)  NI_E_STATUS_PROMOUT)
+   bitstring |= bit;
}
ni_writeb(dev, 0x00, Serial_Command);
 
diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index ac9261a..643f3c2 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -567,14 +567,10 @@
 #define NI_E_STC_WINDOW_ADDR_REG   0x00/* rw16 */
 #define NI_E_STC_WINDOW_DATA_REG   0x02/* rw16 */
 
-/* i/o port offsets */
+#define NI_E_STATUS_REG0x01/* r8 */
+#define NI_E_STATUS_AI_FIFO_LOWER_NE   BIT(3)
+#define NI_E_STATUS_PROMOUTBIT(0)
 
-/* 8 bit registers */
-#define XXX_Status 0x01
-enum XXX_Status_Bits {
-   PROMOUT = 0x1,
-   AI_FIFO_LOWER_NOT_EMPTY = 0x8,
-};
 #define Serial_Command 0x0d
 #define Misc_Command   0x0f
 #define Port_A 0x19
-- 
2.3.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 092/107] staging: comedi: ni_stc.h: tidy up Configuration_Memory_Low register and bits

2015-05-01 Thread H Hartley Sweeten
Rename the CamelCase. Use the BIT() macro to define the bits.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c |  9 +
 drivers/staging/comedi/drivers/ni_stc.h| 12 ++--
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index 74817f8..0fba36d 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -1902,13 +1902,14 @@ static void ni_load_channelgain_list(struct 
comedi_device *dev,
ni_writew(dev, hi, Configuration_Memory_High);
 
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);
}
}
 
diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index ea5999c..8abf78d 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -616,13 +616,13 @@ static inline unsigned GPCT_DMA_Select_Mask(unsigned 
gpct_index)
return 0xf  (4 * gpct_index);
 }
 
-/* 16 bit registers */
+#define NI_E_AI_CFG_LO_REG 0x10/* w16 */
+#define NI_E_AI_CFG_LO_LAST_CHAN   BIT(15)
+#define NI_E_AI_CFG_LO_GEN_TRIGBIT(12)
+#define NI_E_AI_CFG_LO_DITHER  BIT(9)
+#define NI_E_AI_CFG_LO_UNI BIT(8)
+#define NI_E_AI_CFG_LO_GAIN(x) ((x)  0)
 
-#define Configuration_Memory_Low   0x10
-enum Configuration_Memory_Low_Bits {
-   AI_DITHER = 0x200,
-   AI_LAST_CHANNEL = 0x8000,
-};
 #define Configuration_Memory_High  0x12
 enum Configuration_Memory_High_Bits {
AI_AC_COUPLE = 0x800,
-- 
2.3.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 105/107] staging: comedi: ni_stc.h: tidy up the cs5529_command_bits

2015-05-01 Thread H Hartley Sweeten
For aesthetics, convert the enum into defines. Use the BIT() macro
to define the bits.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 12 ++--
 drivers/staging/comedi/drivers/ni_stc.h| 25 ++---
 2 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index 8a484fb..33f01e1 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -4512,7 +4512,7 @@ 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,
@@ -4572,8 +4572,8 @@ static void cs5529_config_write(struct comedi_device 
*dev, unsigned int value,
   CAL_ADC_Config_Data_High_Word_67xx);
ni_ao_win_outw(dev, (value  0x),
   CAL_ADC_Config_Data_Low_Word_67xx);
-   reg_select_bits = CSCMD_REGISTER_SELECT_MASK;
-   cs5529_command(dev, CSCMD_COMMAND | reg_select_bits);
+   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__);
@@ -4587,14 +4587,14 @@ static int init_cs5529(struct comedi_device *dev)
 #if 1
/* do self-calibration */
cs5529_config_write(dev, config_bits | CS5529_CFG_CALIB_BOTH_SELF,
-   CSCMD_CONFIG_REGISTER);
+   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, 0x40, CSCMD_GAIN_REGISTER);
+   cs5529_config_write(dev, 0x40, CS5529_GAIN_REG);
cs5529_config_write(dev, config_bits | CS5529_CFG_CALIB_OFFSET_SELF,
-   CSCMD_CONFIG_REGISTER);
+   CS5529_CFG_REG);
if (cs5529_wait_for_idle(dev))
dev_err(dev-class_dev,
timeout or signal in %s\n, __func__);
diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index 3d1fd9b..0013e30 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -677,6 +677,20 @@ enum AO_Misc_611x_Bits {
CLEAR_WG = 1,
 };
 
+#define CS5529_CMD_CB  BIT(7)
+#define CS5529_CMD_SINGLE_CONV BIT(6)
+#define CS5529_CMD_CONT_CONV   BIT(5)
+#define CS5529_CMD_READBIT(4)
+#define CS5529_CMD_REG(x)  (((x)  0x7)  1)
+#define CS5529_CMD_REG_MASKCS5529_CMD_REG(7)
+#define CS5529_CMD_PWR_SAVEBIT(0)
+
+#define CS5529_OFFSET_REG  CS5529_CMD_REG(0)
+#define CS5529_GAIN_REGCS5529_CMD_REG(1)
+#define CS5529_CONV_DATA_REG   CS5529_CMD_REG(3)
+#define CS5529_SETUP_REG   CS5529_CMD_REG(4)
+
+#define CS5529_CFG_REG CS5529_CMD_REG(2)
 #define CS5529_CFG_AOUT(x) BIT(22 + (x))
 #define CS5529_CFG_DOUT(x) BIT(18 + (x))
 #define CS5529_CFG_LOW_PWR_MODEBIT(16)
@@ -704,17 +718,6 @@ enum AO_Misc_611x_Bits {
 #define CS5529_CFG_CALIB_OFFSET_SYSCS5529_CFG_CALIB(5)
 #define CS5529_CFG_CALIB_GAIN_SYS  CS5529_CFG_CALIB(6)
 
-enum cs5529_command_bits {
-   CSCMD_POWER_SAVE = 0x1,
-   CSCMD_REGISTER_SELECT_MASK = 0xe,
-   CSCMD_OFFSET_REGISTER = 0x0,
-   CSCMD_GAIN_REGISTER = 0x2,
-   CSCMD_CONFIG_REGISTER = 0x4,
-   CSCMD_READ = 0x10,
-   CSCMD_CONTINUOUS_CONVERSIONS = 0x20,
-   CSCMD_SINGLE_CONVERSION = 0x40,
-   CSCMD_COMMAND = 0x80,
-};
 enum cs5529_status_bits {
CSS_ADC_BUSY = 0x1,
CSS_OSC_DETECT = 0x2,   /* indicates adc error */
-- 
2.3.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 079/107] staging: comedi: ni_stc.h: tidy up G_Save_Register

2015-05-01 Thread H Hartley Sweeten
Rename the CamelCase and define the G0 and G1 registers to add clarity
to the mio_regmap tables.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 8 
 drivers/staging/comedi/drivers/ni_stc.h| 7 +++
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index f0f449c..9cd796c 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -418,8 +418,8 @@ static const struct mio_regmap m_series_stc_read_regmap[] = 
{
[NISTC_DIO_IN_REG]  = { 0, 0 }, /* Unknown */
[NISTC_G0_HW_SAVE_REG]  = { 0x110, 4 },
[NISTC_G1_HW_SAVE_REG]  = { 0x114, 4 },
-   [G_Save_Register(0)]= { 0x118, 4 },
-   [G_Save_Register(1)]= { 0x11c, 4 },
+   [NISTC_G0_SAVE_REG] = { 0x118, 4 },
+   [NISTC_G1_SAVE_REG] = { 0x11c, 4 },
[AO_UI_Save_Registers]  = { 0x120, 4 },
[AO_BC_Save_Registers]  = { 0x124, 4 },
[AO_UC_Save_Registers]  = { 0x128, 4 },
@@ -3708,8 +3708,8 @@ static const struct mio_regmap ni_gpct_to_stc_regmap[] = {
[NITIO_G1_CMD]  = { NISTC_G1_CMD_REG, 2 },
[NITIO_G0_HW_SAVE]  = { NISTC_G0_HW_SAVE_REG, 4 },
[NITIO_G1_HW_SAVE]  = { NISTC_G1_HW_SAVE_REG, 4 },
-   [NITIO_G0_SW_SAVE]  = { G_Save_Register(0), 4 },
-   [NITIO_G1_SW_SAVE]  = { G_Save_Register(1), 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 },
diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index 0b4dcc4..ff57721 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -543,6 +543,9 @@
 #define NISTC_G0_HW_SAVE_REG   8
 #define NISTC_G1_HW_SAVE_REG   10
 
+#define NISTC_G0_SAVE_REG  12
+#define NISTC_G1_SAVE_REG  14
+
 #define AI_SI_Save_Registers   64
 #define AI_SC_Save_Registers   66
 
@@ -559,10 +562,6 @@ enum Joint_Status_2_Bits {
 #define AO_BC_Save_Registers   18
 #define AO_UC_Save_Registers   20
 
-#define G_Save_Register(a) (12+(a)*2)
-#define G_Save_Register_High(a)(12+(a)*2)
-#define G_Save_Register_Low(a) (13+(a)*2)
-
 /* command register */
 #define G_Disarm_Copy  _bit15  /* strobe */
 #define G_Save_Trace_Copy  _bit14
-- 
2.3.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 086/107] staging: comedi: ni_stc.h: tidy up Window_{Address, Data} defines

2015-05-01 Thread H Hartley Sweeten
Rename the CamelCase.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c |  8 
 drivers/staging/comedi/drivers/ni_stc.h| 10 +-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index 8dda682..518c033 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -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);
}
diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index 45d8414..ac9261a 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -561,11 +561,11 @@
 #define NISTC_AI_SI_SAVE_REG   64
 #define NISTC_AI_SC_SAVE_REG   66
 
-/* Additional windowed registers unique to E series */
-
-/* 16 bit registers shadowed from DAQ-STC */
-#define Window_Address 0x00
-#define Window_Data0x02
+/*
+ * PCI E Series Registers
+ */
+#define NI_E_STC_WINDOW_ADDR_REG   0x00/* rw16 */
+#define NI_E_STC_WINDOW_DATA_REG   0x02/* rw16 */
 
 /* i/o port offsets */
 
-- 
2.3.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 097/107] staging: comedi: ni_mio_common: remove BUG_ON(gpct_index ...) checks

2015-05-01 Thread H Hartley Sweeten
The gpct_index will always be 0 or 1. Remove the unnecessary BUG_ON()
checks.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 2 --
 drivers/staging/comedi/drivers/ni_stc.h| 2 --
 2 files changed, 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index 4a94bc3..2e1fde3 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -686,7 +686,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 +769,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 =
diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index 23cc490..9ce4c56 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -605,14 +605,12 @@ static inline unsigned 
ni_stc_dma_channel_select_bitfield(unsigned channel)
 static inline unsigned GPCT_DMA_Select_Bits(unsigned gpct_index,
unsigned mite_channel)
 {
-   BUG_ON(gpct_index  1);
return ni_stc_dma_channel_select_bitfield(mite_channel)  (4 *
gpct_index);
 }
 
 static inline unsigned GPCT_DMA_Select_Mask(unsigned gpct_index)
 {
-   BUG_ON(gpct_index  1);
return 0xf  (4 * gpct_index);
 }
 
-- 
2.3.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [HPDD-discuss] [PATCH 2/11] Staging: lustre: fld: Use kzalloc and kfree

2015-05-01 Thread Simmons, James A.
 Yes the LARGE functions do the switching. I was expecting also patches to 
 remove the 
 OBD_ALLOC_LARGE functions as well which is not the case here.  I do have one 
 question still. The
 macro __OBD_MALLOC_VERBOSE allowed the ability to simulate memory allocation 
 failures at
 a certain percentage rate. Does something exist in the kernel to duplicate 
 that functionality?
 Once these macros are gone we lose the ability to simulate high memory 
 allocation failures.

Yes, there are things like https://lkml.org/lkml/2014/12/25/64
So I think the API is even riher compared to what our old wrapper code was 
able to do.

We should look to integrating that into the test suite.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 063/107] staging: comedi: ni_stc.h: tidy up Interrupt_B_Enable_Register and bits

2015-05-01 Thread H Hartley Sweeten
Rename the CamelCase. Use the BIT() macro to define the bits.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 30 +-
 drivers/staging/comedi/drivers/ni_stc.h| 28 
 2 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index 0e7075d..24d2704 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -368,7 +368,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] 
= {
[NISTC_RESET_REG]   = { 0x190, 2 },
[NISTC_INTA_ENA_REG]= { 0x192, 2 },
[NISTC_INTA2_ENA_REG]   = { 0, 0 }, /* E-Series only */
-   [Interrupt_B_Enable_Register]   = { 0x196, 2 },
+   [NISTC_INTB_ENA_REG]= { 0x196, 2 },
[Second_IRQ_B_Enable_Register]  = { 0, 0 }, /* E-Series only */
[AI_Personal_Register]  = { 0x19a, 2 },
[AO_Personal_Register]  = { 0x19c, 2 },
@@ -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);
@@ -1490,9 +1490,9 @@ static void handle_b_interrupt(struct comedi_device *dev,
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;
}
}
@@ -2831,9 +2831,9 @@ 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);
if (devpriv-is_6xxx)
@@ -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,
@@ -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 |
@@ -3092,8 +3092,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,7 +3192,7 @@ 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_set_bits(dev, NISTC_INTB_ENA_REG, ~0, 0);
ni_stc_writew(dev, AO_BC_Source_Select, AO_Personal_Register);
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 |
@@ -3742,7 +3742,7 @@ static const struct mio_regmap ni_gpct_to_stc_regmap[] = {
[NITIO_G0_STATUS]   = { 

[PATCH 068/107] staging: comedi: ni_stc.h: tidy up RTSI_Board_Register

2015-05-01 Thread H Hartley Sweeten
Rename the CamelCase.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 10 +-
 drivers/staging/comedi/drivers/ni_stc.h|  3 ++-
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index a29ee9e..3334c54 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -374,7 +374,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] 
= {
[NISTC_AO_PERSONAL_REG] = { 0x19c, 2 },
[NISTC_RTSI_TRIGA_OUT_REG]  = { 0x19e, 2 },
[NISTC_RTSI_TRIGB_OUT_REG]  = { 0x1a0, 2 },
-   [RTSI_Board_Register]   = { 0, 0 }, /* Unknown */
+   [NISTC_RTSI_BOARD_REG]  = { 0, 0 }, /* Unknown */
[Configuration_Memory_Clear]= { 0x1a4, 2 },
[ADC_FIFO_Clear]= { 0x1a6, 2 },
[DAC_FIFO_Clear]= { 0x1a8, 2 },
@@ -4935,10 +4935,10 @@ static void ni_rtsi_init(struct comedi_device *dev)
ni_stc_writew(dev, devpriv-rtsi_trig_b_output_reg,
  NISTC_RTSI_TRIGB_OUT_REG);
 
-/*
-* Sets the source and direction of the 4 on board lines
-* ni_stc_writew(dev, 0x, 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
diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index 88ffdf0..123cde6 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -455,6 +455,8 @@
 #define NISTC_RTSI_TRIG_MASK(_c)   NISTC_RTSI_TRIG((_c), 0xf)
 #define NISTC_RTSI_TRIG_TO_SRC(_c, _b) (((_b)  (((_c) % 4) * 4))  0xf)
 
+#define NISTC_RTSI_BOARD_REG   81
+
 #define AI_Status_1_Register   2
 #define Interrupt_A_St 0x8000
 #define AI_FIFO_Full_St0x4000
@@ -513,7 +515,6 @@ enum Joint_Status_2_Bits {
 #define AO_BC_Save_Registers   18
 #define AO_UC_Save_Registers   20
 
-#defineRTSI_Board_Register 81
 #define Write_Strobe_0_Register82
 #define Write_Strobe_1_Register83
 #define Write_Strobe_2_Register84
-- 
2.3.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [HPDD-discuss] [PATCH 2/11] Staging: lustre: fld: Use kzalloc and kfree

2015-05-01 Thread Simmons, James A.
 Yes the LARGE functions do the switching. I was expecting also patches to 
 remove the 
 OBD_ALLOC_LARGE functions as well which is not the case here.  I do have one 
 question still. The
 macro __OBD_MALLOC_VERBOSE allowed the ability to simulate memory allocation 
 failures at
 a certain percentage rate. Does something exist in the kernel to duplicate 
 that functionality?

Yes, no need for lustre to duplicate yet-another-thing the kernel
already provides :)

The reason for this is that libcfs was written 10+ years ago which was before 
linux had such nice
features. At that time it was needed to fill the gaps missing which is no 
longer the case. Libcfs is
really showing its age :-)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: media: omap4iss: Constify platform_device_id

2015-05-01 Thread Laurent Pinchart
Hi Krzysztof,

Thank you for the patch.

On Saturday 02 May 2015 00:43:07 Krzysztof Kozlowski wrote:
 The platform_device_id is not modified by the driver and core uses it as
 const.
 
 Signed-off-by: Krzysztof Kozlowski k.kozlowsk...@gmail.com

Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com

and applied to my tree. I'll send a pull request for v4.2.

 ---
  drivers/staging/media/omap4iss/iss.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/staging/media/omap4iss/iss.c
 b/drivers/staging/media/omap4iss/iss.c index e0ad5e520e2d..68867f286afd
 100644
 --- a/drivers/staging/media/omap4iss/iss.c
 +++ b/drivers/staging/media/omap4iss/iss.c
 @@ -1478,7 +1478,7 @@ static int iss_remove(struct platform_device *pdev)
   return 0;
  }
 
 -static struct platform_device_id omap4iss_id_table[] = {
 +static const struct platform_device_id omap4iss_id_table[] = {
   { omap4iss, 0 },
   { },
  };

-- 
Regards,

Laurent Pinchart

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [HPDD-discuss] [PATCH 2/11] Staging: lustre: fld: Use kzalloc and kfree

2015-05-01 Thread Simmons, James A.
 We are hopefully going to get rid of OBD_ALLOC_LARGE() as well, though.
 
 It's simple enough to write a function:
 
 void *obd_zalloc(size_t size)
 {
 if (size  4 * PAGE_CACHE_SIZE)
 return vzalloc(size);
 else
 return kmalloc(size, GFP_NOFS);
 }
 
 Except, huh?  Shouldn't we be using GFP_NOFS for the vzalloc() side?
 There was some discussion of that GFP_NOFS was a bit buggy back in 2010
 (http://marc.info/?l=linux-mmm=128942194520631w=4) but the current
 lustre code doesn't try to pass GFP_NOFS.
 
 The version in the upstream client is out of date. The current macro in the 
 Intel master
 Branch is:

That's not helpful at all, why do we even have an in-kernel version of
this code if you don't do your development in the kernel?

Please sync with the kernel tree very soon, or I'm just going to delete
this whole thing.  This is getting _really_ frustrating.

First I want to make it clear I am here to help clean up the upstream client. I 
agree in the long run
it is important to move the development to what is in the upstream kernel but 
their is reason why
current development is not focus in the upstream client. 

   As the primary engineer responsible for the deployment of Lustre at ORNL 
I have to ensure
Lustre runs flawlessly. There is zero tolerance of problems or even the 
slightest performance
degradation. Trust me the users scream even when 1% performance is lost. The 
amazing 
thing is we have less then 1% down time during the year. To do this I have to 
perform hundreds
of hours of testing at various scales for various versions of Lustre. This 
includes taking time on Titan.
So what does this have to do with upstream testing. Well no super computer in 
the world runs the 
latest and greatest linux kernel so the focus is just not there. Luckily the 
lab does see it is in its interest
to support the upstream client work otherwise I wouldn't be here :-)
  Second and far more importantly the upstream lustre code currently does 
not have the same 
level of QA with what the Intel branch gets.  The bar is very very high to get 
any patch merged for the
Intel branch. Each patch has to first pass a regression test suite besides the 
normal review process.
Besides that sites like ORNL have to evaluated all the changes at all the 
scales present on site. This
means doing testing on Titan because unique problems only show up at that 
scale. Because of this
the work that will soon come your way has to be first evaluated on the Intel 
branch since this is the
current path for QA. You can think of the intel branch as a lustre-next branch 
that needs to be feed back
too your branch. Eventually your branch will have to under go this level of QA 
but we are not quite
their yet.

 Now I like to see the current situation change and Greg you have know me 
for a while so you 
can expect a lot of changes are coming.  In fact I already have rallied people 
from vendors outside Intel
as well as universities which have done some excellent work which you will soon 
see. Now I hope this
is the last email I do like this. Instead I just want to send you patches. Greg 
I think the changes you will
see soon will remove your frustration.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 073/107] staging: comedi: ni_stc.h: tidy up AO_Status_1_Register and bits

2015-05-01 Thread H Hartley Sweeten
Rename the CamelCase. Use the BIT() marco to define the bits.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 32 +++
 drivers/staging/comedi/drivers/ni_stc.h| 36 +-
 2 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index 50a14d2..d7a7232 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -411,7 +411,7 @@ static void m_series_stc_write(struct comedi_device *dev,
 
 static const struct mio_regmap m_series_stc_read_regmap[] = {
[NISTC_AI_STATUS1_REG]  = { 0x104, 2 },
-   [AO_Status_1_Register]  = { 0x106, 2 },
+   [NISTC_AO_STATUS1_REG]  = { 0x106, 2 },
[G_Status_Register] = { 0x108, 2 },
[AI_Status_2_Register]  = { 0, 0 }, /* Unknown */
[AO_Status_2_Register]  = { 0x10c, 2 },
@@ -994,8 +994,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 */
@@ -1428,19 +1428,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);
@@ -1472,18 +1472,18 @@ static void handle_b_interrupt(struct comedi_device 
*dev,
 
if (b_status == 0x)
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));
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);
@@ -3736,7 +3736,7 @@ static const struct mio_regmap ni_gpct_to_stc_regmap[] = {
[NITIO_G0_INT_ACK]  = { NISTC_INTA_ACK_REG, 2 },
[NITIO_G1_INT_ACK]  = { NISTC_INTB_ACK_REG, 2 },
[NITIO_G0_STATUS]   = { NISTC_AI_STATUS1_REG, 2 },
-   [NITIO_G1_STATUS]   = { AO_Status_1_Register, 2 },
+   [NITIO_G1_STATUS]   = { NISTC_AO_STATUS1_REG, 2 },
[NITIO_G0_INT_ENA]  = { NISTC_INTA_ENA_REG, 2 },
[NITIO_G1_INT_ENA]  = { NISTC_INTB_ENA_REG, 2 },
 };
@@ -4992,7 +4992,7 @@ 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, NISTC_AI_STATUS1_REG);
-   b_status = ni_stc_readw(dev, AO_Status_1_Register);
+   b_status = ni_stc_readw(dev, NISTC_AO_STATUS1_REG);
 #ifdef PCIDMA
if (mite) {
struct ni_private *devpriv = dev-private;
@@ -5022,7 +5022,7 @@ static irqreturn_t ni_E_interrupt(int irq, void *d)
ack_b_interrupt(dev, b_status);
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) || 

[PATCH 065/107] staging: comedi: ni_stc.h: tidy up AI_Personal_Register and bits

2015-05-01 Thread H Hartley Sweeten
Rename the CamelCase. Use the BIT() macro to define the bits.

Tidy up ni_ai_reset() by using a local var to set the common bits and
programming the register in the common code path.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 25 ---
 drivers/staging/comedi/drivers/ni_stc.h| 28 +-
 2 files changed, 22 insertions(+), 31 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index 3123fb9..5e0c527 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -370,7 +370,7 @@ static const struct mio_regmap m_series_stc_write_regmap[] 
= {
[NISTC_INTA2_ENA_REG]   = { 0, 0 }, /* E-Series only */
[NISTC_INTB_ENA_REG]= { 0x196, 2 },
[NISTC_INTB2_ENA_REG]   = { 0, 0 }, /* E-Series only */
-   [AI_Personal_Register]  = { 0x19a, 2 },
+   [NISTC_AI_PERSONAL_REG] = { 0x19a, 2 },
[AO_Personal_Register]  = { 0x19c, 2 },
[RTSI_Trig_A_Output_Register]   = { 0x19e, 2 },
[RTSI_Trig_B_Output_Register]   = { 0x1a0, 2 },
@@ -1608,6 +1608,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);
@@ -1631,35 +1632,25 @@ static int ni_ai_reset(struct comedi_device *dev, 
struct comedi_subdevice *s)
/* generate FIFO interrupts on non-empty */
ni_stc_writew(dev, (0  6) | 0x, AI_Mode_3_Register);
 
+   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
@@ -1667,7 +1658,7 @@ static int ni_ai_reset(struct comedi_device *dev, struct 
comedi_subdevice *s)
 * any of these, add a backup register and other appropriate code:
 *  NISTC_AI_MODE1_REG
 *  AI_Mode_3_Register
-*  AI_Personal_Register
+*  NISTC_AI_PERSONAL_REG
 *  NISTC_AI_OUT_CTRL_REG
 */
 
diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index a890243..27f21fa 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -419,6 +419,20 @@
 #define NISTC_INTB_ENA_AO_START1   BIT(1)
 #define NISTC_INTB_ENA_AO_BC_TCBIT(0)
 
+#define NISTC_AI_PERSONAL_REG  77
+#define NISTC_AI_PERSONAL_SHIFTIN_PW   BIT(15)
+#define NISTC_AI_PERSONAL_EOC_POLARITY BIT(14)
+#define NISTC_AI_PERSONAL_SOC_POLARITY BIT(13)
+#define NISTC_AI_PERSONAL_SHIFTIN_POL  BIT(12)
+#define NISTC_AI_PERSONAL_CONVERT_TIMEBASE BIT(11)
+#define NISTC_AI_PERSONAL_CONVERT_PW   BIT(10)
+#define NISTC_AI_PERSONAL_CONVERT_ORIG_PULSE   BIT(9)
+#define NISTC_AI_PERSONAL_FIFO_FLAGS_POL   BIT(8)
+#define 

[PATCH 069/107] staging: comedi: ni_stc.h: tidy up Write_Strobe_*_Register

2015-05-01 Thread H Hartley Sweeten
The Write_Strobe_*_Register defines are noy used. Instead the more
descriptive Configuration_Memory_Clear, ADC_FIFO_Clear and DAC_FIFO_Clear
defines are used. Remove the unused defines and rename the CamelCase.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 18 +-
 drivers/staging/comedi/drivers/ni_stc.h| 14 +-
 2 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index 3334c54..2229006 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -375,9 +375,9 @@ static const struct mio_regmap m_series_stc_write_regmap[] 
= {
[NISTC_RTSI_TRIGA_OUT_REG]  = { 0x19e, 2 },
[NISTC_RTSI_TRIGB_OUT_REG]  = { 0x1a0, 2 },
[NISTC_RTSI_BOARD_REG]  = { 0, 0 }, /* Unknown */
-   [Configuration_Memory_Clear]= { 0x1a4, 2 },
-   [ADC_FIFO_Clear]= { 0x1a6, 2 },
-   [DAC_FIFO_Clear]= { 0x1a8, 2 },
+   [NISTC_CFG_MEM_CLR_REG] = { 0x1a4, 2 },
+   [NISTC_ADC_FIFO_CLR_REG]= { 0x1a6, 2 },
+   [NISTC_DAC_FIFO_CLR_REG]= { 0x1a8, 2 },
[AO_Output_Control_Register]= { 0x1ac, 2 },
[AI_Mode_3_Register]= { 0x1ae, 2 },
 };
@@ -849,7 +849,7 @@ static void ni_clear_ai_fifo(struct comedi_device *dev)
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));
@@ -1084,7 +1084,7 @@ 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);
 
@@ -1696,7 +1696,7 @@ static void ni_prime_channelgain_list(struct 
comedi_device *dev)
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);
+   ni_stc_writew(dev, 1, NISTC_ADC_FIFO_CLR_REG);
return;
}
udelay(1);
@@ -1715,7 +1715,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;
@@ -1830,7 +1830,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) {
@@ -2826,7 +2826,7 @@ static int ni_ao_inttrig(struct comedi_device *dev,
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);
ret = ni_ao_setup_MITE_dma(dev);
diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index 123cde6..2501df8 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -457,6 +457,11 @@
 
 #define NISTC_RTSI_BOARD_REG   81
 
+#define NISTC_CFG_MEM_CLR_REG  82
+#define NISTC_ADC_FIFO_CLR_REG 83
+#define NISTC_DAC_FIFO_CLR_REG 84
+#define NISTC_WR_STROBE3_REG   85
+
 #define AI_Status_1_Register   2
 #define Interrupt_A_St 0x8000
 #define AI_FIFO_Full_St0x4000
@@ -515,11 +520,6 @@ enum Joint_Status_2_Bits {
 #define AO_BC_Save_Registers   18
 #define AO_UC_Save_Registers   20
 
-#define Write_Strobe_0_Register82
-#define Write_Strobe_1_Register83
-#define Write_Strobe_2_Register84
-#define Write_Strobe_3_Register85
-
 #define AO_Output_Control_Register 86
 #define AO_External_Gate_Enable

[PATCH 103/107] staging: comedi: ni_stc.h: rename the NI-6143 register defines

2015-05-01 Thread H Hartley Sweeten
Rename the CamelCase.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 54 ---
 drivers/staging/comedi/drivers/ni_pcimio.c | 15 +++
 drivers/staging/comedi/drivers/ni_stc.h| 60 +-
 3 files changed, 66 insertions(+), 63 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index e50eb9a..802aabf 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -843,11 +843,11 @@ 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);
}
@@ -1134,7 +1134,7 @@ static void ni_ai_fifo_read(struct comedi_device *dev,
} 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)  0x;
comedi_buf_write_samples(s, data, 1);
@@ -1144,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)  0x;
comedi_buf_write_samples(s, data, 1);
}
@@ -1202,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;
@@ -1213,10 +1213,10 @@ 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)  0x;
comedi_buf_write_samples(s, data, 1);
}
@@ -1271,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)  0x;
@@ -1843,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,
- 

[PATCH 094/107] staging: comedi: ni_stc.h: tidy up AO_Configuration register and bits

2015-05-01 Thread H Hartley Sweeten
Rename the CamelCase. Use the BIT() macro to define the bits.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 16 
 drivers/staging/comedi/drivers/ni_stc.h| 14 +++---
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index 64c44a1..39e680e 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -2675,27 +2675,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;
@@ -3698,7 +3698,7 @@ 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,
+   ni_ao_win_outw(dev, NI_E_AO_DACSEL(i) | 0x0,
   AO_Configuration_2_67xx);
}
ni_ao_win_outw(dev, 0x0, AO_Later_Single_Point_Updates);
diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index 14e4351..486e6a0 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -631,17 +631,17 @@ static inline unsigned GPCT_DMA_Select_Mask(unsigned 
gpct_index)
 #define NI_E_AI_CFG_HI_AC_COUPLE   BIT(11)
 #define NI_E_AI_CFG_HI_CHAN(x) (((x)  0x3f)  0)
 
+#define NI_E_AO_CFG_REG0x16/* w16 */
+#define NI_E_AO_DACSEL(x)  ((x)  8)
+#define NI_E_AO_GROUND_REF BIT(3)
+#define NI_E_AO_EXT_REFBIT(2)
+#define NI_E_AO_DEGLITCH   BIT(1)
+#define NI_E_AO_CFG_BIPBIT(0)
+
 #define NI_E_8255_BASE 0x19/* rw8 */
 
 #define NI_E_AI_FIFO_DATA_REG  0x1c/* r16 */
 
-#define AO_Configuration   0x16
-#define AO_Bipolar _bit0
-#define AO_Deglitch_bit1
-#define AO_Ext_Ref _bit2
-#define AO_Ground_Ref  _bit3
-#define AO_Channel(x)  ((x)  8)
-
 #define DAC_FIFO_Data  0x1e
 #define DAC0_Direct_Data   0x18
 #define DAC1_Direct_Data   0x1a
-- 
2.3.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 101/107] staging: comedi: ni_stc.h: remove unused _bit* defines

2015-05-01 Thread H Hartley Sweeten
Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_stc.h | 17 -
 1 file changed, 17 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index dc95e6a..4f4a902 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -26,23 +26,6 @@
 
 #include ni_tio.h
 
-#define _bit15 0x8000
-#define _bit14 0x4000
-#define _bit13 0x2000
-#define _bit12 0x1000
-#define _bit11 0x0800
-#define _bit10 0x0400
-#define _bit9  0x0200
-#define _bit8  0x0100
-#define _bit7  0x0080
-#define _bit6  0x0040
-#define _bit5  0x0020
-#define _bit4  0x0010
-#define _bit3  0x0008
-#define _bit2  0x0004
-#define _bit1  0x0002
-#define _bit0  0x0001
-
 #define NUM_PFI_OUTPUT_SELECT_REGS 6
 
 /*
-- 
2.3.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 099/107] staging: comedi: ni_stc.h: tidy up G0_G1_Select register and bits

2015-05-01 Thread H Hartley Sweeten
Rename the CamelCase. Convert the inline helper functions into macros.

Tidy up the driver code to use the new macros. For consistency, make
the ni_set_gpct_dma_channel() helper follow the same style as the
ni_set_ai_dma_channel() and ni_set_ao_dma_channel() helpers.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 22 +++---
 drivers/staging/comedi/drivers/ni_stc.h| 17 -
 2 files changed, 15 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index 7dfa382..cfb5f34 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -551,7 +551,7 @@ static inline void ni_set_bitfield(struct comedi_device 
*dev, int reg,
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);
@@ -592,19 +592,19 @@ static inline void ni_set_ao_dma_channel(struct 
comedi_device *dev, int channel)
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 */
@@ -5370,7 +5370,7 @@ static int ni_E_init(struct comedi_device *dev,
 
/* DMA setup */
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);
+   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);
diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index 2db29a1..e181d91 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -577,6 +577,10 @@
 #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_DMA_G0_G1_SEL_REG 0x0b/* w8 */
+#define NI_E_DMA_G0_G1_SEL(_g, _c) (((_c)  0xf)  ((_g) * 4))
+#define NI_E_DMA_G0_G1_SEL_MASK(_g)NI_E_DMA_G0_G1_SEL((_g), 0xf)
+
 #define NI_E_SERIAL_CMD_REG0x0d/* w8 */
 #define NI_E_SERIAL_CMD_DAC_LD(x)  BIT(3 + (x))
 #define NI_E_SERIAL_CMD_EEPROM_CS  BIT(2)
@@ -588,7 +592,6 @@
 #define NI_E_MISC_CMD_EXT_ATRIGNI_E_MISC_CMD_INTEXT_ATRIG(0)
 #define NI_E_MISC_CMD_INT_ATRIGNI_E_MISC_CMD_INTEXT_ATRIG(1)
 
-#define G0_G1_Select   0x0b
 static inline unsigned ni_stc_dma_channel_select_bitfield(unsigned channel)
 {
if (channel  4)
@@ -601,18 +604,6 @@ static inline unsigned 
ni_stc_dma_channel_select_bitfield(unsigned channel)
return 0;
 }
 
-static inline unsigned GPCT_DMA_Select_Bits(unsigned gpct_index,
-   unsigned mite_channel)
-{
-   return ni_stc_dma_channel_select_bitfield(mite_channel)  (4 *
-   gpct_index);
-}
-
-static inline unsigned GPCT_DMA_Select_Mask(unsigned gpct_index)
-{
-   return 0xf  (4 * gpct_index);
-}
-
 #define NI_E_AI_CFG_LO_REG 0x10/* w16 */
 #define NI_E_AI_CFG_LO_LAST_CHAN   BIT(15)
 #define NI_E_AI_CFG_LO_GEN_TRIGBIT(12)
-- 
2.3.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 098/107] staging: comedi: ni_stc.h: tidy up AI_AO_Select register and bits

2015-05-01 Thread H Hartley Sweeten
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 hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 28 +++---
 drivers/staging/comedi/drivers/ni_stc.h| 13 ++--
 2 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index 2e1fde3..7dfa382 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -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) {
diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index 9ce4c56..2db29a1 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -571,6 +571,12 @@
 #define NI_E_STATUS_AI_FIFO_LOWER_NE   BIT(3)
 #define NI_E_STATUS_PROMOUTBIT(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_REG0x0d/* 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_ATRIGNI_E_MISC_CMD_INTEXT_ATRIG(0)
 #define NI_E_MISC_CMD_INT_ATRIGNI_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)
 {
-- 
2.3.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 080/107] staging: comedi: ni_stc.h: tidy up AO_*_Save_Registers

2015-05-01 Thread H Hartley Sweeten
Rename the CamelCase.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 6 +++---
 drivers/staging/comedi/drivers/ni_stc.h| 8 
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index 9cd796c..b194d15 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -420,9 +420,9 @@ static const struct mio_regmap m_series_stc_read_regmap[] = 
{
[NISTC_G1_HW_SAVE_REG]  = { 0x114, 4 },
[NISTC_G0_SAVE_REG] = { 0x118, 4 },
[NISTC_G1_SAVE_REG] = { 0x11c, 4 },
-   [AO_UI_Save_Registers]  = { 0x120, 4 },
-   [AO_BC_Save_Registers]  = { 0x124, 4 },
-   [AO_UC_Save_Registers]  = { 0x128, 4 },
+   [NISTC_AO_UI_SAVE_REG]  = { 0x120, 4 },
+   [NISTC_AO_BC_SAVE_REG]  = { 0x124, 4 },
+   [NISTC_AO_UC_SAVE_REG]  = { 0x128, 4 },
[Joint_Status_1_Register]   = { 0x136, 2 },
[DIO_Serial_Input_Register] = { 0x009, 1 },
[Joint_Status_2_Register]   = { 0x13a, 2 },
diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index ff57721..af07e4c 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -546,6 +546,10 @@
 #define NISTC_G0_SAVE_REG  12
 #define NISTC_G1_SAVE_REG  14
 
+#define NISTC_AO_UI_SAVE_REG   16
+#define NISTC_AO_BC_SAVE_REG   18
+#define NISTC_AO_UC_SAVE_REG   20
+
 #define AI_SI_Save_Registers   64
 #define AI_SC_Save_Registers   66
 
@@ -558,10 +562,6 @@ enum Joint_Status_2_Bits {
AO_TMRDACWRs_In_Progress_St = 0x20,
 };
 
-#define AO_UI_Save_Registers   16
-#define AO_BC_Save_Registers   18
-#define AO_UC_Save_Registers   20
-
 /* command register */
 #define G_Disarm_Copy  _bit15  /* strobe */
 #define G_Save_Trace_Copy  _bit14
-- 
2.3.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 102/107] staging: comedi: ni_stc.h: rename the NI-611x register defines

2015-05-01 Thread H Hartley Sweeten
Rename the CamelCase.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 34 ++
 drivers/staging/comedi/drivers/ni_stc.h| 23 -
 2 files changed, 30 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index e2081ea..e50eb9a 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -879,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);
 }
 
@@ -891,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);
 }
 
@@ -903,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;
 }
@@ -1035,7 +1035,7 @@ static void ni_ao_fifo_load(struct comedi_device *dev,
i++;
packed_data |= (d  16)  0x;
}
-   ni_writel(dev, packed_data, DAC_FIFO_Data_611x);
+   ni_writel(dev, packed_data, NI611X_AO_FIFO_DATA_REG);
} else {
ni_writew(dev, d, NI_E_AO_FIFO_DATA_REG);
}
@@ -1118,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)  0x;
comedi_buf_write_samples(s, data, 1);
@@ -1127,7 +1127,7 @@ 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  0x;
comedi_buf_write_samples(s, data, 1);
}
@@ -1192,7 +1192,7 @@ static void ni_handle_fifo_dregs(struct comedi_device 
*dev)
if (devpriv-is_611x) {
while ((ni_stc_readw(dev, NISTC_AI_STATUS1_REG) 
NISTC_AI_STATUS1_FIFO_E) == 0) {
-   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;
@@ -1254,7 +1254,7 @@ static void get_last_sample_611x(struct comedi_device 
*dev)
 
/* Check if there's a single sample stuck in the FIFO */
if (ni_readb(dev, NI_E_STATUS_REG)  0x80) {
-   dl = ni_readl(dev, ADC_FIFO_Data_611x);
+   dl = ni_readl(dev, NI611X_AI_FIFO_DATA_REG);
data = dl  0x;
comedi_buf_write_samples(s, data, 1);
}
@@ -1882,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;
@@ -1953,14 +1953,16 @@ static int ni_ai_insn_read(struct comedi_device *dev,
d = 0;
   

[PATCH 093/107] staging: comedi: ni_stc.h: tidy up Configuration_Memory_High register and bits

2015-05-01 Thread H Hartley Sweeten
Rename the CamelCase. Use the BIT() macro to define the bits.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 10 +-
 drivers/staging/comedi/drivers/ni_stc.h| 18 +++---
 2 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index 0fba36d..64c44a1 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -1885,21 +1885,21 @@ 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 = NI_E_AI_CFG_LO_GAIN(range);
diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index 8abf78d..14e4351 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -623,17 +623,13 @@ static inline unsigned GPCT_DMA_Select_Mask(unsigned 
gpct_index)
 #define NI_E_AI_CFG_LO_UNI BIT(8)
 #define NI_E_AI_CFG_LO_GAIN(x) ((x)  0)
 
-#define Configuration_Memory_High  0x12
-enum Configuration_Memory_High_Bits {
-   AI_AC_COUPLE = 0x800,
-   AI_DIFFERENTIAL = 0x1000,
-   AI_COMMON = 0x2000,
-   AI_GROUND = 0x3000,
-};
-static inline unsigned int AI_CONFIG_CHANNEL(unsigned int channel)
-{
-   return channel  0x3f;
-}
+#define NI_E_AI_CFG_HI_REG 0x12/* w16 */
+#define NI_E_AI_CFG_HI_TYPE(x) (((x)  0x7)  12)
+#define NI_E_AI_CFG_HI_TYPE_DIFF   NI_E_AI_CFG_HI_TYPE(1)
+#define NI_E_AI_CFG_HI_TYPE_COMMON NI_E_AI_CFG_HI_TYPE(2)
+#define NI_E_AI_CFG_HI_TYPE_GROUND NI_E_AI_CFG_HI_TYPE(3)
+#define NI_E_AI_CFG_HI_AC_COUPLE   BIT(11)
+#define NI_E_AI_CFG_HI_CHAN(x) (((x)  0x3f)  0)
 
 #define NI_E_8255_BASE 0x19/* rw8 */
 
-- 
2.3.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 100/107] staging: comedi: ni_mio_common: move ni_stc_dma_channel_select_bitfield()

2015-05-01 Thread H Hartley Sweeten
Move this inline helper function from ni_stc.h. It does not need to be
exposed outside of this file.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 11 +++
 drivers/staging/comedi/drivers/ni_stc.h| 12 
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index cfb5f34..e2081ea 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -567,6 +567,17 @@ 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)
diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index e181d91..dc95e6a 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -592,18 +592,6 @@
 #define NI_E_MISC_CMD_EXT_ATRIGNI_E_MISC_CMD_INTEXT_ATRIG(0)
 #define NI_E_MISC_CMD_INT_ATRIGNI_E_MISC_CMD_INTEXT_ATRIG(1)
 
-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;
-}
-
 #define NI_E_AI_CFG_LO_REG 0x10/* w16 */
 #define NI_E_AI_CFG_LO_LAST_CHAN   BIT(15)
 #define NI_E_AI_CFG_LO_GEN_TRIGBIT(12)
-- 
2.3.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 107/107] staging: comedi: ni_stc.h: final cleanup

2015-05-01 Thread H Hartley Sweeten
1) Move the enum's to a better location and tidy up the whitespace.
2) Tidy up the defines used for some array sizes in the private data.
3) Add comments for the spinlock_t variables in the private data.
4) Move the forward declaration to the end of the file.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_stc.h | 81 +++--
 1 file changed, 47 insertions(+), 34 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index 7988781..1d5af25 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -26,8 +26,6 @@
 
 #include ni_tio.h
 
-#define NUM_PFI_OUTPUT_SELECT_REGS 6
-
 /*
  * Registers in the National Instruments DAQ-STC chip
  */
@@ -714,34 +712,6 @@
 #define CS5529_CFG_CALIB_GAIN_SYS  CS5529_CFG_CALIB(6)
 
 /*
-   This is stuff unique to the NI E series drivers,
-   but I thought I'd put it here anyway.
-*/
-
-enum { ai_gain_16 =
-   0, ai_gain_8, ai_gain_14, ai_gain_4, ai_gain_611x, ai_gain_622x,
-   ai_gain_628x, ai_gain_6143
-};
-enum caldac_enum { caldac_none = 0, mb88341, dac8800, dac8043, ad8522,
-   ad8804, ad8842, ad8804_debug
-};
-enum ni_reg_type {
-   ni_reg_normal = 0x0,
-   ni_reg_611x = 0x1,
-   ni_reg_6711 = 0x2,
-   ni_reg_6713 = 0x4,
-   ni_reg_67xx_mask = 0x6,
-   ni_reg_6xxx_mask = 0x7,
-   ni_reg_622x = 0x8,
-   ni_reg_625x = 0x10,
-   ni_reg_628x = 0x18,
-   ni_reg_m_series_mask = 0x18,
-   ni_reg_6143 = 0x20
-};
-
-static const struct comedi_lrange range_ni_E_ao_ext;
-
-/*
  * M-Series specific registers not handled by the DAQ-STC and GPCT register
  * remapping.
  */
@@ -935,7 +905,41 @@ static const struct comedi_lrange range_ni_E_ao_ext;
 #define NI_M_AO_REF_ATTENUATION_REG(x) (0x264 + (x))
 #define NI_M_AO_REF_ATTENUATION_X5 BIT(0)
 
-#define M_SERIES_EEPROM_SIZE 1024
+enum {
+   ai_gain_16 = 0,
+   ai_gain_8,
+   ai_gain_14,
+   ai_gain_4,
+   ai_gain_611x,
+   ai_gain_622x,
+   ai_gain_628x,
+   ai_gain_6143
+};
+
+enum caldac_enum {
+   caldac_none = 0,
+   mb88341,
+   dac8800,
+   dac8043,
+   ad8522,
+   ad8804,
+   ad8842,
+   ad8804_debug
+};
+
+enum ni_reg_type {
+   ni_reg_normal = 0x0,
+   ni_reg_611x = 0x1,
+   ni_reg_6711 = 0x2,
+   ni_reg_6713 = 0x4,
+   ni_reg_67xx_mask = 0x6,
+   ni_reg_6xxx_mask = 0x7,
+   ni_reg_622x = 0x8,
+   ni_reg_625x = 0x10,
+   ni_reg_628x = 0x18,
+   ni_reg_m_series_mask = 0x18,
+   ni_reg_6143 = 0x20
+};
 
 struct ni_board_struct {
const char *name;
@@ -963,9 +967,13 @@ struct ni_board_struct {
enum caldac_enum caldac[3];
 };
 
-#define MAX_N_CALDACS  34
-#define MAX_N_AO_CHAN  8
-#define NUM_GPCT   2
+#define MAX_N_CALDACS  34
+#define MAX_N_AO_CHAN  8
+#define NUM_GPCT   2
+
+#define NUM_PFI_OUTPUT_SELECT_REGS 6
+
+#define M_SERIES_EEPROM_SIZE   1024
 
 struct ni_private {
unsigned short dio_output;
@@ -973,8 +981,11 @@ struct ni_private {
int aimode;
unsigned int ai_calib_source;
unsigned int ai_calib_source_enabled;
+   /* protects access to windowed registers */
spinlock_t window_lock;
+   /* protects interrupt/dma register access */
spinlock_t soft_reg_copy_lock;
+   /* protects mite DMA channel request/release */
spinlock_t mite_channel_lock;
 
int changain_state;
@@ -1046,4 +1057,6 @@ struct ni_private {
unsigned int is_6713:1;
 };
 
+static const struct comedi_lrange range_ni_E_ao_ext;
+
 #endif /* _COMEDI_NI_STC_H */
-- 
2.3.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 088/107] staging: comedi: ni_stc.h: tidy up Serial_Command register and bits

2015-05-01 Thread H Hartley Sweeten
Rename the CamelCase. Use the BIT() macro to define the bits.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 34 +++---
 drivers/staging/comedi/drivers/ni_stc.h|  8 --
 2 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index b4a8a4c..2f7d64d 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -4129,6 +4129,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;
 
@@ -4142,7 +4143,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;
@@ -4153,15 +4154,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,
@@ -4243,25 +4244,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);
+   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;
 }
diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index 643f3c2..ffd435c 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -571,7 +571,12 @@
 #define NI_E_STATUS_AI_FIFO_LOWER_NE   BIT(3)
 #define NI_E_STATUS_PROMOUTBIT(0)
 
-#define Serial_Command 0x0d
+#define NI_E_SERIAL_CMD_REG0x0d/* w8 */
+#define NI_E_SERIAL_CMD_DAC_LD(x)  BIT(3 + (x))
+#define NI_E_SERIAL_CMD_EEPROM_CS  BIT(2)
+#define NI_E_SERIAL_CMD_SDATA  BIT(1)
+#define NI_E_SERIAL_CMD_SCLK   BIT(0)
+
 #define Misc_Command   0x0f
 #define Port_A 0x19
 #define Port_B 0x1b
@@ -765,7 +770,6 @@ enum cs5529_status_bits {
CSS_OSC_DETECT = 0x2,   /* indicates adc error */
CSS_OVERRANGE = 0x4,
 };
-#define SerDacLd(x)(0x08(x))
 
 /*
This is stuff unique to the NI E series drivers,
-- 
2.3.0


[PATCH 096/107] staging: comedi: ni_stc.h: tidy up DAC[01]_Direct_Data registers

2015-05-01 Thread H Hartley Sweeten
Rename the CamelCase and convert the defines into a macro.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 2 +-
 drivers/staging/comedi/drivers/ni_stc.h| 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index b9e35ea..4a94bc3 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -2733,7 +2733,7 @@ static int ni_ao_insn_write(struct comedi_device *dev,
} 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);
diff --git a/drivers/staging/comedi/drivers/ni_stc.h 
b/drivers/staging/comedi/drivers/ni_stc.h
index 2afa701..23cc490 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -638,13 +638,13 @@ static inline unsigned GPCT_DMA_Select_Mask(unsigned 
gpct_index)
 #define NI_E_AO_DEGLITCH   BIT(1)
 #define NI_E_AO_CFG_BIPBIT(0)
 
+#define NI_E_DAC_DIRECT_DATA_REG(x)(0x18 + ((x) * 2)) /* w16 */
+
 #define NI_E_8255_BASE 0x19/* rw8 */
 
 #define NI_E_AI_FIFO_DATA_REG  0x1c/* r16 */
 
 #define NI_E_AO_FIFO_DATA_REG  0x1e/* w16 */
-#define DAC0_Direct_Data   0x18
-#define DAC1_Direct_Data   0x1a
 
 /* 611x registers (these boards differ from the e-series) */
 
-- 
2.3.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/11] staging: lustre: lclient: Use kzalloc and kfree

2015-05-01 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by
kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree.

A simplified version of the semantic patch that makes these changes is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr,size; @@
- OBD_ALLOC(ptr,size)
+ ptr = kzalloc(size, GFP_NOFS)

@@ expression ptr, size; @@
- OBD_FREE(ptr, size);
+ kfree(ptr);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/lclient/lcommon_cl.c |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff -u -p a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c 
b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c
--- a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c
+++ b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c
@@ -202,7 +202,7 @@ struct lu_device *ccc_device_alloc(const
struct cl_site*site;
int rc;
 
-   OBD_ALLOC_PTR(vdv);
+   vdv = kzalloc(sizeof(*vdv), GFP_NOFS);
if (vdv == NULL)
return ERR_PTR(-ENOMEM);
 
@@ -211,7 +211,7 @@ struct lu_device *ccc_device_alloc(const
ccc2lu_dev(vdv)-ld_ops = luops;
vdv-cdv_cl.cd_ops = clops;
 
-   OBD_ALLOC_PTR(site);
+   site = kzalloc(sizeof(*site), GFP_NOFS);
if (site != NULL) {
rc = cl_site_init(site, vdv-cdv_cl);
if (rc == 0)
@@ -219,7 +219,7 @@ struct lu_device *ccc_device_alloc(const
else {
LASSERT(lud-ld_site == NULL);
CERROR(Cannot init lu_site, rc %d.\n, rc);
-   OBD_FREE_PTR(site);
+   kfree(site);
}
} else
rc = -ENOMEM;
@@ -239,10 +239,10 @@ struct lu_device *ccc_device_free(const
 
if (d-ld_site != NULL) {
cl_site_fini(site);
-   OBD_FREE_PTR(site);
+   kfree(site);
}
cl_device_fini(lu2cl_dev(d));
-   OBD_FREE_PTR(vdv);
+   kfree(vdv);
return next;
 }
 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: iio: ad7606_par: Constify platform_device_id

2015-05-01 Thread Krzysztof Kozlowski
The platform_device_id is not modified by the driver and core uses it as
const.

Signed-off-by: Krzysztof Kozlowski k.kozlowsk...@gmail.com
---
 drivers/staging/iio/adc/ad7606_par.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/iio/adc/ad7606_par.c 
b/drivers/staging/iio/adc/ad7606_par.c
index 9e24b4d4455f..1d48ae381d16 100644
--- a/drivers/staging/iio/adc/ad7606_par.c
+++ b/drivers/staging/iio/adc/ad7606_par.c
@@ -119,7 +119,7 @@ static const struct dev_pm_ops ad7606_pm_ops = {
 #define AD7606_PAR_PM_OPS NULL
 #endif  /* CONFIG_PM */
 
-static struct platform_device_id ad7606_driver_ids[] = {
+static const struct platform_device_id ad7606_driver_ids[] = {
{
.name   = ad7606-8,
.driver_data= ID_AD7606_8,
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: media: omap4iss: Constify platform_device_id

2015-05-01 Thread Krzysztof Kozlowski
The platform_device_id is not modified by the driver and core uses it as
const.

Signed-off-by: Krzysztof Kozlowski k.kozlowsk...@gmail.com
---
 drivers/staging/media/omap4iss/iss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/omap4iss/iss.c 
b/drivers/staging/media/omap4iss/iss.c
index e0ad5e520e2d..68867f286afd 100644
--- a/drivers/staging/media/omap4iss/iss.c
+++ b/drivers/staging/media/omap4iss/iss.c
@@ -1478,7 +1478,7 @@ static int iss_remove(struct platform_device *pdev)
return 0;
 }
 
-static struct platform_device_id omap4iss_id_table[] = {
+static const struct platform_device_id omap4iss_id_table[] = {
{ omap4iss, 0 },
{ },
 };
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: i2o: Remove unwanted semicolon

2015-05-01 Thread gre...@linuxfoundation.org
On Fri, May 01, 2015 at 10:28:00AM +0100, Alan Cox wrote:
 On Fri, 2015-05-01 at 09:41 +0200, gre...@linuxfoundation.org wrote:
  On Thu, Apr 30, 2015 at 11:25:48PM +0100, One Thousand Gnomes wrote:
   On Thu, 30 Apr 2015 16:14:06 +0200
   gre...@linuxfoundation.org gre...@linuxfoundation.org wrote:
   
On Thu, Apr 23, 2015 at 04:09:28PM +0100, Alan Cox wrote:
 On Thu, 2015-04-23 at 13:43 +, Gujulan Elango, Hari Prasath (H.)
 wrote:
  This patch removes unwanted semicolon around close braces of code 
  blocks
 
 
 The i2o driver moved into staging ready to be deleted unless someone
 steps up with hardware willing to maintain it (which is rather
 unlikely).

I think it's now time to delete these, want me to do that for 4.2?  I
can queue that up in my tree now, so that we don't see any more cleanup
patches being made for them?
   
   Yeah I think it can go
  
  I was about to delete it, but what about drivers/scsi/dpt/dpti_i2o.* ?
  Should that be removed as well?
 
 Possibly but that ought to go via staging and really is one for the SCSI
 folks to call. The dpt_i2o was a bit more common than i2o proper.

But if the staging i2o core is removed, doesn't that mean that this
driver will stop working?  It uses code in uapi i2o.h, which I'm
guessing is implemented in the staging i2o core.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 11/11] staging: lustre: ptlrpc: Use kzalloc and kfree

2015-05-01 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by
kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree.

A simplified version of the semantic patch that makes these changes is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr,size; @@
- OBD_ALLOC(ptr,size)
+ ptr = kzalloc(size, GFP_NOFS)

@@ expression ptr, size; @@
- OBD_FREE(ptr, size);
+ kfree(ptr);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/ptlrpc/client.c   |   18 
 drivers/staging/lustre/lustre/ptlrpc/connection.c   |6 +-
 drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c |   24 +--
 drivers/staging/lustre/lustre/ptlrpc/nrs.c  |   18 
 drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c |2 
 drivers/staging/lustre/lustre/ptlrpc/pinger.c   |6 +-
 drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c  |   14 +++---
 drivers/staging/lustre/lustre/ptlrpc/sec.c  |2 
 drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c |   17 +++-
 drivers/staging/lustre/lustre/ptlrpc/sec_config.c   |   16 +++
 drivers/staging/lustre/lustre/ptlrpc/sec_plain.c|   10 ++--
 drivers/staging/lustre/lustre/ptlrpc/service.c  |   42 +---
 12 files changed, 84 insertions(+), 91 deletions(-)

diff -u -p a/drivers/staging/lustre/lustre/ptlrpc/service.c 
b/drivers/staging/lustre/lustre/ptlrpc/service.c
--- a/drivers/staging/lustre/lustre/ptlrpc/service.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/service.c
@@ -87,7 +87,7 @@ ptlrpc_alloc_rqbd(struct ptlrpc_service_
OBD_CPT_ALLOC_LARGE(rqbd-rqbd_buffer, svc-srv_cptable,
svcpt-scp_cpt, svc-srv_buf_size);
if (rqbd-rqbd_buffer == NULL) {
-   OBD_FREE_PTR(rqbd);
+   kfree(rqbd);
return NULL;
}
 
@@ -113,7 +113,7 @@ ptlrpc_free_rqbd(struct ptlrpc_request_b
spin_unlock(svcpt-scp_lock);
 
OBD_FREE_LARGE(rqbd-rqbd_buffer, svcpt-scp_service-srv_buf_size);
-   OBD_FREE_PTR(rqbd);
+   kfree(rqbd);
 }
 
 int
@@ -661,13 +661,12 @@ ptlrpc_service_part_init(struct ptlrpc_s
 
  failed:
if (array-paa_reqs_count != NULL) {
-   OBD_FREE(array-paa_reqs_count, sizeof(__u32) * size);
+   kfree(array-paa_reqs_count);
array-paa_reqs_count = NULL;
}
 
if (array-paa_reqs_array != NULL) {
-   OBD_FREE(array-paa_reqs_array,
-sizeof(struct list_head) * array-paa_size);
+   kfree(array-paa_reqs_array);
array-paa_reqs_array = NULL;
}
 
@@ -724,17 +723,18 @@ ptlrpc_register_service(struct ptlrpc_se
CERROR(%s: failed to parse CPT array %s: %d\n,
   conf-psc_name, cconf-cc_pattern, rc);
if (cpts != NULL)
-   OBD_FREE(cpts, sizeof(*cpts) * ncpts);
+   kfree(cpts);
return ERR_PTR(rc  0 ? rc : -EINVAL);
}
ncpts = rc;
}
}
 
-   OBD_ALLOC(service, offsetof(struct ptlrpc_service, srv_parts[ncpts]));
+   service = kzalloc(offsetof(struct ptlrpc_service, srv_parts[ncpts]),
+ GFP_NOFS);
if (service == NULL) {
if (cpts != NULL)
-   OBD_FREE(cpts, sizeof(*cpts) * ncpts);
+   kfree(cpts);
return ERR_PTR(-ENOMEM);
}
 
@@ -2291,7 +2291,7 @@ static int ptlrpc_main(void *arg)
goto out;
}
 
-   OBD_ALLOC_PTR(env);
+   env = kzalloc(sizeof(*env), GFP_NOFS);
if (env == NULL) {
rc = -ENOMEM;
goto out_srv_fini;
@@ -2414,7 +2414,7 @@ out_srv_fini:
 
if (env != NULL) {
lu_context_fini(env-le_ctx);
-   OBD_FREE_PTR(env);
+   kfree(env);
}
 out:
CDEBUG(D_RPCTRACE, service thread [ %p : %u ] %d exiting: rc %d\n,
@@ -2596,7 +2596,7 @@ static void ptlrpc_svcpt_stop_threads(st
thread = list_entry(zombie.next,
struct ptlrpc_thread, t_link);
list_del(thread-t_link);
-   OBD_FREE_PTR(thread);
+   kfree(thread);
}
 }
 
@@ -2678,7 +2678,7 @@ int ptlrpc_start_thread(struct ptlrpc_se
spin_lock(svcpt-scp_lock);
if (!ptlrpc_threads_increasable(svcpt)) {
spin_unlock(svcpt-scp_lock);
-   OBD_FREE_PTR(thread);
+   kfree(thread);
return -EMFILE;
}
 
@@ -2687,7 +2687,7 @@ int ptlrpc_start_thread(struct ptlrpc_se
 * might require unique and contiguous t_id */
LASSERT(svcpt-scp_nthrs_starting == 

[PATCH 0/11] Use kzalloc and kfree

2015-05-01 Thread Julia Lawall
Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by
kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree.  The complete
semantic patch that makes these changes is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@@
expression ptr,e1,e2;
@@

- OBD_ALLOC(ptr,sizeof e1 * e2)
+ ptr = kcalloc(e2, sizeof e1, GFP_NOFS)

@@
expression ptr,e1,e2;
@@

- OBD_ALLOC_WAIT(ptr,sizeof e1 * e2)
+ ptr = kcalloc(sizeof e1, e2, GFP_KERNEL)

@@
expression ptr,e1,e2;
@@

- OBD_ALLOC(ptr,e2 * sizeof e1)
+ ptr = kcalloc(e2, sizeof e1, GFP_NOFS)

@@
expression ptr,e1,e2;
@@

- OBD_ALLOC_WAIT(ptr,e2 * sizeof e1)
+ ptr = kcalloc(e2, sizeof e1, GFP_KERNEL)

@@
expression ptr,e2;
type t;
@@

- OBD_ALLOC(ptr,sizeof (t) * e2)
+ ptr = kcalloc(e2, sizeof (t), GFP_NOFS)

@@
expression ptr,e2;
type t;
@@

- OBD_ALLOC_WAIT(ptr,sizeof (t) * e2)
+ ptr = kcalloc(e2, sizeof (t), GFP_KERNEL)

@@
expression ptr,e2;
type t;
@@

- OBD_ALLOC(ptr,e2 * sizeof (t))
+ ptr = kcalloc(e2, sizeof (t), GFP_NOFS)

@@
expression ptr,e2;
type t;
@@

- OBD_ALLOC_WAIT(ptr,e2 * sizeof (t))
+ ptr = kcalloc(e2, sizeof (t), GFP_KERNEL)

@@
expression ptr,e1,e2;
@@

- OBD_ALLOC(ptr,e1 * e2)
+ ptr = kcalloc(e1, e2, GFP_NOFS)

@@
expression ptr,e1,e2;
@@

- OBD_ALLOC_WAIT(ptr,e1 * e2)
+ ptr = kcalloc(e1, e2, GFP_KERNEL)

// ---

@@
expression ptr,size;
@@

- OBD_ALLOC(ptr,size)
+ ptr = kzalloc(size, GFP_NOFS)

@@
expression ptr,size;
@@

- OBD_ALLOC_WAIT(ptr,size)
+ ptr = kzalloc(size, GFP_KERNEL)

@@
expression ptr;
@@

- OBD_ALLOC_PTR(ptr)
+ ptr = kzalloc(sizeof(*ptr), GFP_NOFS)

@@
expression ptr;
@@

- OBD_ALLOC_PTR_WAIT(ptr)
+ ptr = kzalloc(sizeof(*ptr), GFP_KERNEL)

// --

@@
expression ptr, size;
@@

- OBD_FREE(ptr, size);
+ kfree(ptr);

@@
expression ptr;
@@

- OBD_FREE_PTR(ptr);
+ kfree(ptr);
// /smpl

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 8/11] staging: lustre: obdclass: Use kzalloc and kfree

2015-05-01 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by
kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree.

A simplified version of the semantic patch that makes these changes is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr,size; @@
- OBD_ALLOC(ptr,size)
+ ptr = kzalloc(size, GFP_NOFS)

@@ expression ptr, size; @@
- OBD_FREE(ptr, size);
+ kfree(ptr);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/obdclass/acl.c|   29 ++---
 drivers/staging/lustre/lustre/obdclass/capa.c   |4 
 drivers/staging/lustre/lustre/obdclass/cl_io.c  |   13 +-
 drivers/staging/lustre/lustre/obdclass/cl_page.c|2 
 drivers/staging/lustre/lustre/obdclass/class_obd.c  |4 
 drivers/staging/lustre/lustre/obdclass/genops.c |   40 +++
 drivers/staging/lustre/lustre/obdclass/llog.c   |   24 ++--
 drivers/staging/lustre/lustre/obdclass/llog_obd.c   |4 
 drivers/staging/lustre/lustre/obdclass/lprocfs_status.c |   14 +-
 drivers/staging/lustre/lustre/obdclass/lu_object.c  |6 -
 drivers/staging/lustre/lustre/obdclass/lustre_handles.c |2 
 drivers/staging/lustre/lustre/obdclass/lustre_peer.c|6 -
 drivers/staging/lustre/lustre/obdclass/obd_config.c |   50 -
 drivers/staging/lustre/lustre/obdclass/obd_mount.c  |   86 +++-
 14 files changed, 138 insertions(+), 146 deletions(-)

diff -u -p a/drivers/staging/lustre/lustre/obdclass/obd_mount.c 
b/drivers/staging/lustre/lustre/obdclass/obd_mount.c
--- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c
+++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c
@@ -84,7 +84,7 @@ int lustre_process_log(struct super_bloc
LASSERT(mgc);
LASSERT(cfg);
 
-   OBD_ALLOC_PTR(bufs);
+   bufs = kzalloc(sizeof(*bufs), GFP_NOFS);
if (bufs == NULL)
return -ENOMEM;
 
@@ -97,7 +97,7 @@ int lustre_process_log(struct super_bloc
rc = obd_process_config(mgc, sizeof(*lcfg), lcfg);
lustre_cfg_free(lcfg);
 
-   OBD_FREE_PTR(bufs);
+   kfree(bufs);
 
if (rc == -EINVAL)
LCONSOLE_ERROR_MSG(0x15b, %s: The configuration from log '%s' 
failed from the MGS (%d).  Make sure this client and the MGS are running 
compatible versions of Lustre.\n,
@@ -247,8 +247,8 @@ int lustre_start_mgc(struct super_block
mutex_lock(mgc_start_lock);
 
len = strlen(LUSTRE_MGC_OBDNAME) + strlen(libcfs_nid2str(nid)) + 1;
-   OBD_ALLOC(mgcname, len);
-   OBD_ALLOC(niduuid, len + 2);
+   mgcname = kzalloc(len, GFP_NOFS);
+   niduuid = kzalloc(len + 2, GFP_NOFS);
if (!mgcname || !niduuid) {
rc = -ENOMEM;
goto out_free;
@@ -257,7 +257,7 @@ int lustre_start_mgc(struct super_block
 
mgssec = lsi-lsi_lmd-lmd_mgssec ? lsi-lsi_lmd-lmd_mgssec : ;
 
-   OBD_ALLOC_PTR(data);
+   data = kzalloc(sizeof(*data), GFP_NOFS);
if (data == NULL) {
rc = -ENOMEM;
goto out_free;
@@ -375,7 +375,7 @@ int lustre_start_mgc(struct super_block
lsi-lsi_lmd-lmd_mgs_failnodes = 1;
 
/* Random uuid for MGC allows easier reconnects */
-   OBD_ALLOC_PTR(uuid);
+   uuid = kzalloc(sizeof(*uuid), GFP_NOFS);
if (!uuid) {
rc = -ENOMEM;
goto out_free;
@@ -388,7 +388,7 @@ int lustre_start_mgc(struct super_block
rc = lustre_start_simple(mgcname, LUSTRE_MGC_NAME,
 (char *)uuid-uuid, LUSTRE_MGS_OBDNAME,
 niduuid, NULL, NULL);
-   OBD_FREE_PTR(uuid);
+   kfree(uuid);
if (rc)
goto out_free;
 
@@ -465,11 +465,11 @@ out_free:
mutex_unlock(mgc_start_lock);
 
if (data)
-   OBD_FREE_PTR(data);
+   kfree(data);
if (mgcname)
-   OBD_FREE(mgcname, len);
+   kfree(mgcname);
if (niduuid)
-   OBD_FREE(niduuid, len + 2);
+   kfree(niduuid);
return rc;
 }
 
@@ -513,7 +513,7 @@ static int lustre_stop_mgc(struct super_
/* Save the obdname for cleaning the nid uuids, which are
   obdname_XX */
len = strlen(obd-obd_name) + 6;
-   OBD_ALLOC(niduuid, len);
+   niduuid = kzalloc(len, GFP_NOFS);
if (niduuid) {
strcpy(niduuid, obd-obd_name);
ptr = niduuid + strlen(niduuid);
@@ -539,7 +539,7 @@ static int lustre_stop_mgc(struct super_
}
 out:
if (niduuid)
-   OBD_FREE(niduuid, len);
+   kfree(niduuid);
 
/* class_import_put will get rid of the additional connections */
mutex_unlock(mgc_start_lock);
@@ -552,12 +552,12 @@ struct lustre_sb_info *lustre_init_lsi(s
 {
struct lustre_sb_info *lsi;
 
-   OBD_ALLOC_PTR(lsi);
+   lsi = 

[PATCH 4/11] staging: lustre: ldlm: Use kzalloc and kfree

2015-05-01 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by
kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree.

A simplified version of the semantic patch that makes these changes is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr,size; @@
- OBD_ALLOC(ptr,size)
+ ptr = kzalloc(size, GFP_NOFS)

@@ expression ptr, size; @@
- OBD_FREE(ptr, size);
+ kfree(ptr);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/ldlm/ldlm_lib.c  |6 +++---
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c |   10 +-
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c|   14 +++---
 drivers/staging/lustre/lustre/ldlm/ldlm_pool.c |   10 +-
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |8 
 5 files changed, 24 insertions(+), 24 deletions(-)

diff -u -p a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -590,7 +590,7 @@ struct ldlm_namespace *ldlm_namespace_ne
break;
}
 
-   OBD_ALLOC_PTR(ns);
+   ns = kzalloc(sizeof(*ns), GFP_NOFS);
if (!ns)
goto out_ref;
 
@@ -657,7 +657,7 @@ out_proc:
 out_hash:
cfs_hash_putref(ns-ns_rs_hash);
 out_ns:
-   OBD_FREE_PTR(ns);
+   kfree(ns);
 out_ref:
ldlm_put_ref();
return NULL;
@@ -904,7 +904,7 @@ void ldlm_namespace_free_post(struct ldl
 * this will cause issues related to using freed \a ns in poold
 * thread. */
LASSERT(list_empty(ns-ns_list_chain));
-   OBD_FREE_PTR(ns);
+   kfree(ns);
ldlm_put_ref();
 }
 
@@ -1138,7 +1138,7 @@ ldlm_resource_get(struct ldlm_namespace
   ns-ns_obd-obd_name, name-name[0],
   name-name[1], rc);
if (res-lr_lvb_data) {
-   OBD_FREE(res-lr_lvb_data, res-lr_lvb_len);
+   kfree(res-lr_lvb_data);
res-lr_lvb_data = NULL;
}
res-lr_lvb_len = rc;
diff -u -p a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
@@ -746,7 +746,7 @@ static int ldlm_pool_proc_init(struct ld
char *var_name = NULL;
int rc = 0;
 
-   OBD_ALLOC(var_name, MAX_STRING_SIZE + 1);
+   var_name = kzalloc(MAX_STRING_SIZE + 1, GFP_NOFS);
if (!var_name)
return -ENOMEM;
 
@@ -828,7 +828,7 @@ static int ldlm_pool_proc_init(struct ld
rc = lprocfs_register_stats(pl-pl_proc_dir, stats, pl-pl_stats);
 
 out_free_name:
-   OBD_FREE(var_name, MAX_STRING_SIZE + 1);
+   kfree(var_name);
return rc;
 }
 
@@ -1383,7 +1383,7 @@ static int ldlm_pools_thread_start(void)
if (ldlm_pools_thread != NULL)
return -EALREADY;
 
-   OBD_ALLOC_PTR(ldlm_pools_thread);
+   ldlm_pools_thread = kzalloc(sizeof(*ldlm_pools_thread), GFP_NOFS);
if (ldlm_pools_thread == NULL)
return -ENOMEM;
 
@@ -1394,7 +1394,7 @@ static int ldlm_pools_thread_start(void)
   ldlm_poold);
if (IS_ERR(task)) {
CERROR(Can't start pool thread, error %ld\n, PTR_ERR(task));
-   OBD_FREE(ldlm_pools_thread, sizeof(*ldlm_pools_thread));
+   kfree(ldlm_pools_thread);
ldlm_pools_thread = NULL;
return PTR_ERR(task);
}
@@ -1417,7 +1417,7 @@ static void ldlm_pools_thread_stop(void)
 * in pools thread.
 */
wait_for_completion(ldlm_pools_comp);
-   OBD_FREE_PTR(ldlm_pools_thread);
+   kfree(ldlm_pools_thread);
ldlm_pools_thread = NULL;
 }
 
diff -u -p a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
@@ -220,7 +220,7 @@ static void ldlm_handle_cp_callback(stru
 * variable length */
void *lvb_data;
 
-   OBD_ALLOC(lvb_data, lvb_len);
+   lvb_data = kzalloc(lvb_len, GFP_NOFS);
if (lvb_data == NULL) {
LDLM_ERROR(lock, No memory: %d.\n, lvb_len);
rc = -ENOMEM;
@@ -448,7 +448,7 @@ static int ldlm_bl_to_thread(struct ldlm
if (cancel_flags  LCF_ASYNC) {
struct ldlm_bl_work_item *blwi;
 
-   OBD_ALLOC(blwi, sizeof(*blwi));
+   blwi = kzalloc(sizeof(*blwi), 

[PATCH 5/11] staging: lustre: lmv: Use kzalloc and kfree

2015-05-01 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by
kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree.

A simplified version of the semantic patch that makes these changes is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr,size; @@
- OBD_ALLOC(ptr,size)
+ ptr = kzalloc(size, GFP_NOFS)

@@ expression ptr, size; @@
- OBD_FREE(ptr, size);
+ kfree(ptr);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/lmv/lmv_intent.c |4 +--
 drivers/staging/lustre/lustre/lmv/lmv_obd.c|   28 -
 2 files changed, 16 insertions(+), 16 deletions(-)

diff -u -p a/drivers/staging/lustre/lustre/lmv/lmv_obd.c 
b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
--- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c
+++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
@@ -442,7 +442,7 @@ static void lmv_del_target(struct lmv_ob
if (lmv-tgts[index] == NULL)
return;
 
-   OBD_FREE_PTR(lmv-tgts[index]);
+   kfree(lmv-tgts[index]);
lmv-tgts[index] = NULL;
return;
 }
@@ -488,7 +488,7 @@ static int lmv_add_target(struct obd_dev
 
while (newsize  index + 1)
newsize = 1;
-   OBD_ALLOC(newtgts, sizeof(*newtgts) * newsize);
+   newtgts = kcalloc(newsize, sizeof(*newtgts), GFP_NOFS);
if (newtgts == NULL) {
lmv_init_unlock(lmv);
return -ENOMEM;
@@ -505,13 +505,13 @@ static int lmv_add_target(struct obd_dev
lmv-tgts_size = newsize;
smp_rmb();
if (old)
-   OBD_FREE(old, sizeof(*old) * oldsize);
+   kfree(old);
 
CDEBUG(D_CONFIG, tgts: %p size: %d\n, lmv-tgts,
   lmv-tgts_size);
}
 
-   OBD_ALLOC_PTR(tgt);
+   tgt = kzalloc(sizeof(*tgt), GFP_NOFS);
if (!tgt) {
lmv_init_unlock(lmv);
return -ENOMEM;
@@ -750,7 +750,7 @@ repeat_fid2path:
/* sigh, has to go to another MDT to do path building further */
if (remote_gf == NULL) {
remote_gf_size = sizeof(*remote_gf) + PATH_MAX;
-   OBD_ALLOC(remote_gf, remote_gf_size);
+   remote_gf = kzalloc(remote_gf_size, GFP_NOFS);
if (remote_gf == NULL) {
rc = -ENOMEM;
goto out_fid2path;
@@ -781,7 +781,7 @@ repeat_fid2path:
 
 out_fid2path:
if (remote_gf != NULL)
-   OBD_FREE(remote_gf, remote_gf_size);
+   kfree(remote_gf);
return rc;
 }
 
@@ -984,7 +984,7 @@ static int lmv_iocontrol(unsigned int cm
return -EAGAIN;
 
LASSERT(tgt  tgt-ltd_exp);
-   OBD_ALLOC_PTR(oqctl);
+   oqctl = kzalloc(sizeof(*oqctl), GFP_NOFS);
if (!oqctl)
return -ENOMEM;
 
@@ -995,7 +995,7 @@ static int lmv_iocontrol(unsigned int cm
qctl-qc_valid = QC_MDTIDX;
qctl-obd_uuid = tgt-ltd_uuid;
}
-   OBD_FREE_PTR(oqctl);
+   kfree(oqctl);
break;
}
case OBD_IOC_CHANGELOG_SEND:
@@ -1327,7 +1327,7 @@ static int lmv_setup(struct obd_device *
return -EINVAL;
}
 
-   OBD_ALLOC(lmv-tgts, sizeof(*lmv-tgts) * 32);
+   lmv-tgts = kcalloc(32, sizeof(*lmv-tgts), GFP_NOFS);
if (lmv-tgts == NULL)
return -ENOMEM;
lmv-tgts_size = 32;
@@ -1380,7 +1380,7 @@ static int lmv_cleanup(struct obd_device
continue;
lmv_del_target(lmv, i);
}
-   OBD_FREE(lmv-tgts, sizeof(*lmv-tgts) * lmv-tgts_size);
+   kfree(lmv-tgts);
lmv-tgts_size = 0;
}
return 0;
@@ -1437,7 +1437,7 @@ static int lmv_statfs(const struct lu_en
if (rc)
return rc;
 
-   OBD_ALLOC(temp, sizeof(*temp));
+   temp = kzalloc(sizeof(*temp), GFP_NOFS);
if (temp == NULL)
return -ENOMEM;
 
@@ -1473,7 +1473,7 @@ static int lmv_statfs(const struct lu_en
}
 
 out_free_temp:
-   OBD_FREE(temp, sizeof(*temp));
+   kfree(temp);
return rc;
 }
 
@@ -1769,7 +1769,7 @@ lmv_enqueue_remote(struct obd_export *ex
goto out;
}
 
-   OBD_ALLOC_PTR(rdata);
+   rdata = kzalloc(sizeof(*rdata), GFP_NOFS);
if (rdata == NULL) {
rc = -ENOMEM;
goto out;
@@ -1780,7 +1780,7 @@ lmv_enqueue_remote(struct obd_export *ex
 
rc = md_enqueue(tgt-ltd_exp, einfo, it, rdata, lockh,
lmm, lmmsize, NULL, extra_lock_flags);
-   OBD_FREE_PTR(rdata);
+   kfree(rdata);
 out:
ldlm_lock_decref(plock, 

[PATCH 10/11] staging: lustre: osc: Use kzalloc and kfree

2015-05-01 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by
kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree.

A simplified version of the semantic patch that makes these changes is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr,size; @@
- OBD_ALLOC(ptr,size)
+ ptr = kzalloc(size, GFP_NOFS)

@@ expression ptr, size; @@
- OBD_FREE(ptr, size);
+ kfree(ptr);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/osc/osc_dev.c |4 +-
 drivers/staging/lustre/lustre/osc/osc_request.c |   33 
 2 files changed, 19 insertions(+), 18 deletions(-)

diff -u -p a/drivers/staging/lustre/lustre/osc/osc_request.c 
b/drivers/staging/lustre/lustre/osc/osc_request.c
--- a/drivers/staging/lustre/lustre/osc/osc_request.c
+++ b/drivers/staging/lustre/lustre/osc/osc_request.c
@@ -110,7 +110,7 @@ static int osc_packmd(struct obd_export
return lmm_size;
 
if (*lmmp != NULL  lsm == NULL) {
-   OBD_FREE(*lmmp, lmm_size);
+   kfree(*lmmp);
*lmmp = NULL;
return 0;
} else if (unlikely(lsm != NULL  ostid_id(lsm-lsm_oi) == 0)) {
@@ -118,7 +118,7 @@ static int osc_packmd(struct obd_export
}
 
if (*lmmp == NULL) {
-   OBD_ALLOC(*lmmp, lmm_size);
+   *lmmp = kzalloc(lmm_size, GFP_NOFS);
if (*lmmp == NULL)
return -ENOMEM;
}
@@ -157,19 +157,20 @@ static int osc_unpackmd(struct obd_expor
return lsm_size;
 
if (*lsmp != NULL  lmm == NULL) {
-   OBD_FREE((*lsmp)-lsm_oinfo[0], sizeof(struct lov_oinfo));
-   OBD_FREE(*lsmp, lsm_size);
+   kfree((*lsmp)-lsm_oinfo[0]);
+   kfree(*lsmp);
*lsmp = NULL;
return 0;
}
 
if (*lsmp == NULL) {
-   OBD_ALLOC(*lsmp, lsm_size);
+   *lsmp = kzalloc(lsm_size, GFP_NOFS);
if (unlikely(*lsmp == NULL))
return -ENOMEM;
-   OBD_ALLOC((*lsmp)-lsm_oinfo[0], sizeof(struct lov_oinfo));
+   (*lsmp)-lsm_oinfo[0] = kzalloc(sizeof(struct lov_oinfo),
+   GFP_NOFS);
if (unlikely((*lsmp)-lsm_oinfo[0] == NULL)) {
-   OBD_FREE(*lsmp, lsm_size);
+   kfree(*lsmp);
return -ENOMEM;
}
loi_init((*lsmp)-lsm_oinfo[0]);
@@ -962,7 +963,7 @@ int osc_shrink_grant_to_target(struct cl
}
client_obd_list_unlock(cli-cl_loi_list_lock);
 
-   OBD_ALLOC_PTR(body);
+   body = kzalloc(sizeof(*body), GFP_NOFS);
if (!body)
return -ENOMEM;
 
@@ -984,7 +985,7 @@ int osc_shrink_grant_to_target(struct cl
sizeof(*body), body, NULL);
if (rc != 0)
__osc_update_grant(cli, body-oa.o_grant);
-   OBD_FREE_PTR(body);
+   kfree(body);
return rc;
 }
 
@@ -1748,7 +1749,7 @@ static void sort_brw_pages(struct brw_pa
 static void osc_release_ppga(struct brw_page **ppga, u32 count)
 {
LASSERT(ppga != NULL);
-   OBD_FREE(ppga, sizeof(*ppga) * count);
+   kfree(ppga);
 }
 
 static int brw_interpret(const struct lu_env *env,
@@ -1908,13 +1909,13 @@ int osc_build_rpc(const struct lu_env *e
if (mem_tight)
mpflag = cfs_memory_pressure_get_and_set();
 
-   OBD_ALLOC(crattr, sizeof(*crattr));
+   crattr = kzalloc(sizeof(*crattr), GFP_NOFS);
if (crattr == NULL) {
rc = -ENOMEM;
goto out;
}
 
-   OBD_ALLOC(pga, sizeof(*pga) * page_count);
+   pga = kcalloc(page_count, sizeof(*pga), GFP_NOFS);
if (pga == NULL) {
rc = -ENOMEM;
goto out;
@@ -2055,7 +2056,7 @@ out:
 
if (crattr != NULL) {
capa_put(crattr-cra_capa);
-   OBD_FREE(crattr, sizeof(*crattr));
+   kfree(crattr);
}
 
if (rc != 0) {
@@ -2064,7 +2065,7 @@ out:
if (oa)
OBDO_FREE(oa);
if (pga)
-   OBD_FREE(pga, sizeof(*pga) * page_count);
+   kfree(pga);
/* this should happen rarely and is pretty bad, it makes the
 * pending list not follow the dirty order */
while (!list_empty(ext_list)) {
@@ -2617,7 +2618,7 @@ static int osc_getstripe(struct lov_stri
 * because lov_user_md_vX and lov_mds_md_vX have the same size */
if (lum.lmm_stripe_count  0) {
lum_size = lov_mds_md_size(lum.lmm_stripe_count, lum.lmm_magic);
-   OBD_ALLOC(lumk, lum_size);
+   lumk = kzalloc(lum_size, GFP_NOFS);
if (!lumk)

[PATCH 1/11] staging: lustre: fid: Use kzalloc and kfree

2015-05-01 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by
kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree.

A simplified version of the semantic patch that makes these changes is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr,size; @@
- OBD_ALLOC(ptr,size)
+ ptr = kzalloc(size, GFP_NOFS)

@@ expression ptr, size; @@
- OBD_FREE(ptr, size);
+ kfree(ptr);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/fid/fid_request.c |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff -u -p a/drivers/staging/lustre/lustre/fid/fid_request.c 
b/drivers/staging/lustre/lustre/fid/fid_request.c
--- a/drivers/staging/lustre/lustre/fid/fid_request.c
+++ b/drivers/staging/lustre/lustre/fid/fid_request.c
@@ -505,11 +505,11 @@ int client_fid_init(struct obd_device *o
char *prefix;
int rc;
 
-   OBD_ALLOC_PTR(cli-cl_seq);
+   cli-cl_seq = kzalloc(sizeof(*cli-cl_seq), GFP_NOFS);
if (cli-cl_seq == NULL)
return -ENOMEM;
 
-   OBD_ALLOC(prefix, MAX_OBD_NAME + 5);
+   prefix = kzalloc(MAX_OBD_NAME + 5, GFP_NOFS);
if (prefix == NULL) {
rc = -ENOMEM;
goto out_free_seq;
@@ -519,13 +519,13 @@ int client_fid_init(struct obd_device *o
 
/* Init client side sequence-manager */
rc = seq_client_init(cli-cl_seq, exp, type, prefix, NULL);
-   OBD_FREE(prefix, MAX_OBD_NAME + 5);
+   kfree(prefix);
if (rc)
goto out_free_seq;
 
return rc;
 out_free_seq:
-   OBD_FREE_PTR(cli-cl_seq);
+   kfree(cli-cl_seq);
cli-cl_seq = NULL;
return rc;
 }
@@ -537,7 +537,7 @@ int client_fid_fini(struct obd_device *o
 
if (cli-cl_seq != NULL) {
seq_client_fini(cli-cl_seq);
-   OBD_FREE_PTR(cli-cl_seq);
+   kfree(cli-cl_seq);
cli-cl_seq = NULL;
}
 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 7/11] staging: lustre: mgc: Use kzalloc and kfree

2015-05-01 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by
kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree.

A simplified version of the semantic patch that makes these changes is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr,size; @@
- OBD_ALLOC(ptr,size)
+ ptr = kzalloc(size, GFP_NOFS)

@@ expression ptr, size; @@
- OBD_FREE(ptr, size);
+ kfree(ptr);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/mgc/mgc_request.c |   20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff -u -p a/drivers/staging/lustre/lustre/mgc/mgc_request.c 
b/drivers/staging/lustre/lustre/mgc/mgc_request.c
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -149,7 +149,7 @@ static void config_log_put(struct config
sptlrpc_conf_log_stop(cld-cld_logname);
 
class_export_put(cld-cld_mgcexp);
-   OBD_FREE(cld, sizeof(*cld) + strlen(cld-cld_logname) + 1);
+   kfree(cld);
}
 }
 
@@ -198,7 +198,7 @@ struct config_llog_data *do_config_log_a
CDEBUG(D_MGC, do adding config log %s:%p\n, logname,
   cfg ? cfg-cfg_instance : NULL);
 
-   OBD_ALLOC(cld, sizeof(*cld) + strlen(logname) + 1);
+   cld = kzalloc(sizeof(*cld) + strlen(logname) + 1, GFP_NOFS);
if (!cld)
return ERR_PTR(-ENOMEM);
 
@@ -1129,14 +1129,14 @@ static int mgc_apply_recover_logs(struct
LASSERT(cfg-cfg_instance != NULL);
LASSERT(cfg-cfg_sb == cfg-cfg_instance);
 
-   OBD_ALLOC(inst, PAGE_CACHE_SIZE);
+   inst = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS);
if (inst == NULL)
return -ENOMEM;
 
if (!IS_SERVER(lsi)) {
pos = snprintf(inst, PAGE_CACHE_SIZE, %p, cfg-cfg_instance);
if (pos = PAGE_CACHE_SIZE) {
-   OBD_FREE(inst, PAGE_CACHE_SIZE);
+   kfree(inst);
return -E2BIG;
}
} else {
@@ -1144,7 +1144,7 @@ static int mgc_apply_recover_logs(struct
rc = server_name2svname(lsi-lsi_svname, inst, NULL,
PAGE_CACHE_SIZE);
if (rc) {
-   OBD_FREE(inst, PAGE_CACHE_SIZE);
+   kfree(inst);
return -EINVAL;
}
pos = strlen(inst);
@@ -1302,7 +1302,7 @@ static int mgc_apply_recover_logs(struct
/* continue, even one with error */
}
 
-   OBD_FREE(inst, PAGE_CACHE_SIZE);
+   kfree(inst);
return rc;
 }
 
@@ -1336,7 +1336,7 @@ static int mgc_process_recover_log(struc
if (cfg-cfg_last_idx == 0) /* the first time */
nrpages = CONFIG_READ_NRPAGES_INIT;
 
-   OBD_ALLOC(pages, sizeof(*pages) * nrpages);
+   pages = kcalloc(nrpages, sizeof(*pages), GFP_NOFS);
if (pages == NULL) {
rc = -ENOMEM;
goto out;
@@ -1466,7 +1466,7 @@ out:
break;
__free_page(pages[i]);
}
-   OBD_FREE(pages, sizeof(*pages) * nrpages);
+   kfree(pages);
}
return rc;
 }
@@ -1494,7 +1494,7 @@ static int mgc_process_cfg_log(struct ob
if (cld-cld_cfg.cfg_sb)
lsi = s2lsi(cld-cld_cfg.cfg_sb);
 
-   OBD_ALLOC_PTR(env);
+   env = kzalloc(sizeof(*env), GFP_NOFS);
if (env == NULL)
return -ENOMEM;
 
@@ -1540,7 +1540,7 @@ out_pop:
 
lu_env_fini(env);
 out_free:
-   OBD_FREE_PTR(env);
+   kfree(env);
return rc;
 }
 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/11] Staging: lustre: fld: Use kzalloc and kfree

2015-05-01 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by
kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree.

A simplified version of the semantic patch that makes these changes is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr,size; @@
- OBD_ALLOC(ptr,size)
+ ptr = kzalloc(size, GFP_NOFS)

@@ expression ptr, size; @@
- OBD_FREE(ptr, size);
+ kfree(ptr);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/fld/fld_cache.c   |   16 
 drivers/staging/lustre/lustre/fld/fld_request.c |8 
 2 files changed, 12 insertions(+), 12 deletions(-)

diff -u -p a/drivers/staging/lustre/lustre/fld/fld_request.c 
b/drivers/staging/lustre/lustre/fld/fld_request.c
--- a/drivers/staging/lustre/lustre/fld/fld_request.c
+++ b/drivers/staging/lustre/lustre/fld/fld_request.c
@@ -221,7 +221,7 @@ int fld_client_add_target(struct lu_clie
CDEBUG(D_INFO, %s: Adding target %s (idx %llu)\n,
fld-lcf_name, name, tar-ft_idx);
 
-   OBD_ALLOC_PTR(target);
+   target = kzalloc(sizeof(*target), GFP_NOFS);
if (target == NULL)
return -ENOMEM;
 
@@ -229,7 +229,7 @@ int fld_client_add_target(struct lu_clie
list_for_each_entry(tmp, fld-lcf_targets, ft_chain) {
if (tmp-ft_idx == tar-ft_idx) {
spin_unlock(fld-lcf_lock);
-   OBD_FREE_PTR(target);
+   kfree(target);
CERROR(Target %s exists in FLD and known as 
%s:#%llu\n,
   name, fld_target_name(tmp), tmp-ft_idx);
return -EEXIST;
@@ -268,7 +268,7 @@ int fld_client_del_target(struct lu_clie
if (target-ft_exp != NULL)
class_export_put(target-ft_exp);
 
-   OBD_FREE_PTR(target);
+   kfree(target);
return 0;
}
}
@@ -396,7 +396,7 @@ void fld_client_fini(struct lu_client_fl
list_del(target-ft_chain);
if (target-ft_exp != NULL)
class_export_put(target-ft_exp);
-   OBD_FREE_PTR(target);
+   kfree(target);
}
spin_unlock(fld-lcf_lock);
 
diff -u -p a/drivers/staging/lustre/lustre/fld/fld_cache.c 
b/drivers/staging/lustre/lustre/fld/fld_cache.c
--- a/drivers/staging/lustre/lustre/fld/fld_cache.c
+++ b/drivers/staging/lustre/lustre/fld/fld_cache.c
@@ -69,7 +69,7 @@ struct fld_cache *fld_cache_init(const c
LASSERT(name != NULL);
LASSERT(cache_threshold  cache_size);
 
-   OBD_ALLOC_PTR(cache);
+   cache = kzalloc(sizeof(*cache), GFP_NOFS);
if (cache == NULL)
return ERR_PTR(-ENOMEM);
 
@@ -116,7 +116,7 @@ void fld_cache_fini(struct fld_cache *ca
CDEBUG(D_INFO,   Cache reqs: %llu\n, cache-fci_stat.fst_cache);
CDEBUG(D_INFO,   Cache hits: %llu%%\n, pct);
 
-   OBD_FREE_PTR(cache);
+   kfree(cache);
 }
 
 /**
@@ -128,7 +128,7 @@ void fld_cache_entry_delete(struct fld_c
list_del(node-fce_list);
list_del(node-fce_lru);
cache-fci_cache_count--;
-   OBD_FREE_PTR(node);
+   kfree(node);
 }
 
 /**
@@ -268,7 +268,7 @@ static void fld_cache_punch_hole(struct
 
OBD_ALLOC_GFP(fldt, sizeof(*fldt), GFP_ATOMIC);
if (!fldt) {
-   OBD_FREE_PTR(f_new);
+   kfree(f_new);
/* overlap is not allowed, so dont mess up list. */
return;
}
@@ -315,7 +315,7 @@ static void fld_cache_overlap_handle(str
f_curr-fce_range.lsr_end = max(f_curr-fce_range.lsr_end,
new_end);
 
-   OBD_FREE_PTR(f_new);
+   kfree(f_new);
fld_fix_new_list(cache);
 
} else if (new_start = f_curr-fce_range.lsr_start 
@@ -324,7 +324,7 @@ static void fld_cache_overlap_handle(str
 *   e.g. whole range migrated. update fld cache entry */
 
f_curr-fce_range = *range;
-   OBD_FREE_PTR(f_new);
+   kfree(f_new);
fld_fix_new_list(cache);
 
} else if (f_curr-fce_range.lsr_start  new_start 
@@ -364,7 +364,7 @@ struct fld_cache_entry
 
LASSERT(range_is_sane(range));
 
-   OBD_ALLOC_PTR(f_new);
+   f_new = kzalloc(sizeof(*f_new), GFP_NOFS);
if (!f_new)
return ERR_PTR(-ENOMEM);
 
@@ -440,7 +440,7 @@ int fld_cache_insert(struct fld_cache *c
rc = fld_cache_insert_nolock(cache, flde);
write_unlock(cache-fci_lock);
if (rc)
-   OBD_FREE_PTR(flde);
+   kfree(flde);
 
return rc;
 }

___
devel mailing list
de...@linuxdriverproject.org

Re: [PATCH] staging: i2o: Remove unwanted semicolon

2015-05-01 Thread Dan Carpenter
On Thu, Apr 30, 2015 at 10:05:00PM +0530, hari prasath wrote:
  Greg I am not sure if this needs to go into next release. I send this 
  patch as checkpatch was complaining about it. May be the owners of this 
  driver can only decide  upon it.  Alan cox also mentioned the same 
  point that its about to be deleted.

When you reply to someone's email then the quoted text should have a
  at the start of the line and the new text should not.  Please stop
doing it in the reverse way.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 9/11] staging: lustre: obdecho: Use kzalloc and kfree

2015-05-01 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by
kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree.

A simplified version of the semantic patch that makes these changes is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr,size; @@
- OBD_ALLOC(ptr,size)
+ ptr = kzalloc(size, GFP_NOFS)

@@ expression ptr, size; @@
- OBD_FREE(ptr, size);
+ kfree(ptr);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/obdecho/echo_client.c |   42 ++--
 1 file changed, 21 insertions(+), 21 deletions(-)

diff -u -p a/drivers/staging/lustre/lustre/obdecho/echo_client.c 
b/drivers/staging/lustre/lustre/obdecho/echo_client.c
--- a/drivers/staging/lustre/lustre/obdecho/echo_client.c
+++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c
@@ -479,13 +479,13 @@ static int echo_alloc_memmd(struct echo_
lsm_size = lov_stripe_md_size(1);
 
LASSERT(*lsmp == NULL);
-   OBD_ALLOC(*lsmp, lsm_size);
+   *lsmp = kzalloc(lsm_size, GFP_NOFS);
if (*lsmp == NULL)
return -ENOMEM;
 
-   OBD_ALLOC((*lsmp)-lsm_oinfo[0], sizeof(struct lov_oinfo));
+   (*lsmp)-lsm_oinfo[0] = kzalloc(sizeof(struct lov_oinfo), GFP_NOFS);
if ((*lsmp)-lsm_oinfo[0] == NULL) {
-   OBD_FREE(*lsmp, lsm_size);
+   kfree(*lsmp);
return -ENOMEM;
}
 
@@ -507,8 +507,8 @@ static int echo_free_memmd(struct echo_d
lsm_size = lov_stripe_md_size(1);
 
LASSERT(*lsmp != NULL);
-   OBD_FREE((*lsmp)-lsm_oinfo[0], sizeof(struct lov_oinfo));
-   OBD_FREE(*lsmp, lsm_size);
+   kfree((*lsmp)-lsm_oinfo[0]);
+   kfree(*lsmp);
*lsmp = NULL;
return 0;
 }
@@ -700,7 +700,7 @@ static struct lu_device *echo_device_all
int rc;
int cleanup = 0;
 
-   OBD_ALLOC_PTR(ed);
+   ed = kzalloc(sizeof(*ed), GFP_NOFS);
if (ed == NULL) {
rc = -ENOMEM;
goto out;
@@ -798,7 +798,7 @@ out:
case 2:
cl_device_fini(ed-ed_cl);
case 1:
-   OBD_FREE_PTR(ed);
+   kfree(ed);
case 0:
default:
break;
@@ -895,7 +895,7 @@ static struct lu_device *echo_device_fre
LASSERT(ed-ed_site == lu2cl_site(d-ld_site));
echo_site_fini(env, ed);
cl_device_fini(ed-ed_cl);
-   OBD_FREE_PTR(ed);
+   kfree(ed);
 
return NULL;
 }
@@ -1577,13 +1577,13 @@ static int echo_client_kbrw(struct echo_
if (rw == OBD_BRW_WRITE)
brw_flags = OBD_BRW_ASYNC;
 
-   OBD_ALLOC(pga, npages * sizeof(*pga));
+   pga = kcalloc(npages, sizeof(*pga), GFP_NOFS);
if (pga == NULL)
return -ENOMEM;
 
-   OBD_ALLOC(pages, npages * sizeof(*pages));
+   pages = kcalloc(npages, sizeof(*pages), GFP_NOFS);
if (pages == NULL) {
-   OBD_FREE(pga, npages * sizeof(*pga));
+   kfree(pga);
return -ENOMEM;
}
 
@@ -1632,8 +1632,8 @@ static int echo_client_kbrw(struct echo_
}
OBD_PAGE_FREE(pgp-pg);
}
-   OBD_FREE(pga, npages * sizeof(*pga));
-   OBD_FREE(pages, npages * sizeof(*pages));
+   kfree(pga);
+   kfree(pages);
return rc;
 }
 
@@ -1659,8 +1659,8 @@ static int echo_client_prep_commit(const
npages = batch  PAGE_CACHE_SHIFT;
tot_pages = count  PAGE_CACHE_SHIFT;
 
-   OBD_ALLOC(lnb, npages * sizeof(struct niobuf_local));
-   OBD_ALLOC(rnb, npages * sizeof(struct niobuf_remote));
+   lnb = kcalloc(npages, sizeof(struct niobuf_local), GFP_NOFS);
+   rnb = kcalloc(npages, sizeof(struct niobuf_remote), GFP_NOFS);
 
if (lnb == NULL || rnb == NULL) {
ret = -ENOMEM;
@@ -1738,9 +1738,9 @@ static int echo_client_prep_commit(const
 
 out:
if (lnb)
-   OBD_FREE(lnb, npages * sizeof(struct niobuf_local));
+   kfree(lnb);
if (rnb)
-   OBD_FREE(rnb, npages * sizeof(struct niobuf_remote));
+   kfree(rnb);
return ret;
 }
 
@@ -1879,7 +1879,7 @@ echo_client_iocontrol(unsigned int cmd,
if (rc  0)
return rc;
 
-   OBD_ALLOC_PTR(env);
+   env = kzalloc(sizeof(*env), GFP_NOFS);
if (env == NULL)
return -ENOMEM;
 
@@ -2010,7 +2010,7 @@ echo_client_iocontrol(unsigned int cmd,
 
 out:
lu_env_fini(env);
-   OBD_FREE_PTR(env);
+   kfree(env);
 
/* XXX this should be in a helper also called by target_send_reply */
for (ack_lock = dummy_oti.oti_ack_locks, i = 0; i  4;
@@ -2050,7 +2050,7 @@ static int echo_client_setup(const struc
ec-ec_unique = 0;
ec-ec_nstripes = 0;
 
-   OBD_ALLOC(ocd, sizeof(*ocd));
+   ocd = kzalloc(sizeof(*ocd), GFP_NOFS);
if (ocd == NULL) {
CERROR(Can't 

[PATCH V2 1/1] scsi: storvsc: Set the SRB flags correctly when no data transfer is needed

2015-05-01 Thread K. Y. Srinivasan
Set the SRB flags correctly when there is no data transfer.  Without this change
some IHV drivers will fail valid commands such as TEST_UNIT_READY.

Cc: sta...@vger.kernel.org
Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Reviewed-by: Long Li lon...@microsoft.com
---
V2: Added additional details to the commit log - Dan Carpenter

 drivers/scsi/storvsc_drv.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index d9dad90..3c6584f 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -1600,8 +1600,7 @@ static int storvsc_queuecommand(struct Scsi_Host *host, 
struct scsi_cmnd *scmnd)
break;
default:
vm_srb-data_in = UNKNOWN_TYPE;
-   vm_srb-win8_extension.srb_flags |= (SRB_FLAGS_DATA_IN |
-SRB_FLAGS_DATA_OUT);
+   vm_srb-win8_extension.srb_flags |= SRB_FLAGS_NO_DATA_TRANSFER;
break;
}
 
-- 
1.7.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 8/8] staging: comedi: mite: use a better MODULE_DESCRIPTION()

2015-05-01 Thread Ian Abbott
Signed-off-by: Ian Abbott abbo...@mev.co.uk
---
 drivers/staging/comedi/drivers/mite.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/mite.c 
b/drivers/staging/comedi/drivers/mite.c
index b514ad1..fa7ae2c 100644
--- a/drivers/staging/comedi/drivers/mite.c
+++ b/drivers/staging/comedi/drivers/mite.c
@@ -624,5 +624,5 @@ module_init(mite_module_init);
 module_exit(mite_module_exit);
 
 MODULE_AUTHOR(Comedi http://www.comedi.org;);
-MODULE_DESCRIPTION(Comedi low-level driver);
+MODULE_DESCRIPTION(Comedi helper for NI Mite PCI interface chip);
 MODULE_LICENSE(GPL);
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/8] staging: comedi: mite.h: remove ../comedi_pci.h and make self-reliant

2015-05-01 Thread Ian Abbott
mite.h relies on a lot of things declared including ../comedi_pci.h,
but doesn't need anything in ../comedi_pci.h itself.  None of the
Comedi modules that include mite.h rely on it to include
../comedi_pci.h on their behalf.

Remove the inclusion of ../comedi_pci.h from mite.h, and add enough
other includes and (incomplete) `struct` declarations to make it compile
without warnings or errors even when included first in a .c file.

Signed-off-by: Ian Abbott abbo...@mev.co.uk
---
 drivers/staging/comedi/drivers/mite.h | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/mite.h 
b/drivers/staging/comedi/drivers/mite.h
index 620de2e..5aa4da9 100644
--- a/drivers/staging/comedi/drivers/mite.h
+++ b/drivers/staging/comedi/drivers/mite.h
@@ -19,11 +19,17 @@
 #ifndef _MITE_H_
 #define _MITE_H_
 
+#include linux/io.h
 #include linux/log2.h
-#include ../comedi_pci.h
+#include linux/spinlock.h
 
 #define MAX_MITE_DMA_CHANNELS 8
 
+struct comedi_device;
+struct comedi_subdevice;
+struct device;
+struct pci_dev;
+
 struct mite_dma_descriptor {
__le32 count;
__le32 addr;
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/8] staging: comedi: mite.c: remove commented out USE_KMALLOC

2015-05-01 Thread Ian Abbott
The definition of the macro `USE_KMALLOC` is commented out, and nothing
refers to it.  Remove the commented out macro.

Signed-off-by: Ian Abbott abbo...@mev.co.uk
---
 drivers/staging/comedi/drivers/mite.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/comedi/drivers/mite.c 
b/drivers/staging/comedi/drivers/mite.c
index e45ce00..66b2bec 100644
--- a/drivers/staging/comedi/drivers/mite.c
+++ b/drivers/staging/comedi/drivers/mite.c
@@ -42,8 +42,6 @@
 
 */
 
-/* #define USE_KMALLOC */
-
 #define pr_fmt(fmt) KBUILD_MODNAME :  fmt
 
 #include linux/module.h
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 5/8] staging: comedi: mite.h: reformat some comments

2015-05-01 Thread Ian Abbott
Use the usual style for block comments.  Squash double spaces after
comment opening sequences.

Signed-off-by: Ian Abbott abbo...@mev.co.uk
---
 drivers/staging/comedi/drivers/mite.h | 59 ++-
 1 file changed, 30 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/comedi/drivers/mite.h 
b/drivers/staging/comedi/drivers/mite.h
index 5aa4da9..0d178c1 100644
--- a/drivers/staging/comedi/drivers/mite.h
+++ b/drivers/staging/comedi/drivers/mite.h
@@ -1,20 +1,20 @@
 /*
-module/mite.h
-Hardware driver for NI Mite PCI interface chip
-
-COMEDI - Linux Control and Measurement Device Interface
-Copyright (C) 1999 David A. Schleef d...@schleef.org
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-*/
+ * module/mite.h
+ * Hardware driver for NI Mite PCI interface chip
+ *
+ * COMEDI - Linux Control and Measurement Device Interface
+ * Copyright (C) 1999 David A. Schleef d...@schleef.org
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
 
 #ifndef _MITE_H_
 #define _MITE_H_
@@ -115,12 +115,14 @@ int mite_buf_change(struct mite_dma_descriptor_ring *ring,
struct comedi_subdevice *s);
 
 enum mite_registers {
-   /* The bits 0x90180700 in MITE_UNKNOWN_DMA_BURST_REG can be
-  written and read back.  The bits 0x1f always read as 1.
-  The rest always read as zero. */
+   /*
+* The bits 0x90180700 in MITE_UNKNOWN_DMA_BURST_REG can be
+* written and read back.  The bits 0x1f always read as 1.
+* The rest always read as zero.
+*/
MITE_UNKNOWN_DMA_BURST_REG = 0x28,
MITE_IODWBSR = 0xc0,/* IO Device Window Base Size Register */
-   MITE_IODWBSR_1 = 0xc4,  /*  IO Device Window Base Size Register 1 */
+   MITE_IODWBSR_1 = 0xc4,  /* IO Device Window Base Size Register 1 */
MITE_IODWCR_1 = 0xf4,
MITE_PCI_CONFIG_OFFSET = 0x300,
MITE_CSIGR = 0x460  /* chip signature */
@@ -146,7 +148,7 @@ enum mite_registers {
 #define MITE_FCR(x)(0x40 + MITE_CHAN(x))   /* fifo count */
 
 enum MITE_IODWBSR_bits {
-   WENAB = 0x80,   /*  window enable */
+   WENAB = 0x80,   /* window enable */
 };
 
 static inline unsigned MITE_IODWBSR_1_WSIZE_bits(unsigned size)
@@ -169,27 +171,27 @@ static inline int mite_csigr_version(u32 csigr_bits)
 };
 
 static inline int mite_csigr_type(u32 csigr_bits)
-{  /*  original mite = 0, minimite = 1 */
+{  /* original mite = 0, minimite = 1 */
return (csigr_bits  4)  0xf;
 };
 
 static inline int mite_csigr_mmode(u32 csigr_bits)
-{  /*  mite mode, minimite = 1 */
+{  /* mite mode, minimite = 1 */
return (csigr_bits  8)  0x3;
 };
 
 static inline int mite_csigr_imode(u32 csigr_bits)
-{  /*  cpu port interface mode, pci = 0x3 */
+{  /* cpu port interface mode, pci = 0x3 */
return (csigr_bits  12)  0x3;
 };
 
 static inline int mite_csigr_dmac(u32 csigr_bits)
-{  /*  number of dma channels */
+{  /* number of dma channels */
return (csigr_bits  16)  0xf;
 };
 
 static inline int mite_csigr_wpdep(u32 csigr_bits)
-{  /*  write post fifo depth */
+{  /* write post fifo depth */
unsigned int wpdep_bits = (csigr_bits  20)  0x7;
 
return (wpdep_bits) ? (1  (wpdep_bits - 1)) : 0;
@@ -201,7 +203,7 @@ static inline int mite_csigr_wins(u32 csigr_bits)
 };
 
 static inline int mite_csigr_iowins(u32 csigr_bits)
-{  /*  number of io windows */
+{  /* number of io windows */
return (csigr_bits  29)  0x7;
 };
 
@@ -290,8 +292,7 @@ static inline int CR_REQS(int source)
 
 static inline int CR_REQSDRQ(unsigned drq_line)
 {
-   /* This also works on m-series when
-  using channels (drq_line) 4 or 5. */
+   /* 

[PATCH 2/8] staging: comedi: mite.h: remove PCIMIO_COMPAT

2015-05-01 Thread Ian Abbott
The macro `PCIMIO_COMPAT` is defined, but never used.  Remove it.

Signed-off-by: Ian Abbott abbo...@mev.co.uk
---
 drivers/staging/comedi/drivers/mite.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/comedi/drivers/mite.h 
b/drivers/staging/comedi/drivers/mite.h
index cf45f88..620de2e 100644
--- a/drivers/staging/comedi/drivers/mite.h
+++ b/drivers/staging/comedi/drivers/mite.h
@@ -22,8 +22,6 @@
 #include linux/log2.h
 #include ../comedi_pci.h
 
-#define PCIMIO_COMPAT
-
 #define MAX_MITE_DMA_CHANNELS 8
 
 struct mite_dma_descriptor {
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/8] staging: comedi: mite: move #include linux/slab.h

2015-05-01 Thread Ian Abbott
The Comedi driver modules build fine if the inclusion of linux/slab.h
is removed from mite.h, so remove it.  However, since mite.c calls
`kzalloc()`, include linux/slab.h there.

Signed-off-by: Ian Abbott abbo...@mev.co.uk
---
 drivers/staging/comedi/drivers/mite.c | 1 +
 drivers/staging/comedi/drivers/mite.h | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/mite.c 
b/drivers/staging/comedi/drivers/mite.c
index e43a0c8..e45ce00 100644
--- a/drivers/staging/comedi/drivers/mite.c
+++ b/drivers/staging/comedi/drivers/mite.c
@@ -47,6 +47,7 @@
 #define pr_fmt(fmt) KBUILD_MODNAME :  fmt
 
 #include linux/module.h
+#include linux/slab.h
 
 #include ../comedi_pci.h
 
diff --git a/drivers/staging/comedi/drivers/mite.h 
b/drivers/staging/comedi/drivers/mite.h
index b3ca7fc..cf45f88 100644
--- a/drivers/staging/comedi/drivers/mite.h
+++ b/drivers/staging/comedi/drivers/mite.h
@@ -20,7 +20,6 @@
 #define _MITE_H_
 
 #include linux/log2.h
-#include linux/slab.h
 #include ../comedi_pci.h
 
 #define PCIMIO_COMPAT
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 0/8] staging: comedi: mite: some clean-ups

2015-05-01 Thread Ian Abbott
1) staging: comedi: mite: move #include linux/slab.h
2) staging: comedi: mite.h: remove PCIMIO_COMPAT
3) staging: comedi: mite.c: remove commented out USE_KMALLOC
4) staging: comedi: mite.h: remove ../comedi_pci.h and make
   self-reliant
5) staging: comedi: mite.h: reformat some comments
6) staging: comedi: mite.c: reformat comments
7) staging: comedi: mite.h: whitespace changes in function declarations
8) staging: comedi: mite: use a better MODULE_DESCRIPTION()

TODO: document the exported functions in mite.c.

 drivers/staging/comedi/drivers/mite.c | 110 +-
 drivers/staging/comedi/drivers/mite.h |  88 ++-
 2 files changed, 101 insertions(+), 97 deletions(-)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 7/8] staging: comedi: mite.h: whitespace changes in function declarations

2015-05-01 Thread Ian Abbott
Reformat some function declarations to avoid bunching up near column 80.

Also add a blank line after a `struct` definition.

Signed-off-by: Ian Abbott abbo...@mev.co.uk
---
 drivers/staging/comedi/drivers/mite.h | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/comedi/drivers/mite.h 
b/drivers/staging/comedi/drivers/mite.h
index 0d178c1..c32d4e4 100644
--- a/drivers/staging/comedi/drivers/mite.h
+++ b/drivers/staging/comedi/drivers/mite.h
@@ -77,16 +77,13 @@ static inline int mite_setup(struct comedi_device *dev,
 void mite_detach(struct mite_struct *mite);
 struct mite_dma_descriptor_ring *mite_alloc_ring(struct mite_struct *mite);
 void mite_free_ring(struct mite_dma_descriptor_ring *ring);
-struct mite_channel *mite_request_channel_in_range(struct mite_struct *mite,
-  struct
-  mite_dma_descriptor_ring
-  *ring, unsigned min_channel,
-  unsigned max_channel);
-static inline struct mite_channel *mite_request_channel(struct mite_struct
-   *mite,
-   struct
-   mite_dma_descriptor_ring
-   *ring)
+struct mite_channel *
+mite_request_channel_in_range(struct mite_struct *mite,
+ struct mite_dma_descriptor_ring *ring,
+ unsigned min_channel, unsigned max_channel);
+static inline struct mite_channel *
+mite_request_channel(struct mite_struct *mite,
+struct mite_dma_descriptor_ring *ring)
 {
return mite_request_channel_in_range(mite, ring, 0,
 mite-num_channels - 1);
@@ -285,6 +282,7 @@ enum ConfigRegister_bits {
CR_PORTMXI = (3  6),
CR_AMDEVICE = (1  0),
 };
+
 static inline int CR_REQS(int source)
 {
return (source  0x7)  16;
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 6/8] staging: comedi: mite.c: reformat comments

2015-05-01 Thread Ian Abbott
Use the usual style for block comments.  Squash double spaces after
comment opening sequences.

Signed-off-by: Ian Abbott abbo...@mev.co.uk
---
 drivers/staging/comedi/drivers/mite.c | 105 +-
 1 file changed, 54 insertions(+), 51 deletions(-)

diff --git a/drivers/staging/comedi/drivers/mite.c 
b/drivers/staging/comedi/drivers/mite.c
index 66b2bec..b514ad1 100644
--- a/drivers/staging/comedi/drivers/mite.c
+++ b/drivers/staging/comedi/drivers/mite.c
@@ -1,46 +1,46 @@
 /*
-comedi/drivers/mite.c
-Hardware driver for NI Mite PCI interface chip
-
-COMEDI - Linux Control and Measurement Device Interface
-Copyright (C) 1997-2002 David A. Schleef d...@schleef.org
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-*/
+ * comedi/drivers/mite.c
+ * Hardware driver for NI Mite PCI interface chip
+ *
+ * COMEDI - Linux Control and Measurement Device Interface
+ * Copyright (C) 1997-2002 David A. Schleef d...@schleef.org
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
 
 /*
-   The PCI-MIO E series driver was originally written by
-   Tomasz Motylewski ..., and ported to comedi by ds.
-
-   References for specifications:
-
-  321747b.pdf  Register Level Programmer Manual (obsolete)
-  321747c.pdf  Register Level Programmer Manual (new)
-  DAQ-STC reference manual
-
-   Other possibly relevant info:
-
-  320517c.pdf  User manual (obsolete)
-  320517f.pdf  User manual (new)
-  320889a.pdf  delete
-  320906c.pdf  maximum signal ratings
-  321066a.pdf  about 16x
-  321791a.pdf  discontinuation of at-mio-16e-10 rev. c
-  321808a.pdf  about at-mio-16e-10 rev P
-  321837a.pdf  discontinuation of at-mio-16de-10 rev d
-  321838a.pdf  about at-mio-16de-10 rev N
-
-   ISSUES:
-
-*/
+ * The PCI-MIO E series driver was originally written by
+ * Tomasz Motylewski ..., and ported to comedi by ds.
+ *
+ * References for specifications:
+ *
+ *321747b.pdf  Register Level Programmer Manual (obsolete)
+ *321747c.pdf  Register Level Programmer Manual (new)
+ *DAQ-STC reference manual
+ *
+ * Other possibly relevant info:
+ *
+ *320517c.pdf  User manual (obsolete)
+ *320517f.pdf  User manual (new)
+ *320889a.pdf  delete
+ *320906c.pdf  maximum signal ratings
+ *321066a.pdf  about 16x
+ *321791a.pdf  discontinuation of at-mio-16e-10 rev. c
+ *321808a.pdf  about at-mio-16e-10 rev P
+ *321837a.pdf  discontinuation of at-mio-16de-10 rev d
+ *321838a.pdf  about at-mio-16de-10 rev N
+ *
+ * ISSUES:
+ *
+ */
 
 #define pr_fmt(fmt) KBUILD_MODNAME :  fmt
 
@@ -131,7 +131,7 @@ int mite_setup2(struct comedi_device *dev,
   mite-mite_io_addr + MITE_IODWBSR);
}
/*
-* make sure dma bursts work. I got this from running a bus analyzer
+* Make sure dma bursts work. I got this from running a bus analyzer
 * on a pxi-6281 and a pxi-6713. 6713 powered up with register value
 * of 0x61f and bursts worked. 6281 powered up with register value of
 * 0x1f and bursts didn't work. The NI windows driver reads the
@@ -223,7 +223,8 @@ struct mite_channel *mite_request_channel_in_range(struct 
mite_struct *mite,
unsigned long flags;
struct mite_channel *channel = NULL;
 
-   /* spin lock so mite_release_channel can be called safely
+   /*
+* spin lock so mite_release_channel can be called safely
 * from interrupts
 */
spin_lock_irqsave(mite-lock, flags);
@@ -245,15 +246,15 @@ void mite_release_channel(struct mite_channel *mite_chan)
struct mite_struct *mite = mite_chan-mite;
unsigned long flags;
 
-   /*  spin lock to prevent races with mite_request_channel */
+   /* spin lock to prevent races with mite_request_channel */
spin_lock_irqsave(mite-lock, flags);
if (mite-channel_allocated[mite_chan-channel]) {
mite_dma_disarm(mite_chan);

RE: [HPDD-discuss] [PATCH 2/11] Staging: lustre: fld: Use kzalloc and kfree

2015-05-01 Thread Julia Lawall
On Fri, 1 May 2015, Simmons, James A. wrote:

 From: Julia Lawall julia.law...@lip6.fr
 
 Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by
 kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree.
 
 Nak: James Simmons jsimm...@infradead.org
 
 A simple replace will not work. The OBD_ALLOC and OBD_FREE functions allocate 
 memory
 anywhere from one page to 4MB in size. You can't use kmalloc for the 4MB 
 allocations.
 Currently lustre uses  a 4 page water mark to determine if we allocate using 
 vmalloc. Even
 using kmalloc for 4 pages has shown high failure rates on some systems. It 
 gets even more
 messy with 64K page systems like ppc64 boxes. Now I'm not suggesting to port 
 the larger
 allocations to vmalloc either since issues have been founded with using 
 vmalloc. For example
 when using large stripe count files the MDS rpc generated crosses the 4 page 
 line and vmalloc
 is used. Using vmalloc caused a global spinlock to be taken which causes meta 
 data operations
 to serialized on the MDS servers.

It's not the LARGE functions that do the switching?  For example OBD_ALLOC 
ends up at  __OBD_MALLOC_VERBOSE, which as far as I can see calls kmalloc 
(with __GFP_ZERO, and hance the use of kzalloc).

julia
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [HPDD-discuss] [PATCH 2/11] Staging: lustre: fld: Use kzalloc and kfree

2015-05-01 Thread Simmons, James A.
From: Julia Lawall julia.law...@lip6.fr

Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by
kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree.

Nak: James Simmons jsimm...@infradead.org

A simple replace will not work. The OBD_ALLOC and OBD_FREE functions allocate 
memory
anywhere from one page to 4MB in size. You can't use kmalloc for the 4MB 
allocations.
Currently lustre uses  a 4 page water mark to determine if we allocate using 
vmalloc. Even
using kmalloc for 4 pages has shown high failure rates on some systems. It gets 
even more
messy with 64K page systems like ppc64 boxes. Now I'm not suggesting to port 
the larger
allocations to vmalloc either since issues have been founded with using 
vmalloc. For example
when using large stripe count files the MDS rpc generated crosses the 4 page 
line and vmalloc
is used. Using vmalloc caused a global spinlock to be taken which causes meta 
data operations
to serialized on the MDS servers.

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[RFC PATCH 09/11] MIPS: OCTEON: move ethernet-specific helpers to staging

2015-05-01 Thread Aaro Koskinen
Move all ethernet-specific helpers to staging.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 arch/mips/cavium-octeon/executive/Makefile|  8 +---
 arch/mips/cavium-octeon/executive/cvmx-helper-board.c |  1 +
 arch/mips/cavium-octeon/executive/cvmx-helper.c   |  1 +
 drivers/staging/octeon/Makefile   | 15 ++-
 .../executive = drivers/staging/octeon}/cvmx-cmd-queue.c |  0
 .../staging/octeon}/cvmx-helper-ethernet.c|  0
 .../staging/octeon}/cvmx-helper-loop.c|  0
 .../staging/octeon}/cvmx-helper-npi.c |  0
 .../staging/octeon}/cvmx-helper-rgmii.c   |  0
 .../staging/octeon}/cvmx-helper-sgmii.c   |  0
 .../staging/octeon}/cvmx-helper-spi.c |  0
 .../staging/octeon}/cvmx-helper-util.c|  0
 .../staging/octeon}/cvmx-helper-xaui.c|  0
 .../staging/octeon}/cvmx-interrupt-decodes.c  |  0
 .../staging/octeon}/cvmx-interrupt-rsl.c  |  0
 .../executive = drivers/staging/octeon}/cvmx-link.c  |  0
 .../executive = drivers/staging/octeon}/cvmx-pko.c   |  0
 .../executive = drivers/staging/octeon}/cvmx-spi.c   |  0
 18 files changed, 17 insertions(+), 8 deletions(-)
 rename {arch/mips/cavium-octeon/executive = 
drivers/staging/octeon}/cvmx-cmd-queue.c (100%)
 rename {arch/mips/cavium-octeon/executive = 
drivers/staging/octeon}/cvmx-helper-ethernet.c (100%)
 rename {arch/mips/cavium-octeon/executive = 
drivers/staging/octeon}/cvmx-helper-loop.c (100%)
 rename {arch/mips/cavium-octeon/executive = 
drivers/staging/octeon}/cvmx-helper-npi.c (100%)
 rename {arch/mips/cavium-octeon/executive = 
drivers/staging/octeon}/cvmx-helper-rgmii.c (100%)
 rename {arch/mips/cavium-octeon/executive = 
drivers/staging/octeon}/cvmx-helper-sgmii.c (100%)
 rename {arch/mips/cavium-octeon/executive = 
drivers/staging/octeon}/cvmx-helper-spi.c (100%)
 rename {arch/mips/cavium-octeon/executive = 
drivers/staging/octeon}/cvmx-helper-util.c (100%)
 rename {arch/mips/cavium-octeon/executive = 
drivers/staging/octeon}/cvmx-helper-xaui.c (100%)
 rename {arch/mips/cavium-octeon/executive = 
drivers/staging/octeon}/cvmx-interrupt-decodes.c (100%)
 rename {arch/mips/cavium-octeon/executive = 
drivers/staging/octeon}/cvmx-interrupt-rsl.c (100%)
 rename {arch/mips/cavium-octeon/executive = 
drivers/staging/octeon}/cvmx-link.c (100%)
 rename {arch/mips/cavium-octeon/executive = 
drivers/staging/octeon}/cvmx-pko.c (100%)
 rename {arch/mips/cavium-octeon/executive = 
drivers/staging/octeon}/cvmx-spi.c (100%)

diff --git a/arch/mips/cavium-octeon/executive/Makefile 
b/arch/mips/cavium-octeon/executive/Makefile
index abafe06..6e59ee4 100644
--- a/arch/mips/cavium-octeon/executive/Makefile
+++ b/arch/mips/cavium-octeon/executive/Makefile
@@ -10,11 +10,5 @@
 #
 
 obj-y += cvmx-bootmem.o cvmx-l2c.o cvmx-sysinfo.o octeon-model.o
-obj-y += cvmx-pko.o cvmx-spi.o cvmx-cmd-queue.o \
-   cvmx-helper-board.o cvmx-helper.o cvmx-helper-xaui.o \
-   cvmx-helper-rgmii.o cvmx-helper-sgmii.o cvmx-helper-npi.o \
-   cvmx-helper-loop.o cvmx-helper-spi.o cvmx-helper-util.o \
-   cvmx-helper-ethernet.o cvmx-link.o \
-   cvmx-interrupt-decodes.o cvmx-interrupt-rsl.o
-
+obj-y += cvmx-helper-board.o cvmx-helper.o
 obj-y += cvmx-helper-errata.o cvmx-helper-jtag.o
diff --git a/arch/mips/cavium-octeon/executive/cvmx-helper-board.c 
b/arch/mips/cavium-octeon/executive/cvmx-helper-board.c
index 10f8de1..32d3284 100644
--- a/arch/mips/cavium-octeon/executive/cvmx-helper-board.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-helper-board.c
@@ -186,6 +186,7 @@ int cvmx_helper_board_get_mii_address(int ipd_port)
 cvmx_sysinfo_get()-board_type);
return -1;
 }
+EXPORT_SYMBOL_GPL(cvmx_helper_board_get_mii_address);
 
 /**
  * This function is called by cvmx_helper_interface_probe() after it
diff --git a/arch/mips/cavium-octeon/executive/cvmx-helper.c 
b/arch/mips/cavium-octeon/executive/cvmx-helper.c
index 414ca1a..995fa42 100644
--- a/arch/mips/cavium-octeon/executive/cvmx-helper.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-helper.c
@@ -506,3 +506,4 @@ int cvmx_helper_interface_enumerate(int interface)
 
return 0;
 }
+EXPORT_SYMBOL_GPL(cvmx_helper_interface_enumerate);
diff --git a/drivers/staging/octeon/Makefile b/drivers/staging/octeon/Makefile
index 9012dee..9a72fea 100644
--- a/drivers/staging/octeon/Makefile
+++ b/drivers/staging/octeon/Makefile
@@ -20,4 +20,17 @@ octeon-ethernet-y += ethernet-sgmii.o
 octeon-ethernet-y += ethernet-spi.o
 octeon-ethernet-y += ethernet-tx.o
 octeon-ethernet-y += ethernet-xaui.o
-
+octeon-ethernet-y += cvmx-cmd-queue.o
+octeon-ethernet-y += cvmx-helper-ethernet.o
+octeon-ethernet-y += cvmx-helper-loop.o
+octeon-ethernet-y += cvmx-helper-npi.o
+octeon-ethernet-y += cvmx-helper-rgmii.o
+octeon-ethernet-y += cvmx-helper-sgmii.o
+octeon-ethernet-y += 

[PATCH 12/20] staging: lustre: obdclass: genops: remove unneeded null test before free

2015-05-01 Thread Julia Lawall
Kfree can cope with a null argument, so drop null tests.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr; @@

- if (ptr != NULL)
  kfree(ptr);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/obdclass/genops.c |   15 +--
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c 
b/drivers/staging/lustre/lustre/obdclass/genops.c
index a107aea..37d6aef 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -213,12 +213,9 @@ int class_register_type(struct obd_ops *dt_ops, struct 
md_ops *md_ops,
return 0;
 
  failed:
-   if (type-typ_name != NULL)
-   kfree(type-typ_name);
-   if (type-typ_md_ops != NULL)
-   kfree(type-typ_md_ops);
-   if (type-typ_dt_ops != NULL)
-   kfree(type-typ_dt_ops);
+   kfree(type-typ_name);
+   kfree(type-typ_md_ops);
+   kfree(type-typ_dt_ops);
kfree(type);
return rc;
 }
@@ -253,10 +250,8 @@ int class_unregister_type(const char *name)
list_del(type-typ_chain);
spin_unlock(obd_types_lock);
kfree(type-typ_name);
-   if (type-typ_dt_ops != NULL)
-   kfree(type-typ_dt_ops);
-   if (type-typ_md_ops != NULL)
-   kfree(type-typ_md_ops);
+   kfree(type-typ_dt_ops);
+   kfree(type-typ_md_ops);
kfree(type);
return 0;
 } /* class_unregister_type */

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 11/20] staging: lustre: mdc: remove unneeded null test before free

2015-05-01 Thread Julia Lawall
Kfree can cope with a null argument, so drop null tests.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr; @@

- if (ptr != NULL)
  kfree(ptr);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---

 drivers/staging/lustre/lustre/mdc/mdc_request.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c 
b/drivers/staging/lustre/lustre/mdc/mdc_request.c
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -1644,8 +1644,7 @@ out:
llog_cat_close(NULL, llh);
if (ctxt)
llog_ctxt_put(ctxt);
-   if (cs-cs_buf)
-   kfree(cs-cs_buf);
+   kfree(cs-cs_buf);
kfree(cs);
return rc;
 }
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 15/20] staging: lustre: obdclass: obd_mount: remove unneeded null test before free

2015-05-01 Thread Julia Lawall
Kfree can cope with a null argument, so drop null tests.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr; @@

- if (ptr != NULL)
  kfree(ptr);

@@ expression ptr; @@

- if (ptr != NULL) {
  kfree(ptr);
  ptr = NULL;
- }
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/obdclass/obd_mount.c |   45 +++--
 1 file changed, 15 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c 
b/drivers/staging/lustre/lustre/obdclass/obd_mount.c
index 04a22169..1f9a5f7 100644
--- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c
+++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c
@@ -464,12 +464,9 @@ out:
 out_free:
mutex_unlock(mgc_start_lock);
 
-   if (data)
-   kfree(data);
-   if (mgcname)
-   kfree(mgcname);
-   if (niduuid)
-   kfree(niduuid);
+   kfree(data);
+   kfree(mgcname);
+   kfree(niduuid);
return rc;
 }
 
@@ -538,8 +535,7 @@ static int lustre_stop_mgc(struct super_block *sb)
   niduuid, rc);
}
 out:
-   if (niduuid)
-   kfree(niduuid);
+   kfree(niduuid);
 
/* class_import_put will get rid of the additional connections */
mutex_unlock(mgc_start_lock);
@@ -585,22 +581,15 @@ static int lustre_free_lsi(struct super_block *sb)
LASSERT(atomic_read(lsi-lsi_mounts) == 0);
 
if (lsi-lsi_lmd != NULL) {
-   if (lsi-lsi_lmd-lmd_dev != NULL)
-   kfree(lsi-lsi_lmd-lmd_dev);
-   if (lsi-lsi_lmd-lmd_profile != NULL)
-   kfree(lsi-lsi_lmd-lmd_profile);
-   if (lsi-lsi_lmd-lmd_mgssec != NULL)
-   kfree(lsi-lsi_lmd-lmd_mgssec);
-   if (lsi-lsi_lmd-lmd_opts != NULL)
-   kfree(lsi-lsi_lmd-lmd_opts);
+   kfree(lsi-lsi_lmd-lmd_dev);
+   kfree(lsi-lsi_lmd-lmd_profile);
+   kfree(lsi-lsi_lmd-lmd_mgssec);
+   kfree(lsi-lsi_lmd-lmd_opts);
if (lsi-lsi_lmd-lmd_exclude_count)
kfree(lsi-lsi_lmd-lmd_exclude);
-   if (lsi-lsi_lmd-lmd_mgs != NULL)
-   kfree(lsi-lsi_lmd-lmd_mgs);
-   if (lsi-lsi_lmd-lmd_osd_type != NULL)
-   kfree(lsi-lsi_lmd-lmd_osd_type);
-   if (lsi-lsi_lmd-lmd_params != NULL)
-   kfree(lsi-lsi_lmd-lmd_params);
+   kfree(lsi-lsi_lmd-lmd_mgs);
+   kfree(lsi-lsi_lmd-lmd_osd_type);
+   kfree(lsi-lsi_lmd-lmd_params);
 
kfree(lsi-lsi_lmd);
}
@@ -886,10 +875,8 @@ static int lmd_parse_mgssec(struct lustre_mount_data *lmd, 
char *ptr)
char   *tail;
int length;
 
-   if (lmd-lmd_mgssec != NULL) {
-   kfree(lmd-lmd_mgssec);
-   lmd-lmd_mgssec = NULL;
-   }
+   kfree(lmd-lmd_mgssec);
+   lmd-lmd_mgssec = NULL;
 
tail = strchr(ptr, ',');
if (tail == NULL)
@@ -914,10 +901,8 @@ static int lmd_parse_string(char **handle, char *ptr)
if ((handle == NULL) || (ptr == NULL))
return -EINVAL;
 
-   if (*handle != NULL) {
-   kfree(*handle);
-   *handle = NULL;
-   }
+   kfree(*handle);
+   *handle = NULL;
 
tail = strchr(ptr, ',');
if (tail == NULL)

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 14/20] staging: lustre: obdclass: obd_config: remove unneeded null test before free

2015-05-01 Thread Julia Lawall
Kfree can cope with a null argument, so drop null tests.

The semantic patch that identifies this issue is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr; @@

- if (ptr != NULL)
  kfree(ptr);
// /smpl

The first part of the patch introduces new labels to avoid unnecessary
calls to kfree.  In addition, lprof-lp_md is always null in the cleanup
code at the end of the function, so that kfree is just dropped.

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/obdclass/obd_config.c |   24 
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c 
b/drivers/staging/lustre/lustre/obdclass/obd_config.c
index 687fbbd..0bda9c5 100644
--- a/drivers/staging/lustre/lustre/obdclass/obd_config.c
+++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c
@@ -869,7 +869,7 @@ int class_add_profile(int proflen, char *prof, int osclen, 
char *osc,
lprof-lp_profile = kzalloc(proflen, GFP_NOFS);
if (lprof-lp_profile == NULL) {
err = -ENOMEM;
-   goto out;
+   goto free_lprof;
}
memcpy(lprof-lp_profile, prof, proflen);
 
@@ -877,7 +877,7 @@ int class_add_profile(int proflen, char *prof, int osclen, 
char *osc,
lprof-lp_dt = kzalloc(osclen, GFP_NOFS);
if (lprof-lp_dt == NULL) {
err = -ENOMEM;
-   goto out;
+   goto free_lp_profile;
}
memcpy(lprof-lp_dt, osc, osclen);
 
@@ -886,7 +886,7 @@ int class_add_profile(int proflen, char *prof, int osclen, 
char *osc,
lprof-lp_md = kzalloc(mdclen, GFP_NOFS);
if (lprof-lp_md == NULL) {
err = -ENOMEM;
-   goto out;
+   goto free_lp_dt;
}
memcpy(lprof-lp_md, mdc, mdclen);
}
@@ -894,13 +894,11 @@ int class_add_profile(int proflen, char *prof, int 
osclen, char *osc,
list_add(lprof-lp_list, lustre_profile_list);
return err;
 
-out:
-   if (lprof-lp_md)
-   kfree(lprof-lp_md);
-   if (lprof-lp_dt)
-   kfree(lprof-lp_dt);
-   if (lprof-lp_profile)
-   kfree(lprof-lp_profile);
+free_lp_dt:
+   kfree(lprof-lp_dt);
+free_lp_profile:
+   kfree(lprof-lp_profile);
+free_lprof:
kfree(lprof);
return err;
 }
@@ -916,8 +914,7 @@ void class_del_profile(const char *prof)
list_del(lprof-lp_list);
kfree(lprof-lp_profile);
kfree(lprof-lp_dt);
-   if (lprof-lp_md)
-   kfree(lprof-lp_md);
+   kfree(lprof-lp_md);
kfree(lprof);
}
 }
@@ -932,8 +929,7 @@ void class_del_profiles(void)
list_del(lprof-lp_list);
kfree(lprof-lp_profile);
kfree(lprof-lp_dt);
-   if (lprof-lp_md)
-   kfree(lprof-lp_md);
+   kfree(lprof-lp_md);
kfree(lprof);
}
 }

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/20] staging: lustre: ldlm: ldlm_resource: remove unneeded null test before free

2015-05-01 Thread Julia Lawall
Kfree can cope with a null argument, so drop null tests.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr; @@

- if (ptr != NULL) {
  kfree(ptr);
  ptr = NULL;
- }
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
index 5922069..7149eda 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -1137,10 +1137,8 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct 
ldlm_resource *parent,
CERROR(%s: lvbo_init failed for resource %#llx:%#llx: 
rc = %d\n,
   ns-ns_obd-obd_name, name-name[0],
   name-name[1], rc);
-   if (res-lr_lvb_data) {
-   kfree(res-lr_lvb_data);
-   res-lr_lvb_data = NULL;
-   }
+   kfree(res-lr_lvb_data);
+   res-lr_lvb_data = NULL;
res-lr_lvb_len = rc;
mutex_unlock(res-lr_lvb_mutex);
ldlm_resource_putref(res);

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 5/20] Staging: lustre: llite: dir: remove unneeded null test before free

2015-05-01 Thread Julia Lawall
Kfree can cope with a null argument, so drop null tests.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr; @@

- if (ptr != NULL)
  kfree(ptr);
// /smpl

This patch additionally simplifies one case where the free, and thus the
jump to the end of the function, is not needed.

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/llite/dir.c |9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/dir.c 
b/drivers/staging/lustre/lustre/llite/dir.c
index f17154a..4b0de8d 100644
--- a/drivers/staging/lustre/lustre/llite/dir.c
+++ b/drivers/staging/lustre/lustre/llite/dir.c
@@ -754,10 +754,8 @@ int ll_dir_setstripe(struct inode *inode, struct 
lov_user_md *lump,
char *buf;
 
param = kzalloc(MGS_PARAM_MAXLEN, GFP_NOFS);
-   if (!param) {
-   rc = -ENOMEM;
-   goto end;
-   }
+   if (!param)
+   return -ENOMEM;
 
buf = param;
/* Get fsname and assume devname to be -MDT. */
@@ -786,8 +784,7 @@ int ll_dir_setstripe(struct inode *inode, struct 
lov_user_md *lump,
rc = ll_send_mgc_param(mgc-u.cli.cl_mgc_mgsexp, param);
 
 end:
-   if (param != NULL)
-   kfree(param);
+   kfree(param);
}
return rc;
 }

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 20/20] staging: lustre: ptlrpc: service: remove unneeded null test before free

2015-05-01 Thread Julia Lawall
Kfree can cope with a null argument, so drop null tests.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr; @@

- if (ptr != NULL)
  kfree(ptr);

@@ expression ptr; @@

- if (ptr != NULL) {
  kfree(ptr);
  ptr = NULL;
- }
// /smpl

In the first case, specific labels are introduced to free only what is needed.

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/ptlrpc/service.c |   39 -
 1 file changed, 14 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c 
b/drivers/staging/lustre/lustre/ptlrpc/service.c
index d0758ab..d85db06 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/service.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/service.c
@@ -641,7 +641,7 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc,
OBD_CPT_ALLOC(array-paa_reqs_count,
  svc-srv_cptable, cpt, sizeof(__u32) * size);
if (array-paa_reqs_count == NULL)
-   goto failed;
+   goto free_reqs_array;
 
cfs_timer_init(svcpt-scp_at_timer, ptlrpc_at_timer, svcpt);
/* At SOW, service time should be quick; 10s seems generous. If client
@@ -655,20 +655,16 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc,
/* We shouldn't be under memory pressure at startup, so
 * fail if we can't allocate all our buffers at this time. */
if (rc != 0)
-   goto failed;
+   goto free_reqs_count;
 
return 0;
 
- failed:
-   if (array-paa_reqs_count != NULL) {
-   kfree(array-paa_reqs_count);
-   array-paa_reqs_count = NULL;
-   }
-
-   if (array-paa_reqs_array != NULL) {
-   kfree(array-paa_reqs_array);
-   array-paa_reqs_array = NULL;
-   }
+free_reqs_count:
+   kfree(array-paa_reqs_count);
+   array-paa_reqs_count = NULL;
+free_reqs_array:
+   kfree(array-paa_reqs_array);
+   array-paa_reqs_array = NULL;
 
return -ENOMEM;
 }
@@ -722,8 +718,7 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf,
if (rc = 0) {
CERROR(%s: failed to parse CPT array %s: %d\n,
   conf-psc_name, cconf-cc_pattern, rc);
-   if (cpts != NULL)
-   kfree(cpts);
+   kfree(cpts);
return ERR_PTR(rc  0 ? rc : -EINVAL);
}
ncpts = rc;
@@ -733,8 +728,7 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf,
service = kzalloc(offsetof(struct ptlrpc_service, srv_parts[ncpts]),
  GFP_NOFS);
if (service == NULL) {
-   if (cpts != NULL)
-   kfree(cpts);
+   kfree(cpts);
return ERR_PTR(-ENOMEM);
}
 
@@ -2997,15 +2991,10 @@ ptlrpc_service_free(struct ptlrpc_service *svc)
cfs_timer_disarm(svcpt-scp_at_timer);
array = svcpt-scp_at_array;
 
-   if (array-paa_reqs_array != NULL) {
-   kfree(array-paa_reqs_array);
-   array-paa_reqs_array = NULL;
-   }
-
-   if (array-paa_reqs_count != NULL) {
-   kfree(array-paa_reqs_count);
-   array-paa_reqs_count = NULL;
-   }
+   kfree(array-paa_reqs_array);
+   array-paa_reqs_array = NULL;
+   kfree(array-paa_reqs_count);
+   array-paa_reqs_count = NULL;
}
 
ptlrpc_service_for_each_part(svcpt, i, svc)

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 6/20] Staging: lustre: llite: file: remove unneeded null test before free

2015-05-01 Thread Julia Lawall
Kfree can cope with a null argument, so drop null tests.

The semantic patch that finds this issue is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr; @@

- if (ptr != NULL)
  kfree(ptr);
// /smpl

In the first case, llss can never be null at the point of the kfree anyway.

In the second set of changes, the gotos are either eliminated, when no
freeing is needed (hss failure case), or rewritten so that there is no call
to free on data that has not yet been allocated (free_hss goto case).
There is no goto at which attr is not null, so the out label is simply
dropped.

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/llite/file.c |   23 ---
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/file.c 
b/drivers/staging/lustre/lustre/llite/file.c
index 6e50b35..702f62d 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -2109,8 +2109,7 @@ putgl:
}
 
 free:
-   if (llss != NULL)
-   kfree(llss);
+   kfree(llss);
 
return rc;
 }
@@ -2152,22 +2151,20 @@ static int ll_hsm_import(struct inode *inode, struct 
file *file,
 
/* set HSM flags */
hss = kzalloc(sizeof(*hss), GFP_NOFS);
-   if (!hss) {
-   rc = -ENOMEM;
-   goto out;
-   }
+   if (!hss)
+   return -ENOMEM;
 
hss-hss_valid = HSS_SETMASK | HSS_ARCHIVE_ID;
hss-hss_archive_id = hui-hui_archive_id;
hss-hss_setmask = HS_ARCHIVED | HS_EXISTS | HS_RELEASED;
rc = ll_hsm_state_set(inode, hss);
if (rc != 0)
-   goto out;
+   goto free_hss;
 
attr = kzalloc(sizeof(*attr), GFP_NOFS);
if (!attr) {
rc = -ENOMEM;
-   goto out;
+   goto free_hss;
}
 
attr-ia_mode = hui-hui_mode  (S_IRWXU | S_IRWXG | S_IRWXO);
@@ -2193,13 +2190,9 @@ static int ll_hsm_import(struct inode *inode, struct 
file *file,
 
mutex_unlock(inode-i_mutex);
 
-out:
-   if (hss != NULL)
-   kfree(hss);
-
-   if (attr != NULL)
-   kfree(attr);
-
+   kfree(attr);
+free_hss:
+   kfree(hss);
return rc;
 }
 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/20] staging: lustre: ldlm: ldlm_lib: remove unneeded null test before free

2015-05-01 Thread Julia Lawall
Kfree can cope with a null argument, so drop null tests.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr; @@

- if (ptr != NULL)
  kfree(ptr);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/ldlm/ldlm_lib.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
index d066771..0a0b435 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
@@ -119,8 +119,7 @@ static int import_set_conn(struct obd_import *imp, struct 
obd_uuid *uuid,
spin_unlock(imp-imp_lock);
return 0;
 out_free:
-   if (imp_conn)
-   kfree(imp_conn);
+   kfree(imp_conn);
 out_put:
ptlrpc_connection_put(ptlrpc_conn);
return rc;

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 16/20] staging: lustre: obdecho: remove unneeded null test before free

2015-05-01 Thread Julia Lawall
Kfree can cope with a null argument, so drop null tests.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr; @@

- if (ptr != NULL)
  kfree(ptr);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/obdecho/echo_client.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c 
b/drivers/staging/lustre/lustre/obdecho/echo_client.c
index cf64538..5376178 100644
--- a/drivers/staging/lustre/lustre/obdecho/echo_client.c
+++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c
@@ -1737,10 +1737,8 @@ static int echo_client_prep_commit(const struct lu_env 
*env,
}
 
 out:
-   if (lnb)
-   kfree(lnb);
-   if (rnb)
-   kfree(rnb);
+   kfree(lnb);
+   kfree(rnb);
return ret;
 }
 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 10/20] staging: lustre: lov: lov_dev: remove unneeded null test before free

2015-05-01 Thread Julia Lawall
Kfree can cope with a null argument, so drop null tests.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr; @@

- if (ptr != NULL)
  kfree(ptr);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/lov/lov_dev.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lustre/lov/lov_dev.c 
b/drivers/staging/lustre/lustre/lov/lov_dev.c
index 63db87a..504b24a 100644
--- a/drivers/staging/lustre/lustre/lov/lov_dev.c
+++ b/drivers/staging/lustre/lustre/lov/lov_dev.c
@@ -298,8 +298,7 @@ static struct lu_device *lov_device_free(const struct 
lu_env *env,
const int nr = ld-ld_target_nr;
 
cl_device_fini(lu2cl_dev(d));
-   if (ld-ld_target != NULL)
-   kfree(ld-ld_target);
+   kfree(ld-ld_target);
if (ld-ld_emrg != NULL)
lov_emerg_free(ld-ld_emrg, nr);
kfree(ld);

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 0/20] remove unneeded null test before free

2015-05-01 Thread Julia Lawall
These patches are motivated by the preceding patch series that converts
uses of OBD_FREE and OBD_FREE_PTR to kfree.  These patches should thus be
applied after that previous patch series (subject: Use kzalloc and kfree).

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 17/20] Staging: lustre: osc: remove unneeded null test before free

2015-05-01 Thread Julia Lawall
Kfree can cope with a null argument, so drop null tests.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr; @@

- if (ptr != NULL)
  kfree(ptr);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/osc/osc_request.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c 
b/drivers/staging/lustre/lustre/osc/osc_request.c
index 7ddf46b..ded184e 100644
--- a/drivers/staging/lustre/lustre/osc/osc_request.c
+++ b/drivers/staging/lustre/lustre/osc/osc_request.c
@@ -2064,8 +2064,7 @@ out:
 
if (oa)
OBDO_FREE(oa);
-   if (pga)
-   kfree(pga);
+   kfree(pga);
/* this should happen rarely and is pretty bad, it makes the
 * pending list not follow the dirty order */
while (!list_empty(ext_list)) {

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 19/20] staging: lustre: ptlrpc: sec_plain: remove unneeded null test before free

2015-05-01 Thread Julia Lawall
Kfree can cope with a null argument, so drop null tests.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr; @@

- if (ptr != NULL)
  kfree(ptr);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/ptlrpc/sec_plain.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c 
b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
index 604e511..989cdcd 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
@@ -384,8 +384,7 @@ struct ptlrpc_cli_ctx *plain_sec_install_ctx(struct 
plain_sec *plsec)
if (ctx) {
atomic_inc(ctx-cc_refcount);
 
-   if (ctx_new)
-   kfree(ctx_new);
+   kfree(ctx_new);
} else if (ctx_new) {
ctx = ctx_new;
 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 18/20] Staging: lustre: ptlrpc: lproc_ptlrpc: remove unneeded null test before free

2015-05-01 Thread Julia Lawall
Kfree can cope with a null argument, so drop null tests.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr; @@

- if (ptr != NULL)
  kfree(ptr);
// /smpl

In the first case, the only cleanup needed is the unlock, so jump to that
directly.

Likewise, in the first two failure cases of ptlrpc_lprocfs_nrs_seq_write,
no cleanup is needed, so just drop the goto and return directly.

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c |   26 ++--
 1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c 
b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
index 1391784..aeceef5 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
@@ -510,7 +510,7 @@ static int ptlrpc_lprocfs_nrs_seq_show(struct seq_file *m, 
void *n)
infos = kcalloc(num_pols, sizeof(*infos), GFP_NOFS);
if (infos == NULL) {
rc = -ENOMEM;
-   goto out;
+   goto unlock;
}
 again:
 
@@ -617,10 +617,8 @@ again:
goto again;
}
 
-out:
-   if (infos)
-   kfree(infos);
-
+   kfree(infos);
+unlock:
mutex_unlock(nrs_core.nrs_mutex);
 
return rc;
@@ -650,16 +648,12 @@ static ssize_t ptlrpc_lprocfs_nrs_seq_write(struct file 
*file,
char   *token;
int rc = 0;
 
-   if (count = LPROCFS_NRS_WR_MAX_CMD) {
-   rc = -EINVAL;
-   goto out;
-   }
+   if (count = LPROCFS_NRS_WR_MAX_CMD)
+   return -EINVAL;
 
cmd = kzalloc(LPROCFS_NRS_WR_MAX_CMD, GFP_NOFS);
-   if (cmd == NULL) {
-   rc = -ENOMEM;
-   goto out;
-   }
+   if (cmd == NULL)
+   return -ENOMEM;
/**
 * strsep() modifies its argument, so keep a copy
 */
@@ -716,8 +710,7 @@ default_queue:
 
mutex_unlock(nrs_core.nrs_mutex);
 out:
-   if (cmd_copy)
-   kfree(cmd_copy);
+   kfree(cmd_copy);
 
return rc  0 ? rc : count;
 }
@@ -860,8 +853,7 @@ ptlrpc_lprocfs_svc_req_history_stop(struct seq_file *s, 
void *iter)
 {
struct ptlrpc_srh_iterator *srhi = iter;
 
-   if (srhi != NULL)
-   kfree(srhi);
+   kfree(srhi);
 }
 
 static void *

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 9/20] staging: lustre: lmv: remove unneeded null test before free

2015-05-01 Thread Julia Lawall
Kfree can cope with a null argument, so drop null tests.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr; @@

- if (ptr != NULL)
  kfree(ptr);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/lmv/lmv_obd.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c 
b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
index 59b8fac..8e05852 100644
--- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c
+++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
@@ -504,8 +504,7 @@ static int lmv_add_target(struct obd_device *obd, struct 
obd_uuid *uuidp,
lmv-tgts = newtgts;
lmv-tgts_size = newsize;
smp_rmb();
-   if (old)
-   kfree(old);
+   kfree(old);
 
CDEBUG(D_CONFIG, tgts: %p size: %d\n, lmv-tgts,
   lmv-tgts_size);
@@ -780,8 +779,7 @@ repeat_fid2path:
goto repeat_fid2path;
 
 out_fid2path:
-   if (remote_gf != NULL)
-   kfree(remote_gf);
+   kfree(remote_gf);
return rc;
 }
 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 7/20] Staging: lustre: llite: llite_lib: remove unneeded null test before free

2015-05-01 Thread Julia Lawall
Kfree can cope with a null argument, so drop null tests.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr; @@

- if (ptr != NULL)
  kfree(ptr);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/llite/llite_lib.c |   12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c 
b/drivers/staging/lustre/lustre/llite/llite_lib.c
index e5bac94..c6611b1 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -574,10 +574,8 @@ static int client_common_fill_super(struct super_block 
*sb, char *md, char *dt,
get_uuid2fsid(uuid-uuid, strlen(uuid-uuid), sbi-ll_fsid);
}
 
-   if (data != NULL)
-   kfree(data);
-   if (osfs != NULL)
-   kfree(osfs);
+   kfree(data);
+   kfree(osfs);
 
return err;
 out_root:
@@ -595,10 +593,8 @@ out_md:
obd_disconnect(sbi-ll_md_exp);
sbi-ll_md_exp = NULL;
 out:
-   if (data != NULL)
-   kfree(data);
-   if (osfs != NULL)
-   kfree(osfs);
+   kfree(data);
+   kfree(osfs);
lprocfs_unregister_mountpoint(sbi);
return err;
 }

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/20] staging: lustre: ldlm: ldlm_lock: remove unneeded null test before free

2015-05-01 Thread Julia Lawall
Kfree can cope with a null argument, so drop null tests.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr; @@

- if (ptr != NULL)
  kfree(ptr);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index 2c5fe14..6a22f41 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -208,8 +208,7 @@ void ldlm_lock_put(struct ldlm_lock *lock)
lock-l_export = NULL;
}
 
-   if (lock-l_lvb_data != NULL)
-   kfree(lock-l_lvb_data);
+   kfree(lock-l_lvb_data);
 
ldlm_interval_free(ldlm_interval_detach(lock));
lu_ref_fini(lock-l_reference);

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/20] staging: lustre: libcfs: linux: remove unneeded null test before free

2015-05-01 Thread Julia Lawall
Kfree can cope with a null argument, so drop null tests.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr; @@

- if (ptr != NULL) {
  kfree(ptr);
  ptr = NULL;
- }
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c |9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c 
b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c
index c8e2930..483cbc8 100644
--- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c
+++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c
@@ -102,11 +102,10 @@ void cfs_tracefile_fini_arch(void)
intj;
 
for (i = 0; i  num_possible_cpus(); i++)
-   for (j = 0; j  3; j++)
-   if (cfs_trace_console_buffers[i][j] != NULL) {
-   kfree(cfs_trace_console_buffers[i][j]);
-   cfs_trace_console_buffers[i][j] = NULL;
-   }
+   for (j = 0; j  3; j++) {
+   kfree(cfs_trace_console_buffers[i][j]);
+   cfs_trace_console_buffers[i][j] = NULL;
+   }
 
for (i = 0; cfs_trace_data[i] != NULL; i++) {
kfree(cfs_trace_data[i]);

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 13/20] staging: lustre: obdclass: llog: remove unneeded null test before free

2015-05-01 Thread Julia Lawall
Kfree can cope with a null argument, so drop null tests.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@@ expression ptr; @@

- if (ptr != NULL)
  kfree(ptr);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/staging/lustre/lustre/obdclass/llog.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c 
b/drivers/staging/lustre/lustre/obdclass/llog.c
index 636df94..4fa52d1 100644
--- a/drivers/staging/lustre/lustre/obdclass/llog.c
+++ b/drivers/staging/lustre/lustre/obdclass/llog.c
@@ -563,8 +563,7 @@ int llog_reverse_process(const struct lu_env *env,
}
 
 out:
-   if (buf)
-   kfree(buf);
+   kfree(buf);
return rc;
 }
 EXPORT_SYMBOL(llog_reverse_process);

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [HPDD-discuss] [PATCH 2/11] Staging: lustre: fld: Use kzalloc and kfree

2015-05-01 Thread Simmons, James A.
We are hopefully going to get rid of OBD_ALLOC_LARGE() as well, though.

It's simple enough to write a function:

void *obd_zalloc(size_t size)
{
   if (size  4 * PAGE_CACHE_SIZE)
   return vzalloc(size);
   else
   return kmalloc(size, GFP_NOFS);
}

Except, huh?  Shouldn't we be using GFP_NOFS for the vzalloc() side?
There was some discussion of that GFP_NOFS was a bit buggy back in 2010
(http://marc.info/?l=linux-mmm=128942194520631w=4) but the current
lustre code doesn't try to pass GFP_NOFS.

The version in the upstream client is out of date. The current macro in the 
Intel master
Branch is:

#define __OBD_VMALLOC_VERBOSE(ptr, cptab, cpt, size)  \
do {  \
(ptr) = cptab == NULL ?   \
__vmalloc(size, GFP_NOFS | __GFP_HIGHMEM | __GFP_ZERO,\
  PAGE_KERNEL) :  \
cfs_cpt_vzalloc(cptab, cpt, size);\
if (unlikely((ptr) == NULL)) {\
CERROR(vmalloc of ' #ptr ' (%d bytes) failed\n,   \
   (int)(size));  \
CERROR(LPU64 total bytes allocated by Lustre, %d by LNET\n, \
   obd_memory_sum(), atomic_read(libcfs_kmemory));   \
} else {  \
OBD_ALLOC_POST(ptr, size, vmalloced);   \
} \
} while(0)
 
Then it's simple enough to change OBD_FREE_LARGE() to kvfree().

Also it's weird that only the lustre people have thought of this trick
to allocate big chunks of RAM and no one else has.  What would happen if
we just change vmalloc() so it worked this way for everyone?

Do we really want to encourage vmalloc usages?
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[RFC PATCH 05/11] MIPS: OCTEON: delete calls to __cvmx_helper_npi/rgmii_probe

2015-05-01 Thread Aaro Koskinen
These calls have no side effects so drop the calls, so that we
don't need to export these functions to modules.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 arch/mips/cavium-octeon/executive/cvmx-helper-ethernet.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/mips/cavium-octeon/executive/cvmx-helper-ethernet.c 
b/arch/mips/cavium-octeon/executive/cvmx-helper-ethernet.c
index 6fe990e..390f8f80 100644
--- a/arch/mips/cavium-octeon/executive/cvmx-helper-ethernet.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-helper-ethernet.c
@@ -130,7 +130,6 @@ int cvmx_helper_interface_probe(int interface)
 */
case CVMX_HELPER_INTERFACE_MODE_RGMII:
case CVMX_HELPER_INTERFACE_MODE_GMII:
-   __cvmx_helper_rgmii_probe(interface);
break;
/*
 * SPI4 can have 1-16 ports depending on the device at
@@ -149,7 +148,6 @@ int cvmx_helper_interface_probe(int interface)
break;
/* PCI target Network Packet Interface */
case CVMX_HELPER_INTERFACE_MODE_NPI:
-   __cvmx_helper_npi_probe(interface);
break;
/*
 * Special loopback only ports. These are not the same
-- 
2.3.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[RFC PATCH 03/11] MIPS: OCTEON: make __cvmx_helper_sgmii/xaui_probe void

2015-05-01 Thread Aaro Koskinen
Make __cvmx_helper_sgmii/xaui_probe void, nobody is using return values
and this makes functions independent of enumeration functions.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 arch/mips/cavium-octeon/executive/cvmx-helper-sgmii.c | 5 +
 arch/mips/cavium-octeon/executive/cvmx-helper-xaui.c  | 5 +
 arch/mips/include/asm/octeon/cvmx-helper-sgmii.h  | 2 +-
 arch/mips/include/asm/octeon/cvmx-helper-xaui.h   | 2 +-
 4 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/arch/mips/cavium-octeon/executive/cvmx-helper-sgmii.c 
b/arch/mips/cavium-octeon/executive/cvmx-helper-sgmii.c
index 6f9609e..6a47b04 100644
--- a/arch/mips/cavium-octeon/executive/cvmx-helper-sgmii.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-helper-sgmii.c
@@ -340,10 +340,8 @@ int __cvmx_helper_sgmii_enumerate(int interface)
  * this call.
  *
  * @interface: Interface to probe
- *
- * Returns Number of ports on the interface. Zero to disable.
  */
-int __cvmx_helper_sgmii_probe(int interface)
+void __cvmx_helper_sgmii_probe(int interface)
 {
union cvmx_gmxx_inf_mode mode;
 
@@ -355,7 +353,6 @@ int __cvmx_helper_sgmii_probe(int interface)
mode.u64 = cvmx_read_csr(CVMX_GMXX_INF_MODE(interface));
mode.s.en = 1;
cvmx_write_csr(CVMX_GMXX_INF_MODE(interface), mode.u64);
-   return __cvmx_helper_sgmii_enumerate(interface);
 }
 
 /**
diff --git a/arch/mips/cavium-octeon/executive/cvmx-helper-xaui.c 
b/arch/mips/cavium-octeon/executive/cvmx-helper-xaui.c
index 7653b7e..49d7507 100644
--- a/arch/mips/cavium-octeon/executive/cvmx-helper-xaui.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-helper-xaui.c
@@ -63,10 +63,8 @@ int __cvmx_helper_xaui_enumerate(int interface)
  * after this call.
  *
  * @interface: Interface to probe
- *
- * Returns Number of ports on the interface. Zero to disable.
  */
-int __cvmx_helper_xaui_probe(int interface)
+void __cvmx_helper_xaui_probe(int interface)
 {
int i;
union cvmx_gmxx_inf_mode mode;
@@ -102,7 +100,6 @@ int __cvmx_helper_xaui_probe(int interface)
pko_mem_port_ptrs.s.pid = interface * 16 + i;
cvmx_write_csr(CVMX_PKO_MEM_PORT_PTRS, pko_mem_port_ptrs.u64);
}
-   return __cvmx_helper_xaui_enumerate(interface);
 }
 
 /**
diff --git a/arch/mips/include/asm/octeon/cvmx-helper-sgmii.h 
b/arch/mips/include/asm/octeon/cvmx-helper-sgmii.h
index 4debb1c..eb51835 100644
--- a/arch/mips/include/asm/octeon/cvmx-helper-sgmii.h
+++ b/arch/mips/include/asm/octeon/cvmx-helper-sgmii.h
@@ -44,7 +44,7 @@
  *
  * Returns Number of ports on the interface. Zero to disable.
  */
-extern int __cvmx_helper_sgmii_probe(int interface);
+extern void __cvmx_helper_sgmii_probe(int interface);
 extern int __cvmx_helper_sgmii_enumerate(int interface);
 
 /**
diff --git a/arch/mips/include/asm/octeon/cvmx-helper-xaui.h 
b/arch/mips/include/asm/octeon/cvmx-helper-xaui.h
index 5e89ed7..9fbcea3 100644
--- a/arch/mips/include/asm/octeon/cvmx-helper-xaui.h
+++ b/arch/mips/include/asm/octeon/cvmx-helper-xaui.h
@@ -44,7 +44,7 @@
  *
  * Returns Number of ports on the interface. Zero to disable.
  */
-extern int __cvmx_helper_xaui_probe(int interface);
+extern void __cvmx_helper_xaui_probe(int interface);
 extern int __cvmx_helper_xaui_enumerate(int interface);
 
 /**
-- 
2.3.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[RFC PATCH 00/11] MIPS: OCTEON: move all octeon-ethernet code to staging

2015-05-01 Thread Aaro Koskinen
Hi,

In order to octeon-ethernet staging work to proceed, we should have all
the code in the same tree (staging). Currently, most of the driver code
actually lives in the MIPS tree in the cvmx helper or OS abstraction
routines and include files. Majority of this code needs refactoring
(or deletion) for the octeon-ethernet to become a normal Linux driver.
Since rest of the kernel does not need this code at all, it should
make sense to move it all into the same place while the driver
is being developed.

This series does not make any functional changes, just moves the code.
Tested on EdgeRouter Lite, EdgeRouter Pro and D-Link DSR-1000N. Also build
tested with octeon-ethernet as built-in, module and completely disabled.
Patches are based on staging-next.

A.

Aaro Koskinen (11):
  MIPS: OCTEON: cvmx-helper: use function to access interface_port_count
  MIPS: OCTEON: move ethernet-specific helpers into a separate file
  MIPS: OCTEON: make __cvmx_helper_sgmii/xaui_probe void
  MIPS: OCTEON: move interface enumeration helpers to cvmx-helper
  MIPS: OCTEON: delete calls to __cvmx_helper_npi/rgmii_probe
  MIPS: OCTEON: rename __cvmx_helper_npi/rgmii_probe
  MIPS: OCTEON: make all interface enumeration helpers static
  MIPS: OCTEON: move the link helpers into a separate file
  MIPS: OCTEON: move ethernet-specific helpers to staging
  MIPS: OCTEON: ethernet: delete unneeded symbol exports
  MIPS: OCTEON: move all ethernet-specific headers to staging

 arch/mips/cavium-octeon/executive/Makefile |7 +-
 .../cavium-octeon/executive/cvmx-helper-board.c|  512 +-
 arch/mips/cavium-octeon/executive/cvmx-helper.c| 1017 +++-
 arch/mips/include/asm/octeon/cvmx-helper-board.h   |   70 --
 arch/mips/include/asm/octeon/cvmx-helper.h |  124 ---
 drivers/staging/octeon/Makefile|   15 +-
 .../asm = drivers/staging}/octeon/cvmx-address.h  |0
 .../staging}/octeon/cvmx-asxx-defs.h   |0
 .../staging/octeon}/cvmx-cmd-queue.c   |   12 +-
 .../staging}/octeon/cvmx-cmd-queue.h   |4 +-
 .../asm = drivers/staging}/octeon/cvmx-dbg-defs.h |0
 .../asm = drivers/staging}/octeon/cvmx-fau.h  |0
 .../asm = drivers/staging}/octeon/cvmx-fpa-defs.h |0
 .../asm = drivers/staging}/octeon/cvmx-fpa.h  |4 +-
 drivers/staging/octeon/cvmx-helper-ethernet.c  |  914 ++
 drivers/staging/octeon/cvmx-helper-ethernet.h  |  219 +
 .../staging/octeon}/cvmx-helper-loop.c |6 +-
 .../staging}/octeon/cvmx-helper-loop.h |1 -
 .../staging/octeon}/cvmx-helper-npi.c  |   44 +-
 .../staging}/octeon/cvmx-helper-npi.h  |   12 -
 .../staging/octeon}/cvmx-helper-rgmii.c|   63 +-
 .../staging}/octeon/cvmx-helper-rgmii.h|   10 +-
 .../staging/octeon}/cvmx-helper-sgmii.c|   20 +-
 .../staging}/octeon/cvmx-helper-sgmii.h|5 +-
 .../staging/octeon}/cvmx-helper-spi.c  |   19 +-
 .../staging}/octeon/cvmx-helper-spi.h  |3 +-
 .../staging/octeon}/cvmx-helper-util.c |   22 +-
 .../staging}/octeon/cvmx-helper-util.h |3 +
 .../staging/octeon}/cvmx-helper-xaui.c |   28 +-
 .../staging}/octeon/cvmx-helper-xaui.h |5 +-
 .../staging/octeon}/cvmx-interrupt-decodes.c   |   11 +-
 .../staging/octeon}/cvmx-interrupt-rsl.c   |5 +-
 .../asm = drivers/staging}/octeon/cvmx-ipd.h  |3 +-
 drivers/staging/octeon/cvmx-link.c |  531 ++
 .../asm = drivers/staging}/octeon/cvmx-mdio.h |0
 .../staging}/octeon/cvmx-pcsx-defs.h   |0
 .../staging}/octeon/cvmx-pcsxx-defs.h  |0
 .../asm = drivers/staging}/octeon/cvmx-pip-defs.h |0
 .../asm = drivers/staging}/octeon/cvmx-pip.h  |6 +-
 .../asm = drivers/staging}/octeon/cvmx-pko-defs.h |0
 .../staging/octeon}/cvmx-pko.c |8 +-
 .../asm = drivers/staging}/octeon/cvmx-pko.h  |8 +-
 .../asm = drivers/staging}/octeon/cvmx-pow.h  |5 +-
 .../asm = drivers/staging}/octeon/cvmx-scratch.h  |0
 .../staging/octeon}/cvmx-spi.c |   13 +-
 .../staging}/octeon/cvmx-spxx-defs.h   |0
 .../staging}/octeon/cvmx-srxx-defs.h   |0
 .../staging}/octeon/cvmx-stxx-defs.h   |0
 .../asm = drivers/staging}/octeon/cvmx-wqe.h  |0
 drivers/staging/octeon/ethernet-mem.c  |6 +-
 drivers/staging/octeon/ethernet-rgmii.c|   18 +-
 drivers/staging/octeon/ethernet-rx.c   |   24 +-
 drivers/staging/octeon/ethernet-rx.h   |4 +-
 drivers/staging/octeon/ethernet-spi.c  |   17 +-
 drivers/staging/octeon/ethernet-tx.c   |   19 +-
 drivers/staging/octeon/ethernet-xaui.c |   14 +-
 drivers/staging/octeon/ethernet.c  |   40 +-
 

[RFC PATCH 01/11] MIPS: OCTEON: cvmx-helper: use function to access interface_port_count

2015-05-01 Thread Aaro Koskinen
Use function to access interface_port_count. This allows moving
functions requiring the info to different files.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 arch/mips/cavium-octeon/executive/cvmx-helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/mips/cavium-octeon/executive/cvmx-helper.c 
b/arch/mips/cavium-octeon/executive/cvmx-helper.c
index 7e5cf7a..301a9ce 100644
--- a/arch/mips/cavium-octeon/executive/cvmx-helper.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-helper.c
@@ -557,7 +557,7 @@ int cvmx_helper_interface_probe(int interface)
 static int __cvmx_helper_interface_setup_ipd(int interface)
 {
int ipd_port = cvmx_helper_get_ipd_port(interface, 0);
-   int num_ports = interface_port_count[interface];
+   int num_ports = cvmx_helper_ports_on_interface(interface);
 
while (num_ports--) {
__cvmx_helper_port_setup_ipd(ipd_port);
@@ -620,7 +620,7 @@ static int __cvmx_helper_interface_setup_pko(int interface)
 * priorities are set.
 */
int ipd_port = cvmx_helper_get_ipd_port(interface, 0);
-   int num_ports = interface_port_count[interface];
+   int num_ports = cvmx_helper_ports_on_interface(interface);
while (num_ports--) {
/*
 * Give the user a chance to override the per queue
-- 
2.3.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[RFC PATCH 11/11] MIPS: OCTEON: move all ethernet-specific headers to staging

2015-05-01 Thread Aaro Koskinen
Move all ethernet-specific headers to staging.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 arch/mips/include/asm/octeon/cvmx-helper-board.h   |  70 ---
 arch/mips/include/asm/octeon/cvmx-helper.h | 124 
 .../asm = drivers/staging}/octeon/cvmx-address.h  |   0
 .../staging}/octeon/cvmx-asxx-defs.h   |   0
 drivers/staging/octeon/cvmx-cmd-queue.c|  11 +-
 .../staging}/octeon/cvmx-cmd-queue.h   |   4 +-
 .../asm = drivers/staging}/octeon/cvmx-dbg-defs.h |   0
 .../asm = drivers/staging}/octeon/cvmx-fau.h  |   0
 .../asm = drivers/staging}/octeon/cvmx-fpa-defs.h |   0
 .../asm = drivers/staging}/octeon/cvmx-fpa.h  |   4 +-
 drivers/staging/octeon/cvmx-helper-ethernet.c  |  25 ++-
 drivers/staging/octeon/cvmx-helper-ethernet.h  | 219 +
 drivers/staging/octeon/cvmx-helper-loop.c  |   6 +-
 .../staging}/octeon/cvmx-helper-loop.h |   0
 drivers/staging/octeon/cvmx-helper-npi.c   |   6 +-
 .../staging}/octeon/cvmx-helper-npi.h  |   0
 drivers/staging/octeon/cvmx-helper-rgmii.c |  17 +-
 .../staging}/octeon/cvmx-helper-rgmii.h|   2 +
 drivers/staging/octeon/cvmx-helper-sgmii.c |  11 +-
 .../staging}/octeon/cvmx-helper-sgmii.h|   2 +
 drivers/staging/octeon/cvmx-helper-spi.c   |   9 +-
 .../staging}/octeon/cvmx-helper-spi.h  |   2 +
 drivers/staging/octeon/cvmx-helper-util.c  |  18 +-
 .../staging}/octeon/cvmx-helper-util.h |   3 +
 drivers/staging/octeon/cvmx-helper-xaui.c  |  11 +-
 .../staging}/octeon/cvmx-helper-xaui.h |   2 +
 drivers/staging/octeon/cvmx-interrupt-decodes.c|  11 +-
 drivers/staging/octeon/cvmx-interrupt-rsl.c|   5 +-
 .../asm = drivers/staging}/octeon/cvmx-ipd.h  |   3 +-
 drivers/staging/octeon/cvmx-link.c |  15 +-
 .../asm = drivers/staging}/octeon/cvmx-mdio.h |   0
 .../staging}/octeon/cvmx-pcsx-defs.h   |   0
 .../staging}/octeon/cvmx-pcsxx-defs.h  |   0
 .../asm = drivers/staging}/octeon/cvmx-pip-defs.h |   0
 .../asm = drivers/staging}/octeon/cvmx-pip.h  |   6 +-
 .../asm = drivers/staging}/octeon/cvmx-pko-defs.h |   0
 drivers/staging/octeon/cvmx-pko.c  |   6 +-
 .../asm = drivers/staging}/octeon/cvmx-pko.h  |   8 +-
 .../asm = drivers/staging}/octeon/cvmx-pow.h  |   5 +-
 .../asm = drivers/staging}/octeon/cvmx-scratch.h  |   0
 drivers/staging/octeon/cvmx-spi.c  |  12 +-
 .../staging}/octeon/cvmx-spxx-defs.h   |   0
 .../staging}/octeon/cvmx-srxx-defs.h   |   0
 .../staging}/octeon/cvmx-stxx-defs.h   |   0
 .../asm = drivers/staging}/octeon/cvmx-wqe.h  |   0
 drivers/staging/octeon/ethernet-mem.c  |   6 +-
 drivers/staging/octeon/ethernet-rgmii.c|  18 +-
 drivers/staging/octeon/ethernet-rx.c   |  24 ++-
 drivers/staging/octeon/ethernet-rx.h   |   4 +-
 drivers/staging/octeon/ethernet-spi.c  |  17 +-
 drivers/staging/octeon/ethernet-tx.c   |  19 +-
 drivers/staging/octeon/ethernet-xaui.c |  14 +-
 drivers/staging/octeon/ethernet.c  |  40 ++--
 drivers/staging/octeon/octeon-ethernet.h   |   3 +-
 54 files changed, 390 insertions(+), 372 deletions(-)
 rename {arch/mips/include/asm = drivers/staging}/octeon/cvmx-address.h (100%)
 rename {arch/mips/include/asm = drivers/staging}/octeon/cvmx-asxx-defs.h 
(100%)
 rename {arch/mips/include/asm = drivers/staging}/octeon/cvmx-cmd-queue.h (99%)
 rename {arch/mips/include/asm = drivers/staging}/octeon/cvmx-dbg-defs.h (100%)
 rename {arch/mips/include/asm = drivers/staging}/octeon/cvmx-fau.h (100%)
 rename {arch/mips/include/asm = drivers/staging}/octeon/cvmx-fpa-defs.h (100%)
 rename {arch/mips/include/asm = drivers/staging}/octeon/cvmx-fpa.h (99%)
 create mode 100644 drivers/staging/octeon/cvmx-helper-ethernet.h
 rename {arch/mips/include/asm = drivers/staging}/octeon/cvmx-helper-loop.h 
(100%)
 rename {arch/mips/include/asm = drivers/staging}/octeon/cvmx-helper-npi.h 
(100%)
 rename {arch/mips/include/asm = drivers/staging}/octeon/cvmx-helper-rgmii.h 
(98%)
 rename {arch/mips/include/asm = drivers/staging}/octeon/cvmx-helper-sgmii.h 
(98%)
 rename {arch/mips/include/asm = drivers/staging}/octeon/cvmx-helper-spi.h 
(98%)
 rename {arch/mips/include/asm = drivers/staging}/octeon/cvmx-helper-util.h 
(99%)
 rename {arch/mips/include/asm = drivers/staging}/octeon/cvmx-helper-xaui.h 
(98%)
 rename {arch/mips/include/asm = drivers/staging}/octeon/cvmx-ipd.h (99%)
 rename {arch/mips/include/asm = drivers/staging}/octeon/cvmx-mdio.h (100%)
 rename {arch/mips/include/asm = drivers/staging}/octeon/cvmx-pcsx-defs.h 
(100%)
 rename {arch/mips/include/asm = drivers/staging}/octeon/cvmx-pcsxx-defs.h 
(100%)
 rename {arch/mips/include/asm = 

Re: [HPDD-discuss] [PATCH 2/11] Staging: lustre: fld: Use kzalloc and kfree

2015-05-01 Thread Dan Carpenter
We are hopefully going to get rid of OBD_ALLOC_LARGE() as well, though.

It's simple enough to write a function:

void *obd_zalloc(size_t size)
{
if (size  4 * PAGE_CACHE_SIZE)
return vzalloc(size);
else
return kmalloc(size, GFP_NOFS);
}

Except, huh?  Shouldn't we be using GFP_NOFS for the vzalloc() side?
There was some discussion of that GFP_NOFS was a bit buggy back in 2010
(http://marc.info/?l=linux-mmm=128942194520631w=4) but the current
lustre code doesn't try to pass GFP_NOFS.

Then it's simple enough to change OBD_FREE_LARGE() to kvfree().

Also it's weird that only the lustre people have thought of this trick
to allocate big chunks of RAM and no one else has.  What would happen if
we just change vmalloc() so it worked this way for everyone?

regards,
dan carpenter
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [HPDD-discuss] [PATCH 2/11] Staging: lustre: fld: Use kzalloc and kfree

2015-05-01 Thread Drokin, Oleg

On May 1, 2015, at 4:02 PM, Dan Carpenter wrote:

 We are hopefully going to get rid of OBD_ALLOC_LARGE() as well, though.
 
 It's simple enough to write a function:
 
 void *obd_zalloc(size_t size)
 {
   if (size  4 * PAGE_CACHE_SIZE)
   return vzalloc(size);
   else
   return kmalloc(size, GFP_NOFS);

kzalloc here too. Except e also want to have locality of allocations.

 }
 
 Except, huh?  Shouldn't we be using GFP_NOFS for the vzalloc() side?
 There was some discussion of that GFP_NOFS was a bit buggy back in 2010
 (http://marc.info/?l=linux-mmm=128942194520631w=4) but the current
 lustre code doesn't try to pass GFP_NOFS.

The patch I submitted was rejected, or so I think to remember, because we use 
__vmalloc_node
or something and it's not an exported symbol.
http://www.spinics.net/lists/linux-mm/msg83997.html

 Then it's simple enough to change OBD_FREE_LARGE() to kvfree().
 
 Also it's weird that only the lustre people have thought of this trick
 to allocate big chunks of RAM and no one else has.  What would happen if
 we just change vmalloc() so it worked this way for everyone?

We are certainly not alone.
I saw this in a few other pieces of code.

void *ext4_kvmalloc(size_t size, gfp_t flags)
{
void *ret;

ret = kmalloc(size, flags | __GFP_NOWARN);
if (!ret)
ret = __vmalloc(size, flags, PAGE_KERNEL);
return ret;
}

or kmem_zalloc_large in xfs.

The difference at hand is that we pessimistically assume anything over certain 
threshold would
fail in kmalloc anyway and others actually do try kmalloc and only switch to 
vmalloc if kmaloc failed.
Considerign how expensive (and unsafe) vmalloc is, there might be some benefit 
to converting to their
way of doing things too.

Bye,
Oleg
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [HPDD-discuss] [PATCH 2/11] Staging: lustre: fld: Use kzalloc and kfree

2015-05-01 Thread Simmons, James A.
 From: Julia Lawall julia.law...@lip6.fr
 
 Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by
 kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree.
 
 Nak: James Simmons jsimm...@infradead.org
 
 A simple replace will not work. The OBD_ALLOC and OBD_FREE functions 
 allocate memory
 anywhere from one page to 4MB in size. You can't use kmalloc for the 4MB 
 allocations.
 Currently lustre uses  a 4 page water mark to determine if we allocate using 
 vmalloc. Even
 using kmalloc for 4 pages has shown high failure rates on some systems. It 
 gets even more
 messy with 64K page systems like ppc64 boxes. Now I'm not suggesting to port 
 the larger
 allocations to vmalloc either since issues have been founded with using 
 vmalloc. For example
 when using large stripe count files the MDS rpc generated crosses the 4 page 
 line and vmalloc
 is used. Using vmalloc caused a global spinlock to be taken which causes 
 meta data operations
 to serialized on the MDS servers.

It's not the LARGE functions that do the switching?  For example OBD_ALLOC 
ends up at  __OBD_MALLOC_VERBOSE, which as far as I can see calls kmalloc 
(with __GFP_ZERO, and hance the use of kzalloc).

Yes the LARGE functions do the switching. I was expecting also patches to 
remove the 
OBD_ALLOC_LARGE functions as well which is not the case here.  I do have one 
question still. The
macro __OBD_MALLOC_VERBOSE allowed the ability to simulate memory allocation 
failures at
a certain percentage rate. Does something exist in the kernel to duplicate that 
functionality?
Once these macros are gone we lose the ability to simulate high memory 
allocation failures.


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 0/8] staging: comedi: mite: some clean-ups

2015-05-01 Thread Hartley Sweeten
On Friday, May 01, 2015 10:04 AM, Ian Abbott wrote:
 1) staging: comedi: mite: move #include linux/slab.h
 2) staging: comedi: mite.h: remove PCIMIO_COMPAT
 3) staging: comedi: mite.c: remove commented out USE_KMALLOC
 4) staging: comedi: mite.h: remove ../comedi_pci.h and make
self-reliant
 5) staging: comedi: mite.h: reformat some comments
 6) staging: comedi: mite.c: reformat comments
 7) staging: comedi: mite.h: whitespace changes in function declarations
 8) staging: comedi: mite: use a better MODULE_DESCRIPTION()

 TODO: document the exported functions in mite.c.

  drivers/staging/comedi/drivers/mite.c | 110 
 +-
  drivers/staging/comedi/drivers/mite.h |  88 ++-
  2 files changed, 101 insertions(+), 97 deletions(-)

Reviewed-by: H Hartley Sweeten hswee...@visionengravers.com

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[RFC PATCH 10/11] MIPS: OCTEON: ethernet: delete unneeded symbol exports

2015-05-01 Thread Aaro Koskinen
Delete unneeded symbol exports.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/staging/octeon/cvmx-cmd-queue.c   | 1 -
 drivers/staging/octeon/cvmx-helper-ethernet.c | 5 -
 drivers/staging/octeon/cvmx-helper-util.c | 4 
 drivers/staging/octeon/cvmx-pko.c | 2 --
 drivers/staging/octeon/cvmx-spi.c | 1 -
 5 files changed, 13 deletions(-)

diff --git a/drivers/staging/octeon/cvmx-cmd-queue.c 
b/drivers/staging/octeon/cvmx-cmd-queue.c
index 8241fc6..132bccc 100644
--- a/drivers/staging/octeon/cvmx-cmd-queue.c
+++ b/drivers/staging/octeon/cvmx-cmd-queue.c
@@ -47,7 +47,6 @@
  * state. It points to a bootmem named block.
  */
 __cvmx_cmd_queue_all_state_t *__cvmx_cmd_queue_state_ptr;
-EXPORT_SYMBOL_GPL(__cvmx_cmd_queue_state_ptr);
 
 /**
  * Initialize the Global queue state pointer.
diff --git a/drivers/staging/octeon/cvmx-helper-ethernet.c 
b/drivers/staging/octeon/cvmx-helper-ethernet.c
index 390f8f80..ba90678 100644
--- a/drivers/staging/octeon/cvmx-helper-ethernet.c
+++ b/drivers/staging/octeon/cvmx-helper-ethernet.c
@@ -614,7 +614,6 @@ int cvmx_helper_ipd_and_packet_input_enable(void)
__cvmx_helper_errata_fix_ipd_ptr_alignment();
return 0;
 }
-EXPORT_SYMBOL_GPL(cvmx_helper_ipd_and_packet_input_enable);
 
 /**
  * Initialize the PIP, IPD, and PKO hardware to support
@@ -693,7 +692,6 @@ int cvmx_helper_initialize_packet_io_global(void)
 #endif
return result;
 }
-EXPORT_SYMBOL_GPL(cvmx_helper_initialize_packet_io_global);
 
 /**
  * Does core local initialization for packet io
@@ -738,7 +736,6 @@ cvmx_helper_link_info_t cvmx_helper_link_autoconf(int 
ipd_port)
 */
return port_link_info[ipd_port];
 }
-EXPORT_SYMBOL_GPL(cvmx_helper_link_autoconf);
 
 /**
  * Return the link state of an IPD/PKO port as returned by
@@ -797,7 +794,6 @@ cvmx_helper_link_info_t cvmx_helper_link_get(int ipd_port)
}
return result;
 }
-EXPORT_SYMBOL_GPL(cvmx_helper_link_get);
 
 /**
  * Configure an IPD/PKO port for the specified link state. This
@@ -853,7 +849,6 @@ int cvmx_helper_link_set(int ipd_port, 
cvmx_helper_link_info_t link_info)
port_link_info[ipd_port].u64 = link_info.u64;
return result;
 }
-EXPORT_SYMBOL_GPL(cvmx_helper_link_set);
 
 /**
  * Configure a port for internal and/or external loopback. Internal loopback
diff --git a/drivers/staging/octeon/cvmx-helper-util.c 
b/drivers/staging/octeon/cvmx-helper-util.c
index 453d7f6..65d2bc9 100644
--- a/drivers/staging/octeon/cvmx-helper-util.c
+++ b/drivers/staging/octeon/cvmx-helper-util.c
@@ -251,7 +251,6 @@ int cvmx_helper_setup_red(int pass_thresh, int drop_thresh)
 
return 0;
 }
-EXPORT_SYMBOL_GPL(cvmx_helper_setup_red);
 
 /**
  * Setup the common GMX settings that determine the number of
@@ -385,7 +384,6 @@ int cvmx_helper_get_ipd_port(int interface, int port)
}
return -1;
 }
-EXPORT_SYMBOL_GPL(cvmx_helper_get_ipd_port);
 
 /**
  * Returns the interface number for an IPD/PKO port number.
@@ -410,7 +408,6 @@ int cvmx_helper_get_interface_num(int ipd_port)
 
return -1;
 }
-EXPORT_SYMBOL_GPL(cvmx_helper_get_interface_num);
 
 /**
  * Returns the interface index number for an IPD/PKO port
@@ -434,4 +431,3 @@ int cvmx_helper_get_interface_index_num(int ipd_port)
 
return -1;
 }
-EXPORT_SYMBOL_GPL(cvmx_helper_get_interface_index_num);
diff --git a/drivers/staging/octeon/cvmx-pko.c 
b/drivers/staging/octeon/cvmx-pko.c
index 008b881..ade16c6a 100644
--- a/drivers/staging/octeon/cvmx-pko.c
+++ b/drivers/staging/octeon/cvmx-pko.c
@@ -140,7 +140,6 @@ void cvmx_pko_disable(void)
pko_reg_flags.s.ena_pko = 0;
cvmx_write_csr(CVMX_PKO_REG_FLAGS, pko_reg_flags.u64);
 }
-EXPORT_SYMBOL_GPL(cvmx_pko_disable);
 
 /**
  * Reset the packet output.
@@ -182,7 +181,6 @@ void cvmx_pko_shutdown(void)
}
__cvmx_pko_reset();
 }
-EXPORT_SYMBOL_GPL(cvmx_pko_shutdown);
 
 /**
  * Configure a output port and the associated queues for use.
diff --git a/drivers/staging/octeon/cvmx-spi.c 
b/drivers/staging/octeon/cvmx-spi.c
index 459e3b1..ef5198d 100644
--- a/drivers/staging/octeon/cvmx-spi.c
+++ b/drivers/staging/octeon/cvmx-spi.c
@@ -177,7 +177,6 @@ int cvmx_spi_restart_interface(int interface, 
cvmx_spi_mode_t mode, int timeout)
 
return res;
 }
-EXPORT_SYMBOL_GPL(cvmx_spi_restart_interface);
 
 /**
  * Callback to perform SPI4 reset
-- 
2.3.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[RFC PATCH 02/11] MIPS: OCTEON: move ethernet-specific helpers into a separate file

2015-05-01 Thread Aaro Koskinen
Move ethernet-specific helpers into a separate file.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 arch/mips/cavium-octeon/executive/Makefile |   1 +
 .../cavium-octeon/executive/cvmx-helper-ethernet.c | 912 
 arch/mips/cavium-octeon/executive/cvmx-helper.c| 915 +
 3 files changed, 921 insertions(+), 907 deletions(-)
 create mode 100644 arch/mips/cavium-octeon/executive/cvmx-helper-ethernet.c

diff --git a/arch/mips/cavium-octeon/executive/Makefile 
b/arch/mips/cavium-octeon/executive/Makefile
index b6d6e84..e755a73 100644
--- a/arch/mips/cavium-octeon/executive/Makefile
+++ b/arch/mips/cavium-octeon/executive/Makefile
@@ -14,6 +14,7 @@ obj-y += cvmx-pko.o cvmx-spi.o cvmx-cmd-queue.o \
cvmx-helper-board.o cvmx-helper.o cvmx-helper-xaui.o \
cvmx-helper-rgmii.o cvmx-helper-sgmii.o cvmx-helper-npi.o \
cvmx-helper-loop.o cvmx-helper-spi.o cvmx-helper-util.o \
+   cvmx-helper-ethernet.o \
cvmx-interrupt-decodes.o cvmx-interrupt-rsl.o
 
 obj-y += cvmx-helper-errata.o cvmx-helper-jtag.o
diff --git a/arch/mips/cavium-octeon/executive/cvmx-helper-ethernet.c 
b/arch/mips/cavium-octeon/executive/cvmx-helper-ethernet.c
new file mode 100644
index 000..6fe990e
--- /dev/null
+++ b/arch/mips/cavium-octeon/executive/cvmx-helper-ethernet.c
@@ -0,0 +1,912 @@
+/*
+ * This file is based on code from OCTEON SDK by Cavium Networks.
+ *
+ * Copyright (c) 2003-2008 Cavium Networks
+ *
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, Version 2, as
+ * published by the Free Software Foundation.
+ */
+
+#include asm/octeon/octeon.h
+#include asm/octeon/cvmx-config.h
+#include asm/octeon/cvmx-fpa.h
+#include asm/octeon/cvmx-pip.h
+#include asm/octeon/cvmx-pko.h
+#include asm/octeon/cvmx-ipd.h
+#include asm/octeon/cvmx-spi.h
+#include asm/octeon/cvmx-helper.h
+#include asm/octeon/cvmx-helper-board.h
+#include asm/octeon/cvmx-pip-defs.h
+#include asm/octeon/cvmx-smix-defs.h
+#include asm/octeon/cvmx-asxx-defs.h
+
+/**
+ * cvmx_override_pko_queue_priority(int ipd_port, uint64_t
+ * priorities[16]) is a function pointer. It is meant to allow
+ * customization of the PKO queue priorities based on the port
+ * number. Users should set this pointer to a function before
+ * calling any cvmx-helper operations.
+ */
+void (*cvmx_override_pko_queue_priority) (int pko_port,
+ uint64_t priorities[16]);
+
+/**
+ * cvmx_override_ipd_port_setup(int ipd_port) is a function
+ * pointer. It is meant to allow customization of the IPD port
+ * setup before packet input/output comes online. It is called
+ * after cvmx-helper does the default IPD configuration, but
+ * before IPD is enabled. Users should set this pointer to a
+ * function before calling any cvmx-helper operations.
+ */
+void (*cvmx_override_ipd_port_setup) (int ipd_port);
+
+/* Port last configured link info index by IPD/PKO port */
+static cvmx_helper_link_info_t
+port_link_info[CVMX_PIP_NUM_INPUT_PORTS];
+
+/**
+ * Configure the IPD/PIP tagging and QoS options for a specific
+ * port. This function determines the POW work queue entry
+ * contents for a port. The setup performed here is controlled by
+ * the defines in executive-config.h.
+ *
+ * @ipd_port: Port to configure. This follows the IPD numbering, not the
+ *per interface numbering
+ *
+ * Returns Zero on success, negative on failure
+ */
+static int __cvmx_helper_port_setup_ipd(int ipd_port)
+{
+   union cvmx_pip_prt_cfgx port_config;
+   union cvmx_pip_prt_tagx tag_config;
+
+   port_config.u64 = cvmx_read_csr(CVMX_PIP_PRT_CFGX(ipd_port));
+   tag_config.u64 = cvmx_read_csr(CVMX_PIP_PRT_TAGX(ipd_port));
+
+   /* Have each port go to a different POW queue */
+   port_config.s.qos = ipd_port  0x7;
+
+   /* Process the headers and place the IP header in the work queue */
+   port_config.s.mode = CVMX_HELPER_INPUT_PORT_SKIP_MODE;
+
+   tag_config.s.ip6_src_flag = CVMX_HELPER_INPUT_TAG_IPV6_SRC_IP;
+   tag_config.s.ip6_dst_flag = CVMX_HELPER_INPUT_TAG_IPV6_DST_IP;
+   tag_config.s.ip6_sprt_flag = CVMX_HELPER_INPUT_TAG_IPV6_SRC_PORT;
+   tag_config.s.ip6_dprt_flag = CVMX_HELPER_INPUT_TAG_IPV6_DST_PORT;
+   tag_config.s.ip6_nxth_flag = CVMX_HELPER_INPUT_TAG_IPV6_NEXT_HEADER;
+   tag_config.s.ip4_src_flag = CVMX_HELPER_INPUT_TAG_IPV4_SRC_IP;
+   tag_config.s.ip4_dst_flag = CVMX_HELPER_INPUT_TAG_IPV4_DST_IP;
+   tag_config.s.ip4_sprt_flag = CVMX_HELPER_INPUT_TAG_IPV4_SRC_PORT;
+   tag_config.s.ip4_dprt_flag = CVMX_HELPER_INPUT_TAG_IPV4_DST_PORT;
+   tag_config.s.ip4_pctl_flag = CVMX_HELPER_INPUT_TAG_IPV4_PROTOCOL;
+   tag_config.s.inc_prt_flag = CVMX_HELPER_INPUT_TAG_INPUT_PORT;
+   tag_config.s.tcp6_tag_type = CVMX_HELPER_INPUT_TAG_TYPE;
+   tag_config.s.tcp4_tag_type = CVMX_HELPER_INPUT_TAG_TYPE;
+   

[RFC PATCH 08/11] MIPS: OCTEON: move the link helpers into a separate file

2015-05-01 Thread Aaro Koskinen
Move the link helpers into a separate file.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 arch/mips/cavium-octeon/executive/Makefile |   2 +-
 .../cavium-octeon/executive/cvmx-helper-board.c| 511 
 arch/mips/cavium-octeon/executive/cvmx-link.c  | 534 +
 3 files changed, 535 insertions(+), 512 deletions(-)
 create mode 100644 arch/mips/cavium-octeon/executive/cvmx-link.c

diff --git a/arch/mips/cavium-octeon/executive/Makefile 
b/arch/mips/cavium-octeon/executive/Makefile
index e755a73..abafe06 100644
--- a/arch/mips/cavium-octeon/executive/Makefile
+++ b/arch/mips/cavium-octeon/executive/Makefile
@@ -14,7 +14,7 @@ obj-y += cvmx-pko.o cvmx-spi.o cvmx-cmd-queue.o \
cvmx-helper-board.o cvmx-helper.o cvmx-helper-xaui.o \
cvmx-helper-rgmii.o cvmx-helper-sgmii.o cvmx-helper-npi.o \
cvmx-helper-loop.o cvmx-helper-spi.o cvmx-helper-util.o \
-   cvmx-helper-ethernet.o \
+   cvmx-helper-ethernet.o cvmx-link.o \
cvmx-interrupt-decodes.o cvmx-interrupt-rsl.o
 
 obj-y += cvmx-helper-errata.o cvmx-helper-jtag.o
diff --git a/arch/mips/cavium-octeon/executive/cvmx-helper-board.c 
b/arch/mips/cavium-octeon/executive/cvmx-helper-board.c
index 9eb0fee..10f8de1 100644
--- a/arch/mips/cavium-octeon/executive/cvmx-helper-board.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-helper-board.c
@@ -36,26 +36,9 @@
 
 #include asm/octeon/cvmx-config.h
 
-#include asm/octeon/cvmx-mdio.h
-
 #include asm/octeon/cvmx-helper.h
-#include asm/octeon/cvmx-helper-util.h
 #include asm/octeon/cvmx-helper-board.h
 
-#include asm/octeon/cvmx-gmxx-defs.h
-#include asm/octeon/cvmx-asxx-defs.h
-
-/**
- * cvmx_override_board_link_get(int ipd_port) is a function
- * pointer. It is meant to allow customization of the process of
- * talking to a PHY to determine link speed. It is called every
- * time a PHY must be polled for link status. Users should set
- * this pointer to a function before calling any cvmx-helper
- * operations.
- */
-cvmx_helper_link_info_t(*cvmx_override_board_link_get) (int ipd_port) =
-NULL;
-
 /**
  * Return the MII PHY address associated with the given IPD
  * port. A result of -1 means there isn't a MII capable PHY
@@ -205,419 +188,6 @@ int cvmx_helper_board_get_mii_address(int ipd_port)
 }
 
 /**
- * This function is the board specific method of determining an
- * ethernet ports link speed. Most Octeon boards have Marvell PHYs
- * and are handled by the fall through case. This function must be
- * updated for boards that don't have the normal Marvell PHYs.
- *
- * This function must be modified for every new Octeon board.
- * Internally it uses switch statements based on the cvmx_sysinfo
- * data to determine board types and revisions. It relies on the
- * fact that every Octeon board receives a unique board type
- * enumeration from the bootloader.
- *
- * @ipd_port: IPD input port associated with the port we want to get link
- *status for.
- *
- * Returns The ports link status. If the link isn't fully resolved, this must
- *return zero.
- */
-cvmx_helper_link_info_t __cvmx_helper_board_link_get(int ipd_port)
-{
-   cvmx_helper_link_info_t result;
-   int phy_addr;
-   int is_broadcom_phy = 0;
-
-   /* Give the user a chance to override the processing of this function */
-   if (cvmx_override_board_link_get)
-   return cvmx_override_board_link_get(ipd_port);
-
-   /* Unless we fix it later, all links are defaulted to down */
-   result.u64 = 0;
-
-   /*
-* This switch statement should handle all ports that either don't use
-* Marvell PHYS, or don't support in-band status.
-*/
-   switch (cvmx_sysinfo_get()-board_type) {
-   case CVMX_BOARD_TYPE_SIM:
-   /* The simulator gives you a simulated 1Gbps full duplex link */
-   result.s.link_up = 1;
-   result.s.full_duplex = 1;
-   result.s.speed = 1000;
-   return result;
-   case CVMX_BOARD_TYPE_EBH3100:
-   case CVMX_BOARD_TYPE_CN3010_EVB_HS5:
-   case CVMX_BOARD_TYPE_CN3005_EVB_HS5:
-   case CVMX_BOARD_TYPE_CN3020_EVB_HS5:
-   /* Port 1 on these boards is always Gigabit */
-   if (ipd_port == 1) {
-   result.s.link_up = 1;
-   result.s.full_duplex = 1;
-   result.s.speed = 1000;
-   return result;
-   }
-   /* Fall through to the generic code below */
-   break;
-   case CVMX_BOARD_TYPE_CUST_NB5:
-   /* Port 1 on these boards is always Gigabit */
-   if (ipd_port == 1) {
-   result.s.link_up = 1;
-   result.s.full_duplex = 1;
-   result.s.speed = 1000;
-   return result;
-   } else  /* The other port uses a broadcom PHY */
-

[RFC PATCH 04/11] MIPS: OCTEON: move interface enumeration helpers to cvmx-helper

2015-05-01 Thread Aaro Koskinen
Move interface enumeration helpers to cvmx-helper.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 .../mips/cavium-octeon/executive/cvmx-helper-npi.c |  38 ---
 .../cavium-octeon/executive/cvmx-helper-rgmii.c|  46 
 .../cavium-octeon/executive/cvmx-helper-sgmii.c|   4 -
 .../mips/cavium-octeon/executive/cvmx-helper-spi.c |  10 --
 .../cavium-octeon/executive/cvmx-helper-xaui.c |  12 ---
 arch/mips/cavium-octeon/executive/cvmx-helper.c| 117 +
 arch/mips/include/asm/octeon/cvmx-helper-loop.h|   1 -
 7 files changed, 117 insertions(+), 111 deletions(-)

diff --git a/arch/mips/cavium-octeon/executive/cvmx-helper-npi.c 
b/arch/mips/cavium-octeon/executive/cvmx-helper-npi.c
index cc94cfa..9f7bcc4 100644
--- a/arch/mips/cavium-octeon/executive/cvmx-helper-npi.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-helper-npi.c
@@ -38,44 +38,6 @@
 #include asm/octeon/cvmx-pip-defs.h
 
 /**
- * Probe a NPI interface and determine the number of ports
- * connected to it. The NPI interface should still be down
- * after this call.
- *
- * @interface: Interface to probe
- *
- * Returns Number of ports on the interface. Zero to disable.
- */
-int __cvmx_helper_npi_probe(int interface)
-{
-#if CVMX_PKO_QUEUES_PER_PORT_PCI  0
-   if (OCTEON_IS_MODEL(OCTEON_CN38XX) || OCTEON_IS_MODEL(OCTEON_CN58XX))
-   return 4;
-   else if (OCTEON_IS_MODEL(OCTEON_CN56XX)
- !OCTEON_IS_MODEL(OCTEON_CN56XX_PASS1_X))
-   /* The packet engines didn't exist before pass 2 */
-   return 4;
-   else if (OCTEON_IS_MODEL(OCTEON_CN52XX)
- !OCTEON_IS_MODEL(OCTEON_CN52XX_PASS1_X))
-   /* The packet engines didn't exist before pass 2 */
-   return 4;
-#if 0
-   /*
-* Technically CN30XX, CN31XX, and CN50XX contain packet
-* engines, but nobody ever uses them. Since this is the case,
-* we disable them here.
-*/
-   else if (OCTEON_IS_MODEL(OCTEON_CN31XX)
-|| OCTEON_IS_MODEL(OCTEON_CN50XX))
-   return 2;
-   else if (OCTEON_IS_MODEL(OCTEON_CN30XX))
-   return 1;
-#endif
-#endif
-   return 0;
-}
-
-/**
  * Bringup and enable a NPI interface. After this call packet
  * I/O should be fully functional. This is called with IPD
  * enabled but PKO disabled.
diff --git a/arch/mips/cavium-octeon/executive/cvmx-helper-rgmii.c 
b/arch/mips/cavium-octeon/executive/cvmx-helper-rgmii.c
index f59c88e..730812c 100644
--- a/arch/mips/cavium-octeon/executive/cvmx-helper-rgmii.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-helper-rgmii.c
@@ -48,52 +48,6 @@ void __cvmx_interrupt_gmxx_enable(int interface);
 void __cvmx_interrupt_asxx_enable(int block);
 
 /**
- * Probe RGMII ports and determine the number present
- *
- * @interface: Interface to probe
- *
- * Returns Number of RGMII/GMII/MII ports (0-4).
- */
-int __cvmx_helper_rgmii_probe(int interface)
-{
-   int num_ports = 0;
-   union cvmx_gmxx_inf_mode mode;
-   mode.u64 = cvmx_read_csr(CVMX_GMXX_INF_MODE(interface));
-
-   if (mode.s.type) {
-   if (OCTEON_IS_MODEL(OCTEON_CN38XX)
-   || OCTEON_IS_MODEL(OCTEON_CN58XX)) {
-   cvmx_dprintf(ERROR: RGMII initialize called in 
-SPI interface\n);
-   } else if (OCTEON_IS_MODEL(OCTEON_CN31XX)
-  || OCTEON_IS_MODEL(OCTEON_CN30XX)
-  || OCTEON_IS_MODEL(OCTEON_CN50XX)) {
-   /*
-* On these chips type says we're in
-* GMII/MII mode. This limits us to 2 ports
-*/
-   num_ports = 2;
-   } else {
-   cvmx_dprintf(ERROR: Unsupported Octeon model in %s\n,
-__func__);
-   }
-   } else {
-   if (OCTEON_IS_MODEL(OCTEON_CN38XX)
-   || OCTEON_IS_MODEL(OCTEON_CN58XX)) {
-   num_ports = 4;
-   } else if (OCTEON_IS_MODEL(OCTEON_CN31XX)
-  || OCTEON_IS_MODEL(OCTEON_CN30XX)
-  || OCTEON_IS_MODEL(OCTEON_CN50XX)) {
-   num_ports = 3;
-   } else {
-   cvmx_dprintf(ERROR: Unsupported Octeon model in %s\n,
-__func__);
-   }
-   }
-   return num_ports;
-}
-
-/**
  * Put an RGMII interface in loopback mode. Internal packets sent
  * out will be received back again on the same port. Externally
  * received packets will echo back out.
diff --git a/arch/mips/cavium-octeon/executive/cvmx-helper-sgmii.c 
b/arch/mips/cavium-octeon/executive/cvmx-helper-sgmii.c
index 6a47b04..03ae748 100644
--- a/arch/mips/cavium-octeon/executive/cvmx-helper-sgmii.c
+++ 

  1   2   >