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: 75155 Delivered-To: patch@linaro.org Received: by 10.140.29.8 with SMTP id a8csp20870qga; Wed, 31 Aug 2016 17:44:38 -0700 (PDT) X-Received: by 10.98.16.193 with SMTP id 62mr22117434pfq.132.1472690678805; Wed, 31 Aug 2016 17:44:38 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id mu1si2370166pab.286.2016.08.31.17.44.38; Wed, 31 Aug 2016 17:44:38 -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 S934049AbcIAAoS (ORCPT + 27 others); Wed, 31 Aug 2016 20:44:18 -0400 Received: from mail-pf0-f177.google.com ([209.85.192.177]:34756 "EHLO mail-pf0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933840AbcIAAkt (ORCPT ); Wed, 31 Aug 2016 20:40:49 -0400 Received: by mail-pf0-f177.google.com with SMTP id p64so24788479pfb.1 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=I7gLagI+1myj8QRYQ3Cmr8D2wHEkaLiTtBPCoYBjrLsqfigzek8Xy0K08vcqALpclW ACEjnudNe02bVtOLzd9T7q7mKVTewSNVgJcYAVMyTRxW/DyRSsZM4dneKvIwGMw936bo Smxe8pB/cGGVpCeby2LPNcdKXKnyttkLyqbopxRR1CdGOrKVj46nmKSy2z9b/DGLsu/v 7Boz14MYLT5AAc4rN3ifLe9PB1Y3spGzXGqNp1XlaoUREvn7TXpO2OWehTRNTYEqmfgP SCALnzryBqx29THgSMvN7NQX18ngrOk52VVU5fYO3Tyk8gwzq3ivO3ihXSwrYYl0Eg+e 7/wg== X-Gm-Message-State: AE9vXwNtuAR5fuHAVAunQgn2eFiyKox5rsZBajo6+RWgj3tFvgbqMrYh+/AaaOajx3EsuHca 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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Andy Gross , Bjorn Andersson , Neil Armstrong , Arnd Bergmann , Felipe Balbi , Peter Chen , Greg Kroah-Hartman , "Ivan T. Ivanov" 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.9.0.rc2.8.ga28705d 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;