Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp526658lqg; Fri, 1 Mar 2024 12:20:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU9TNTIGKKBrHnnclwlgDLFQDCfFnAan+ydfslazgW/lmwRKf6BEsOIl6kRFhBq78OsItl4TCGfjop3KI82qCW9bxozo1B4ZhuFmERzhA== X-Google-Smtp-Source: AGHT+IEYrHRetKU5zCznfRRFtLYzUzYzYHe1KnxgaZoeKXGNvADmfqMAw2fYnX2qjclUWrO7RsJM X-Received: by 2002:ad4:46d0:0:b0:690:58a4:360c with SMTP id pm16-20020ad446d0000000b0069058a4360cmr2202810qvb.45.1709324401930; Fri, 01 Mar 2024 12:20:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709324401; cv=pass; d=google.com; s=arc-20160816; b=LG3ulaS33R9n9OuxWTbTqKPRcBZkSwQ6vr2N/BqhUfL7mEIH5sAGF7QHzbGGva2mgR bYD9T8u3i9Vlcyn9fOit8TtLg54HyFc4VC5Lw/TTVPuVvZmBxbB+OI+z85xq8mS0ChuA ohGqYix124APHTEcaDYDuRU1tJQ7L/R1O+WxjghOo1eSb8oRLCzf0AB0orXL3XFtqCnm oS+kgiSuH12y2d/oWWdFg/kPbdsG20CoyDLe8BDEFOBV9GAhkwfmMRym6qzuEzP8H3Fy FQ5dPfNA20I7NykRZ9Eq0evfAc4kxv911SO8m/IquAJ8F8Xx0w01oMS8QMUQN1HWMKYc 0NdA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=qQqMoRGiUhsJ85D1d1LyXHH/mrcTJO9vDe4huSo0hLM=; fh=Hp6gfLLaHYxx9QryLynraQzgnPtI/zJBdxd2pbVUth8=; b=BGokfLjKaVInRdrb5VXURMWckIRtx2qEWqmPMaUVphHt6cLo8YK9evayAXx7QeVWkm nwI02RW8rFv2Dbac0N2dMM2UctZOIr3gk6L/uyH10MVndM46axKoOBW2m/7nf7hPPQL+ 26G9bNtUWEB5F1WuLpaw3S4d7kh5KpTYph45MfGTegcTwIFjVnKdERr78AFqBA+TyUPY 9KanebnmodFdET64jDE2WNR+7N2rPdd9MxAYsGLbvQE2b9hZTDH19TYryGh+tWU18C0l 3mYPBKRkoVg6vQvRIMFifXWhSXyTBStbm/Hgj8LfMlfjakBi6bYBcfgOcVd2Bo74dm/d Z0sQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=netrider.rowland.org); spf=pass (google.com: domain of linux-kernel+bounces-89073-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89073-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 7-20020a0562140dc700b0068c83271adcsi4264085qvt.228.2024.03.01.12.20.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 12:20:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89073-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=netrider.rowland.org); spf=pass (google.com: domain of linux-kernel+bounces-89073-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89073-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 8F61B1C24713 for ; Fri, 1 Mar 2024 20:20:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 895F43C689; Fri, 1 Mar 2024 20:19:54 +0000 (UTC) Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by smtp.subspace.kernel.org (Postfix) with SMTP id 325C63C067 for ; Fri, 1 Mar 2024 20:19:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.131.102.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709324394; cv=none; b=q3+B0prnO+Y87Cn8qJhwAOAEVFCY1n3WDJ+JcrXu5rmYcol/1P3xZ1rGrrhe6PGU17/6b1Hm08fN+6pN1YimlO/0hjmDoSnaUTwzgn+aLGIVIJxVmQXqGcDo8Vity55BsYT/Faezdm9xKQVqVTjrv67PGvEflmqWyKyUyvw6nVA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709324394; c=relaxed/simple; bh=dmdQvBgGcFUSe5KL71t4XKvpm2QFV83YwaoViTYlKAk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Hgb/z2rcXJXOLhGNYh0R0M7FRf/5oC6eeF3HKwlHkrpL+hsQQpk9erGjVbW/Gc0Wqodj52ezGl76PBTiwp9RZ+RK37+evOnqpSO9GryD6fdkqvdmokdPdUbLTM7kMZ7M7BeYOpDiZqQPrTPsF/vNQZWX05KdkzPCgzYMnfSiBr4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=rowland.harvard.edu; spf=pass smtp.mailfrom=netrider.rowland.org; arc=none smtp.client-ip=192.131.102.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=rowland.harvard.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netrider.rowland.org Received: (qmail 45205 invoked by uid 1000); 1 Mar 2024 15:19:47 -0500 Date: Fri, 1 Mar 2024 15:19:47 -0500 From: Alan Stern To: Anand Moon Cc: Greg Kroah-Hartman , Krzysztof Kozlowski , Alim Akhtar , linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 1/4] usb: ehci-exynos: Use devm_clk_get_enabled() helpers Message-ID: References: <20240301193831.3346-1-linux.amoon@gmail.com> <20240301193831.3346-2-linux.amoon@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240301193831.3346-2-linux.amoon@gmail.com> On Sat, Mar 02, 2024 at 01:08:08AM +0530, Anand Moon wrote: > The devm_clk_get_enabled() helpers: > - call devm_clk_get() > - call clk_prepare_enable() and register what is needed in order to > call clk_disable_unprepare() when needed, as a managed resource. > > This simplifies the code and avoids the calls to clk_disable_unprepare(). > > While at it, use dev_err_probe consistently, and use its return value > to return the error code. > > Signed-off-by: Anand Moon > --- > drivers/usb/host/ehci-exynos.c | 30 +++++------------------------- > 1 file changed, 5 insertions(+), 25 deletions(-) > > diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c > index f644b131cc0b..05aa3d9c2a3b 100644 > --- a/drivers/usb/host/ehci-exynos.c > +++ b/drivers/usb/host/ehci-exynos.c > @@ -159,19 +159,12 @@ static int exynos_ehci_probe(struct platform_device *pdev) > > err = exynos_ehci_get_phy(&pdev->dev, exynos_ehci); > if (err) > - goto fail_clk; > - > - exynos_ehci->clk = devm_clk_get(&pdev->dev, "usbhost"); > - > - if (IS_ERR(exynos_ehci->clk)) { > - dev_err(&pdev->dev, "Failed to get usbhost clock\n"); > - err = PTR_ERR(exynos_ehci->clk); > - goto fail_clk; > - } > + goto fail_io; > > - err = clk_prepare_enable(exynos_ehci->clk); > - if (err) > - goto fail_clk; > + exynos_ehci->clk = devm_clk_get_enabled(&pdev->dev, "usbhost"); > + if (IS_ERR(exynos_ehci->clk)) > + return dev_err_probe(&pdev->dev, PTR_ERR(exynos_ehci->clk), > + "Failed to get usbhost clock\n"); What about the usb_put_hcd(hcd) call that used to happen here? Alan Stern > > hcd->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res); > if (IS_ERR(hcd->regs)) { > @@ -223,8 +216,6 @@ static int exynos_ehci_probe(struct platform_device *pdev) > exynos_ehci_phy_disable(&pdev->dev); > pdev->dev.of_node = exynos_ehci->of_node; > fail_io: > - clk_disable_unprepare(exynos_ehci->clk); > -fail_clk: > usb_put_hcd(hcd); > return err; > } > @@ -240,8 +231,6 @@ static void exynos_ehci_remove(struct platform_device *pdev) > > exynos_ehci_phy_disable(&pdev->dev); > > - clk_disable_unprepare(exynos_ehci->clk); > - > usb_put_hcd(hcd); > } > > @@ -249,7 +238,6 @@ static void exynos_ehci_remove(struct platform_device *pdev) > static int exynos_ehci_suspend(struct device *dev) > { > struct usb_hcd *hcd = dev_get_drvdata(dev); > - struct exynos_ehci_hcd *exynos_ehci = to_exynos_ehci(hcd); > > bool do_wakeup = device_may_wakeup(dev); > int rc; > @@ -260,25 +248,17 @@ static int exynos_ehci_suspend(struct device *dev) > > exynos_ehci_phy_disable(dev); > > - clk_disable_unprepare(exynos_ehci->clk); > - > return rc; > } > > static int exynos_ehci_resume(struct device *dev) > { > struct usb_hcd *hcd = dev_get_drvdata(dev); > - struct exynos_ehci_hcd *exynos_ehci = to_exynos_ehci(hcd); > int ret; > > - ret = clk_prepare_enable(exynos_ehci->clk); > - if (ret) > - return ret; > - > ret = exynos_ehci_phy_enable(dev); > if (ret) { > dev_err(dev, "Failed to enable USB phy\n"); > - clk_disable_unprepare(exynos_ehci->clk); > return ret; > } > > -- > 2.43.0 >