Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (c) 2014 Redpine Signals Inc.
0003  *
0004  * Permission to use, copy, modify, and/or distribute this software for any
0005  * purpose with or without fee is hereby granted, provided that the above
0006  * copyright notice and this permission notice appear in all copies.
0007  *
0008  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
0009  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
0010  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
0011  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
0012  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
0013  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
0014  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
0015  *
0016  */
0017 
0018 #include <linux/firmware.h>
0019 #include "rsi_usb.h"
0020 
0021 /**
0022  * rsi_usb_rx_thread() - This is a kernel thread to receive the packets from
0023  *           the USB device.
0024  * @common: Pointer to the driver private structure.
0025  *
0026  * Return: None.
0027  */
0028 void rsi_usb_rx_thread(struct rsi_common *common)
0029 {
0030     struct rsi_hw *adapter = common->priv;
0031     struct rsi_91x_usbdev *dev = (struct rsi_91x_usbdev *)adapter->rsi_dev;
0032     int status;
0033     struct sk_buff *skb;
0034 
0035     do {
0036         rsi_wait_event(&dev->rx_thread.event, EVENT_WAIT_FOREVER);
0037         rsi_reset_event(&dev->rx_thread.event);
0038 
0039         while (true) {
0040             if (atomic_read(&dev->rx_thread.thread_done))
0041                 goto out;
0042 
0043             skb = skb_dequeue(&dev->rx_q);
0044             if (!skb)
0045                 break;
0046             status = rsi_read_pkt(common, skb->data, 0);
0047             if (status) {
0048                 rsi_dbg(ERR_ZONE, "%s: Failed To read data",
0049                     __func__);
0050                 break;
0051             }
0052             dev_kfree_skb(skb);
0053         }
0054     } while (1);
0055 
0056 out:
0057     rsi_dbg(INFO_ZONE, "%s: Terminated thread\n", __func__);
0058     skb_queue_purge(&dev->rx_q);
0059     kthread_complete_and_exit(&dev->rx_thread.completion, 0);
0060 }
0061