xref: /openbmc/linux/net/nfc/hci/llc_nop.c (revision a7d0281bbf7e1b0eff2de3c7ed6a5ffce6b62dac)
18af00d48SEric Lapuyade /*
28af00d48SEric Lapuyade  * nop (passthrough) Link Layer Control
38af00d48SEric Lapuyade  *
48af00d48SEric Lapuyade  * Copyright (C) 2012  Intel Corporation. All rights reserved.
58af00d48SEric Lapuyade  *
68af00d48SEric Lapuyade  * This program is free software; you can redistribute it and/or modify it
78af00d48SEric Lapuyade  * under the terms and conditions of the GNU General Public License,
88af00d48SEric Lapuyade  * version 2, as published by the Free Software Foundation.
98af00d48SEric Lapuyade  *
108af00d48SEric Lapuyade  * This program is distributed in the hope that it will be useful,
118af00d48SEric Lapuyade  * but WITHOUT ANY WARRANTY; without even the implied warranty of
128af00d48SEric Lapuyade  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
138af00d48SEric Lapuyade  * GNU General Public License for more details.
148af00d48SEric Lapuyade  *
158af00d48SEric Lapuyade  * You should have received a copy of the GNU General Public License
168af00d48SEric Lapuyade  * along with this program; if not, write to the
178af00d48SEric Lapuyade  * Free Software Foundation, Inc.,
188af00d48SEric Lapuyade  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
198af00d48SEric Lapuyade  */
208af00d48SEric Lapuyade 
218af00d48SEric Lapuyade #include <linux/types.h>
228af00d48SEric Lapuyade 
238af00d48SEric Lapuyade #include "llc.h"
248af00d48SEric Lapuyade 
258af00d48SEric Lapuyade struct llc_nop {
268af00d48SEric Lapuyade 	struct nfc_hci_dev *hdev;
278af00d48SEric Lapuyade 	xmit_to_drv_t xmit_to_drv;
288af00d48SEric Lapuyade 	rcv_to_hci_t rcv_to_hci;
298af00d48SEric Lapuyade 	int tx_headroom;
308af00d48SEric Lapuyade 	int tx_tailroom;
318af00d48SEric Lapuyade 	llc_failure_t llc_failure;
328af00d48SEric Lapuyade };
338af00d48SEric Lapuyade 
348af00d48SEric Lapuyade static void *llc_nop_init(struct nfc_hci_dev *hdev, xmit_to_drv_t xmit_to_drv,
358af00d48SEric Lapuyade 			  rcv_to_hci_t rcv_to_hci, int tx_headroom,
368af00d48SEric Lapuyade 			  int tx_tailroom, int *rx_headroom, int *rx_tailroom,
378af00d48SEric Lapuyade 			  llc_failure_t llc_failure)
388af00d48SEric Lapuyade {
398af00d48SEric Lapuyade 	struct llc_nop *llc_nop;
408af00d48SEric Lapuyade 
418af00d48SEric Lapuyade 	*rx_headroom = 0;
428af00d48SEric Lapuyade 	*rx_tailroom = 0;
438af00d48SEric Lapuyade 
448af00d48SEric Lapuyade 	llc_nop = kzalloc(sizeof(struct llc_nop), GFP_KERNEL);
458af00d48SEric Lapuyade 	if (llc_nop == NULL)
468af00d48SEric Lapuyade 		return NULL;
478af00d48SEric Lapuyade 
488af00d48SEric Lapuyade 	llc_nop->hdev = hdev;
498af00d48SEric Lapuyade 	llc_nop->xmit_to_drv = xmit_to_drv;
508af00d48SEric Lapuyade 	llc_nop->rcv_to_hci = rcv_to_hci;
518af00d48SEric Lapuyade 	llc_nop->tx_headroom = tx_headroom;
528af00d48SEric Lapuyade 	llc_nop->tx_tailroom = tx_tailroom;
538af00d48SEric Lapuyade 	llc_nop->llc_failure = llc_failure;
548af00d48SEric Lapuyade 
558af00d48SEric Lapuyade 	return llc_nop;
568af00d48SEric Lapuyade }
578af00d48SEric Lapuyade 
588af00d48SEric Lapuyade static void llc_nop_deinit(struct nfc_llc *llc)
598af00d48SEric Lapuyade {
608af00d48SEric Lapuyade 	kfree(nfc_llc_get_data(llc));
618af00d48SEric Lapuyade }
628af00d48SEric Lapuyade 
638af00d48SEric Lapuyade static int llc_nop_start(struct nfc_llc *llc)
648af00d48SEric Lapuyade {
658af00d48SEric Lapuyade 	return 0;
668af00d48SEric Lapuyade }
678af00d48SEric Lapuyade 
688af00d48SEric Lapuyade static int llc_nop_stop(struct nfc_llc *llc)
698af00d48SEric Lapuyade {
708af00d48SEric Lapuyade 	return 0;
718af00d48SEric Lapuyade }
728af00d48SEric Lapuyade 
738af00d48SEric Lapuyade static void llc_nop_rcv_from_drv(struct nfc_llc *llc, struct sk_buff *skb)
748af00d48SEric Lapuyade {
758af00d48SEric Lapuyade 	struct llc_nop *llc_nop = nfc_llc_get_data(llc);
768af00d48SEric Lapuyade 
778af00d48SEric Lapuyade 	llc_nop->rcv_to_hci(llc_nop->hdev, skb);
788af00d48SEric Lapuyade }
798af00d48SEric Lapuyade 
808af00d48SEric Lapuyade static int llc_nop_xmit_from_hci(struct nfc_llc *llc, struct sk_buff *skb)
818af00d48SEric Lapuyade {
828af00d48SEric Lapuyade 	struct llc_nop *llc_nop = nfc_llc_get_data(llc);
838af00d48SEric Lapuyade 
848af00d48SEric Lapuyade 	return llc_nop->xmit_to_drv(llc_nop->hdev, skb);
858af00d48SEric Lapuyade }
868af00d48SEric Lapuyade 
878af00d48SEric Lapuyade static struct nfc_llc_ops llc_nop_ops = {
888af00d48SEric Lapuyade 	.init = llc_nop_init,
898af00d48SEric Lapuyade 	.deinit = llc_nop_deinit,
908af00d48SEric Lapuyade 	.start = llc_nop_start,
918af00d48SEric Lapuyade 	.stop = llc_nop_stop,
928af00d48SEric Lapuyade 	.rcv_from_drv = llc_nop_rcv_from_drv,
938af00d48SEric Lapuyade 	.xmit_from_hci = llc_nop_xmit_from_hci,
948af00d48SEric Lapuyade };
958af00d48SEric Lapuyade 
96*a7d0281bSEric Lapuyade int nfc_llc_nop_register(void)
978af00d48SEric Lapuyade {
988af00d48SEric Lapuyade 	return nfc_llc_register(LLC_NOP_NAME, &llc_nop_ops);
998af00d48SEric Lapuyade }
100