From patchwork Wed Sep 24 13:47:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 37823 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 11BC8204FF for ; Wed, 24 Sep 2014 13:48:46 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id hi2sf3599845wib.7 for ; Wed, 24 Sep 2014 06:48:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=4Hre+mYP/tInRLMfBK0qT21Kw8WfLmR89ndhSitmAUI=; b=jJJJ8oVpxbW0/tiULFLXzQ1efQbKLmaxG+o+BtsxnLB3OPEadU6V2o0MX4p+coZ2GB KHAIa0k/i1q60rqrGbvEguxBolOPj6iVDFUzcY7rJt3y+pAQmDMQx1hnWcYjBFmjhh5f nxVwJOIa+uBUcHqCbcR+4r10n9pBfdHYuHf7jiWNUYqMioMX2g8NufYLdr92fC/35ng8 +v4uSTtg5fQX16NASM5VWUG50HSvTUUmUMypg/vRfyWd3ISuKU3RTNXw9xXZHDWXa1sR uRRh4Yn4DyviV89QSHCssNpE+DbkMB/ZB2dL1fDkUqFqoKrnMsawLhpVRXoc7KLncXnJ 0yZA== X-Gm-Message-State: ALoCoQmnTJYt5ex/lDnJJVL1h2lpHGPxdGxuzWU9R8uXWd6jDa56EXPGg0VyK6cpJbBMpuv1/D2M X-Received: by 10.112.76.229 with SMTP id n5mr1034656lbw.8.1411566526252; Wed, 24 Sep 2014 06:48:46 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.88.103 with SMTP id bf7ls160294lab.11.gmail; Wed, 24 Sep 2014 06:48:46 -0700 (PDT) X-Received: by 10.112.34.143 with SMTP id z15mr6293374lbi.86.1411566525994; Wed, 24 Sep 2014 06:48:45 -0700 (PDT) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com [209.85.217.179]) by mx.google.com with ESMTPS id ue9si22967033lac.20.2014.09.24.06.48.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 24 Sep 2014 06:48:45 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by mail-lb0-f179.google.com with SMTP id 10so10022956lbg.38 for ; Wed, 24 Sep 2014 06:48:45 -0700 (PDT) X-Received: by 10.152.42.136 with SMTP id o8mr6469258lal.71.1411566525929; Wed, 24 Sep 2014 06:48:45 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.130.169 with SMTP id of9csp585178lbb; Wed, 24 Sep 2014 06:48:45 -0700 (PDT) X-Received: by 10.70.41.236 with SMTP id i12mr8539124pdl.110.1411566519050; Wed, 24 Sep 2014 06:48:39 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id id8si26374912pad.155.2014.09.24.06.48.38 for ; Wed, 24 Sep 2014 06:48:39 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753873AbaIXNsE (ORCPT + 27 others); Wed, 24 Sep 2014 09:48:04 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:51015 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753807AbaIXNsA (ORCPT ); Wed, 24 Sep 2014 09:48:00 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id s8ODm0qM031939; Wed, 24 Sep 2014 08:48:00 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s8ODliLA009508; Wed, 24 Sep 2014 08:47:44 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Wed, 24 Sep 2014 08:47:44 -0500 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s8ODlKDX015622; Wed, 24 Sep 2014 08:47:43 -0500 From: Kishon Vijay Abraham I To: CC: , Subject: [PATCH 14/22] usb: phy: twl4030-usb: Use mutex instead of spinlock for protecting the data Date: Wed, 24 Sep 2014 19:17:12 +0530 Message-ID: <1411566440-19169-15-git-send-email-kishon@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1411566440-19169-1-git-send-email-kishon@ti.com> References: <1411566440-19169-1-git-send-email-kishon@ti.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: kishon@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Tony Lindgren We're using threaded irq on a I2C bus and we're sleeping in twl4030_usb_irq() as it calls twl4030_usb_linkstat() which calls the i2c functions. If we ever need to lock for longer I2C transaction sequences a mutex will allow us to do that easily. Signed-off-by: Tony Lindgren Signed-off-by: Kishon Vijay Abraham I --- drivers/phy/phy-twl4030-usb.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c index 24ff3c6..1e0e2d1 100644 --- a/drivers/phy/phy-twl4030-usb.c +++ b/drivers/phy/phy-twl4030-usb.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -155,7 +154,7 @@ struct twl4030_usb { struct regulator *usb3v1; /* for vbus reporting with irqs disabled */ - spinlock_t lock; + struct mutex lock; /* pin configuration */ enum twl4030_usb_mode usb_mode; @@ -516,13 +515,12 @@ static ssize_t twl4030_usb_vbus_show(struct device *dev, struct device_attribute *attr, char *buf) { struct twl4030_usb *twl = dev_get_drvdata(dev); - unsigned long flags; int ret = -EINVAL; - spin_lock_irqsave(&twl->lock, flags); + mutex_lock(&twl->lock); ret = sprintf(buf, "%s\n", twl->vbus_supplied ? "on" : "off"); - spin_unlock_irqrestore(&twl->lock, flags); + mutex_unlock(&twl->lock); return ret; } @@ -536,12 +534,12 @@ static irqreturn_t twl4030_usb_irq(int irq, void *_twl) status = twl4030_usb_linkstat(twl); - spin_lock_irq(&twl->lock); + mutex_lock(&twl->lock); if (status >= 0 && status != twl->linkstat) { twl->linkstat = status; status_changed = true; } - spin_unlock_irq(&twl->lock); + mutex_unlock(&twl->lock); if (status_changed) { /* FIXME add a set_power() method so that B-devices can @@ -695,8 +693,8 @@ static int twl4030_usb_probe(struct platform_device *pdev) if (IS_ERR(phy_provider)) return PTR_ERR(phy_provider); - /* init spinlock for workqueue */ - spin_lock_init(&twl->lock); + /* init mutex for workqueue */ + mutex_init(&twl->lock); INIT_DELAYED_WORK(&twl->id_workaround_work, twl4030_id_workaround_work);