xref: /linux/net/nfc/hci/llc_nop.c (revision 762f99f4f3cb41a775b5157dd761217beba65873)
146fe7771SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
28af00d48SEric Lapuyade /*
38af00d48SEric Lapuyade  * nop (passthrough) Link Layer Control
48af00d48SEric Lapuyade  *
58af00d48SEric Lapuyade  * Copyright (C) 2012  Intel Corporation. All rights reserved.
68af00d48SEric Lapuyade  */
78af00d48SEric Lapuyade 
88af00d48SEric Lapuyade #include <linux/types.h>
98af00d48SEric Lapuyade 
108af00d48SEric Lapuyade #include "llc.h"
118af00d48SEric Lapuyade 
128af00d48SEric Lapuyade struct llc_nop {
138af00d48SEric Lapuyade 	struct nfc_hci_dev *hdev;
148af00d48SEric Lapuyade 	xmit_to_drv_t xmit_to_drv;
158af00d48SEric Lapuyade 	rcv_to_hci_t rcv_to_hci;
168af00d48SEric Lapuyade 	int tx_headroom;
178af00d48SEric Lapuyade 	int tx_tailroom;
188af00d48SEric Lapuyade 	llc_failure_t llc_failure;
198af00d48SEric Lapuyade };
208af00d48SEric Lapuyade 
llc_nop_init(struct nfc_hci_dev * hdev,xmit_to_drv_t xmit_to_drv,rcv_to_hci_t rcv_to_hci,int tx_headroom,int tx_tailroom,int * rx_headroom,int * rx_tailroom,llc_failure_t llc_failure)218af00d48SEric Lapuyade static void *llc_nop_init(struct nfc_hci_dev *hdev, xmit_to_drv_t xmit_to_drv,
228af00d48SEric Lapuyade 			  rcv_to_hci_t rcv_to_hci, int tx_headroom,
238af00d48SEric Lapuyade 			  int tx_tailroom, int *rx_headroom, int *rx_tailroom,
248af00d48SEric Lapuyade 			  llc_failure_t llc_failure)
258af00d48SEric Lapuyade {
268af00d48SEric Lapuyade 	struct llc_nop *llc_nop;
278af00d48SEric Lapuyade 
288af00d48SEric Lapuyade 	*rx_headroom = 0;
298af00d48SEric Lapuyade 	*rx_tailroom = 0;
308af00d48SEric Lapuyade 
318af00d48SEric Lapuyade 	llc_nop = kzalloc(sizeof(struct llc_nop), GFP_KERNEL);
328af00d48SEric Lapuyade 	if (llc_nop == NULL)
338af00d48SEric Lapuyade 		return NULL;
348af00d48SEric Lapuyade 
358af00d48SEric Lapuyade 	llc_nop->hdev = hdev;
368af00d48SEric Lapuyade 	llc_nop->xmit_to_drv = xmit_to_drv;
378af00d48SEric Lapuyade 	llc_nop->rcv_to_hci = rcv_to_hci;
388af00d48SEric Lapuyade 	llc_nop->tx_headroom = tx_headroom;
398af00d48SEric Lapuyade 	llc_nop->tx_tailroom = tx_tailroom;
408af00d48SEric Lapuyade 	llc_nop->llc_failure = llc_failure;
418af00d48SEric Lapuyade 
428af00d48SEric Lapuyade 	return llc_nop;
438af00d48SEric Lapuyade }
448af00d48SEric Lapuyade 
llc_nop_deinit(struct nfc_llc * llc)458af00d48SEric Lapuyade static void llc_nop_deinit(struct nfc_llc *llc)
468af00d48SEric Lapuyade {
478af00d48SEric Lapuyade 	kfree(nfc_llc_get_data(llc));
488af00d48SEric Lapuyade }
498af00d48SEric Lapuyade 
llc_nop_start(struct nfc_llc * llc)508af00d48SEric Lapuyade static int llc_nop_start(struct nfc_llc *llc)
518af00d48SEric Lapuyade {
528af00d48SEric Lapuyade 	return 0;
538af00d48SEric Lapuyade }
548af00d48SEric Lapuyade 
llc_nop_stop(struct nfc_llc * llc)558af00d48SEric Lapuyade static int llc_nop_stop(struct nfc_llc *llc)
568af00d48SEric Lapuyade {
578af00d48SEric Lapuyade 	return 0;
588af00d48SEric Lapuyade }
598af00d48SEric Lapuyade 
llc_nop_rcv_from_drv(struct nfc_llc * llc,struct sk_buff * skb)608af00d48SEric Lapuyade static void llc_nop_rcv_from_drv(struct nfc_llc *llc, struct sk_buff *skb)
618af00d48SEric Lapuyade {
628af00d48SEric Lapuyade 	struct llc_nop *llc_nop = nfc_llc_get_data(llc);
638af00d48SEric Lapuyade 
648af00d48SEric Lapuyade 	llc_nop->rcv_to_hci(llc_nop->hdev, skb);
658af00d48SEric Lapuyade }
668af00d48SEric Lapuyade 
llc_nop_xmit_from_hci(struct nfc_llc * llc,struct sk_buff * skb)678af00d48SEric Lapuyade static int llc_nop_xmit_from_hci(struct nfc_llc *llc, struct sk_buff *skb)
688af00d48SEric Lapuyade {
698af00d48SEric Lapuyade 	struct llc_nop *llc_nop = nfc_llc_get_data(llc);
708af00d48SEric Lapuyade 
718af00d48SEric Lapuyade 	return llc_nop->xmit_to_drv(llc_nop->hdev, skb);
728af00d48SEric Lapuyade }
738af00d48SEric Lapuyade 
74*49545357SKrzysztof Kozlowski static const struct nfc_llc_ops llc_nop_ops = {
758af00d48SEric Lapuyade 	.init = llc_nop_init,
768af00d48SEric Lapuyade 	.deinit = llc_nop_deinit,
778af00d48SEric Lapuyade 	.start = llc_nop_start,
788af00d48SEric Lapuyade 	.stop = llc_nop_stop,
798af00d48SEric Lapuyade 	.rcv_from_drv = llc_nop_rcv_from_drv,
808af00d48SEric Lapuyade 	.xmit_from_hci = llc_nop_xmit_from_hci,
818af00d48SEric Lapuyade };
828af00d48SEric Lapuyade 
nfc_llc_nop_register(void)83a7d0281bSEric Lapuyade int nfc_llc_nop_register(void)
848af00d48SEric Lapuyade {
858af00d48SEric Lapuyade 	return nfc_llc_register(LLC_NOP_NAME, &llc_nop_ops);
868af00d48SEric Lapuyade }
87