From patchwork Mon Mar 21 23:39:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaehyun Lim X-Patchwork-Id: 8636571 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E6C66C0553 for ; Mon, 21 Mar 2016 23:39:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ED83C20270 for ; Mon, 21 Mar 2016 23:39:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1C13B20211 for ; Mon, 21 Mar 2016 23:39:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755740AbcCUXjh (ORCPT ); Mon, 21 Mar 2016 19:39:37 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:34264 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751092AbcCUXjg (ORCPT ); Mon, 21 Mar 2016 19:39:36 -0400 Received: by mail-pf0-f194.google.com with SMTP id n5so32536667pfn.1 for ; Mon, 21 Mar 2016 16:39:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=KR6fYCjUlGc0up5s/fOcNkQrVjF4vd9BdqSrIKOs1ds=; b=HSbEgytXNtdrCA5gkp7BwbChIrrJa2Pb8MfPxKykukGP+Xp3b/86GsVW4+rYXwfi9M lrRBMMnLW4PHy/b7GJysoz2jsxUUwrlfR7Z4k4UfIB3AEttVQNqWA5qre2mh7fjQmwDh NQsh4jJWv3G5Qi6mOCMtLbyZcmbMycLEUgYK2v6uindWUCDSluIOYuMIoe0YBg2TX9YX p+Jv/u3bBL45I4k/rgDnq1E8w8MU4Za6UH8f+iv6gkl8hz8MFtEExkDt8qYAqlw0vejo CcBcuTeomuJUmgok8mXiK06EWFpYoxCjypEGKgWNS8A0L8g/Gsbx3r11iWzEczIf9wQW 31yg== 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; bh=KR6fYCjUlGc0up5s/fOcNkQrVjF4vd9BdqSrIKOs1ds=; b=kyZdeUwYEaAF97fqc/NPD7NoKBGrbdQbEFv+qAkwmCRmJn4RHFY/Bp/YeKmwqMBLkP nRxGqV/X2Op/thCLPlhDE0IT3fhO1xPAvbEwB4vy191oH55IhMQyX8bUeNGiPJb6Sfmv HoqIPIecme4eK1b3mJY0LiXQF/xaGUPJLzSPjNKFVHfOkyn8N0PVvsRagNRf8+dlpU2g 6mFvt3BphcHk0K5EKdFdi0wIJjeJ21VzJ0S6gkI9lw30E3BSeqJiRx1uNmEEUR9XyBPQ RGnbjkPvbPYpNo50vs6R1eQmhDQRTmr4K3PkCqJ50K6CDBP4Ov3SIftdao43/hnYaTm2 oxPQ== X-Gm-Message-State: AD7BkJKHd8fHPOv+Qy6l/d3tp900SbCrIxC0KYn5D2E/zlPHDk5vDJs6pqYbroF96q55Xg== X-Received: by 10.98.34.18 with SMTP id i18mr49405857pfi.26.1458603576010; Mon, 21 Mar 2016 16:39:36 -0700 (PDT) Received: from localhost.localdomain ([218.233.16.2]) by smtp.gmail.com with ESMTPSA id f65sm43248691pfd.47.2016.03.21.16.39.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 Mar 2016 16:39:35 -0700 (PDT) From: Chaehyun Lim To: gregkh@linuxfoundation.org Cc: johnny.kim@atmel.com, austin.shin@atmel.com, chris.park@atmel.com, tony.cho@atmel.com, glen.lee@atmel.com, leo.kim@atmel.com, linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org, Chaehyun Lim Subject: [PATCH] staging: wilc1000: use mutex instead of struct semaphore hif_sema_deinit Date: Tue, 22 Mar 2016 08:39:24 +0900 Message-Id: <1458603564-5537-1-git-send-email-chaehyun.lim@gmail.com> X-Mailer: git-send-email 2.7.3 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch replaces struct semaphore hif_sema_deinit with struct mutex hif_deinit_lock. It is better to use mutex because mutex gives better performance than semaphore. Signed-off-by: Chaehyun Lim --- drivers/staging/wilc1000/host_interface.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 4be8b31..b1ffa91 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -234,7 +234,7 @@ static struct message_queue hif_msg_q; static struct semaphore hif_sema_thread; static struct semaphore hif_sema_driver; static struct completion hif_wait_response; -static struct semaphore hif_sema_deinit; +static struct mutex hif_deinit_lock; static struct timer_list periodic_rssi; u8 wilc_multicast_mac_addr_list[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN]; @@ -3402,7 +3402,7 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) if (clients_count == 0) { sema_init(&hif_sema_thread, 0); sema_init(&hif_sema_driver, 0); - sema_init(&hif_sema_deinit, 1); + mutex_init(&hif_deinit_lock); } init_completion(&hif_drv->comp_test_key_block); @@ -3470,7 +3470,7 @@ int wilc_deinit(struct wilc_vif *vif) return -EFAULT; } - down(&hif_sema_deinit); + mutex_lock(&hif_deinit_lock); terminated_handle = hif_drv; @@ -3512,7 +3512,7 @@ int wilc_deinit(struct wilc_vif *vif) clients_count--; terminated_handle = NULL; - up(&hif_sema_deinit); + mutex_unlock(&hif_deinit_lock); return result; } @@ -3559,25 +3559,25 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *pu8Buffer, struct host_if_drv *hif_drv = NULL; struct wilc_vif *vif; - down(&hif_sema_deinit); + mutex_lock(&hif_deinit_lock); id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24)); vif = wilc_get_vif_from_idx(wilc, id); if (!vif) { - up(&hif_sema_deinit); + mutex_unlock(&hif_deinit_lock); return; } hif_drv = vif->hif_drv; if (!hif_drv || hif_drv == terminated_handle) { - up(&hif_sema_deinit); + mutex_unlock(&hif_deinit_lock); return; } if (!hif_drv->usr_conn_req.conn_result) { netdev_err(vif->ndev, "there is no current Connect Request\n"); - up(&hif_sema_deinit); + mutex_unlock(&hif_deinit_lock); return; } @@ -3594,7 +3594,7 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *pu8Buffer, if (result) netdev_err(vif->ndev, "synchronous info (%d)\n", result); - up(&hif_sema_deinit); + mutex_unlock(&hif_deinit_lock); } void wilc_scan_complete_received(struct wilc *wilc, u8 *pu8Buffer,