Path: blob/main/sys/contrib/dev/broadcom/brcm80211/brcmfmac/proto.c
178665 views
// SPDX-License-Identifier: ISC1/*2* Copyright (c) 2013 Broadcom Corporation3*/456#include <linux/types.h>7#include <linux/slab.h>8#include <linux/netdevice.h>910#include <brcmu_wifi.h>11#include "core.h"12#include "bus.h"13#include "debug.h"14#include "proto.h"15#include "bcdc.h"16#include "msgbuf.h"171819int brcmf_proto_attach(struct brcmf_pub *drvr)20{21struct brcmf_proto *proto;2223brcmf_dbg(TRACE, "Enter\n");2425proto = kzalloc(sizeof(*proto), GFP_ATOMIC);26if (!proto)27goto fail;2829drvr->proto = proto;3031if (drvr->bus_if->proto_type == BRCMF_PROTO_BCDC) {32if (brcmf_proto_bcdc_attach(drvr))33goto fail;34} else if (drvr->bus_if->proto_type == BRCMF_PROTO_MSGBUF) {35if (brcmf_proto_msgbuf_attach(drvr))36goto fail;37} else {38bphy_err(drvr, "Unsupported proto type %d\n",39drvr->bus_if->proto_type);40goto fail;41}42if (!proto->tx_queue_data || (proto->hdrpull == NULL) ||43(proto->query_dcmd == NULL) || (proto->set_dcmd == NULL) ||44(proto->configure_addr_mode == NULL) ||45(proto->delete_peer == NULL) || (proto->add_tdls_peer == NULL) ||46(proto->debugfs_create == NULL)) {47bphy_err(drvr, "Not all proto handlers have been installed\n");48goto fail;49}50return 0;5152fail:53kfree(proto);54drvr->proto = NULL;55return -ENOMEM;56}5758void brcmf_proto_detach(struct brcmf_pub *drvr)59{60brcmf_dbg(TRACE, "Enter\n");6162if (drvr->proto) {63if (drvr->bus_if->proto_type == BRCMF_PROTO_BCDC)64brcmf_proto_bcdc_detach(drvr);65else if (drvr->bus_if->proto_type == BRCMF_PROTO_MSGBUF)66brcmf_proto_msgbuf_detach(drvr);67kfree(drvr->proto);68drvr->proto = NULL;69}70}717273