From patchwork Fri Apr 12 12:36:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10898159 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4676B1515 for ; Fri, 12 Apr 2019 12:37:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23E8128D12 for ; Fri, 12 Apr 2019 12:37:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 18B2D28D1B; Fri, 12 Apr 2019 12:37:17 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B63B28D12 for ; Fri, 12 Apr 2019 12:37:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728355AbfDLMgs (ORCPT ); Fri, 12 Apr 2019 08:36:48 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:39405 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727958AbfDLMgr (ORCPT ); Fri, 12 Apr 2019 08:36:47 -0400 Received: by mail-wm1-f66.google.com with SMTP id n25so10821924wmk.4 for ; Fri, 12 Apr 2019 05:36:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=joOQiQILwSUQpc0pTrHcK/ya5VvWQmcmFsscTsVp5Yw=; b=ZzNHNCwB2MHMWsVsm62DVxQ40e64KQJi/5XS/zJI3Rjuz6UiIQiQMIUYlicxAUcMyR wRQ2JIBoVs7/ncCvHJ8+S+E26InWJTkutfL6OgVcBXzDapJNRwkL6ud3lxmQO4+sVf4U yrD+9EoL68IteFtZqS3XoRyLkBvfZRS5hkK3azO7M0CKgRK+VNnHorMzdE0bDI76P7kf SZkyMPqvWdXwelb9aV+hp3POKqHftBQGR1+CLlP3EWsRrn86DrGUe2IkOYctdhH88lEH Sg149a9nAHReBS9/uCKfoRyPgwqhxf4H+pCB/ty922D4QH/Nt4/GLMfK1INdKe7RXtD5 xnPg== 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:mime-version:content-transfer-encoding; bh=joOQiQILwSUQpc0pTrHcK/ya5VvWQmcmFsscTsVp5Yw=; b=cpkU3I0vA8+9aF6WG2eLJXmWTBbErh0n0Gx6PWilHVuw1Rmjja/yjI5eRlUC0vBylz Qg82RPsNElhuxWR5PdOju5CYVEYzIMt+PRcGqWnOycBb2pAEkxVX5ISlAhFzakGME2WZ 6uM4QJCuCHwtwue8z8cJpr2rJdVVQ+BhZaLNV1C6xKc2LTTXTde0KvPpLsSr8WUZ289s 9FuTJSiUlT7iFwBugj+WOQqDmAKeBO5D7BzhrDZvmveHlUlIb5k9ME8zldc4fahh+O1b jelkMTfv66p8BL1cAzR5ZJmTWRJLs4cVmrZ1+8aabUJb+jG3G626LENesNupqNjTiz1+ /zJQ== X-Gm-Message-State: APjAAAXVxDgRHsOS91R4Hy2QBKPnTR2KIGlh/cucB+AMMidHMq86YnFh +Lk5YOgy62+iuC4wMkmQH0yZ0Q== X-Google-Smtp-Source: APXvYqyElSWkpRR37KwhB8kBDZhyovKNUnSkJGF/0UvOx0kMpkjnAmtwpkNmPmgtdNBA9lHMZWqVSg== X-Received: by 2002:a1c:1a4d:: with SMTP id a74mr11089006wma.50.1555072605753; Fri, 12 Apr 2019 05:36:45 -0700 (PDT) Received: from localhost.localdomain (aputeaux-684-1-35-248.w90-86.abo.wanadoo.fr. [90.86.90.248]) by smtp.gmail.com with ESMTPSA id v190sm12384030wme.18.2019.04.12.05.36.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Apr 2019 05:36:45 -0700 (PDT) From: Bartosz Golaszewski To: Sekhar Nori , Kevin Hilman , Alan Stern , Greg Kroah-Hartman Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v5 2/6] usb: ohci-da8xx: let the regulator framework keep track of use count Date: Fri, 12 Apr 2019 14:36:36 +0200 Message-Id: <20190412123640.11437-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190412123640.11437-1-brgl@bgdev.pl> References: <20190412123640.11437-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski There's no reason to have a separate variable to keep track of the regulator state. The regulator core already does that. Remove reg_enabled from struct da8xx_ohci_hcd. Signed-off-by: Bartosz Golaszewski Acked-by: Alan Stern --- drivers/usb/host/ohci-da8xx.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c index ca8a94f15ac0..209a262b5565 100644 --- a/drivers/usb/host/ohci-da8xx.c +++ b/drivers/usb/host/ohci-da8xx.c @@ -40,7 +40,6 @@ struct da8xx_ohci_hcd { struct phy *usb11_phy; struct regulator *vbus_reg; struct notifier_block nb; - unsigned int reg_enabled; struct gpio_desc *vbus_gpio; struct gpio_desc *oc_gpio; }; @@ -100,21 +99,18 @@ static int ohci_da8xx_set_power(struct usb_hcd *hcd, int on) if (!da8xx_ohci->vbus_reg) return 0; - if (on && !da8xx_ohci->reg_enabled) { + if (on) { ret = regulator_enable(da8xx_ohci->vbus_reg); if (ret) { dev_err(dev, "Failed to enable regulator: %d\n", ret); return ret; } - da8xx_ohci->reg_enabled = 1; - - } else if (!on && da8xx_ohci->reg_enabled) { + } else { ret = regulator_disable(da8xx_ohci->vbus_reg); if (ret) { dev_err(dev, "Failed to disable regulator: %d\n", ret); return ret; } - da8xx_ohci->reg_enabled = 0; } return 0;