brcmfmac: error messages should not be suppressed
[platform/kernel/linux-starfive.git] / drivers / net / wireless / brcm80211 / brcmfmac / dhd_cdc.c
index b3e3b7f..8392355 100644 (file)
@@ -23,8 +23,6 @@
 
 #include <linux/types.h>
 #include <linux/netdevice.h>
-#include <linux/sched.h>
-#include <defs.h>
 
 #include <brcmu_utils.h>
 #include <brcmu_wifi.h>
@@ -119,9 +117,7 @@ static int brcmf_proto_cdc_msg(struct brcmf_pub *drvr)
                len = CDC_MAX_MSG_SIZE;
 
        /* Send request */
-       return drvr->bus_if->brcmf_bus_txctl(drvr->dev,
-                                            (unsigned char *)&prot->msg,
-                                            len);
+       return brcmf_bus_txctl(drvr->bus_if, (unsigned char *)&prot->msg, len);
 }
 
 static int brcmf_proto_cdc_cmplt(struct brcmf_pub *drvr, u32 id, u32 len)
@@ -130,11 +126,10 @@ static int brcmf_proto_cdc_cmplt(struct brcmf_pub *drvr, u32 id, u32 len)
        struct brcmf_proto *prot = drvr->prot;
 
        brcmf_dbg(TRACE, "Enter\n");
-
+       len += sizeof(struct brcmf_proto_cdc_dcmd);
        do {
-               ret = drvr->bus_if->brcmf_bus_rxctl(drvr->dev,
-                               (unsigned char *)&prot->msg,
-                               len + sizeof(struct brcmf_proto_cdc_dcmd));
+               ret = brcmf_bus_rxctl(drvr->bus_if, (unsigned char *)&prot->msg,
+                                     len);
                if (ret < 0)
                        break;
        } while (CDC_DCMD_ID(le32_to_cpu(prot->msg.flags)) != id);
@@ -181,7 +176,7 @@ brcmf_proto_cdc_query_dcmd(struct brcmf_pub *drvr, int ifidx, uint cmd,
 
        ret = brcmf_proto_cdc_msg(drvr);
        if (ret < 0) {
-               brcmf_dbg(ERROR, "brcmf_proto_cdc_msg failed w/status %d\n",
+               brcmf_err("brcmf_proto_cdc_msg failed w/status %d\n",
                          ret);
                goto done;
        }
@@ -198,7 +193,7 @@ retry:
        if ((id < prot->reqid) && (++retries < RETRIES))
                goto retry;
        if (id != prot->reqid) {
-               brcmf_dbg(ERROR, "%s: unexpected request id %d (expected %d)\n",
+               brcmf_err("%s: unexpected request id %d (expected %d)\n",
                          brcmf_ifname(drvr, ifidx), id, prot->reqid);
                ret = -EINVAL;
                goto done;
@@ -260,7 +255,7 @@ int brcmf_proto_cdc_set_dcmd(struct brcmf_pub *drvr, int ifidx, uint cmd,
        id = (flags & CDC_DCMD_ID_MASK) >> CDC_DCMD_ID_SHIFT;
 
        if (id != prot->reqid) {
-               brcmf_dbg(ERROR, "%s: unexpected request id %d (expected %d)\n",
+               brcmf_err("%s: unexpected request id %d (expected %d)\n",
                          brcmf_ifname(drvr, ifidx), id, prot->reqid);
                ret = -EINVAL;
                goto done;
@@ -277,76 +272,6 @@ done:
        return ret;
 }
 
-int
-brcmf_proto_dcmd(struct brcmf_pub *drvr, int ifidx, struct brcmf_dcmd *dcmd,
-                 int len)
-{
-       struct brcmf_proto *prot = drvr->prot;
-       int ret = -1;
-
-       if (drvr->bus_if->state == BRCMF_BUS_DOWN) {
-               brcmf_dbg(ERROR, "bus is down. we have nothing to do.\n");
-               return ret;
-       }
-       mutex_lock(&drvr->proto_block);
-
-       brcmf_dbg(TRACE, "Enter\n");
-
-       if (len > BRCMF_DCMD_MAXLEN)
-               goto done;
-
-       if (prot->pending == true) {
-               brcmf_dbg(TRACE, "CDC packet is pending!!!! cmd=0x%x (%lu) lastcmd=0x%x (%lu)\n",
-                         dcmd->cmd, (unsigned long)dcmd->cmd, prot->lastcmd,
-                         (unsigned long)prot->lastcmd);
-               if (dcmd->cmd == BRCMF_C_SET_VAR ||
-                   dcmd->cmd == BRCMF_C_GET_VAR)
-                       brcmf_dbg(TRACE, "iovar cmd=%s\n", (char *)dcmd->buf);
-
-               goto done;
-       }
-
-       prot->pending = true;
-       prot->lastcmd = dcmd->cmd;
-       if (dcmd->set)
-               ret = brcmf_proto_cdc_set_dcmd(drvr, ifidx, dcmd->cmd,
-                                                  dcmd->buf, len);
-       else {
-               ret = brcmf_proto_cdc_query_dcmd(drvr, ifidx, dcmd->cmd,
-                                                    dcmd->buf, len);
-               if (ret > 0)
-                       dcmd->used = ret -
-                                       sizeof(struct brcmf_proto_cdc_dcmd);
-       }
-
-       if (ret >= 0)
-               ret = 0;
-       else {
-               struct brcmf_proto_cdc_dcmd *msg = &prot->msg;
-               /* len == needed when set/query fails from dongle */
-               dcmd->needed = le32_to_cpu(msg->len);
-       }
-
-       /* Intercept the wme_dp dongle cmd here */
-       if (!ret && dcmd->cmd == BRCMF_C_SET_VAR &&
-           !strcmp(dcmd->buf, "wme_dp")) {
-               int slen;
-               __le32 val = 0;
-
-               slen = strlen("wme_dp") + 1;
-               if (len >= (int)(slen + sizeof(int)))
-                       memcpy(&val, (char *)dcmd->buf + slen, sizeof(int));
-               drvr->wme_dp = (u8) le32_to_cpu(val);
-       }
-
-       prot->pending = false;
-
-done:
-       mutex_unlock(&drvr->proto_block);
-
-       return ret;
-}
-
 static bool pkt_sum_needed(struct sk_buff *skb)
 {
        return skb->ip_summed == CHECKSUM_PARTIAL;
@@ -392,7 +317,7 @@ int brcmf_proto_hdrpull(struct device *dev, int *ifidx,
        /* Pop BDC header used to convey priority for buses that don't */
 
        if (pktbuf->len < BDC_HEADER_LEN) {
-               brcmf_dbg(ERROR, "rx data too short (%d < %d)\n",
+               brcmf_err("rx data too short (%d < %d)\n",
                          pktbuf->len, BDC_HEADER_LEN);
                return -EBADE;
        }
@@ -401,13 +326,13 @@ int brcmf_proto_hdrpull(struct device *dev, int *ifidx,
 
        *ifidx = BDC_GET_IF_IDX(h);
        if (*ifidx >= BRCMF_MAX_IFS) {
-               brcmf_dbg(ERROR, "rx data ifnum out of range (%d)\n", *ifidx);
+               brcmf_err("rx data ifnum out of range (%d)\n", *ifidx);
                return -EBADE;
        }
 
        if (((h->flags & BDC_FLAG_VER_MASK) >> BDC_FLAG_VER_SHIFT) !=
            BDC_PROTO_VER) {
-               brcmf_dbg(ERROR, "%s: non-BDC packet received, flags 0x%x\n",
+               brcmf_err("%s: non-BDC packet received, flags 0x%x\n",
                          brcmf_ifname(drvr, *ifidx), h->flags);
                return -EBADE;
        }
@@ -421,6 +346,7 @@ int brcmf_proto_hdrpull(struct device *dev, int *ifidx,
        pktbuf->priority = h->priority & BDC_PRIORITY_MASK;
 
        skb_pull(pktbuf, BDC_HEADER_LEN);
+       skb_pull(pktbuf, h->data_offset << 2);
 
        return 0;
 }
@@ -435,7 +361,7 @@ int brcmf_proto_attach(struct brcmf_pub *drvr)
 
        /* ensure that the msg buf directly follows the cdc msg struct */
        if ((unsigned long)(&cdc->msg + 1) != (unsigned long)cdc->buf) {
-               brcmf_dbg(ERROR, "struct brcmf_proto is not correctly defined\n");
+               brcmf_err("struct brcmf_proto is not correctly defined\n");
                goto fail;
        }
 
@@ -457,35 +383,6 @@ void brcmf_proto_detach(struct brcmf_pub *drvr)
        drvr->prot = NULL;
 }
 
-int brcmf_proto_init(struct brcmf_pub *drvr)
-{
-       int ret = 0;
-       char buf[128];
-
-       brcmf_dbg(TRACE, "Enter\n");
-
-       mutex_lock(&drvr->proto_block);
-
-       /* Get the device MAC address */
-       strcpy(buf, "cur_etheraddr");
-       ret = brcmf_proto_cdc_query_dcmd(drvr, 0, BRCMF_C_GET_VAR,
-                                         buf, sizeof(buf));
-       if (ret < 0) {
-               mutex_unlock(&drvr->proto_block);
-               return ret;
-       }
-       memcpy(drvr->mac, buf, ETH_ALEN);
-
-       mutex_unlock(&drvr->proto_block);
-
-       ret = brcmf_c_preinit_dcmds(drvr);
-
-       /* Always assumes wl for now */
-       drvr->iswl = true;
-
-       return ret;
-}
-
 void brcmf_proto_stop(struct brcmf_pub *drvr)
 {
        /* Nothing to do for CDC */