brcmfmac: make brcmf_proto_hdrpull() return struct brcmf_if instance
authorArend van Spriel <arend@broadcom.com>
Wed, 26 Aug 2015 20:14:54 +0000 (22:14 +0200)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 29 Sep 2015 07:28:30 +0000 (10:28 +0300)
Avoid spreading the ifidx in the driver, but have it return the
struct brcmf_if instance.

Reviewed-by: Hante Meuleman <meuleman@broadcom.com>
Reviewed-by: Franky (Zhenhui) Lin <frankyl@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/brcm80211/brcmfmac/bcdc.c
drivers/net/wireless/brcm80211/brcmfmac/core.c
drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c
drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
drivers/net/wireless/brcm80211/brcmfmac/proto.h

index 83aa6a00aa359d543b036f64ecf5a0afab07d501..aa5ed651625d4c928956216302145d962749c817 100644 (file)
@@ -272,11 +272,11 @@ brcmf_proto_bcdc_hdrpush(struct brcmf_pub *drvr, int ifidx, u8 offset,
 }
 
 static int
-brcmf_proto_bcdc_hdrpull(struct brcmf_pub *drvr, bool do_fws, u8 *ifidx,
-                        struct sk_buff *pktbuf)
+brcmf_proto_bcdc_hdrpull(struct brcmf_pub *drvr, bool do_fws,
+                        struct sk_buff *pktbuf, struct brcmf_if **ifp)
 {
        struct brcmf_proto_bcdc_header *h;
-       struct brcmf_if *ifp;
+       struct brcmf_if *tmp_if;
 
        brcmf_dbg(BCDC, "Enter\n");
 
@@ -290,21 +290,21 @@ brcmf_proto_bcdc_hdrpull(struct brcmf_pub *drvr, bool do_fws, u8 *ifidx,
        trace_brcmf_bcdchdr(pktbuf->data);
        h = (struct brcmf_proto_bcdc_header *)(pktbuf->data);
 
-       ifp = brcmf_get_ifp(drvr, BCDC_GET_IF_IDX(h));
-       if (IS_ERR_OR_NULL(ifp)) {
+       tmp_if = brcmf_get_ifp(drvr, BCDC_GET_IF_IDX(h));
+       if (!tmp_if) {
                brcmf_dbg(INFO, "no matching ifp found\n");
                return -EBADE;
        }
        if (((h->flags & BCDC_FLAG_VER_MASK) >> BCDC_FLAG_VER_SHIFT) !=
            BCDC_PROTO_VER) {
                brcmf_err("%s: non-BCDC packet received, flags 0x%x\n",
-                         brcmf_ifname(drvr, ifp->ifidx), h->flags);
+                         brcmf_ifname(drvr, tmp_if->ifidx), h->flags);
                return -EBADE;
        }
 
        if (h->flags & BCDC_FLAG_SUM_GOOD) {
                brcmf_dbg(BCDC, "%s: BDC rcv, good checksum, flags 0x%x\n",
-                         brcmf_ifname(drvr, ifp->ifidx), h->flags);
+                         brcmf_ifname(drvr, tmp_if->ifidx), h->flags);
                pktbuf->ip_summed = CHECKSUM_UNNECESSARY;
        }
 
@@ -312,7 +312,7 @@ brcmf_proto_bcdc_hdrpull(struct brcmf_pub *drvr, bool do_fws, u8 *ifidx,
 
        skb_pull(pktbuf, BCDC_HEADER_LEN);
        if (do_fws)
-               brcmf_fws_hdrpull(drvr, ifp->ifidx, h->data_offset << 2,
+               brcmf_fws_hdrpull(drvr, tmp_if->ifidx, h->data_offset << 2,
                                  pktbuf);
        else
                skb_pull(pktbuf, h->data_offset << 2);
@@ -320,7 +320,7 @@ brcmf_proto_bcdc_hdrpull(struct brcmf_pub *drvr, bool do_fws, u8 *ifidx,
        if (pktbuf->len == 0)
                return -ENODATA;
 
-       *ifidx = ifp->ifidx;
+       *ifp = tmp_if;
        return 0;
 }
 
index 1747d59ef4c702e8e59a6810204481f4318d5dd8..1f65ce867b1621867534d60a9fb820017ec59ede 100644 (file)
@@ -87,7 +87,7 @@ struct brcmf_if *brcmf_get_ifp(struct brcmf_pub *drvr, int ifidx)
 {
        if (ifidx < 0 || ifidx >= BRCMF_MAX_IFS) {
                brcmf_err("ifidx %d out of range\n", ifidx);
-               return ERR_PTR(-ERANGE);
+               return NULL;
        }
 
        /* The ifidx is the idx to map to matching netdev/ifp. When receiving
@@ -539,17 +539,15 @@ void brcmf_rx_frame(struct device *dev, struct sk_buff *skb)
        struct brcmf_bus *bus_if = dev_get_drvdata(dev);
        struct brcmf_pub *drvr = bus_if->drvr;
        struct brcmf_skb_reorder_data *rd;
-       u8 ifidx;
        int ret;
 
        brcmf_dbg(DATA, "Enter: %s: rxp=%p\n", dev_name(dev), skb);
 
        /* process and remove protocol-specific header */
-       ret = brcmf_proto_hdrpull(drvr, true, &ifidx, skb);
-       ifp = drvr->iflist[ifidx];
+       ret = brcmf_proto_hdrpull(drvr, true, skb, &ifp);
 
        if (ret || !ifp || !ifp->ndev) {
-               if ((ret != -ENODATA) && ifp)
+               if (ret != -ENODATA && ifp)
                        ifp->stats.rx_errors++;
                brcmu_pkt_buf_free_skb(skb);
                return;
@@ -592,17 +590,17 @@ void brcmf_txcomplete(struct device *dev, struct sk_buff *txp, bool success)
 {
        struct brcmf_bus *bus_if = dev_get_drvdata(dev);
        struct brcmf_pub *drvr = bus_if->drvr;
-       u8 ifidx;
+       struct brcmf_if *ifp;
 
        /* await txstatus signal for firmware if active */
        if (brcmf_fws_fc_active(drvr->fws)) {
                if (!success)
                        brcmf_fws_bustxfail(drvr->fws, txp);
        } else {
-               if (brcmf_proto_hdrpull(drvr, false, &ifidx, txp))
+               if (brcmf_proto_hdrpull(drvr, false, txp, &ifp))
                        brcmu_pkt_buf_free_skb(txp);
                else
-                       brcmf_txfinalize(drvr, txp, ifidx, success);
+                       brcmf_txfinalize(drvr, txp, ifp->ifidx, success);
        }
 }
 
index 5017eaa4af45fdd8f9dfd1034919c5042cce7cd8..fd438739a91ece169096c31dbea371284bbf9194 100644 (file)
@@ -1448,7 +1448,7 @@ brcmf_fws_txs_process(struct brcmf_fws_info *fws, u8 flags, u32 hslot,
        struct sk_buff *skb;
        struct brcmf_skbuff_cb *skcb;
        struct brcmf_fws_mac_descriptor *entry = NULL;
-       u8 ifidx;
+       struct brcmf_if *ifp;
 
        brcmf_dbg(DATA, "flags %d\n", flags);
 
@@ -1497,15 +1497,16 @@ brcmf_fws_txs_process(struct brcmf_fws_info *fws, u8 flags, u32 hslot,
        }
        brcmf_fws_macdesc_return_req_credit(skb);
 
-       if (brcmf_proto_hdrpull(fws->drvr, false, &ifidx, skb)) {
+       ret = brcmf_proto_hdrpull(fws->drvr, false, skb, &ifp);
+       if (ret) {
                brcmu_pkt_buf_free_skb(skb);
                return -EINVAL;
        }
        if (!remove_from_hanger)
-               ret = brcmf_fws_txstatus_suppressed(fws, fifo, skb, ifidx,
+               ret = brcmf_fws_txstatus_suppressed(fws, fifo, skb, ifp->ifidx,
                                                    genbit, seq);
        if (remove_from_hanger || ret)
-               brcmf_txfinalize(fws->drvr, skb, ifidx, true);
+               brcmf_txfinalize(fws->drvr, skb, ifp->ifidx, true);
 
        return 0;
 }
@@ -1848,7 +1849,7 @@ static int brcmf_fws_commit_skb(struct brcmf_fws_info *fws, int fifo,
                entry->transit_count--;
                if (entry->suppressed)
                        entry->suppr_transit_count--;
-               brcmf_proto_hdrpull(fws->drvr, false, &ifidx, skb);
+               (void)brcmf_proto_hdrpull(fws->drvr, false, skb, NULL);
                goto rollback;
        }
 
index 1271d1d86ec9ddfa85ab2bbab0d6ab2b4dee6dc6..d582f6993574c8cbc5d1bbfc23afc932d6094b57 100644 (file)
@@ -522,7 +522,7 @@ static int brcmf_msgbuf_set_dcmd(struct brcmf_pub *drvr, int ifidx,
 
 
 static int brcmf_msgbuf_hdrpull(struct brcmf_pub *drvr, bool do_fws,
-                               u8 *ifidx, struct sk_buff *skb)
+                               struct sk_buff *skb, struct brcmf_if **ifp)
 {
        return -ENODEV;
 }
@@ -1082,7 +1082,7 @@ brcmf_msgbuf_rx_skb(struct brcmf_msgbuf *msgbuf, struct sk_buff *skb,
        struct brcmf_if *ifp;
 
        ifp = brcmf_get_ifp(msgbuf->drvr, ifidx);
-       if (IS_ERR_OR_NULL(ifp) || !ifp->ndev) {
+       if (!ifp || !ifp->ndev) {
                brcmf_err("Received pkt for invalid ifidx %d\n", ifidx);
                brcmu_pkt_buf_free_skb(skb);
                return;
index 971172ff686c80fc16b61ab083372eab783c0ef3..d55119d3675516ec79dbcc66af54f202d9693bf8 100644 (file)
@@ -24,8 +24,8 @@ enum proto_addr_mode {
 
 
 struct brcmf_proto {
-       int (*hdrpull)(struct brcmf_pub *drvr, bool do_fws, u8 *ifidx,
-                      struct sk_buff *skb);
+       int (*hdrpull)(struct brcmf_pub *drvr, bool do_fws,
+                      struct sk_buff *skb, struct brcmf_if **ifp);
        int (*query_dcmd)(struct brcmf_pub *drvr, int ifidx, uint cmd,
                          void *buf, uint len);
        int (*set_dcmd)(struct brcmf_pub *drvr, int ifidx, uint cmd, void *buf,
@@ -46,9 +46,19 @@ int brcmf_proto_attach(struct brcmf_pub *drvr);
 void brcmf_proto_detach(struct brcmf_pub *drvr);
 
 static inline int brcmf_proto_hdrpull(struct brcmf_pub *drvr, bool do_fws,
-                                     u8 *ifidx, struct sk_buff *skb)
+                                     struct sk_buff *skb,
+                                     struct brcmf_if **ifp)
 {
-       return drvr->proto->hdrpull(drvr, do_fws, ifidx, skb);
+       struct brcmf_if *tmp = NULL;
+
+       /* assure protocol is always called with
+        * non-null initialized pointer.
+        */
+       if (ifp)
+               *ifp = NULL;
+       else
+               ifp = &tmp;
+       return drvr->proto->hdrpull(drvr, do_fws, skb, ifp);
 }
 static inline int brcmf_proto_query_dcmd(struct brcmf_pub *drvr, int ifidx,
                                         uint cmd, void *buf, uint len)