From patchwork Fri Jun 3 09:59:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Binoy Jayan X-Patchwork-Id: 69232 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp178037qgf; Fri, 3 Jun 2016 02:59:54 -0700 (PDT) X-Received: by 10.107.180.11 with SMTP id d11mr3461161iof.151.1464947991610; Fri, 03 Jun 2016 02:59:51 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m64si6672837pfb.124.2016.06.03.02.59.51; Fri, 03 Jun 2016 02:59:51 -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 S1752805AbcFCJ7u (ORCPT + 31 others); Fri, 3 Jun 2016 05:59:50 -0400 Received: from mail-pf0-f173.google.com ([209.85.192.173]:34665 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752123AbcFCJ7q (ORCPT ); Fri, 3 Jun 2016 05:59:46 -0400 Received: by mail-pf0-f173.google.com with SMTP id 62so42283070pfd.1 for ; Fri, 03 Jun 2016 02:59:46 -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=3wwOnYIsx8kMlrZqTtUd82Vv6cZ3bIj5hv2+Va0IWKQ=; b=Xk5eWYtbM5m/XMiTXQzHkW/R0fDzCy20nwVPfKIvKcQ/SZOc8hxVhTSfqyZCTtPbr9 1k0ywbKZnp67WFCdacjQQm2mlxEx3mDXGiIZgP9IanGqnEQGnOzufO4M7SXjbyoJghq0 fa6vhHNhPG76BEoUuSAKweWnHE6Cf41RXEg28= 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=3wwOnYIsx8kMlrZqTtUd82Vv6cZ3bIj5hv2+Va0IWKQ=; b=L/LXcwIyflmOG58gx/5XUJWsoiMYEk3o5jEbiUHC1gzv9TNwrDIf/GnrAmWcb4N/lO yXq3nctda/hvH94UKTXPlyChOuiSNgMJFef8uOXNldMaATfEdDhPqAYGd2/z41sSACDZ 84lZa46DC8IVcR8Mh8xChwi9b023dxk8Z6lmA6oHjNpRxMNwN5aFueaHDXNGCnA+thEJ zhqtQiSL6WODjE+nukIB11M9rYMrJeB2aliH1vpEDr8LNGsguohrZbUNyE15SF8tqYaC MYtx2r+Gzwuf5jgCZ6W5PdUJ8iLahQIGZSavUvcKJcOx2tESXaKFIG+FoSz4koYWUBrS M2Zg== X-Gm-Message-State: ALyK8tLlNXA/tjHPX6hSykwdVE5PVxxOB3+WfUjJ2xxPpTyZNOhzGiv3Arsr5Qg/jG5yYhe8 X-Received: by 10.98.157.146 with SMTP id a18mr5101623pfk.117.1464947985570; Fri, 03 Jun 2016 02:59:45 -0700 (PDT) Received: from blr-ubuntu-59.ap.qualcomm.com ([202.46.23.61]) by smtp.gmail.com with ESMTPSA id a19sm7010383pfc.57.2016.06.03.02.59.42 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Jun 2016 02:59:45 -0700 (PDT) From: Binoy Jayan To: Greg Kroah-Hartman , Larry Finger Cc: Jakub Sitnicki , Arnd Bergmann , driverdev-devel@linuxdriverproject.org, linux-kernel@vger.kernel.org, Binoy Jayan Subject: [PATCH 3/4] rtl8188eu: pwrctrl_priv: Replace semaphore 'lock' with mutex Date: Fri, 3 Jun 2016 15:29:02 +0530 Message-Id: <1464947943-2008-4-git-send-email-binoy.jayan@linaro.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1464947943-2008-1-git-send-email-binoy.jayan@linaro.org> References: <1464947943-2008-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 'lock' in pwrctrl_priv is a simple mutex, so it should be written as one. Semaphores are going away in the future. Also, remove the now unused wrappers _init_pwrlock, _enter_pwrlock, _exit_pwrlock and _rtw_down_sema. Signed-off-by: Binoy Jayan --- This patch depends on the following patch: rtl8188eu: Replace semaphore terminate_cmdthread_sema with completion drivers/staging/rtl8188eu/core/rtw_pwrctrl.c | 20 ++++++++++---------- drivers/staging/rtl8188eu/include/osdep_service.h | 3 +-- drivers/staging/rtl8188eu/include/rtw_event.h | 1 + drivers/staging/rtl8188eu/include/rtw_pwrctrl.h | 17 +---------------- drivers/staging/rtl8188eu/os_dep/osdep_service.c | 7 ------- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 8 ++++---- 6 files changed, 17 insertions(+), 39 deletions(-) -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project diff --git a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c index 59c6d8a..0b70fe7 100644 --- a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c @@ -38,7 +38,7 @@ static int rtw_hw_suspend(struct adapter *padapter) LeaveAllPowerSaveMode(padapter); DBG_88E("==> rtw_hw_suspend\n"); - _enter_pwrlock(&pwrpriv->lock); + mutex_lock(&pwrpriv->mutex_lock); pwrpriv->bips_processing = true; /* s1. */ if (pnetdev) { @@ -73,7 +73,7 @@ static int rtw_hw_suspend(struct adapter *padapter) pwrpriv->rf_pwrstate = rf_off; pwrpriv->bips_processing = false; - _exit_pwrlock(&pwrpriv->lock); + mutex_unlock(&pwrpriv->mutex_lock); return 0; @@ -90,12 +90,12 @@ static int rtw_hw_resume(struct adapter *padapter) /* system resume */ DBG_88E("==> rtw_hw_resume\n"); - _enter_pwrlock(&pwrpriv->lock); + mutex_lock(&pwrpriv->mutex_lock); pwrpriv->bips_processing = true; rtw_reset_drv_sw(padapter); if (pm_netdev_open(pnetdev, false) != 0) { - _exit_pwrlock(&pwrpriv->lock); + mutex_unlock(&pwrpriv->mutex_lock); goto error_exit; } @@ -113,7 +113,7 @@ static int rtw_hw_resume(struct adapter *padapter) pwrpriv->rf_pwrstate = rf_on; pwrpriv->bips_processing = false; - _exit_pwrlock(&pwrpriv->lock); + mutex_unlock(&pwrpriv->mutex_lock); return 0; @@ -138,7 +138,7 @@ void ips_enter(struct adapter *padapter) return; } - _enter_pwrlock(&pwrpriv->lock); + mutex_lock(&pwrpriv->mutex_lock); pwrpriv->bips_processing = true; @@ -159,7 +159,7 @@ void ips_enter(struct adapter *padapter) } pwrpriv->bips_processing = false; - _exit_pwrlock(&pwrpriv->lock); + mutex_unlock(&pwrpriv->mutex_lock); } int ips_leave(struct adapter *padapter) @@ -171,7 +171,7 @@ int ips_leave(struct adapter *padapter) int keyid; - _enter_pwrlock(&pwrpriv->lock); + mutex_lock(&pwrpriv->mutex_lock); if ((pwrpriv->rf_pwrstate == rf_off) && (!pwrpriv->bips_processing)) { pwrpriv->bips_processing = true; @@ -205,7 +205,7 @@ int ips_leave(struct adapter *padapter) pwrpriv->bpower_saving = false; } - _exit_pwrlock(&pwrpriv->lock); + mutex_unlock(&pwrpriv->mutex_lock); return result; } @@ -504,7 +504,7 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter) { struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; - _init_pwrlock(&pwrctrlpriv->lock); + mutex_init(&pwrctrlpriv->mutex_lock); pwrctrlpriv->rf_pwrstate = rf_on; pwrctrlpriv->ips_enter_cnts = 0; pwrctrlpriv->ips_leave_cnts = 0; diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h index 5475956..c53c9ea 100644 --- a/drivers/staging/rtl8188eu/include/osdep_service.h +++ b/drivers/staging/rtl8188eu/include/osdep_service.h @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -78,8 +79,6 @@ u8 *_rtw_malloc(u32 sz); void *rtw_malloc2d(int h, int w, int size); -u32 _rtw_down_sema(struct semaphore *sema); - void _rtw_init_queue(struct __queue *pqueue); struct rtw_netdev_priv_indicator { diff --git a/drivers/staging/rtl8188eu/include/rtw_event.h b/drivers/staging/rtl8188eu/include/rtw_event.h index 5c34e56..0dc63f2 100644 --- a/drivers/staging/rtl8188eu/include/rtw_event.h +++ b/drivers/staging/rtl8188eu/include/rtw_event.h @@ -19,6 +19,7 @@ #include #include +#include #include /* diff --git a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h index 9680e2e..18a9e74 100644 --- a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h +++ b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h @@ -92,21 +92,6 @@ struct reportpwrstate_parm { unsigned short rsvd; }; -static inline void _init_pwrlock(struct semaphore *plock) -{ - sema_init(plock, 1); -} - -static inline void _enter_pwrlock(struct semaphore *plock) -{ - _rtw_down_sema(plock); -} - -static inline void _exit_pwrlock(struct semaphore *plock) -{ - up(plock); -} - #define LPS_DELAY_TIME 1*HZ /* 1 sec */ #define EXE_PWR_NONE 0x01 @@ -157,7 +142,7 @@ enum { /* for ips_mode */ }; struct pwrctrl_priv { - struct semaphore lock; + struct mutex mutex_lock; volatile u8 rpwm; /* requested power state for fw */ volatile u8 cpwm; /* fw current power state. updated when * 1. read from HCPWM 2. driver lowers power level */ diff --git a/drivers/staging/rtl8188eu/os_dep/osdep_service.c b/drivers/staging/rtl8188eu/os_dep/osdep_service.c index 764250b..24d1774 100644 --- a/drivers/staging/rtl8188eu/os_dep/osdep_service.c +++ b/drivers/staging/rtl8188eu/os_dep/osdep_service.c @@ -55,13 +55,6 @@ void *rtw_malloc2d(int h, int w, int size) return a; } -u32 _rtw_down_sema(struct semaphore *sema) -{ - if (down_interruptible(sema)) - return _FAIL; - return _SUCCESS; -} - void _rtw_init_queue(struct __queue *pqueue) { INIT_LIST_HEAD(&(pqueue->queue)); diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index 11d51a3..a5ba1e4 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -238,7 +238,7 @@ static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message) rtw_cancel_all_timer(padapter); LeaveAllPowerSaveMode(padapter); - _enter_pwrlock(&pwrpriv->lock); + mutex_lock(&pwrpriv->mutex_lock); /* s1. */ if (pnetdev) { netif_carrier_off(pnetdev); @@ -267,7 +267,7 @@ static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message) rtw_free_network_queue(padapter, true); rtw_dev_unload(padapter); - _exit_pwrlock(&pwrpriv->lock); + mutex_unlock(&pwrpriv->mutex_lock); if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) rtw_indicate_scan_done(padapter, 1); @@ -298,7 +298,7 @@ static int rtw_resume_process(struct adapter *padapter) goto exit; } - _enter_pwrlock(&pwrpriv->lock); + mutex_lock(&pwrpriv->mutex_lock); rtw_reset_drv_sw(padapter); pwrpriv->bkeepfwalive = false; @@ -309,7 +309,7 @@ static int rtw_resume_process(struct adapter *padapter) netif_device_attach(pnetdev); netif_carrier_on(pnetdev); - _exit_pwrlock(&pwrpriv->lock); + mutex_unlock(&pwrpriv->mutex_lock); rtw_roaming(padapter, NULL);