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 82CA7C46CD2 for ; Wed, 24 Jan 2024 09:46:56 +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:MIME-Version:References:In-Reply-To: Date:To:From:Subject:Message-ID:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=b5GTrXvTn2TRT6HFc+rtIsBQxX6rc1HA0Yq3EwgwVz0=; b=zUjUjJZNUpTnJs 349gkEaXSktT/ZNMIpiDghAPE+OqSfIvsdMiDfAjthyZki2tY7aHCMTbBYmIXG2IO7VhZhGfRf8YE N7koShCM8T0hE1sFy9ZDARp4oH70NYUv+cOdfoSTU/mhNPqkLPKEkcP0Wicxir3+usk3wmEXEybDd o2D2pVw4nmsXyQ8osYrvZdTJcMjUqqgcP/DLbVgU4tD0BuyOVlbvNMSa6SYaSEOUInP8f4oCkb2tO x/Uqxi3KBlQ79fWNmebo8niDnZqbM/iuFnHOxQwPyDV5V8KVLEIFIYm2POS8CpXjakMpI7kbpeazq cyXyQdUeTiJloSzkNhKQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rSZq2-002K5T-2y; Wed, 24 Jan 2024 09:46:30 +0000 Received: from metis.whiteo.stw.pengutronix.de ([185.203.201.7]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rSZpy-002K2G-0v for linux-arm-kernel@lists.infradead.org; Wed, 24 Jan 2024 09:46:28 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rSZpc-0003zO-ML; Wed, 24 Jan 2024 10:46:04 +0100 Received: from [2a0a:edc0:0:900:1d::4e] (helo=lupine) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rSZpX-0021gf-GI; Wed, 24 Jan 2024 10:45:59 +0100 Received: from pza by lupine with local (Exim 4.96) (envelope-from ) id 1rSZpX-00064D-1N; Wed, 24 Jan 2024 10:45:59 +0100 Message-ID: Subject: Re: [PATCH v13 3/3] hwmon: (aspeed-g6-pwm-tacho): Support for ASPEED g6 PWM/Fan tach From: Philipp Zabel To: Billy Tsai , jdelvare@suse.com, linux@roeck-us.net, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, joel@jms.id.au, andrew@codeconstruct.com.au, corbet@lwn.net, u.kleine-koenig@pengutronix.de, naresh.solanki@9elements.com, linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-pwm@vger.kernel.org, BMC-SW@aspeedtech.com, patrick@stwcx.xyz Date: Wed, 24 Jan 2024 10:45:59 +0100 In-Reply-To: <20240124060705.1342461-4-billy_tsai@aspeedtech.com> References: <20240124060705.1342461-1-billy_tsai@aspeedtech.com> <20240124060705.1342461-4-billy_tsai@aspeedtech.com> User-Agent: Evolution 3.46.4-2 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240124_014626_323093_4E370813 X-CRM114-Status: GOOD ( 13.11 ) 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 On Mi, 2024-01-24 at 14:07 +0800, Billy Tsai wrote: [...] > +static int aspeed_pwm_tach_probe(struct platform_device *pdev) > +{ > + struct device *dev = &pdev->dev, *hwmon; > + int ret; > + struct device_node *child; > + struct aspeed_pwm_tach_data *priv; > + > + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); > + if (!priv) > + return -ENOMEM; > + priv->dev = dev; > + priv->base = devm_platform_ioremap_resource(pdev, 0); > + if (IS_ERR(priv->base)) > + return PTR_ERR(priv->base); > + > + priv->clk = devm_clk_get_enabled(dev, NULL); > + if (IS_ERR(priv->clk)) > + return dev_err_probe(dev, PTR_ERR(priv->clk), > + "Couldn't get clock\n"); > + priv->clk_rate = clk_get_rate(priv->clk); > + priv->reset = devm_reset_control_get_exclusive(dev, NULL); > + if (IS_ERR(priv->reset)) > + return dev_err_probe(dev, PTR_ERR(priv->reset), > + "Couldn't get reset control\n"); > + > + ret = reset_control_deassert(priv->reset); > + if (ret) > + return dev_err_probe(dev, ret, > + "Couldn't deassert reset control\n"); Consider using devm_add_action_or_reset() to assert the reset in the error paths and on driver unbind. > + > + priv->chip.dev = dev; > + priv->chip.ops = &aspeed_pwm_ops; > + priv->chip.npwm = PWM_ASPEED_NR_PWMS; > + > + ret = devm_pwmchip_add(dev, &priv->chip); > + if (ret < 0) { > + reset_control_assert(priv->reset); Then this ... > + return dev_err_probe(dev, ret, "Failed to add PWM chip\n"); > + } > + > + for_each_child_of_node(dev->of_node, child) { > + ret = aspeed_tach_create_fan(dev, child, priv); > + if (ret < 0) { > + of_node_put(child); > + dev_warn(dev, "Failed to create fan %d", ret); > + return 0; > + } > + } > + > + of_platform_populate(dev->of_node, NULL, NULL, dev); > + > + hwmon = devm_hwmon_device_register_with_info(dev, "aspeed_tach", priv, > + &aspeed_tach_chip_info, NULL); > + ret = PTR_ERR_OR_ZERO(hwmon); > + if (ret) { > + reset_control_assert(priv->reset); ... and this ... > + return dev_err_probe(dev, ret, > + "Failed to register hwmon device\n"); > + } > + > + return 0; > +} > + > +static int aspeed_pwm_tach_remove(struct platform_device *pdev) > +{ > + struct aspeed_pwm_tach_data *priv = platform_get_drvdata(pdev); > + > + reset_control_assert(priv->reset); > + > + return 0; > +} ... and this could be dropped. regards Philipp _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel