treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / power / reset / rmobile-reset.c
blobbd3b396558e0df8c469ddc18869620289885665e
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Renesas R-Mobile Reset Driver
5 * Copyright (C) 2014 Glider bvba
6 */
8 #include <linux/io.h>
9 #include <linux/module.h>
10 #include <linux/notifier.h>
11 #include <linux/of_address.h>
12 #include <linux/platform_device.h>
13 #include <linux/printk.h>
14 #include <linux/reboot.h>
16 /* SYSC Register Bank 2 */
17 #define RESCNT2 0x20 /* Reset Control Register 2 */
19 /* Reset Control Register 2 */
20 #define RESCNT2_PRES 0x80000000 /* Soft power-on reset */
22 static void __iomem *sysc_base2;
24 static int rmobile_reset_handler(struct notifier_block *this,
25 unsigned long mode, void *cmd)
27 pr_debug("%s %lu\n", __func__, mode);
29 /* Let's assume we have acquired the HPB semaphore */
30 writel(RESCNT2_PRES, sysc_base2 + RESCNT2);
32 return NOTIFY_DONE;
35 static struct notifier_block rmobile_reset_nb = {
36 .notifier_call = rmobile_reset_handler,
37 .priority = 192,
40 static int rmobile_reset_probe(struct platform_device *pdev)
42 int error;
44 sysc_base2 = of_iomap(pdev->dev.of_node, 1);
45 if (!sysc_base2)
46 return -ENODEV;
48 error = register_restart_handler(&rmobile_reset_nb);
49 if (error) {
50 dev_err(&pdev->dev,
51 "cannot register restart handler (err=%d)\n", error);
52 goto fail_unmap;
55 return 0;
57 fail_unmap:
58 iounmap(sysc_base2);
59 return error;
62 static int rmobile_reset_remove(struct platform_device *pdev)
64 unregister_restart_handler(&rmobile_reset_nb);
65 iounmap(sysc_base2);
66 return 0;
69 static const struct of_device_id rmobile_reset_of_match[] = {
70 { .compatible = "renesas,sysc-rmobile", },
71 { /* sentinel */ }
73 MODULE_DEVICE_TABLE(of, rmobile_reset_of_match);
75 static struct platform_driver rmobile_reset_driver = {
76 .probe = rmobile_reset_probe,
77 .remove = rmobile_reset_remove,
78 .driver = {
79 .name = "rmobile_reset",
80 .of_match_table = rmobile_reset_of_match,
84 module_platform_driver(rmobile_reset_driver);
86 MODULE_DESCRIPTION("Renesas R-Mobile Reset Driver");
87 MODULE_AUTHOR("Geert Uytterhoeven <geert+renesas@glider.be>");
88 MODULE_LICENSE("GPL v2");