pkt_sched: remove unnecessary xchg() in packet classifiers
[pandora-kernel.git] / net / sched / sch_tbf.c
index 435076c..a2f93c0 100644 (file)
@@ -139,19 +139,6 @@ static int tbf_enqueue(struct sk_buff *skb, struct Qdisc* sch)
        return 0;
 }
 
-static int tbf_requeue(struct sk_buff *skb, struct Qdisc* sch)
-{
-       struct tbf_sched_data *q = qdisc_priv(sch);
-       int ret;
-
-       if ((ret = q->qdisc->ops->requeue(skb, q->qdisc)) == 0) {
-               sch->q.qlen++;
-               sch->qstats.requeues++;
-       }
-
-       return ret;
-}
-
 static unsigned int tbf_drop(struct Qdisc* sch)
 {
        struct tbf_sched_data *q = qdisc_priv(sch);
@@ -249,6 +236,7 @@ static int tbf_change(struct Qdisc* sch, struct nlattr *opt)
        struct tc_tbf_qopt *qopt;
        struct qdisc_rate_table *rtab = NULL;
        struct qdisc_rate_table *ptab = NULL;
+       struct qdisc_rate_table *tmp;
        struct Qdisc *child = NULL;
        int max_size,n;
 
@@ -297,7 +285,8 @@ static int tbf_change(struct Qdisc* sch, struct nlattr *opt)
        sch_tree_lock(sch);
        if (child) {
                qdisc_tree_decrease_qlen(q->qdisc, q->qdisc->q.qlen);
-               qdisc_destroy(xchg(&q->qdisc, child));
+               qdisc_destroy(q->qdisc);
+               q->qdisc = child;
        }
        q->limit = qopt->limit;
        q->mtu = qopt->mtu;
@@ -305,8 +294,14 @@ static int tbf_change(struct Qdisc* sch, struct nlattr *opt)
        q->buffer = qopt->buffer;
        q->tokens = q->buffer;
        q->ptokens = q->mtu;
-       rtab = xchg(&q->R_tab, rtab);
-       ptab = xchg(&q->P_tab, ptab);
+
+       tmp = q->R_tab;
+       q->R_tab = rtab;
+       rtab = tmp;
+
+       tmp = q->P_tab;
+       q->P_tab = ptab;
+       ptab = tmp;
        sch_tree_unlock(sch);
        err = 0;
 done:
@@ -396,7 +391,8 @@ static int tbf_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
                new = &noop_qdisc;
 
        sch_tree_lock(sch);
-       *old = xchg(&q->qdisc, new);
+       *old = q->qdisc;
+       q->qdisc = new;
        qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
        qdisc_reset(*old);
        sch_tree_unlock(sch);
@@ -468,7 +464,6 @@ static struct Qdisc_ops tbf_qdisc_ops __read_mostly = {
        .enqueue        =       tbf_enqueue,
        .dequeue        =       tbf_dequeue,
        .peek           =       qdisc_peek_dequeued,
-       .requeue        =       tbf_requeue,
        .drop           =       tbf_drop,
        .init           =       tbf_init,
        .reset          =       tbf_reset,