From patchwork Thu Sep 1 00:40:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 9308145 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3348160865 for ; Thu, 1 Sep 2016 00:45:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2190C28F2F for ; Thu, 1 Sep 2016 00:45:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 14B2829158; Thu, 1 Sep 2016 00:45:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8D9A728F2F for ; Thu, 1 Sep 2016 00:45:54 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bfG76-0001KU-R8; Thu, 01 Sep 2016 00:44:16 +0000 Received: from mail-pf0-x22e.google.com ([2607:f8b0:400e:c00::22e]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bfG45-0007YX-QH for linux-arm-kernel@lists.infradead.org; Thu, 01 Sep 2016 00:41:12 +0000 Received: by mail-pf0-x22e.google.com with SMTP id h186so24732318pfg.3 for ; Wed, 31 Aug 2016 17:40:49 -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=IOsR+g6wy9IKJnRpOzZekLMYQrnlBaprHhL8c3ZZ8q8=; b=QZgEJyn1N8URas4wL+PfCnJfWLorDwl5i3qRh3YvhTjoj2Ds0EvLvZ6Hk247lWKQcW +ZTRf9ih36umNHzPjRw1lyiNRouAHWT65GeOg//5FMqYCEeEPAkn+uMXvE4cShaykWy0 JXuwJEKJA/9EfoUEfERDv586Km6OpYHBetkw0= 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=IOsR+g6wy9IKJnRpOzZekLMYQrnlBaprHhL8c3ZZ8q8=; b=Xoqf01o5PI/xN2U1RC/9NJoxipLOOkhky4TITdHTB8FKoaSlYB3umYXHFLOo7jHNc4 eBfCrRYNRhrj86fbNC0sJkk94n3LbnwKWUwk4I1SC/zXo9EuuA7zOLtooOixtsAyaZhV 9cYOdTiFX0iTvBXjE4FzgrQAo2qMyWDN0clKTyDNZZulLHBwcUkD3GWI8TGoU8FDB75S TLJ6OVFIxe89LZ9r+97fI6ntpUSVG4ZS3mCsDCiDm7t04n0lvub7obaasDgNj1oImig+ bhBPcQ97hq7i9jLQjN7Gc1Ae527jTzsmd6HDaAPVv5jxM6PXMTTBBJWvTYSM42p6kzp0 ujgA== X-Gm-Message-State: AE9vXwO4jmVQRxcXuetAP7Lf3WqjhWUF+aUKM4wCBUbPCJDqvqdU1hZbZPAmQC6Lo2dSpPEy X-Received: by 10.98.75.65 with SMTP id y62mr21663753pfa.99.1472690449023; Wed, 31 Aug 2016 17:40:49 -0700 (PDT) Received: from localhost.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id m5sm2292303paw.40.2016.08.31.17.40.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 31 Aug 2016 17:40:48 -0700 (PDT) From: Stephen Boyd To: linux-usb@vger.kernel.org Subject: [PATCH v3 10/22] usb: chipidea: Consolidate extcon notifiers Date: Wed, 31 Aug 2016 17:40:24 -0700 Message-Id: <20160901004036.23936-11-stephen.boyd@linaro.org> X-Mailer: git-send-email 2.9.0.rc2.8.ga28705d In-Reply-To: <20160901004036.23936-1-stephen.boyd@linaro.org> References: <20160901004036.23936-1-stephen.boyd@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160831_174110_011494_0918BE8E X-CRM114-Status: GOOD ( 13.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Felipe Balbi , Arnd Bergmann , Neil Armstrong , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Andersson , Peter Chen , Greg Kroah-Hartman , Andy Gross , "Ivan T. Ivanov" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The two extcon notifiers are almost the same except for the variable name for the cable structure and the id notifier inverts the cable->state logic. Make it the same and replace two functions with one to save some lines. This also makes it so that the id cable state is true when the id pin is pulled low. Cc: Peter Chen Cc: Greg Kroah-Hartman Cc: "Ivan T. Ivanov" Signed-off-by: Stephen Boyd --- drivers/usb/chipidea/core.c | 41 ++++++++++------------------------------- drivers/usb/chipidea/otg.c | 4 ++-- 2 files changed, 12 insertions(+), 33 deletions(-) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index f144e1bbcc82..f3b8d7488648 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -577,35 +577,14 @@ static irqreturn_t ci_irq(int irq, void *data) return ret; } -static int ci_vbus_notifier(struct notifier_block *nb, unsigned long event, - void *ptr) +static int ci_cable_notifier(struct notifier_block *nb, unsigned long event, + void *ptr) { - struct ci_hdrc_cable *vbus = container_of(nb, struct ci_hdrc_cable, nb); - struct ci_hdrc *ci = vbus->ci; + struct ci_hdrc_cable *cbl = container_of(nb, struct ci_hdrc_cable, nb); + struct ci_hdrc *ci = cbl->ci; - if (event) - vbus->state = true; - else - vbus->state = false; - - vbus->changed = true; - - ci_irq(ci->irq, ci); - return NOTIFY_DONE; -} - -static int ci_id_notifier(struct notifier_block *nb, unsigned long event, - void *ptr) -{ - struct ci_hdrc_cable *id = container_of(nb, struct ci_hdrc_cable, nb); - struct ci_hdrc *ci = id->ci; - - if (event) - id->state = false; - else - id->state = true; - - id->changed = true; + cbl->state = event; + cbl->changed = true; ci_irq(ci->irq, ci); return NOTIFY_DONE; @@ -714,7 +693,7 @@ static int ci_get_platdata(struct device *dev, } cable = &platdata->vbus_extcon; - cable->nb.notifier_call = ci_vbus_notifier; + cable->nb.notifier_call = ci_cable_notifier; cable->edev = ext_vbus; if (!IS_ERR(ext_vbus)) { @@ -726,15 +705,15 @@ static int ci_get_platdata(struct device *dev, } cable = &platdata->id_extcon; - cable->nb.notifier_call = ci_id_notifier; + cable->nb.notifier_call = ci_cable_notifier; cable->edev = ext_id; if (!IS_ERR(ext_id)) { ret = extcon_get_cable_state_(cable->edev, EXTCON_USB_HOST); if (ret) - cable->state = false; - else cable->state = true; + else + cable->state = false; } return 0; } diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c index 0cf149edddd8..fb58d6b312c2 100644 --- a/drivers/usb/chipidea/otg.c +++ b/drivers/usb/chipidea/otg.c @@ -63,9 +63,9 @@ u32 hw_read_otgsc(struct ci_hdrc *ci, u32 mask) val &= ~OTGSC_IDIS; if (cable->state) - val |= OTGSC_ID; + val &= ~OTGSC_ID; /* A device */ else - val &= ~OTGSC_ID; + val |= OTGSC_ID; /* B device */ if (cable->enabled) val |= OTGSC_IDIE;