rsi_91x_usb_ops.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * Copyright (c) 2014 Redpine Signals Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. *
  16. */
  17. #include <linux/firmware.h>
  18. #include "rsi_usb.h"
  19. /**
  20. * rsi_usb_rx_thread() - This is a kernel thread to receive the packets from
  21. * the USB device.
  22. * @common: Pointer to the driver private structure.
  23. *
  24. * Return: None.
  25. */
  26. void rsi_usb_rx_thread(struct rsi_common *common)
  27. {
  28. struct rsi_hw *adapter = common->priv;
  29. struct rsi_91x_usbdev *dev = (struct rsi_91x_usbdev *)adapter->rsi_dev;
  30. int status;
  31. do {
  32. rsi_wait_event(&dev->rx_thread.event, EVENT_WAIT_FOREVER);
  33. if (atomic_read(&dev->rx_thread.thread_done))
  34. goto out;
  35. mutex_lock(&common->rx_lock);
  36. status = rsi_read_pkt(common, 0);
  37. if (status) {
  38. rsi_dbg(ERR_ZONE, "%s: Failed To read data", __func__);
  39. mutex_unlock(&common->rx_lock);
  40. return;
  41. }
  42. mutex_unlock(&common->rx_lock);
  43. rsi_reset_event(&dev->rx_thread.event);
  44. if (adapter->rx_urb_submit(adapter)) {
  45. rsi_dbg(ERR_ZONE,
  46. "%s: Failed in urb submission", __func__);
  47. return;
  48. }
  49. } while (1);
  50. out:
  51. rsi_dbg(INFO_ZONE, "%s: Terminated thread\n", __func__);
  52. complete_and_exit(&dev->rx_thread.completion, 0);
  53. }