From: Arend van Spriel Date: Mon, 11 Apr 2016 09:35:28 +0000 (+0200) Subject: brcmfmac: create common function for handling brcmf_proto_hdrpull() X-Git-Tag: v4.7-rc1~154^2~146^2~94 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=c462ebcdfe425a132aaba950d114ac32de3cdf44;p=karo-tx-linux.git brcmfmac: create common function for handling brcmf_proto_hdrpull() In receive path brcmf_proto_hdrpull() needs to be called and handled similar in brcmf_rx_frame() and brcmf_rx_event(). Move that duplicated code in separate function. Reviewed-by: Hante Meuleman Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: Kalle Valo --- diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c index 9b53555cf85c..1b476d1fec2c 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c @@ -322,26 +322,35 @@ void brcmf_netif_rx(struct brcmf_if *ifp, struct sk_buff *skb) netif_rx_ni(skb); } -void brcmf_rx_frame(struct device *dev, struct sk_buff *skb, bool handle_event) +static int brcmf_rx_hdrpull(struct brcmf_pub *drvr, struct sk_buff *skb, + struct brcmf_if **ifp) { - struct brcmf_if *ifp; - struct brcmf_bus *bus_if = dev_get_drvdata(dev); - struct brcmf_pub *drvr = bus_if->drvr; 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, skb, &ifp); + ret = brcmf_proto_hdrpull(drvr, true, skb, ifp); - if (ret || !ifp || !ifp->ndev) { + if (ret || !(*ifp) || !(*ifp)->ndev) { if (ret != -ENODATA && ifp) - ifp->stats.rx_errors++; + (*ifp)->stats.rx_errors++; brcmu_pkt_buf_free_skb(skb); - return; + return -ENODATA; } - skb->protocol = eth_type_trans(skb, ifp->ndev); + skb->protocol = eth_type_trans(skb, (*ifp)->ndev); + return 0; +} + +void brcmf_rx_frame(struct device *dev, struct sk_buff *skb, bool handle_event) +{ + struct brcmf_if *ifp; + struct brcmf_bus *bus_if = dev_get_drvdata(dev); + struct brcmf_pub *drvr = bus_if->drvr; + + brcmf_dbg(DATA, "Enter: %s: rxp=%p\n", dev_name(dev), skb); + + if (brcmf_rx_hdrpull(drvr, skb, &ifp)) + return; if (brcmf_proto_is_reorder_skb(skb)) { brcmf_proto_rxreorder(ifp, skb); @@ -359,21 +368,11 @@ void brcmf_rx_event(struct device *dev, struct sk_buff *skb) struct brcmf_if *ifp; struct brcmf_bus *bus_if = dev_get_drvdata(dev); struct brcmf_pub *drvr = bus_if->drvr; - int ret; brcmf_dbg(EVENT, "Enter: %s: rxp=%p\n", dev_name(dev), skb); - /* process and remove protocol-specific header */ - ret = brcmf_proto_hdrpull(drvr, true, skb, &ifp); - - if (ret || !ifp || !ifp->ndev) { - if (ret != -ENODATA && ifp) - ifp->stats.rx_errors++; - brcmu_pkt_buf_free_skb(skb); + if (brcmf_rx_hdrpull(drvr, skb, &ifp)) return; - } - - skb->protocol = eth_type_trans(skb, ifp->ndev); brcmf_fweh_process_skb(ifp->drvr, skb); brcmu_pkt_buf_free_skb(skb);