| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * ST Random Number Generator Driver ST's Platforms |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 5 | 6 | * Lee Jones <lee.jones@linaro.org> |
|---|
| 6 | 7 | * |
|---|
| 7 | 8 | * 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. |
|---|
| 12 | 9 | */ |
|---|
| 13 | 10 | |
|---|
| 14 | 11 | #include <linux/clk.h> |
|---|
| 15 | 12 | #include <linux/delay.h> |
|---|
| 16 | 13 | #include <linux/hw_random.h> |
|---|
| 17 | 14 | #include <linux/io.h> |
|---|
| 15 | +#include <linux/kernel.h> |
|---|
| 18 | 16 | #include <linux/module.h> |
|---|
| 19 | 17 | #include <linux/of.h> |
|---|
| 20 | 18 | #include <linux/platform_device.h> |
|---|
| .. | .. |
|---|
| 75 | 73 | static int st_rng_probe(struct platform_device *pdev) |
|---|
| 76 | 74 | { |
|---|
| 77 | 75 | struct st_rng_data *ddata; |
|---|
| 78 | | - struct resource *res; |
|---|
| 79 | 76 | struct clk *clk; |
|---|
| 80 | 77 | void __iomem *base; |
|---|
| 81 | 78 | int ret; |
|---|
| .. | .. |
|---|
| 84 | 81 | if (!ddata) |
|---|
| 85 | 82 | return -ENOMEM; |
|---|
| 86 | 83 | |
|---|
| 87 | | - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
|---|
| 88 | | - base = devm_ioremap_resource(&pdev->dev, res); |
|---|
| 84 | + base = devm_platform_ioremap_resource(pdev, 0); |
|---|
| 89 | 85 | if (IS_ERR(base)) |
|---|
| 90 | 86 | return PTR_ERR(base); |
|---|
| 91 | 87 | |
|---|
| .. | .. |
|---|
| 105 | 101 | |
|---|
| 106 | 102 | dev_set_drvdata(&pdev->dev, ddata); |
|---|
| 107 | 103 | |
|---|
| 108 | | - ret = hwrng_register(&ddata->ops); |
|---|
| 104 | + ret = devm_hwrng_register(&pdev->dev, &ddata->ops); |
|---|
| 109 | 105 | if (ret) { |
|---|
| 110 | 106 | dev_err(&pdev->dev, "Failed to register HW RNG\n"); |
|---|
| 111 | 107 | clk_disable_unprepare(clk); |
|---|
| .. | .. |
|---|
| 121 | 117 | { |
|---|
| 122 | 118 | struct st_rng_data *ddata = dev_get_drvdata(&pdev->dev); |
|---|
| 123 | 119 | |
|---|
| 124 | | - hwrng_unregister(&ddata->ops); |
|---|
| 125 | | - |
|---|
| 126 | 120 | clk_disable_unprepare(ddata->clk); |
|---|
| 127 | 121 | |
|---|
| 128 | 122 | return 0; |
|---|
| 129 | 123 | } |
|---|
| 130 | 124 | |
|---|
| 131 | | -static const struct of_device_id st_rng_match[] = { |
|---|
| 125 | +static const struct of_device_id st_rng_match[] __maybe_unused = { |
|---|
| 132 | 126 | { .compatible = "st,rng" }, |
|---|
| 133 | 127 | {}, |
|---|
| 134 | 128 | }; |
|---|