From patchwork Mon Aug 8 13:58:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arend van Spriel X-Patchwork-Id: 1045292 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p78E0AGH008563 for ; Mon, 8 Aug 2011 14:14:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753267Ab1HHOCb (ORCPT ); Mon, 8 Aug 2011 10:02:31 -0400 Received: from mms3.broadcom.com ([216.31.210.19]:3093 "EHLO MMS3.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752180Ab1HHN7Z (ORCPT ); Mon, 8 Aug 2011 09:59:25 -0400 Received: from [10.9.200.133] by MMS3.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.3.2)); Mon, 08 Aug 2011 07:04:22 -0700 X-Server-Uuid: B55A25B1-5D7D-41F8-BC53-C57E7AD3C201 Received: from mail-irva-13.broadcom.com (10.11.16.103) by IRVEXCHHUB02.corp.ad.broadcom.com (10.9.200.133) with Microsoft SMTP Server id 8.2.247.2; Mon, 8 Aug 2011 06:58:59 -0700 Received: from mail-sj1-12.sj.broadcom.com (mail-sj1-12.sj.broadcom.com [10.17.16.106]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 2221074D0F; Mon, 8 Aug 2011 06:59:15 -0700 (PDT) Received: from arend-laptop (unknown [10.176.68.34]) by mail-sj1-12.sj.broadcom.com (Postfix) with ESMTP id 8B8482051E; Mon, 8 Aug 2011 06:59:12 -0700 (PDT) Received: from arend by arend-laptop with local (Exim 4.74) ( envelope-from ) id 1QqQMJ-0004P3-MU; Mon, 08 Aug 2011 15:59:11 +0200 From: "Arend van Spriel" To: gregkh@suse.de cc: devel@linuxdriverproject.org, linux-wireless@vger.kernel.org, "Arend van Spriel" Subject: [PATCHv2 33/82] staging: brcm80211: replace semaphore by wait_queue for sysioc thread Date: Mon, 8 Aug 2011 15:58:17 +0200 Message-ID: <1312811946-16713-34-git-send-email-arend@broadcom.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1312811946-16713-1-git-send-email-arend@broadcom.com> References: <1312811946-16713-1-git-send-email-arend@broadcom.com> MIME-Version: 1.0 X-WSS-ID: 6221336C3KO3788503-01-01 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 08 Aug 2011 14:14:25 +0000 (UTC) The sysioc thread was triggered using a semaphore. Now it waits for a wake_up() on its wait queue and the semaphore has been removed as the semaphore serves another purpose. This removes a checkpatch warning for dhd_linux.c. Signed-off-by: Arend van Spriel Reviewed-by: Roland Vossen Reviewed-by: Franky Lin --- drivers/staging/brcm80211/brcmfmac/dhd_linux.c | 27 ++++++++++++++++-------- 1 files changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index b7a741b..0d86819 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -79,7 +80,7 @@ struct brcmf_info { /* Thread to issue ioctl for multicast */ struct task_struct *sysioc_tsk; - struct semaphore sysioc_sem; + wait_queue_head_t sysioc_waitq; bool set_multicast; bool set_macaddress; u8 macvalue[ETH_ALEN]; @@ -494,12 +495,20 @@ static int _brcmf_sysioc_thread(void *data) #ifdef SOFTAP bool in_ap = false; #endif - + DECLARE_WAITQUEUE(wait, current); allow_signal(SIGTERM); - while (down_interruptible(&drvr_priv->sysioc_sem) == 0) { + add_wait_queue(&drvr_priv->sysioc_waitq, &wait); + while (1) { + prepare_to_wait(&drvr_priv->sysioc_waitq, &wait, + TASK_INTERRUPTIBLE); + + /* wait for event */ + schedule(); + if (kthread_should_stop()) break; + for (i = 0; i < BRCMF_MAX_IFS; i++) { struct brcmf_if *ifentry = drvr_priv->iflist[i]; if (ifentry) { @@ -546,6 +555,7 @@ static int _brcmf_sysioc_thread(void *data) } } } + finish_wait(&drvr_priv->sysioc_waitq, &wait); return 0; } @@ -563,8 +573,7 @@ static int brcmf_netdev_set_mac_address(struct net_device *dev, void *addr) memcpy(&drvr_priv->macvalue, sa->sa_data, ETH_ALEN); drvr_priv->set_macaddress = true; - up(&drvr_priv->sysioc_sem); - + wake_up(&drvr_priv->sysioc_waitq); return ret; } @@ -578,7 +587,7 @@ static void brcmf_netdev_set_multicast_list(struct net_device *dev) return; drvr_priv->set_multicast = true; - up(&drvr_priv->sysioc_sem); + wake_up(&drvr_priv->sysioc_waitq); } int brcmf_sendpkt(struct brcmf_pub *drvr, int ifidx, struct sk_buff *pktbuf) @@ -1218,7 +1227,7 @@ brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, void *handle, char *name, if (handle == NULL) { ifp->state = BRCMF_E_IF_ADD; ifp->idx = ifidx; - up(&drvr_priv->sysioc_sem); + wake_up(&drvr_priv->sysioc_waitq); } else ifp->net = (struct net_device *)handle; @@ -1239,7 +1248,7 @@ void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx) ifp->state = BRCMF_E_IF_DEL; ifp->idx = ifidx; - up(&drvr_priv->sysioc_sem); + wake_up(&drvr_priv->sysioc_waitq); } struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) @@ -1307,7 +1316,7 @@ struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) } if (brcmf_sysioc) { - sema_init(&drvr_priv->sysioc_sem, 0); + init_waitqueue_head(&drvr_priv->sysioc_waitq); drvr_priv->sysioc_tsk = kthread_run(_brcmf_sysioc_thread, drvr_priv, "_brcmf_sysioc"); if (IS_ERR(drvr_priv->sysioc_tsk)) {