From: Philipp Zabel <p.zabel@pengutronix.de>
To: Billy Tsai <billy_tsai@aspeedtech.com>,
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
Subject: Re: [PATCH v13 3/3] hwmon: (aspeed-g6-pwm-tacho): Support for ASPEED g6 PWM/Fan tach
Date: Wed, 24 Jan 2024 10:45:59 +0100 [thread overview]
Message-ID: <dccb808a2ba6ccb0fd0b4e7ccfe40cd871886b6b.camel@pengutronix.de> (raw)
In-Reply-To: <20240124060705.1342461-4-billy_tsai@aspeedtech.com>
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
next prev parent reply other threads:[~2024-01-24 9:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-24 6:07 [PATCH v13 0/3] Support pwm/tach driver for aspeed ast26xx Billy Tsai
2024-01-24 6:07 ` [PATCH v13 1/3] dt-bindings: hwmon: fan: Add fan binding to schema Billy Tsai
2024-02-03 15:13 ` Guenter Roeck
2024-02-05 6:59 ` Billy Tsai
2024-01-24 6:07 ` [PATCH v13 2/3] dt-bindings: hwmon: Support Aspeed g6 PWM TACH Control Billy Tsai
2024-01-24 7:39 ` Rob Herring
2024-01-24 6:07 ` [PATCH v13 3/3] hwmon: (aspeed-g6-pwm-tacho): Support for ASPEED g6 PWM/Fan tach Billy Tsai
2024-01-24 9:45 ` Philipp Zabel [this message]
2024-01-29 16:02 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dccb808a2ba6ccb0fd0b4e7ccfe40cd871886b6b.camel@pengutronix.de \
--to=p.zabel@pengutronix.de \
--cc=BMC-SW@aspeedtech.com \
--cc=andrew@codeconstruct.com.au \
--cc=billy_tsai@aspeedtech.com \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=jdelvare@suse.com \
--cc=joel@jms.id.au \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=naresh.solanki@9elements.com \
--cc=patrick@stwcx.xyz \
--cc=robh+dt@kernel.org \
--cc=u.kleine-koenig@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).