aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-omap2-mcspi.c
diff options
context:
space:
mode:
authorShubhrajyoti D <shubhrajyoti@ti.com>2012-08-22 02:05:13 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-08-22 12:58:01 -0400
commitaf4e944dbda418034d1b08628b10e753369fbdc7 (patch)
tree79b56d897b97536452aac67d8e2c46da8a356f63 /drivers/spi/spi-omap2-mcspi.c
parentb2af045c70aa60f7231b22a363d74a1ab5a6297b (diff)
spi: omap2-mcspi: Remove the macro MOD_REG_BIT
Remove the macro MOD_REG_BIT instead make the bit field modifications directly. This deletes a branch operation in cases where the the set is predecided. While at it optimise two sequential bit clear in one step. Acked-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/spi/spi-omap2-mcspi.c')
-rw-r--r--drivers/spi/spi-omap2-mcspi.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 84aeaf0e5a0f..cd87f90588e7 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -140,13 +140,6 @@ struct omap2_mcspi_cs {
140 u32 chconf0; 140 u32 chconf0;
141}; 141};
142 142
143#define MOD_REG_BIT(val, mask, set) do { \
144 if (set) \
145 val |= mask; \
146 else \
147 val &= ~mask; \
148} while (0)
149
150static inline void mcspi_write_reg(struct spi_master *master, 143static inline void mcspi_write_reg(struct spi_master *master,
151 int idx, u32 val) 144 int idx, u32 val)
152{ 145{
@@ -205,7 +198,11 @@ static void omap2_mcspi_set_dma_req(const struct spi_device *spi,
205 else 198 else
206 rw = OMAP2_MCSPI_CHCONF_DMAW; 199 rw = OMAP2_MCSPI_CHCONF_DMAW;
207 200
208 MOD_REG_BIT(l, rw, enable); 201 if (enable)
202 l |= rw;
203 else
204 l &= ~rw;
205
209 mcspi_write_chconf0(spi, l); 206 mcspi_write_chconf0(spi, l);
210} 207}
211 208
@@ -224,7 +221,11 @@ static void omap2_mcspi_force_cs(struct spi_device *spi, int cs_active)
224 u32 l; 221 u32 l;
225 222
226 l = mcspi_cached_chconf0(spi); 223 l = mcspi_cached_chconf0(spi);
227 MOD_REG_BIT(l, OMAP2_MCSPI_CHCONF_FORCE, cs_active); 224 if (cs_active)
225 l |= OMAP2_MCSPI_CHCONF_FORCE;
226 else
227 l &= ~OMAP2_MCSPI_CHCONF_FORCE;
228
228 mcspi_write_chconf0(spi, l); 229 mcspi_write_chconf0(spi, l);
229} 230}
230 231
@@ -239,9 +240,8 @@ static void omap2_mcspi_set_master_mode(struct spi_master *master)
239 * to single-channel master mode 240 * to single-channel master mode
240 */ 241 */
241 l = mcspi_read_reg(master, OMAP2_MCSPI_MODULCTRL); 242 l = mcspi_read_reg(master, OMAP2_MCSPI_MODULCTRL);
242 MOD_REG_BIT(l, OMAP2_MCSPI_MODULCTRL_STEST, 0); 243 l &= ~(OMAP2_MCSPI_MODULCTRL_STEST | OMAP2_MCSPI_MODULCTRL_MS);
243 MOD_REG_BIT(l, OMAP2_MCSPI_MODULCTRL_MS, 0); 244 l |= OMAP2_MCSPI_MODULCTRL_SINGLE;
244 MOD_REG_BIT(l, OMAP2_MCSPI_MODULCTRL_SINGLE, 1);
245 mcspi_write_reg(master, OMAP2_MCSPI_MODULCTRL, l); 245 mcspi_write_reg(master, OMAP2_MCSPI_MODULCTRL, l);
246 246
247 ctx->modulctrl = l; 247 ctx->modulctrl = l;
@@ -1285,9 +1285,9 @@ static int omap2_mcspi_resume(struct device *dev)
1285 * We need to toggle CS state for OMAP take this 1285 * We need to toggle CS state for OMAP take this
1286 * change in account. 1286 * change in account.
1287 */ 1287 */
1288 MOD_REG_BIT(cs->chconf0, OMAP2_MCSPI_CHCONF_FORCE, 1); 1288 cs->chconf0 |= OMAP2_MCSPI_CHCONF_FORCE;
1289 __raw_writel(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0); 1289 __raw_writel(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0);
1290 MOD_REG_BIT(cs->chconf0, OMAP2_MCSPI_CHCONF_FORCE, 0); 1290 cs->chconf0 &= ~OMAP2_MCSPI_CHCONF_FORCE;
1291 __raw_writel(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0); 1291 __raw_writel(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0);
1292 } 1292 }
1293 } 1293 }