llc_nop.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * nop (passthrough) Link Layer Control
  4. *
  5. * Copyright (C) 2012 Intel Corporation. All rights reserved.
  6. */
  7. #include <linux/types.h>
  8. #include "llc.h"
  9. struct llc_nop {
  10. struct nfc_hci_dev *hdev;
  11. xmit_to_drv_t xmit_to_drv;
  12. rcv_to_hci_t rcv_to_hci;
  13. int tx_headroom;
  14. int tx_tailroom;
  15. llc_failure_t llc_failure;
  16. };
  17. static void *llc_nop_init(struct nfc_hci_dev *hdev, xmit_to_drv_t xmit_to_drv,
  18. rcv_to_hci_t rcv_to_hci, int tx_headroom,
  19. int tx_tailroom, int *rx_headroom, int *rx_tailroom,
  20. llc_failure_t llc_failure)
  21. {
  22. struct llc_nop *llc_nop;
  23. *rx_headroom = 0;
  24. *rx_tailroom = 0;
  25. llc_nop = kzalloc(sizeof(struct llc_nop), GFP_KERNEL);
  26. if (llc_nop == NULL)
  27. return NULL;
  28. llc_nop->hdev = hdev;
  29. llc_nop->xmit_to_drv = xmit_to_drv;
  30. llc_nop->rcv_to_hci = rcv_to_hci;
  31. llc_nop->tx_headroom = tx_headroom;
  32. llc_nop->tx_tailroom = tx_tailroom;
  33. llc_nop->llc_failure = llc_failure;
  34. return llc_nop;
  35. }
  36. static void llc_nop_deinit(struct nfc_llc *llc)
  37. {
  38. kfree(nfc_llc_get_data(llc));
  39. }
  40. static int llc_nop_start(struct nfc_llc *llc)
  41. {
  42. return 0;
  43. }
  44. static int llc_nop_stop(struct nfc_llc *llc)
  45. {
  46. return 0;
  47. }
  48. static void llc_nop_rcv_from_drv(struct nfc_llc *llc, struct sk_buff *skb)
  49. {
  50. struct llc_nop *llc_nop = nfc_llc_get_data(llc);
  51. llc_nop->rcv_to_hci(llc_nop->hdev, skb);
  52. }
  53. static int llc_nop_xmit_from_hci(struct nfc_llc *llc, struct sk_buff *skb)
  54. {
  55. struct llc_nop *llc_nop = nfc_llc_get_data(llc);
  56. return llc_nop->xmit_to_drv(llc_nop->hdev, skb);
  57. }
  58. static struct nfc_llc_ops llc_nop_ops = {
  59. .init = llc_nop_init,
  60. .deinit = llc_nop_deinit,
  61. .start = llc_nop_start,
  62. .stop = llc_nop_stop,
  63. .rcv_from_drv = llc_nop_rcv_from_drv,
  64. .xmit_from_hci = llc_nop_xmit_from_hci,
  65. };
  66. int nfc_llc_nop_register(void)
  67. {
  68. return nfc_llc_register(LLC_NOP_NAME, &llc_nop_ops);
  69. }