Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * nop (passthrough) Link Layer Control
0004  *
0005  * Copyright (C) 2012  Intel Corporation. All rights reserved.
0006  */
0007 
0008 #include <linux/types.h>
0009 
0010 #include "llc.h"
0011 
0012 struct llc_nop {
0013     struct nfc_hci_dev *hdev;
0014     xmit_to_drv_t xmit_to_drv;
0015     rcv_to_hci_t rcv_to_hci;
0016     int tx_headroom;
0017     int tx_tailroom;
0018     llc_failure_t llc_failure;
0019 };
0020 
0021 static void *llc_nop_init(struct nfc_hci_dev *hdev, xmit_to_drv_t xmit_to_drv,
0022               rcv_to_hci_t rcv_to_hci, int tx_headroom,
0023               int tx_tailroom, int *rx_headroom, int *rx_tailroom,
0024               llc_failure_t llc_failure)
0025 {
0026     struct llc_nop *llc_nop;
0027 
0028     *rx_headroom = 0;
0029     *rx_tailroom = 0;
0030 
0031     llc_nop = kzalloc(sizeof(struct llc_nop), GFP_KERNEL);
0032     if (llc_nop == NULL)
0033         return NULL;
0034 
0035     llc_nop->hdev = hdev;
0036     llc_nop->xmit_to_drv = xmit_to_drv;
0037     llc_nop->rcv_to_hci = rcv_to_hci;
0038     llc_nop->tx_headroom = tx_headroom;
0039     llc_nop->tx_tailroom = tx_tailroom;
0040     llc_nop->llc_failure = llc_failure;
0041 
0042     return llc_nop;
0043 }
0044 
0045 static void llc_nop_deinit(struct nfc_llc *llc)
0046 {
0047     kfree(nfc_llc_get_data(llc));
0048 }
0049 
0050 static int llc_nop_start(struct nfc_llc *llc)
0051 {
0052     return 0;
0053 }
0054 
0055 static int llc_nop_stop(struct nfc_llc *llc)
0056 {
0057     return 0;
0058 }
0059 
0060 static void llc_nop_rcv_from_drv(struct nfc_llc *llc, struct sk_buff *skb)
0061 {
0062     struct llc_nop *llc_nop = nfc_llc_get_data(llc);
0063 
0064     llc_nop->rcv_to_hci(llc_nop->hdev, skb);
0065 }
0066 
0067 static int llc_nop_xmit_from_hci(struct nfc_llc *llc, struct sk_buff *skb)
0068 {
0069     struct llc_nop *llc_nop = nfc_llc_get_data(llc);
0070 
0071     return llc_nop->xmit_to_drv(llc_nop->hdev, skb);
0072 }
0073 
0074 static const struct nfc_llc_ops llc_nop_ops = {
0075     .init = llc_nop_init,
0076     .deinit = llc_nop_deinit,
0077     .start = llc_nop_start,
0078     .stop = llc_nop_stop,
0079     .rcv_from_drv = llc_nop_rcv_from_drv,
0080     .xmit_from_hci = llc_nop_xmit_from_hci,
0081 };
0082 
0083 int nfc_llc_nop_register(void)
0084 {
0085     return nfc_llc_register(LLC_NOP_NAME, &llc_nop_ops);
0086 }