From patchwork Tue Jun 13 08:58:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Binoy Jayan X-Patchwork-Id: 104346 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp301657qgd; Tue, 13 Jun 2017 01:59:39 -0700 (PDT) X-Received: by 10.99.126.90 with SMTP id o26mr29871579pgn.8.1497344379635; Tue, 13 Jun 2017 01:59:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497344379; cv=none; d=google.com; s=arc-20160816; b=H9gdRozO9ynF6QrU0gUVswaFbnTCFY3Uw/yKWtjkIFOX5doRzTMX3Zm4GnzhxupARf 5L3IieI6UesFuxYoK8b7FSq+GbLszHH/YIzNG428N5AvoNTon/kHiuA26jj0p+utQL2G Kn0rhEayyVRpXVPk3xER1ihW0qJZ0cIGjVF7J7mP5SONuYx17x+qvi+E/yyYU2I6vcuT +RTu7V0v3T0X1lZl0pkRRYKKcMvRVbpJZ2cZxV52OdZwK8IgFEOAkIHcepP9RaD9TkI6 qBTplQeR2aCbX3AwhosGB7s7fQEH8CYHm2e7CoAykLxKeZYKa9iMWYZPjI4ArJvGgn4E Mr0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=AaM8NPS9B7Oj8WjKx0XB6xplsROTFwiu4REpc77GMrE=; b=tzfIypKLR5hs8ZKMoXmu163ikCku8TJmZyPyQC+DATy5AVLqCtkkyMMbodmPrMQueu xtrWUraehwTnFf9QcFsG1ej/RyH1hdgUnsF+5Gmt+q9WD4INm9Hc+o6rFBppitGiqkWu /D5cuIcQYdVozHTExryfvlNKG6UpSyGW3RUZptwPjcC6X00kkrxhhMN0lQXDjazT2/dv Ja/tmYnRpHxm6ii6aXnrZJ7Nb8TQpepiOAFCJMbawlq2vit+FSw8LMUhZ0Q8eOCpPJ7g QUIVv/tBqF8ARIt/rVpBRLkmvOszTHn4wlmUohAtjVn3bA+2vOVyfXM/tzjeCDj5tG28 yKPg== ARC-Authentication-Results: i=1; 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 sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a187si966725pge.160.2017.06.13.01.59.39; Tue, 13 Jun 2017 01:59:39 -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 sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752562AbdFMI7R (ORCPT + 25 others); Tue, 13 Jun 2017 04:59:17 -0400 Received: from mail-pg0-f41.google.com ([74.125.83.41]:36343 "EHLO mail-pg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752401AbdFMI7P (ORCPT ); Tue, 13 Jun 2017 04:59:15 -0400 Received: by mail-pg0-f41.google.com with SMTP id a70so57610267pge.3 for ; Tue, 13 Jun 2017 01:59:09 -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=AaM8NPS9B7Oj8WjKx0XB6xplsROTFwiu4REpc77GMrE=; b=HHj5ID9kIhzo1hBRp9tRZmpSHEov0LmcYaRt9xYyyG3R5MgqCx+USMrDGOsnh24HXG gII0nFe/yzeQRRA3e8S+AFf/aLTEL0MJxa8Ej7h8CVaKWAm9c+RG1pjq013tU+W/DC40 VvuP7uphjq+KEL0tQ8E6QOQXb26ppvwJabVlw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AaM8NPS9B7Oj8WjKx0XB6xplsROTFwiu4REpc77GMrE=; b=NHTfBedncmqb12A8mo7ErfT3++lgxQ+tfzGxeLO2SqB43U/dqPW5RYgFSIRAWtclWB Iw9psy5XR+EMCaspJ762SDW2x0E/tCjIS7w2lFsaygHI0t3WlFr1zfku52U2g9Qlu8Jv bsGlbvIpK2Biads554D42S2sYFQxNol2cp6gzyD/7Ni3rKDt0TTQOKlQqHvCZEn+F39V FqvKBbYbDk19fRQQU+Z1hfwQl/El1oK4iuTklZKp6ljgyVvT9Ie0PKdHWLOlJhdUlIDW 2l8Jch7PS7YRnQORywb1BXKix+vHc8n0OoqbFldqTJ/MOEZ5LU1aeXGRE7HBtf95ktl2 ETvg== X-Gm-Message-State: AODbwcDBW+cNcuMpT5fqD6KeGxbs2jr1qPwafrEjJQ11mlOiRKzbvSo8 8k40DmBuZq5ibfSk X-Received: by 10.99.23.100 with SMTP id 36mr61123741pgx.118.1497344339269; Tue, 13 Jun 2017 01:58:59 -0700 (PDT) Received: from blr-ubuntu-59.ap.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id p89sm24054354pfk.67.2017.06.13.01.58.55 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Jun 2017 01:58:58 -0700 (PDT) From: Binoy Jayan To: Binoy Jayan Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Rajendra , Mark Brown , Mauro Carvalho Chehab , Sakari Ailus , Julia Lawall , "Michael S. Tsirkin" , Cao jin , linux-media@vger.kernel.org Subject: [PATCH v2 1/3] media: ngene: Replace semaphore cmd_mutex with mutex Date: Tue, 13 Jun 2017 14:28:48 +0530 Message-Id: <1497344330-13915-2-git-send-email-binoy.jayan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1497344330-13915-1-git-send-email-binoy.jayan@linaro.org> References: <1497344330-13915-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 'cmd_mutex' is used as a simple mutex, so it should be written as one. Also, replace down with mutex_destroy to ensure sane state when ngene_stop is called. Signed-off-by: Binoy Jayan --- drivers/media/pci/ngene/ngene-core.c | 12 ++++++------ drivers/media/pci/ngene/ngene.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) -- Binoy Jayan diff --git a/drivers/media/pci/ngene/ngene-core.c b/drivers/media/pci/ngene/ngene-core.c index ce69e64..eeb61eb 100644 --- a/drivers/media/pci/ngene/ngene-core.c +++ b/drivers/media/pci/ngene/ngene-core.c @@ -336,9 +336,9 @@ int ngene_command(struct ngene *dev, struct ngene_command *com) { int result; - down(&dev->cmd_mutex); + mutex_lock(&dev->cmd_mutex); result = ngene_command_mutex(dev, com); - up(&dev->cmd_mutex); + mutex_unlock(&dev->cmd_mutex); return result; } @@ -1283,7 +1283,7 @@ static int ngene_load_firm(struct ngene *dev) static void ngene_stop(struct ngene *dev) { - down(&dev->cmd_mutex); + mutex_destroy(&dev->cmd_mutex); i2c_del_adapter(&(dev->channel[0].i2c_adapter)); i2c_del_adapter(&(dev->channel[1].i2c_adapter)); ngwritel(0, NGENE_INT_ENABLE); @@ -1346,7 +1346,7 @@ static int ngene_start(struct ngene *dev) init_waitqueue_head(&dev->cmd_wq); init_waitqueue_head(&dev->tx_wq); init_waitqueue_head(&dev->rx_wq); - sema_init(&dev->cmd_mutex, 1); + mutex_init(&dev->cmd_mutex); sema_init(&dev->stream_mutex, 1); sema_init(&dev->pll_mutex, 1); sema_init(&dev->i2c_switch_mutex, 1); @@ -1606,10 +1606,10 @@ static void ngene_unlink(struct ngene *dev) com.in_len = 3; com.out_len = 1; - down(&dev->cmd_mutex); + mutex_lock(&dev->cmd_mutex); ngwritel(0, NGENE_INT_ENABLE); ngene_command_mutex(dev, &com); - up(&dev->cmd_mutex); + mutex_unlock(&dev->cmd_mutex); } void ngene_shutdown(struct pci_dev *pdev) diff --git a/drivers/media/pci/ngene/ngene.h b/drivers/media/pci/ngene/ngene.h index 10d8f74..e600b70 100644 --- a/drivers/media/pci/ngene/ngene.h +++ b/drivers/media/pci/ngene/ngene.h @@ -762,7 +762,7 @@ struct ngene { wait_queue_head_t cmd_wq; int cmd_done; - struct semaphore cmd_mutex; + struct mutex cmd_mutex; struct semaphore stream_mutex; struct semaphore pll_mutex; struct semaphore i2c_switch_mutex;