From patchwork Mon Jun 13 10:37:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Binoy Jayan X-Patchwork-Id: 69861 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp1472449qgf; Mon, 13 Jun 2016 03:38:24 -0700 (PDT) X-Received: by 10.98.13.81 with SMTP id v78mr21030258pfi.91.1465814304031; Mon, 13 Jun 2016 03:38:24 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t8si17270895pay.32.2016.06.13.03.38.23; Mon, 13 Jun 2016 03:38:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965442AbcFMKiP (ORCPT + 30 others); Mon, 13 Jun 2016 06:38:15 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:35070 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965028AbcFMKiM (ORCPT ); Mon, 13 Jun 2016 06:38:12 -0400 Received: by mail-pa0-f45.google.com with SMTP id hl6so44776854pac.2 for ; Mon, 13 Jun 2016 03:38:12 -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=XN0I50+dRf6rq6IE8GE3N0JF7xyxqPc6K3sOfgHRw6g=; b=LKFNn8v8unHKzQPz4BBJZ4WRGzlRcjYxuJECFIkY/DPHWoyQ3WkcZF3tlq0+7YANM9 45X7sJyFxXDC6qpy/G+GxUHj+Ga/Uq6C3xs0cNNyN9N+L4DpS+mGpqqIELtFPs4sirHo qhhJoap0nurv7S7TqExCAo+u/fJDkZk2Dj/z0= 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=XN0I50+dRf6rq6IE8GE3N0JF7xyxqPc6K3sOfgHRw6g=; b=N3QDV2W2Cnkiod4+q+VbUjSXL3v1C+RkVRyyyW9tX4DAcOnzIUA5O4T6FVmxEVmnpA bLL3DDvLMRAR4BdNK007a4LpuhukhJviMmv++TQ61xOvgdmRGNfK86Xb8Gl9kDDc0QC9 RgMKjFuDQBJc7pZkgOW2qxZoWRg0wi4QoQa+p+Kx9p0p1qp+kRP6b4zolLL4zchz+sAi 4ZsJPpnGL1BFnAnp4VJLqDhXQpb2eCvf9MCVy1p6S1euinbMNFFOM7vvKCtdipz8tKZQ FAcmyOTd6mkZxiP746lYWW1qDM71tZnEebYpSJurLr7xa1IQI2YPajaTXonaoZJRGwft kXlw== X-Gm-Message-State: ALyK8tL0j86/hTcckipCkmnnGiTAo3vH0CWYz6LB4yUKXbNoBfEtAGQZWGpdKdINX6I5kLzz X-Received: by 10.66.122.73 with SMTP id lq9mr21153923pab.124.1465814291526; Mon, 13 Jun 2016 03:38:11 -0700 (PDT) Received: from localhost.localdomain ([116.68.103.40]) by smtp.gmail.com with ESMTPSA id h6sm24194895pac.46.2016.06.13.03.38.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Jun 2016 03:38:11 -0700 (PDT) From: Binoy Jayan To: Greg Kroah-Hartman Cc: Arnd Bergmann , Johnny Kim , Austin Shin , Chris Park , Tony Cho , Glen Lee , Leo Kim , devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Binoy Jayan Subject: [PATCH 2/7] staging: wilc1000: Replace semaphore txq_add_to_head_cs with mutex Date: Mon, 13 Jun 2016 16:07:34 +0530 Message-Id: <1465814259-3009-3-git-send-email-binoy.jayan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1465814259-3009-1-git-send-email-binoy.jayan@linaro.org> References: <1465814259-3009-1-git-send-email-binoy.jayan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The semaphore 'txq_add_to_head_cs' is a simple mutex, so it should be written as one. Semaphores are going away in the future. Also, removing the timeout scenario as the error handling code does not propagate the timeout properly. Signed-off-by: Binoy Jayan --- drivers/staging/wilc1000/linux_wlan.c | 4 ++-- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 3 ++- drivers/staging/wilc1000/wilc_wlan.c | 11 ++++------- 3 files changed, 8 insertions(+), 10 deletions(-) -- 2.7.4 diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 90f906d..a933551 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -20,7 +20,7 @@ #include #include #include - +#include #include #include @@ -679,7 +679,7 @@ static int wlan_init_locks(struct net_device *dev) mutex_init(&wl->rxq_cs); spin_lock_init(&wl->txq_spinlock); - sema_init(&wl->txq_add_to_head_cs, 1); + mutex_init(&wl->txq_add_to_head_cs); init_completion(&wl->txq_event); diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index 12d7c7b..239cd43 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -43,6 +43,7 @@ #include "wilc_wlan.h" #include #include +#include #define FLOW_CONTROL_LOWER_THRESHOLD 128 #define FLOW_CONTROL_UPPER_THRESHOLD 256 @@ -171,7 +172,7 @@ struct wilc { struct wilc_vif *vif[NUM_CONCURRENT_IFC]; u8 open_ifcs; - struct semaphore txq_add_to_head_cs; + struct mutex txq_add_to_head_cs; spinlock_t txq_spinlock; struct mutex rxq_cs; diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index 1a57135..9afbe8d 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -99,9 +99,7 @@ static int wilc_wlan_txq_add_to_head(struct wilc_vif *vif, unsigned long flags; struct wilc *wilc = vif->wilc; - if (wilc_lock_timeout(wilc, &wilc->txq_add_to_head_cs, - CFG_PKTS_TIMEOUT)) - return -1; + mutex_lock(&wilc->txq_add_to_head_cs); spin_lock_irqsave(&wilc->txq_spinlock, flags); @@ -119,7 +117,7 @@ static int wilc_wlan_txq_add_to_head(struct wilc_vif *vif, wilc->txq_entries += 1; spin_unlock_irqrestore(&wilc->txq_spinlock, flags); - up(&wilc->txq_add_to_head_cs); + mutex_unlock(&wilc->txq_add_to_head_cs); complete(&wilc->txq_event); return 0; @@ -573,8 +571,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) if (wilc->quit) break; - wilc_lock_timeout(wilc, &wilc->txq_add_to_head_cs, - CFG_PKTS_TIMEOUT); + mutex_lock(&wilc->txq_add_to_head_cs); wilc_wlan_txq_filter_dup_tcp_ack(dev); tqe = wilc_wlan_txq_get_first(wilc); i = 0; @@ -755,7 +752,7 @@ _end_: if (ret != 1) break; } while (0); - up(&wilc->txq_add_to_head_cs); + mutex_unlock(&wilc->txq_add_to_head_cs); wilc->txq_exit = 1; *txq_count = wilc->txq_entries;