hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/char/hw_random/omap-rng.c
....@@ -22,6 +22,7 @@
2222 #include <linux/platform_device.h>
2323 #include <linux/hw_random.h>
2424 #include <linux/delay.h>
25
+#include <linux/kernel.h>
2526 #include <linux/slab.h>
2627 #include <linux/pm_runtime.h>
2728 #include <linux/of.h>
....@@ -243,7 +244,6 @@
243244 .cleanup = omap2_rng_cleanup,
244245 };
245246
246
-#if defined(CONFIG_OF)
247247 static inline u32 omap4_rng_data_present(struct omap_rng_dev *priv)
248248 {
249249 return omap_rng_read(priv, RNG_STATUS_REG) & RNG_REG_STATUS_RDY;
....@@ -358,7 +358,7 @@
358358 .cleanup = omap4_rng_cleanup,
359359 };
360360
361
-static const struct of_device_id omap_rng_of_match[] = {
361
+static const struct of_device_id omap_rng_of_match[] __maybe_unused = {
362362 {
363363 .compatible = "ti,omap2-rng",
364364 .data = &omap2_rng_pdata,
....@@ -392,11 +392,8 @@
392392 if (of_device_is_compatible(dev->of_node, "ti,omap4-rng") ||
393393 of_device_is_compatible(dev->of_node, "inside-secure,safexcel-eip76")) {
394394 irq = platform_get_irq(pdev, 0);
395
- if (irq < 0) {
396
- dev_err(dev, "%s: error getting IRQ resource - %d\n",
397
- __func__, irq);
395
+ if (irq < 0)
398396 return irq;
399
- }
400397
401398 err = devm_request_irq(dev, irq, omap4_rng_irq,
402399 IRQF_TRIGGER_NONE, dev_name(dev), priv);
....@@ -421,13 +418,6 @@
421418 }
422419 return 0;
423420 }
424
-#else
425
-static int of_get_omap_rng_device_details(struct omap_rng_dev *omap_rng,
426
- struct platform_device *pdev)
427
-{
428
- return -EINVAL;
429
-}
430
-#endif
431421
432422 static int get_omap_rng_device_details(struct omap_rng_dev *omap_rng)
433423 {
....@@ -439,7 +429,6 @@
439429 static int omap_rng_probe(struct platform_device *pdev)
440430 {
441431 struct omap_rng_dev *priv;
442
- struct resource *res;
443432 struct device *dev = &pdev->dev;
444433 int ret;
445434
....@@ -456,8 +445,7 @@
456445 platform_set_drvdata(pdev, priv);
457446 priv->dev = dev;
458447
459
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
460
- priv->base = devm_ioremap_resource(dev, res);
448
+ priv->base = devm_platform_ioremap_resource(pdev, 0);
461449 if (IS_ERR(priv->base)) {
462450 ret = PTR_ERR(priv->base);
463451 goto err_ioremap;
....@@ -478,7 +466,7 @@
478466 }
479467
480468 priv->clk = devm_clk_get(&pdev->dev, NULL);
481
- if (IS_ERR(priv->clk) && PTR_ERR(priv->clk) == -EPROBE_DEFER)
469
+ if (PTR_ERR(priv->clk) == -EPROBE_DEFER)
482470 return -EPROBE_DEFER;
483471 if (!IS_ERR(priv->clk)) {
484472 ret = clk_prepare_enable(priv->clk);
....@@ -490,7 +478,7 @@
490478 }
491479
492480 priv->clk_reg = devm_clk_get(&pdev->dev, "reg");
493
- if (IS_ERR(priv->clk_reg) && PTR_ERR(priv->clk_reg) == -EPROBE_DEFER)
481
+ if (PTR_ERR(priv->clk_reg) == -EPROBE_DEFER)
494482 return -EPROBE_DEFER;
495483 if (!IS_ERR(priv->clk_reg)) {
496484 ret = clk_prepare_enable(priv->clk_reg);
....@@ -507,7 +495,7 @@
507495 if (ret)
508496 goto err_register;
509497
510
- ret = hwrng_register(&priv->rng);
498
+ ret = devm_hwrng_register(&pdev->dev, &priv->rng);
511499 if (ret)
512500 goto err_register;
513501
....@@ -532,7 +520,6 @@
532520 {
533521 struct omap_rng_dev *priv = platform_get_drvdata(pdev);
534522
535
- hwrng_unregister(&priv->rng);
536523
537524 priv->pdata->cleanup(priv);
538525