net: ethernet: ti: cpdma: fit rated channels in backward order
authorIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Mon, 23 Jul 2018 21:26:30 +0000 (00:26 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 24 Jul 2018 03:34:36 +0000 (20:34 -0700)
According to TRM tx rated channels should be in 7..0 order,
so correct it.

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/ti/davinci_cpdma.c

index 4f1267477aa4b56b7f3e1d19420302728da56e7d..4236dcdd56348512d6d2393ea27c19c0bd9078bf 100644 (file)
@@ -406,37 +406,36 @@ static int cpdma_chan_fit_rate(struct cpdma_chan *ch, u32 rate,
        struct cpdma_chan *chan;
        u32 old_rate = ch->rate;
        u32 new_rmask = 0;
-       int rlim = 1;
+       int rlim = 0;
        int i;
 
-       *prio_mode = 0;
        for (i = tx_chan_num(0); i < tx_chan_num(CPDMA_MAX_CHANNELS); i++) {
                chan = ctlr->channels[i];
-               if (!chan) {
-                       rlim = 0;
+               if (!chan)
                        continue;
-               }
 
                if (chan == ch)
                        chan->rate = rate;
 
                if (chan->rate) {
-                       if (rlim) {
-                               new_rmask |= chan->mask;
-                       } else {
-                               ch->rate = old_rate;
-                               dev_err(ctlr->dev, "Prev channel of %dch is not rate limited\n",
-                                       chan->chan_num);
-                               return -EINVAL;
-                       }
-               } else {
-                       *prio_mode = 1;
-                       rlim = 0;
+                       rlim = 1;
+                       new_rmask |= chan->mask;
+                       continue;
                }
+
+               if (rlim)
+                       goto err;
        }
 
        *rmask = new_rmask;
+       *prio_mode = rlim;
        return 0;
+
+err:
+       ch->rate = old_rate;
+       dev_err(ctlr->dev, "Upper cpdma ch%d is not rate limited\n",
+               chan->chan_num);
+       return -EINVAL;
 }
 
 static u32 cpdma_chan_set_factors(struct cpdma_ctlr *ctlr,