From patchwork Sun Mar 17 18:23:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grazvydas Ignotas X-Patchwork-Id: 2284301 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 22AF3E00DD for ; Sun, 17 Mar 2013 18:24:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932729Ab3CQSXt (ORCPT ); Sun, 17 Mar 2013 14:23:49 -0400 Received: from mail-ea0-f181.google.com ([209.85.215.181]:52910 "EHLO mail-ea0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932570Ab3CQSXp (ORCPT ); Sun, 17 Mar 2013 14:23:45 -0400 Received: by mail-ea0-f181.google.com with SMTP id z10so2173242ead.12 for ; Sun, 17 Mar 2013 11:23:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=GpZ53Nn0r3UNu+EBgYAPRe9EI2NKldVX95YJPTOSqaM=; b=zhYUXEvuLxZ7F7aNjVf9blpFP2mSiNJrlp/5/HQKzUCVEUItebL7RwRCMMzo9a0Njj HfrfxtJCXmxZOJRnHt4lUmaiQGIE6DHZkx7LQsAIMfnwG5IzX6c1eF4Wf/sF2ziUjCzH CzyQi042tEdxWkZlJgUKn5O/RMQ7EK9tFfwZH+LWW+Ys5QJMNz8d/8Wg7SRDLAFPlUAf eVR3epF4c6hJNzjOlzCn2qaq1x1ST1t4flsejVi1KM0qYfKqjDlY4hr4QVyMgZVall1v X2HSkpBIKJE/3xmWi0IRkKMU9PcQ8m5BoyNuc0VPQ+xuedH0ZE8nr6xac1Ggt8DvQTzA GquA== X-Received: by 10.14.1.130 with SMTP id 2mr40714424eed.15.1363544623793; Sun, 17 Mar 2013 11:23:43 -0700 (PDT) Received: from localhost.localdomain (ip-88-119-226-136.static.b4net.lt. [88.119.226.136]) by mx.google.com with ESMTPS id a1sm22724358eep.2.2013.03.17.11.23.41 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 17 Mar 2013 11:23:42 -0700 (PDT) From: Grazvydas Ignotas To: linux-usb@vger.kernel.org Cc: linux-omap@vger.kernel.org, Felipe Balbi , NeilBrown , kishon , Grazvydas Ignotas Subject: [PATCHv2 2/7] usb: phy: twl4030-usb: ignore duplicate events Date: Sun, 17 Mar 2013 20:23:22 +0200 Message-Id: <1363544607-17634-3-git-send-email-notasas@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1363544607-17634-1-git-send-email-notasas@gmail.com> References: <1363544607-17634-1-git-send-email-notasas@gmail.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org In some rare cases we may get multiple interrupts that will generate duplicate omap_musb_mailbox() calls. This is a problem because each VBUS/ID event generates runtime_pm call in OMAP glue code, causing unbalanced gets or puts and breaking PM. The same goes for initial state, glue already defaults to "no cable" state, so only bother it if we have VBUS or ID. Signed-off-by: Grazvydas Ignotas Reviewed-by: Kishon Vijay Abraham I --- drivers/usb/phy/phy-twl4030-usb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/phy/phy-twl4030-usb.c b/drivers/usb/phy/phy-twl4030-usb.c index 9e47118..305463b 100644 --- a/drivers/usb/phy/phy-twl4030-usb.c +++ b/drivers/usb/phy/phy-twl4030-usb.c @@ -491,9 +491,10 @@ static irqreturn_t twl4030_usb_irq(int irq, void *_twl) { struct twl4030_usb *twl = _twl; enum omap_musb_vbus_id_status status; + enum omap_musb_vbus_id_status status_prev = twl->linkstat; status = twl4030_usb_linkstat(twl); - if (status > 0) { + if (status > 0 && status != status_prev) { /* FIXME add a set_power() method so that B-devices can * configure the charger appropriately. It's not always * correct to consume VBUS power, and how much current to @@ -530,7 +531,7 @@ static void twl4030_usb_phy_init(struct twl4030_usb *twl) twl->asleep = 1; status = twl4030_usb_linkstat(twl); - if (status > 0) + if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID) omap_musb_mailbox(twl->linkstat); sysfs_notify(&twl->dev->kobj, NULL, "vbus");