0001
0002
0003
0004
0005
0006
0007 #include <linux/types.h>
0008 #include <linux/slab.h>
0009 #include <linux/netdevice.h>
0010
0011 #include <brcmu_wifi.h>
0012 #include "core.h"
0013 #include "bus.h"
0014 #include "debug.h"
0015 #include "proto.h"
0016 #include "bcdc.h"
0017 #include "msgbuf.h"
0018
0019
0020 int brcmf_proto_attach(struct brcmf_pub *drvr)
0021 {
0022 struct brcmf_proto *proto;
0023
0024 brcmf_dbg(TRACE, "Enter\n");
0025
0026 proto = kzalloc(sizeof(*proto), GFP_ATOMIC);
0027 if (!proto)
0028 goto fail;
0029
0030 drvr->proto = proto;
0031
0032 if (drvr->bus_if->proto_type == BRCMF_PROTO_BCDC) {
0033 if (brcmf_proto_bcdc_attach(drvr))
0034 goto fail;
0035 } else if (drvr->bus_if->proto_type == BRCMF_PROTO_MSGBUF) {
0036 if (brcmf_proto_msgbuf_attach(drvr))
0037 goto fail;
0038 } else {
0039 bphy_err(drvr, "Unsupported proto type %d\n",
0040 drvr->bus_if->proto_type);
0041 goto fail;
0042 }
0043 if (!proto->tx_queue_data || (proto->hdrpull == NULL) ||
0044 (proto->query_dcmd == NULL) || (proto->set_dcmd == NULL) ||
0045 (proto->configure_addr_mode == NULL) ||
0046 (proto->delete_peer == NULL) || (proto->add_tdls_peer == NULL) ||
0047 (proto->debugfs_create == NULL)) {
0048 bphy_err(drvr, "Not all proto handlers have been installed\n");
0049 goto fail;
0050 }
0051 return 0;
0052
0053 fail:
0054 kfree(proto);
0055 drvr->proto = NULL;
0056 return -ENOMEM;
0057 }
0058
0059 void brcmf_proto_detach(struct brcmf_pub *drvr)
0060 {
0061 brcmf_dbg(TRACE, "Enter\n");
0062
0063 if (drvr->proto) {
0064 if (drvr->bus_if->proto_type == BRCMF_PROTO_BCDC)
0065 brcmf_proto_bcdc_detach(drvr);
0066 else if (drvr->bus_if->proto_type == BRCMF_PROTO_MSGBUF)
0067 brcmf_proto_msgbuf_detach(drvr);
0068 kfree(drvr->proto);
0069 drvr->proto = NULL;
0070 }
0071 }