forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/char/hw_random/st-rng.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * ST Random Number Generator Driver ST's Platforms
34 *
....@@ -5,16 +6,13 @@
56 * Lee Jones <lee.jones@linaro.org>
67 *
78 * Copyright (C) 2015 STMicroelectronics (R&D) Limited
8
- *
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License version 2 as
11
- * published by the Free Software Foundation.
129 */
1310
1411 #include <linux/clk.h>
1512 #include <linux/delay.h>
1613 #include <linux/hw_random.h>
1714 #include <linux/io.h>
15
+#include <linux/kernel.h>
1816 #include <linux/module.h>
1917 #include <linux/of.h>
2018 #include <linux/platform_device.h>
....@@ -44,7 +42,6 @@
4442
4543 struct st_rng_data {
4644 void __iomem *base;
47
- struct clk *clk;
4845 struct hwrng ops;
4946 };
5047
....@@ -75,7 +72,6 @@
7572 static int st_rng_probe(struct platform_device *pdev)
7673 {
7774 struct st_rng_data *ddata;
78
- struct resource *res;
7975 struct clk *clk;
8076 void __iomem *base;
8177 int ret;
....@@ -84,31 +80,22 @@
8480 if (!ddata)
8581 return -ENOMEM;
8682
87
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
88
- base = devm_ioremap_resource(&pdev->dev, res);
83
+ base = devm_platform_ioremap_resource(pdev, 0);
8984 if (IS_ERR(base))
9085 return PTR_ERR(base);
9186
92
- clk = devm_clk_get(&pdev->dev, NULL);
87
+ clk = devm_clk_get_enabled(&pdev->dev, NULL);
9388 if (IS_ERR(clk))
9489 return PTR_ERR(clk);
95
-
96
- ret = clk_prepare_enable(clk);
97
- if (ret)
98
- return ret;
9990
10091 ddata->ops.priv = (unsigned long)ddata;
10192 ddata->ops.read = st_rng_read;
10293 ddata->ops.name = pdev->name;
10394 ddata->base = base;
104
- ddata->clk = clk;
10595
106
- dev_set_drvdata(&pdev->dev, ddata);
107
-
108
- ret = hwrng_register(&ddata->ops);
96
+ ret = devm_hwrng_register(&pdev->dev, &ddata->ops);
10997 if (ret) {
11098 dev_err(&pdev->dev, "Failed to register HW RNG\n");
111
- clk_disable_unprepare(clk);
11299 return ret;
113100 }
114101
....@@ -117,18 +104,7 @@
117104 return 0;
118105 }
119106
120
-static int st_rng_remove(struct platform_device *pdev)
121
-{
122
- struct st_rng_data *ddata = dev_get_drvdata(&pdev->dev);
123
-
124
- hwrng_unregister(&ddata->ops);
125
-
126
- clk_disable_unprepare(ddata->clk);
127
-
128
- return 0;
129
-}
130
-
131
-static const struct of_device_id st_rng_match[] = {
107
+static const struct of_device_id st_rng_match[] __maybe_unused = {
132108 { .compatible = "st,rng" },
133109 {},
134110 };
....@@ -140,7 +116,6 @@
140116 .of_match_table = of_match_ptr(st_rng_match),
141117 },
142118 .probe = st_rng_probe,
143
- .remove = st_rng_remove
144119 };
145120
146121 module_platform_driver(st_rng_driver);