.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Nomadik RNG support |
---|
3 | 4 | * Copyright 2009 Alessandro Rubini |
---|
4 | | - * |
---|
5 | | - * This program is free software; you can redistribute it and/or modify |
---|
6 | | - * it under the terms of the GNU General Public License as published by |
---|
7 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
8 | | - * (at your option) any later version. |
---|
9 | 5 | */ |
---|
10 | 6 | |
---|
11 | 7 | #include <linux/kernel.h> |
---|
.. | .. |
---|
16 | 12 | #include <linux/io.h> |
---|
17 | 13 | #include <linux/clk.h> |
---|
18 | 14 | #include <linux/err.h> |
---|
19 | | - |
---|
20 | | -static struct clk *rng_clk; |
---|
21 | 15 | |
---|
22 | 16 | static int nmk_rng_read(struct hwrng *rng, void *data, size_t max, bool wait) |
---|
23 | 17 | { |
---|
.. | .. |
---|
40 | 34 | |
---|
41 | 35 | static int nmk_rng_probe(struct amba_device *dev, const struct amba_id *id) |
---|
42 | 36 | { |
---|
| 37 | + struct clk *rng_clk; |
---|
43 | 38 | void __iomem *base; |
---|
44 | 39 | int ret; |
---|
45 | 40 | |
---|
46 | | - rng_clk = devm_clk_get(&dev->dev, NULL); |
---|
| 41 | + rng_clk = devm_clk_get_enabled(&dev->dev, NULL); |
---|
47 | 42 | if (IS_ERR(rng_clk)) { |
---|
48 | 43 | dev_err(&dev->dev, "could not get rng clock\n"); |
---|
49 | 44 | ret = PTR_ERR(rng_clk); |
---|
50 | 45 | return ret; |
---|
51 | 46 | } |
---|
52 | 47 | |
---|
53 | | - clk_prepare_enable(rng_clk); |
---|
54 | | - |
---|
55 | 48 | ret = amba_request_regions(dev, dev->dev.init_name); |
---|
56 | 49 | if (ret) |
---|
57 | | - goto out_clk; |
---|
| 50 | + return ret; |
---|
58 | 51 | ret = -ENOMEM; |
---|
59 | 52 | base = devm_ioremap(&dev->dev, dev->res.start, |
---|
60 | 53 | resource_size(&dev->res)); |
---|
61 | 54 | if (!base) |
---|
62 | 55 | goto out_release; |
---|
63 | 56 | nmk_rng.priv = (unsigned long)base; |
---|
64 | | - ret = hwrng_register(&nmk_rng); |
---|
| 57 | + ret = devm_hwrng_register(&dev->dev, &nmk_rng); |
---|
65 | 58 | if (ret) |
---|
66 | 59 | goto out_release; |
---|
67 | 60 | return 0; |
---|
68 | 61 | |
---|
69 | 62 | out_release: |
---|
70 | 63 | amba_release_regions(dev); |
---|
71 | | -out_clk: |
---|
72 | | - clk_disable(rng_clk); |
---|
73 | 64 | return ret; |
---|
74 | 65 | } |
---|
75 | 66 | |
---|
76 | | -static int nmk_rng_remove(struct amba_device *dev) |
---|
| 67 | +static void nmk_rng_remove(struct amba_device *dev) |
---|
77 | 68 | { |
---|
78 | | - hwrng_unregister(&nmk_rng); |
---|
79 | 69 | amba_release_regions(dev); |
---|
80 | | - clk_disable(rng_clk); |
---|
81 | | - return 0; |
---|
82 | 70 | } |
---|
83 | 71 | |
---|
84 | | -static struct amba_id nmk_rng_ids[] = { |
---|
| 72 | +static const struct amba_id nmk_rng_ids[] = { |
---|
85 | 73 | { |
---|
86 | 74 | .id = 0x000805e1, |
---|
87 | 75 | .mask = 0x000fffff, /* top bits are rev and cfg: accept all */ |
---|