From: Heiner Kallweit <hkallweit1@gmail.com>
To: Olivia Mackall <olivia@selenic.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
Neil Armstrong <neil.armstrong@linaro.org>,
Kevin Hilman <khilman@baylibre.com>,
Jerome Brunet <jbrunet@baylibre.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: Linux Crypto Mailing List <linux-crypto@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"open list:ARM/Amlogic Meson..."
<linux-amlogic@lists.infradead.org>
Subject: [PATCH 2/5] hwrng: meson: use devm_clk_get_optional_enabled
Date: Sat, 18 Feb 2023 21:56:39 +0100 [thread overview]
Message-ID: <abd9a2ce-5b9b-c6bd-d3bf-8791d4005231@gmail.com> (raw)
In-Reply-To: <26216f60-d9b9-f40c-2c2a-95b3fde6c3bc@gmail.com>
Use devm_clk_get_optional_enabled() to simplify the code.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/char/hw_random/meson-rng.c | 24 ++++--------------------
1 file changed, 4 insertions(+), 20 deletions(-)
diff --git a/drivers/char/hw_random/meson-rng.c b/drivers/char/hw_random/meson-rng.c
index e79069b6d..22e3dcc6f 100644
--- a/drivers/char/hw_random/meson-rng.c
+++ b/drivers/char/hw_random/meson-rng.c
@@ -19,7 +19,6 @@
struct meson_rng_data {
void __iomem *base;
struct hwrng rng;
- struct clk *core_clk;
};
static int meson_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
@@ -32,16 +31,11 @@ static int meson_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
return sizeof(u32);
}
-static void meson_rng_clk_disable(void *data)
-{
- clk_disable_unprepare(data);
-}
-
static int meson_rng_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct meson_rng_data *data;
- int ret;
+ struct clk *core_clk;
data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
if (!data)
@@ -51,21 +45,11 @@ static int meson_rng_probe(struct platform_device *pdev)
if (IS_ERR(data->base))
return PTR_ERR(data->base);
- data->core_clk = devm_clk_get_optional(dev, "core");
- if (IS_ERR(data->core_clk))
- return dev_err_probe(dev, PTR_ERR(data->core_clk),
+ core_clk = devm_clk_get_optional_enabled(dev, "core");
+ if (IS_ERR(core_clk))
+ return dev_err_probe(dev, PTR_ERR(core_clk),
"Failed to get core clock\n");
- if (data->core_clk) {
- ret = clk_prepare_enable(data->core_clk);
- if (ret)
- return ret;
- ret = devm_add_action_or_reset(dev, meson_rng_clk_disable,
- data->core_clk);
- if (ret)
- return ret;
- }
-
data->rng.name = pdev->name;
data->rng.read = meson_rng_read;
--
2.39.2
next prev parent reply other threads:[~2023-02-18 20:59 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-18 20:54 [PATCH 0/5] hwrng: meson: simplify driver Heiner Kallweit
2023-02-18 20:55 ` [PATCH 1/5] hwrng: meson: remove unused member of struct meson_rng_data Heiner Kallweit
2023-02-19 17:26 ` Martin Blumenstingl
2023-02-18 20:56 ` Heiner Kallweit [this message]
2023-02-19 17:27 ` [PATCH 2/5] hwrng: meson: use devm_clk_get_optional_enabled Martin Blumenstingl
2023-02-18 20:57 ` [PATCH 3/5] hwrng: meson: remove not needed call to platform_set_drvdata Heiner Kallweit
2023-02-19 17:28 ` Martin Blumenstingl
2023-02-18 20:58 ` [PATCH 4/5] hwrng: meson: use struct hw_random priv data Heiner Kallweit
2023-02-19 18:26 ` Martin Blumenstingl
2023-02-19 23:51 ` Heiner Kallweit
2023-02-20 4:41 ` Herbert Xu
2023-02-20 7:18 ` Heiner Kallweit
2023-02-20 9:01 ` Herbert Xu
2023-02-18 20:59 ` [PATCH 5/5] hwrng: meson: remove struct meson_rng_data Heiner Kallweit
2023-03-10 11:26 ` [PATCH 0/5] hwrng: meson: simplify driver Herbert Xu
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=abd9a2ce-5b9b-c6bd-d3bf-8791d4005231@gmail.com \
--to=hkallweit1@gmail.com \
--cc=herbert@gondor.apana.org.au \
--cc=jbrunet@baylibre.com \
--cc=khilman@baylibre.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-crypto@vger.kernel.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=neil.armstrong@linaro.org \
--cc=olivia@selenic.com \
/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