dmaengine: sun6i: Remove switch statement from buswidth convertion routine
authorMaxime Ripard <maxime.ripard@free-electrons.com>
Wed, 30 Jul 2014 08:30:21 +0000 (10:30 +0200)
committerVinod Koul <vinod.koul@intel.com>
Wed, 30 Jul 2014 13:44:17 +0000 (19:14 +0530)
Since the conversion routine is quite trivial, we don't need this switch, and
we can just use a simple calculation.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
drivers/dma/sun6i-dma.c

index c771d90..609c5d8 100644 (file)
@@ -248,20 +248,11 @@ static inline int convert_burst(u32 maxburst, u8 *burst)
 
 static inline int convert_buswidth(enum dma_slave_buswidth addr_width, u8 *width)
 {
-       switch (addr_width) {
-       case DMA_SLAVE_BUSWIDTH_1_BYTE:
-               *width = 0;
-               break;
-       case DMA_SLAVE_BUSWIDTH_2_BYTES:
-               *width = 1;
-               break;
-       case DMA_SLAVE_BUSWIDTH_4_BYTES:
-               *width = 2;
-               break;
-       default:
+       if ((addr_width < DMA_SLAVE_BUSWIDTH_1_BYTE) ||
+           (addr_width > DMA_SLAVE_BUSWIDTH_4_BYTES))
                return -EINVAL;
-       }
 
+       *width = addr_width >> 1;
        return 0;
 }