xref: /openbmc/linux/net/nfc/hci/llc_nop.c (revision 8af00d48dc929442644bf68e9cd3d951d9697296)
1*8af00d48SEric Lapuyade /*
2*8af00d48SEric Lapuyade  * nop (passthrough) Link Layer Control
3*8af00d48SEric Lapuyade  *
4*8af00d48SEric Lapuyade  * Copyright (C) 2012  Intel Corporation. All rights reserved.
5*8af00d48SEric Lapuyade  *
6*8af00d48SEric Lapuyade  * This program is free software; you can redistribute it and/or modify it
7*8af00d48SEric Lapuyade  * under the terms and conditions of the GNU General Public License,
8*8af00d48SEric Lapuyade  * version 2, as published by the Free Software Foundation.
9*8af00d48SEric Lapuyade  *
10*8af00d48SEric Lapuyade  * This program is distributed in the hope that it will be useful,
11*8af00d48SEric Lapuyade  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12*8af00d48SEric Lapuyade  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13*8af00d48SEric Lapuyade  * GNU General Public License for more details.
14*8af00d48SEric Lapuyade  *
15*8af00d48SEric Lapuyade  * You should have received a copy of the GNU General Public License
16*8af00d48SEric Lapuyade  * along with this program; if not, write to the
17*8af00d48SEric Lapuyade  * Free Software Foundation, Inc.,
18*8af00d48SEric Lapuyade  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19*8af00d48SEric Lapuyade  */
20*8af00d48SEric Lapuyade 
21*8af00d48SEric Lapuyade #include <linux/types.h>
22*8af00d48SEric Lapuyade #include <linux/export.h>
23*8af00d48SEric Lapuyade 
24*8af00d48SEric Lapuyade #include "llc.h"
25*8af00d48SEric Lapuyade 
26*8af00d48SEric Lapuyade struct llc_nop {
27*8af00d48SEric Lapuyade 	struct nfc_hci_dev *hdev;
28*8af00d48SEric Lapuyade 	xmit_to_drv_t xmit_to_drv;
29*8af00d48SEric Lapuyade 	rcv_to_hci_t rcv_to_hci;
30*8af00d48SEric Lapuyade 	int tx_headroom;
31*8af00d48SEric Lapuyade 	int tx_tailroom;
32*8af00d48SEric Lapuyade 	llc_failure_t llc_failure;
33*8af00d48SEric Lapuyade };
34*8af00d48SEric Lapuyade 
35*8af00d48SEric Lapuyade static void *llc_nop_init(struct nfc_hci_dev *hdev, xmit_to_drv_t xmit_to_drv,
36*8af00d48SEric Lapuyade 			  rcv_to_hci_t rcv_to_hci, int tx_headroom,
37*8af00d48SEric Lapuyade 			  int tx_tailroom, int *rx_headroom, int *rx_tailroom,
38*8af00d48SEric Lapuyade 			  llc_failure_t llc_failure)
39*8af00d48SEric Lapuyade {
40*8af00d48SEric Lapuyade 	struct llc_nop *llc_nop;
41*8af00d48SEric Lapuyade 
42*8af00d48SEric Lapuyade 	*rx_headroom = 0;
43*8af00d48SEric Lapuyade 	*rx_tailroom = 0;
44*8af00d48SEric Lapuyade 
45*8af00d48SEric Lapuyade 	llc_nop = kzalloc(sizeof(struct llc_nop), GFP_KERNEL);
46*8af00d48SEric Lapuyade 	if (llc_nop == NULL)
47*8af00d48SEric Lapuyade 		return NULL;
48*8af00d48SEric Lapuyade 
49*8af00d48SEric Lapuyade 	llc_nop->hdev = hdev;
50*8af00d48SEric Lapuyade 	llc_nop->xmit_to_drv = xmit_to_drv;
51*8af00d48SEric Lapuyade 	llc_nop->rcv_to_hci = rcv_to_hci;
52*8af00d48SEric Lapuyade 	llc_nop->tx_headroom = tx_headroom;
53*8af00d48SEric Lapuyade 	llc_nop->tx_tailroom = tx_tailroom;
54*8af00d48SEric Lapuyade 	llc_nop->llc_failure = llc_failure;
55*8af00d48SEric Lapuyade 
56*8af00d48SEric Lapuyade 	return llc_nop;
57*8af00d48SEric Lapuyade }
58*8af00d48SEric Lapuyade 
59*8af00d48SEric Lapuyade static void llc_nop_deinit(struct nfc_llc *llc)
60*8af00d48SEric Lapuyade {
61*8af00d48SEric Lapuyade 	kfree(nfc_llc_get_data(llc));
62*8af00d48SEric Lapuyade }
63*8af00d48SEric Lapuyade 
64*8af00d48SEric Lapuyade static int llc_nop_start(struct nfc_llc *llc)
65*8af00d48SEric Lapuyade {
66*8af00d48SEric Lapuyade 	return 0;
67*8af00d48SEric Lapuyade }
68*8af00d48SEric Lapuyade 
69*8af00d48SEric Lapuyade static int llc_nop_stop(struct nfc_llc *llc)
70*8af00d48SEric Lapuyade {
71*8af00d48SEric Lapuyade 	return 0;
72*8af00d48SEric Lapuyade }
73*8af00d48SEric Lapuyade 
74*8af00d48SEric Lapuyade static void llc_nop_rcv_from_drv(struct nfc_llc *llc, struct sk_buff *skb)
75*8af00d48SEric Lapuyade {
76*8af00d48SEric Lapuyade 	struct llc_nop *llc_nop = nfc_llc_get_data(llc);
77*8af00d48SEric Lapuyade 
78*8af00d48SEric Lapuyade 	llc_nop->rcv_to_hci(llc_nop->hdev, skb);
79*8af00d48SEric Lapuyade }
80*8af00d48SEric Lapuyade 
81*8af00d48SEric Lapuyade static int llc_nop_xmit_from_hci(struct nfc_llc *llc, struct sk_buff *skb)
82*8af00d48SEric Lapuyade {
83*8af00d48SEric Lapuyade 	struct llc_nop *llc_nop = nfc_llc_get_data(llc);
84*8af00d48SEric Lapuyade 
85*8af00d48SEric Lapuyade 	return llc_nop->xmit_to_drv(llc_nop->hdev, skb);
86*8af00d48SEric Lapuyade }
87*8af00d48SEric Lapuyade 
88*8af00d48SEric Lapuyade static struct nfc_llc_ops llc_nop_ops = {
89*8af00d48SEric Lapuyade 	.init = llc_nop_init,
90*8af00d48SEric Lapuyade 	.deinit = llc_nop_deinit,
91*8af00d48SEric Lapuyade 	.start = llc_nop_start,
92*8af00d48SEric Lapuyade 	.stop = llc_nop_stop,
93*8af00d48SEric Lapuyade 	.rcv_from_drv = llc_nop_rcv_from_drv,
94*8af00d48SEric Lapuyade 	.xmit_from_hci = llc_nop_xmit_from_hci,
95*8af00d48SEric Lapuyade };
96*8af00d48SEric Lapuyade 
97*8af00d48SEric Lapuyade int nfc_llc_nop_register()
98*8af00d48SEric Lapuyade {
99*8af00d48SEric Lapuyade 	return nfc_llc_register(LLC_NOP_NAME, &llc_nop_ops);
100*8af00d48SEric Lapuyade }
101*8af00d48SEric Lapuyade EXPORT_SYMBOL(nfc_llc_nop_register);
102