From patchwork Thu Apr 11 09:30:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10895479 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 84FA014DB for ; Thu, 11 Apr 2019 09:30:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F8A928CD3 for ; Thu, 11 Apr 2019 09:30:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E65628CC6; Thu, 11 Apr 2019 09:30:57 +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 1BF4D28CD5 for ; Thu, 11 Apr 2019 09:30:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727080AbfDKJag (ORCPT ); Thu, 11 Apr 2019 05:30:36 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:43794 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726106AbfDKJae (ORCPT ); Thu, 11 Apr 2019 05:30:34 -0400 Received: by mail-wr1-f67.google.com with SMTP id k17so1698810wrx.10 for ; Thu, 11 Apr 2019 02:30:32 -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=EgQOslscCdg9QNMZU/Bmy89sWYhpPCz71b3AUgk9nLqxNHNg1pI/E5AN+sMPGwj0no dLLWajdIxgW6ZXMt0sD9MPDdhZey85TqREKHcEoQ5dItHGElCuMk+LDOKuV0CiuYAS3Z qx0krI14O7/bgOxhziDK099EixwkG4mR7RvOaXhf8yz/FGfnzV9o1QRcXvGpBpm9HvKN QlkJJ+JuuKpMyz4xOoSW03IcBBKcAz/HV9yKR4VnkBh4QcItjeS181kTJAURjl1ruz6A fkRxdxAgWImttXyvzhGfBpaEkZfdasotYPRLd/S7Pk19gH2BqHsm+Y1HzgRQ45Xgmfo9 K3ig== 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=h5Ps9c/fxQMV3iVRkYhB58XgliLshLiwfsxGO4F0AsZTWIKPnyc0d31dXXBgoDdl5o 8XY2yxtyxGMTrYS8RLxW05CAD/rHI5yntNbrNfroEBMZnNrdCUpnQ0ISWbN8fdQQ2Wxr ho/u0KDwPgLxCWqLMzey7C4n58EAa89apsj+0I+c4+DvjtkdU/ukgwkZNmnY7UgKiZ0h p1cKgdkSq7xMkc4G0SH5dRIZcBGZG5sZ0pocia6PoDSjBAtMSLT1zFKj1ooxRB+wWyxk 5gxqzB7NIMqd6S2uYZ6nTrmEFzL/kxE4SJezziQexpJd2Dw8Mu8SG28XrJTDlZNT5ZIv 8hzA== X-Gm-Message-State: APjAAAWcrRIGyrXxrh39OUlGT/ufGNfu8FPT3/ljkvX5uM+xEUySic3k HkEdio/fGpHBSkyLgT4Bi7blng== X-Google-Smtp-Source: APXvYqyUOAE+neN/xsO+xoLZUe6zOOYX4bRL3Bf0Vlw1KF3Q1rQEfh4MaSvn1jgF2DVc2WcCsdXfAw== X-Received: by 2002:a5d:6988:: with SMTP id g8mr30852625wru.117.1554975032038; Thu, 11 Apr 2019 02:30:32 -0700 (PDT) Received: from debian-brgl.home ([2a01:cb1d:af:5b00:6d6c:8493:1ab5:dad7]) by smtp.gmail.com with ESMTPSA id a9sm37517228wrt.29.2019.04.11.02.30.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Apr 2019 02:30:31 -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 v4 2/6] usb: ohci-da8xx: let the regulator framework keep track of use count Date: Thu, 11 Apr 2019 11:30:20 +0200 Message-Id: <20190411093024.23555-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190411093024.23555-1-brgl@bgdev.pl> References: <20190411093024.23555-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;