From patchwork Mon Jun 13 10:37:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Binoy Jayan X-Patchwork-Id: 69865 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp1472586qgf; Mon, 13 Jun 2016 03:38:48 -0700 (PDT) X-Received: by 10.36.206.66 with SMTP id v63mr16678852itg.54.1465814324903; Mon, 13 Jun 2016 03:38:44 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s1si17288593pan.105.2016.06.13.03.38.44; Mon, 13 Jun 2016 03:38:44 -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 S1422766AbcFMKih (ORCPT + 30 others); Mon, 13 Jun 2016 06:38:37 -0400 Received: from mail-pa0-f42.google.com ([209.85.220.42]:36780 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422699AbcFMKid (ORCPT ); Mon, 13 Jun 2016 06:38:33 -0400 Received: by mail-pa0-f42.google.com with SMTP id b5so44694352pas.3 for ; Mon, 13 Jun 2016 03:38:32 -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=8zcwlA84taM39E7/CvuLZCIaXSSpXPd2NHCorRHIauo=; b=NPUJMuyFyQY44T9wqJT4McBAJvQace5jD8KhcVg4+XCWlmNJSpxDHf199uQsSxRTbH wfVADcNJBtT4seaYwrKRBVY4O/w6Ciz/5Y/MYI6ho1/8PeZj2fsnrepmiRZNecN80Plp 0uZEt8jJvu0qeD+95iGwWfA/JE7G3/pNEOMyE= 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=8zcwlA84taM39E7/CvuLZCIaXSSpXPd2NHCorRHIauo=; b=N06PcFN0WLvebEHMJSBWDg8d0e1WQhmDdaa39OZ0Se7FD9r579uij5OQOQT9PC++SP hFh4zsmoUJ+Qd6GykCMQDtRvsQ/0Z4EHd7w9F28K7AHNezIq1BnMnHzBnt5wN/hs/uCD Jjp6o/k0OMUqd47hCK0pgDhT9E5B/HfUTbzGUFMAU/0JBbkSlfXwVQtjClGolw3BsoNb m5anJYkPMLaPPYeZSL+CwkjwInpX1fHvs+orKWf1Wt5Q9p5FY9pXukRqfnoEd5QmiZDb i7MAEw3hxQzG04mMwWj8OYRh+Z53D/972OAwAr//SVEgPOgr6bDtRxyKU3GonyBVkMTj WlCg== X-Gm-Message-State: ALyK8tJoFpeHZ33QJy/+BAEtXYwNcg18rr5xdW0rnKqb8BCMB14PRyauEXw0lePsp3r80R7v X-Received: by 10.67.7.199 with SMTP id de7mr21045785pad.94.1465814312438; Mon, 13 Jun 2016 03:38:32 -0700 (PDT) Received: from localhost.localdomain ([116.68.103.40]) by smtp.gmail.com with ESMTPSA id h6sm24194895pac.46.2016.06.13.03.38.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Jun 2016 03:38:31 -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 6/7] staging: wilc1000: message_queue: Replace semaphore sem with completion Date: Mon, 13 Jun 2016 16:07:38 +0530 Message-Id: <1465814259-3009-7-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 'sem' is used as completion, so convert it to a struct completion type. Signed-off-by: Binoy Jayan --- drivers/staging/wilc1000/wilc_msgqueue.c | 13 +++++++------ drivers/staging/wilc1000/wilc_msgqueue.h | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c b/drivers/staging/wilc1000/wilc_msgqueue.c index 6cb894e..80c9631 100644 --- a/drivers/staging/wilc1000/wilc_msgqueue.c +++ b/drivers/staging/wilc1000/wilc_msgqueue.c @@ -3,6 +3,7 @@ #include #include #include +#include /*! * @author syounan @@ -13,7 +14,7 @@ int wilc_mq_create(struct message_queue *mq) { spin_lock_init(&mq->lock); - sema_init(&mq->sem, 0); + init_completion(&mq->comp); INIT_LIST_HEAD(&mq->msg_list); mq->recv_count = 0; mq->exiting = false; @@ -34,7 +35,7 @@ int wilc_mq_destroy(struct message_queue *mq) /* Release any waiting receiver thread. */ while (mq->recv_count > 0) { - up(&mq->sem); + complete(&mq->comp); mq->recv_count--; } @@ -85,7 +86,7 @@ int wilc_mq_send(struct message_queue *mq, spin_unlock_irqrestore(&mq->lock, flags); - up(&mq->sem); + complete(&mq->comp); return 0; } @@ -112,19 +113,19 @@ int wilc_mq_recv(struct message_queue *mq, mq->recv_count++; spin_unlock_irqrestore(&mq->lock, flags); - down(&mq->sem); + wait_for_completion(&mq->comp); spin_lock_irqsave(&mq->lock, flags); if (list_empty(&mq->msg_list)) { spin_unlock_irqrestore(&mq->lock, flags); - up(&mq->sem); + complete(&mq->comp); 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); + complete(&mq->comp); return -EOVERFLOW; } diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h b/drivers/staging/wilc1000/wilc_msgqueue.h index 846a484..a7a2e55 100644 --- a/drivers/staging/wilc1000/wilc_msgqueue.h +++ b/drivers/staging/wilc1000/wilc_msgqueue.h @@ -1,7 +1,7 @@ #ifndef __WILC_MSG_QUEUE_H__ #define __WILC_MSG_QUEUE_H__ -#include +#include #include struct message { @@ -11,7 +11,7 @@ struct message { }; struct message_queue { - struct semaphore sem; + struct completion comp; spinlock_t lock; bool exiting; u32 recv_count;