Commit | Line | Data |
---|---|---|
85b84133 HM |
1 | /* |
2 | * Copyright (c) 2013 Broadcom Corporation | |
3 | * | |
4 | * Permission to use, copy, modify, and/or distribute this software for any | |
5 | * purpose with or without fee is hereby granted, provided that the above | |
6 | * copyright notice and this permission notice appear in all copies. | |
7 | * | |
8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | |
11 | * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION | |
13 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |
14 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
15 | */ | |
16 | ||
17 | ||
18 | #include <linux/types.h> | |
19 | #include <linux/slab.h> | |
20 | #include <linux/netdevice.h> | |
21 | ||
22 | #include <brcmu_wifi.h> | |
23 | #include "dhd.h" | |
24 | #include "dhd_dbg.h" | |
25 | #include "proto.h" | |
26 | #include "bcdc.h" | |
27 | ||
28 | ||
29 | int brcmf_proto_attach(struct brcmf_pub *drvr) | |
30 | { | |
31 | struct brcmf_proto *proto; | |
32 | ||
33 | proto = kzalloc(sizeof(*proto), GFP_ATOMIC); | |
34 | if (!proto) | |
35 | goto fail; | |
36 | ||
37 | drvr->proto = proto; | |
38 | /* BCDC protocol is only protocol supported for the moment */ | |
39 | if (brcmf_proto_bcdc_attach(drvr)) | |
40 | goto fail; | |
41 | ||
42 | if ((proto->hdrpush == NULL) || (proto->hdrpull == NULL) || | |
43 | (proto->query_dcmd == NULL) || (proto->set_dcmd == NULL)) { | |
44 | brcmf_err("Not all proto handlers have been installed\n"); | |
45 | goto fail; | |
46 | } | |
47 | return 0; | |
48 | ||
49 | fail: | |
50 | kfree(proto); | |
51 | drvr->proto = NULL; | |
52 | return -ENOMEM; | |
53 | } | |
54 | ||
55 | void brcmf_proto_detach(struct brcmf_pub *drvr) | |
56 | { | |
57 | if (drvr->proto) { | |
58 | brcmf_proto_bcdc_detach(drvr); | |
59 | kfree(drvr->proto); | |
60 | drvr->proto = NULL; | |
61 | } | |
62 | } |