From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BBFEFC433F5 for ; Tue, 31 May 2022 15:18:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Qc42MAh0YIJYgqu0c0h+/jQGBzhHm/DntZa0aqvK6p8=; b=b/opLq5ktXY602 goSx1ZkaCFIl+rHr/vC6wcBhv0BPSgrGcux7bZdg+rO89GnxTLi4EOyDUasAYVT+uMImTrgBEWK7+ 6DV/WyxmdoLuhf4oIJr8KdaugWJdALm2cjMOaXzxXnXKIx8Ea6C5jvL6d5wJ50WlqVYHgJIpp0EZt ETxlzdkFFyykypqoLChn2oXBZIg4em1dffTZznqH8RRB5vXarw/8lhpeLfxJPCCGlJ0iv6eouMXf5 5/jnSrNuBPTwuDKiwx5LCZBlpxoQ4b48NortCxY0I2WrrdBDccwRswHJ4ZZ1x/b1z9R3FjEVY6Kdh 1m4t6L3Pyzt59aj2dLew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nw3c7-00BVsa-Dn; Tue, 31 May 2022 15:16:55 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nw3c2-00BVqb-BC for linux-arm-kernel@lists.infradead.org; Tue, 31 May 2022 15:16:52 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 824375C08D3; Tue, 31 May 2022 11:16:44 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Tue, 31 May 2022 11:16:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1654010204; x= 1654096604; bh=ulNAQ1pcXqswmEceuSuobLoT1dHK6KJ4SW3DfbzzGUY=; b=B H2E1JaI1iWt9XB94fqwKNbQIyCGNujQn7s3wjr+KqygI88F6Bhsq71tCuDVZiw8z 6agTebYezaPRkIJ3tL2LyYd6kZdvimN8B2h6hZd6PN/1YkzFvcfEbdnBM2dGGe10 rGxCZixgYmP5TloGmatV9mWmnULu9Z2ZN1NBd+Kb5XjfC0RuTx7bwjUshFlBnnXv ppdkdvgy6pIAQi4qySCdN7pMTmYx41br5IP8661Op3GEJPb392clk5vXAl5n9hVy 0H4tW5O9RWtBmM8m+/ZyusnS4QRJjW+9LXVfRdk4iqlX1BIV5/skdPAfQPDyiZx/ c9N9yTx+4kqdQCPsjvKRA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1654010204; x= 1654096604; bh=ulNAQ1pcXqswmEceuSuobLoT1dHK6KJ4SW3DfbzzGUY=; b=R v4Mq8lEWXMRg1AgCgs2ukEf1JMq/M1rAaLX3Ll68u85m8MmIVMW3z79ky8WAS8S5 /AniW47OaB00dgNouonWeQLGvGvDxUtqNhDodNC7foW+rh2BuLAR7wOq0gtJv6yn KCIq72lwWrmMnar9/KUoqOSNP5YhxtctB2jpoZrUbunyB3VxeeZNgXwwHhJznUCV 4vLy6iqmS4TohTEfaVfoLrVbAiyKRT8ItXJmFUc7IcMXmQkSR7H1IUGz/ATsSkWs CFborkc25htZ5pvOl/+Vuo1VAa1xmlXAdMyQrpCk235sKu4+ZVWqLBrLtm7UrYHg pPbd9bWr4OoNdic0C3wKg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrkeekgdekhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtugfgjgesthhqredttddtvdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeetgfelgefggeekkefggfeludeiudffjeffgeevveekjedukedtudeuteef teefgfenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 31 May 2022 11:16:42 -0400 (EDT) Date: Tue, 31 May 2022 17:16:41 +0200 From: Maxime Ripard To: Samuel Holland Cc: Chen-Yu Tsai , Jernej Skrabec , Daniel Vetter , David Airlie , Philipp Zabel , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev Subject: Re: [PATCH 3/6] drm/sun4i: sun8i-hdmi-phy: Used device-managed clocks/resets Message-ID: <20220531151641.ua6jzr2pmnuarcfv@penduick> References: <20220412043512.49364-1-samuel@sholland.org> <20220412043512.49364-4-samuel@sholland.org> <20220412132325.bq2c3g2fskckfgpz@houat> <4b3b2515-d180-fee4-6095-c2e197a3f195@sholland.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4b3b2515-d180-fee4-6095-c2e197a3f195@sholland.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220531_081651_096029_1CED644E X-CRM114-Status: GOOD ( 27.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Samuel, Sorry for the (very) late answer On Tue, Apr 12, 2022 at 06:34:40PM -0500, Samuel Holland wrote: > On 4/12/22 8:23 AM, Maxime Ripard wrote: > > Hi, > > > > On Mon, Apr 11, 2022 at 11:35:08PM -0500, Samuel Holland wrote: > >> Now that the HDMI PHY is using a platform driver, it can use device- > >> managed resources. Use these, as well as the dev_err_probe helper, to > >> simplify the probe function and get rid of the remove function. > >> > >> Signed-off-by: Samuel Holland > >> --- > >> > >> drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c | 100 ++++++++----------------- > >> 1 file changed, 30 insertions(+), 70 deletions(-) > >> > >> diff --git a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c > >> index 1effa30bfe62..1351e633d485 100644 > >> --- a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c > >> +++ b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c > >> @@ -673,10 +673,8 @@ int sun8i_hdmi_phy_get(struct sun8i_dw_hdmi *hdmi, struct device_node *node) > >> static int sun8i_hdmi_phy_probe(struct platform_device *pdev) > >> { > >> struct device *dev = &pdev->dev; > >> - struct device_node *node = dev->of_node; > >> struct sun8i_hdmi_phy *phy; > >> void __iomem *regs; > >> - int ret; > >> > >> phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL); > >> if (!phy) > >> @@ -686,88 +684,50 @@ static int sun8i_hdmi_phy_probe(struct platform_device *pdev) > >> phy->dev = dev; > >> > >> regs = devm_platform_ioremap_resource(pdev, 0); > >> - if (IS_ERR(regs)) { > >> - dev_err(dev, "Couldn't map the HDMI PHY registers\n"); > >> - return PTR_ERR(regs); > >> - } > >> + if (IS_ERR(regs)) > >> + return dev_err_probe(dev, PTR_ERR(regs), > >> + "Couldn't map the HDMI PHY registers\n"); > >> > >> phy->regs = devm_regmap_init_mmio(dev, regs, > >> &sun8i_hdmi_phy_regmap_config); > >> - if (IS_ERR(phy->regs)) { > >> - dev_err(dev, "Couldn't create the HDMI PHY regmap\n"); > >> - return PTR_ERR(phy->regs); > >> - } > >> + if (IS_ERR(phy->regs)) > >> + return dev_err_probe(dev, PTR_ERR(phy->regs), > >> + "Couldn't create the HDMI PHY regmap\n"); > >> > >> - phy->clk_bus = of_clk_get_by_name(node, "bus"); > >> - if (IS_ERR(phy->clk_bus)) { > >> - dev_err(dev, "Could not get bus clock\n"); > >> - return PTR_ERR(phy->clk_bus); > >> - } > >> - > >> - phy->clk_mod = of_clk_get_by_name(node, "mod"); > >> - if (IS_ERR(phy->clk_mod)) { > >> - dev_err(dev, "Could not get mod clock\n"); > >> - ret = PTR_ERR(phy->clk_mod); > >> - goto err_put_clk_bus; > >> - } > >> + phy->clk_bus = devm_clk_get(dev, "bus"); > >> + if (IS_ERR(phy->clk_bus)) > >> + return dev_err_probe(dev, PTR_ERR(phy->clk_bus), > >> + "Could not get bus clock\n"); > >> > >> - if (phy->variant->has_phy_clk) { > >> - phy->clk_pll0 = of_clk_get_by_name(node, "pll-0"); > >> - if (IS_ERR(phy->clk_pll0)) { > >> - dev_err(dev, "Could not get pll-0 clock\n"); > >> - ret = PTR_ERR(phy->clk_pll0); > >> - goto err_put_clk_mod; > >> - } > >> - > >> - if (phy->variant->has_second_pll) { > >> - phy->clk_pll1 = of_clk_get_by_name(node, "pll-1"); > >> - if (IS_ERR(phy->clk_pll1)) { > >> - dev_err(dev, "Could not get pll-1 clock\n"); > >> - ret = PTR_ERR(phy->clk_pll1); > >> - goto err_put_clk_pll0; > >> - } > >> - } > >> - } > >> + phy->clk_mod = devm_clk_get(dev, "mod"); > >> + if (IS_ERR(phy->clk_mod)) > >> + return dev_err_probe(dev, PTR_ERR(phy->clk_mod), > >> + "Could not get mod clock\n"); > >> > >> - phy->rst_phy = of_reset_control_get_shared(node, "phy"); > >> - if (IS_ERR(phy->rst_phy)) { > >> - dev_err(dev, "Could not get phy reset control\n"); > >> - ret = PTR_ERR(phy->rst_phy); > >> - goto err_put_clk_pll1; > >> - } > >> + if (phy->variant->has_phy_clk) > >> + phy->clk_pll0 = devm_clk_get(dev, "pll-0"); > >> + if (IS_ERR(phy->clk_pll0)) > >> + return dev_err_probe(dev, PTR_ERR(phy->clk_pll0), > >> + "Could not get pll-0 clock\n"); > >> + > >> + if (phy->variant->has_second_pll) > >> + phy->clk_pll1 = devm_clk_get(dev, "pll-1"); > >> + if (IS_ERR(phy->clk_pll1)) > >> + return dev_err_probe(dev, PTR_ERR(phy->clk_pll1), > >> + "Could not get pll-1 clock\n"); > >> + > >> + phy->rst_phy = devm_reset_control_get_shared(dev, "phy"); > >> + if (IS_ERR(phy->rst_phy)) > >> + return dev_err_probe(dev, PTR_ERR(phy->rst_phy), > >> + "Could not get phy reset control\n"); > > > > I find the old construct clearer with the imbricated blocks. > > I'm not sure what you mean here. Are you suggesting braces around the > dev_err_probe statements? Or do you want me to put the error handling for > variant-specific resources inside the variant checks? Please clarify. I meant that we went, for example, from: if (phy->variant->has_phy_clk) { phy->clk_pll0 = devm_clk_get(dev, "pll-0"); if (IS_ERR(phy->clk_pll0)) { ... } } to if (phy->variant->has_phy_clk) phy->clk_pll0 = devm_clk_get(dev, "pll-0"); if (IS_ERR(phy->clk_pll0)) { ... } Which relies on the fact that phy->clk_pll0 is initialized to !IS_ERR(...), which we never explicitly enforced. I find the first and original code clearer for that aspect (since we only use that value if it was set), and less fragile. Maxime _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel