From patchwork Mon Jun 20 10:10:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Binoy Jayan X-Patchwork-Id: 70425 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1431974qgy; Mon, 20 Jun 2016 03:11:05 -0700 (PDT) X-Received: by 10.67.3.227 with SMTP id bz3mr20589286pad.67.1466417464755; Mon, 20 Jun 2016 03:11:04 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e28si32546632pfk.242.2016.06.20.03.11.04; Mon, 20 Jun 2016 03:11:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754186AbcFTKK4 (ORCPT + 1 other); Mon, 20 Jun 2016 06:10:56 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:34237 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752664AbcFTKKu (ORCPT ); Mon, 20 Jun 2016 06:10:50 -0400 Received: by mail-pa0-f52.google.com with SMTP id bz2so49728526pad.1 for ; Mon, 20 Jun 2016 03:10:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rukCITl+dPLYN9HaaGMtUOg8F+rFTPiUgGyMp7qqn/A=; b=AIJ4SiNd0Th2tisxyhl/1MK55mfNmICKZUQBs5wKcyBr6P+8vOji5bHQ4DKEvMFvKu aUlXXXgu6bsTp/0DBTmivn77aZmU9N9BLDh/zY6zzy4CVeBdsmlmwyGc09ltwD9gpphn AVqIQKeV+xcdTq8SSufmil3mgS5Us9GnJ6eKI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rukCITl+dPLYN9HaaGMtUOg8F+rFTPiUgGyMp7qqn/A=; b=KBpUt0mI6meNvT+yok2I/mCAyxXBna61IOiQ3mmsCxgfzPdb6NPhBFW+FHCpUBqP2f o7FQvr12nrnwipgXadU26b1VFGvsi8om/6PVTqkkLLgi7vx2TOcBcdeli/uaNDob0Oog wO6mAys4Ilm4VEkQImIHzKvlN7z534KjvT4DHnfXO8VpPue0hFh3jhuodRkShQu86y1G 25qgBvA8w+GzBLxBeJXY83WejrD1fWr2wfozPn0niyGXYaJHR0nfuk2TS67KMksPQw2I cRdlxg+Yfc0TpF3xhXNrLmjIMHoav+VE7OwR9AxzHoXGXVluGzpIX2kgjHkPlP7Lc/UE 46qQ== X-Gm-Message-State: ALyK8tKE67XUOLdES9d1FIhp7zwjz4IP8VcDC33c6gxkJZDfw2LC2rILH6EehuWC1IqwvFqq X-Received: by 10.66.33.132 with SMTP id r4mr20889962pai.38.1466417437598; Mon, 20 Jun 2016 03:10:37 -0700 (PDT) Received: from blr-ubuntu-59.ap.qualcomm.com ([202.46.23.61]) by smtp.gmail.com with ESMTPSA id q127sm86966321pfb.34.2016.06.20.03.10.33 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Jun 2016 03:10:36 -0700 (PDT) From: Binoy Jayan To: Greg Kroah-Hartman Cc: Johnny Kim , Austin Shin , Chris Park , Tony Cho , Glen Lee , Leo Kim , Arnd Bergmann , linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Binoy Jayan Subject: [PATCH v2 1/2] staging: wilc1000: message_queue: Move code to host interface Date: Mon, 20 Jun 2016 15:40:18 +0530 Message-Id: <1466417419-13568-2-git-send-email-binoy.jayan@linaro.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1466417419-13568-1-git-send-email-binoy.jayan@linaro.org> References: <1465814259-3009-1-git-send-email-binoy.jayan@linaro.org> <1466417419-13568-1-git-send-email-binoy.jayan@linaro.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Move the contents of wilc_msgqueue.c and wilc_msgqueue.h into host_interface.c, remove 'wilc_msgqueue.c' and 'wilc_msgqueue.h'. This is done so as to restructure the implementation of the kthread 'hostIFthread' using a work queue. Signed-off-by: Binoy Jayan Reviewed-by: Arnd Bergmann --- drivers/staging/wilc1000/Makefile | 1 - drivers/staging/wilc1000/host_interface.c | 163 +++++++++++++++++++++++++++++- drivers/staging/wilc1000/wilc_msgqueue.c | 144 -------------------------- drivers/staging/wilc1000/wilc_msgqueue.h | 28 ----- 4 files changed, 162 insertions(+), 174 deletions(-) delete mode 100644 drivers/staging/wilc1000/wilc_msgqueue.c delete mode 100644 drivers/staging/wilc1000/wilc_msgqueue.h -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/staging/wilc1000/Makefile b/drivers/staging/wilc1000/Makefile index acc3f3e..d226283 100644 --- a/drivers/staging/wilc1000/Makefile +++ b/drivers/staging/wilc1000/Makefile @@ -6,7 +6,6 @@ ccflags-y += -DFIRMWARE_1002=\"atmel/wilc1002_firmware.bin\" \ ccflags-y += -I$(src)/ -DWILC_ASIC_A0 -DWILC_DEBUGFS wilc1000-objs := wilc_wfi_cfgoperations.o linux_wlan.o linux_mon.o \ - wilc_msgqueue.o \ coreconfigurator.o host_interface.o \ wilc_wlan_cfg.o wilc_debugfs.o \ wilc_wlan.o diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 9535842..494345b 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -3,11 +3,13 @@ #include #include #include +#include #include "host_interface.h" +#include +#include #include "coreconfigurator.h" #include "wilc_wlan.h" #include "wilc_wlan_if.h" -#include "wilc_msgqueue.h" #include #include "wilc_wfi_netdevice.h" @@ -57,6 +59,20 @@ #define TCP_ACK_FILTER_LINK_SPEED_THRESH 54 #define DEFAULT_LINK_SPEED 72 +struct message { + void *buf; + u32 len; + struct list_head list; +}; + +struct message_queue { + struct semaphore sem; + spinlock_t lock; + bool exiting; + u32 recv_count; + struct list_head msg_list; +}; + struct host_if_wpa_attr { u8 *key; const u8 *mac_addr; @@ -264,6 +280,151 @@ static struct wilc_vif *join_req_vif; static void *host_int_ParseJoinBssParam(struct network_info *ptstrNetworkInfo); static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx); static s32 Handle_ScanDone(struct wilc_vif *vif, enum scan_event enuEvent); +static int wilc_mq_create(struct message_queue *mq); +static int wilc_mq_send(struct message_queue *mq, + const void *send_buf, u32 send_buf_size); +static int wilc_mq_recv(struct message_queue *mq, + void *recv_buf, u32 recv_buf_size, u32 *recv_len); +static int wilc_mq_destroy(struct message_queue *mq); + +/*! + * @author syounan + * @date 1 Sep 2010 + * @note copied from FLO glue implementatuion + * @version 1.0 + */ +static int wilc_mq_create(struct message_queue *mq) +{ + spin_lock_init(&mq->lock); + sema_init(&mq->sem, 0); + INIT_LIST_HEAD(&mq->msg_list); + mq->recv_count = 0; + mq->exiting = false; + return 0; +} + +/*! + * @author syounan + * @date 1 Sep 2010 + * @note copied from FLO glue implementatuion + * @version 1.0 + */ +static int wilc_mq_destroy(struct message_queue *mq) +{ + struct message *msg; + + mq->exiting = true; + + /* Release any waiting receiver thread. */ + while (mq->recv_count > 0) { + up(&mq->sem); + mq->recv_count--; + } + + while (!list_empty(&mq->msg_list)) { + msg = list_first_entry(&mq->msg_list, struct message, list); + list_del(&msg->list); + kfree(msg->buf); + } + + return 0; +} + +/*! + * @author syounan + * @date 1 Sep 2010 + * @note copied from FLO glue implementatuion + * @version 1.0 + */ +static int wilc_mq_send(struct message_queue *mq, + const void *send_buf, u32 send_buf_size) +{ + unsigned long flags; + struct message *new_msg = NULL; + + if (!mq || (send_buf_size == 0) || !send_buf) + return -EINVAL; + + if (mq->exiting) + return -EFAULT; + + /* construct a new message */ + new_msg = kmalloc(sizeof(*new_msg), GFP_ATOMIC); + if (!new_msg) + return -ENOMEM; + + new_msg->len = send_buf_size; + INIT_LIST_HEAD(&new_msg->list); + new_msg->buf = kmemdup(send_buf, send_buf_size, GFP_ATOMIC); + if (!new_msg->buf) { + kfree(new_msg); + return -ENOMEM; + } + + spin_lock_irqsave(&mq->lock, flags); + + /* add it to the message queue */ + list_add_tail(&new_msg->list, &mq->msg_list); + + spin_unlock_irqrestore(&mq->lock, flags); + + up(&mq->sem); + + return 0; +} + +/*! + * @author syounan + * @date 1 Sep 2010 + * @note copied from FLO glue implementatuion + * @version 1.0 + */ +static int wilc_mq_recv(struct message_queue *mq, + void *recv_buf, u32 recv_buf_size, u32 *recv_len) +{ + struct message *msg; + unsigned long flags; + + if (!mq || (recv_buf_size == 0) || !recv_buf || !recv_len) + return -EINVAL; + + if (mq->exiting) + return -EFAULT; + + spin_lock_irqsave(&mq->lock, flags); + mq->recv_count++; + spin_unlock_irqrestore(&mq->lock, flags); + + down(&mq->sem); + spin_lock_irqsave(&mq->lock, flags); + + if (list_empty(&mq->msg_list)) { + spin_unlock_irqrestore(&mq->lock, flags); + up(&mq->sem); + return -EFAULT; + } + /* check buffer size */ + msg = list_first_entry(&mq->msg_list, struct message, list); + if (recv_buf_size < msg->len) { + spin_unlock_irqrestore(&mq->lock, flags); + up(&mq->sem); + return -EOVERFLOW; + } + + /* consume the message */ + mq->recv_count--; + memcpy(recv_buf, msg->buf, msg->len); + *recv_len = msg->len; + + list_del(&msg->list); + + kfree(msg->buf); + kfree(msg); + + spin_unlock_irqrestore(&mq->lock, flags); + + return 0; +} /* The u8IfIdx starts from 0 to NUM_CONCURRENT_IFC -1, but 0 index used as * special purpose in wilc device, so we add 1 to the index to starts from 1. diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c b/drivers/staging/wilc1000/wilc_msgqueue.c deleted file mode 100644 index 6cb894e..0000000 --- a/drivers/staging/wilc1000/wilc_msgqueue.c +++ /dev/null @@ -1,144 +0,0 @@ - -#include "wilc_msgqueue.h" -#include -#include -#include - -/*! - * @author syounan - * @date 1 Sep 2010 - * @note copied from FLO glue implementatuion - * @version 1.0 - */ -int wilc_mq_create(struct message_queue *mq) -{ - spin_lock_init(&mq->lock); - sema_init(&mq->sem, 0); - INIT_LIST_HEAD(&mq->msg_list); - mq->recv_count = 0; - mq->exiting = false; - return 0; -} - -/*! - * @author syounan - * @date 1 Sep 2010 - * @note copied from FLO glue implementatuion - * @version 1.0 - */ -int wilc_mq_destroy(struct message_queue *mq) -{ - struct message *msg; - - mq->exiting = true; - - /* Release any waiting receiver thread. */ - while (mq->recv_count > 0) { - up(&mq->sem); - mq->recv_count--; - } - - while (!list_empty(&mq->msg_list)) { - msg = list_first_entry(&mq->msg_list, struct message, list); - list_del(&msg->list); - kfree(msg->buf); - } - - return 0; -} - -/*! - * @author syounan - * @date 1 Sep 2010 - * @note copied from FLO glue implementatuion - * @version 1.0 - */ -int wilc_mq_send(struct message_queue *mq, - const void *send_buf, u32 send_buf_size) -{ - unsigned long flags; - struct message *new_msg = NULL; - - if (!mq || (send_buf_size == 0) || !send_buf) - return -EINVAL; - - if (mq->exiting) - return -EFAULT; - - /* construct a new message */ - new_msg = kmalloc(sizeof(*new_msg), GFP_ATOMIC); - if (!new_msg) - return -ENOMEM; - - new_msg->len = send_buf_size; - INIT_LIST_HEAD(&new_msg->list); - new_msg->buf = kmemdup(send_buf, send_buf_size, GFP_ATOMIC); - if (!new_msg->buf) { - kfree(new_msg); - return -ENOMEM; - } - - spin_lock_irqsave(&mq->lock, flags); - - /* add it to the message queue */ - list_add_tail(&new_msg->list, &mq->msg_list); - - spin_unlock_irqrestore(&mq->lock, flags); - - up(&mq->sem); - - return 0; -} - -/*! - * @author syounan - * @date 1 Sep 2010 - * @note copied from FLO glue implementatuion - * @version 1.0 - */ -int wilc_mq_recv(struct message_queue *mq, - void *recv_buf, u32 recv_buf_size, u32 *recv_len) -{ - struct message *msg; - unsigned long flags; - - if (!mq || (recv_buf_size == 0) || !recv_buf || !recv_len) - return -EINVAL; - - if (mq->exiting) - return -EFAULT; - - spin_lock_irqsave(&mq->lock, flags); - mq->recv_count++; - spin_unlock_irqrestore(&mq->lock, flags); - - down(&mq->sem); - spin_lock_irqsave(&mq->lock, flags); - - if (list_empty(&mq->msg_list)) { - spin_unlock_irqrestore(&mq->lock, flags); - up(&mq->sem); - return -EFAULT; - } - /* check buffer size */ - msg = list_first_entry(&mq->msg_list, struct message, list); - if (recv_buf_size < msg->len) { - spin_unlock_irqrestore(&mq->lock, flags); - up(&mq->sem); - return -EOVERFLOW; - } - - /* consume the message */ - mq->recv_count--; - memcpy(recv_buf, msg->buf, msg->len); - *recv_len = msg->len; - - list_del(&msg->list); - - kfree(msg->buf); - kfree(msg); - - spin_unlock_irqrestore(&mq->lock, flags); - - return 0; -} diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h b/drivers/staging/wilc1000/wilc_msgqueue.h deleted file mode 100644 index 846a484..0000000 --- a/drivers/staging/wilc1000/wilc_msgqueue.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef __WILC_MSG_QUEUE_H__ -#define __WILC_MSG_QUEUE_H__ - -#include -#include - -struct message { - void *buf; - u32 len; - struct list_head list; -}; - -struct message_queue { - struct semaphore sem; - spinlock_t lock; - bool exiting; - u32 recv_count; - struct list_head msg_list; -}; - -int wilc_mq_create(struct message_queue *mq); -int wilc_mq_send(struct message_queue *mq, - const void *send_buf, u32 send_buf_size); -int wilc_mq_recv(struct message_queue *mq, - void *recv_buf, u32 recv_buf_size, u32 *recv_len); -int wilc_mq_destroy(struct message_queue *mq); - -#endif