llc_nop.c 2.3 KB

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