hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/input/misc/rk805-pwrkey.c
....@@ -1,14 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Rockchip RK805 PMIC Power Key driver
34 *
45 * Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd
56 *
67 * Author: Joseph Chen <chenjh@rock-chips.com>
7
- *
8
- * This program is free software; you can redistribute it and/or modify it
9
- * under the terms of the GNU General Public License as published by the
10
- * Free Software Foundation; either version 2 of the License, or (at your
11
- * option) any later version.
128 */
139
1410 #include <linux/errno.h>
....@@ -17,6 +13,7 @@
1713 #include <linux/interrupt.h>
1814 #include <linux/kernel.h>
1915 #include <linux/module.h>
16
+#include <linux/of.h>
2017 #include <linux/platform_device.h>
2118
2219 static irqreturn_t pwrkey_fall_irq(int irq, void *_pwr)
....@@ -43,7 +40,14 @@
4340 {
4441 struct input_dev *pwr;
4542 int fall_irq, rise_irq;
43
+ struct device_node *np;
4644 int err;
45
+
46
+ np = of_get_child_by_name(pdev->dev.parent->of_node, "pwrkey");
47
+ if (np && !of_device_is_available(np)) {
48
+ dev_info(&pdev->dev, "device is disabled\n");
49
+ return -EINVAL;
50
+ }
4751
4852 pwr = devm_input_allocate_device(&pdev->dev);
4953 if (!pwr) {
....@@ -57,16 +61,12 @@
5761 input_set_capability(pwr, EV_KEY, KEY_POWER);
5862
5963 fall_irq = platform_get_irq(pdev, 0);
60
- if (fall_irq < 0) {
61
- dev_err(&pdev->dev, "Can't get fall irq: %d\n", fall_irq);
64
+ if (fall_irq < 0)
6265 return fall_irq;
63
- }
6466
6567 rise_irq = platform_get_irq(pdev, 1);
66
- if (rise_irq < 0) {
67
- dev_err(&pdev->dev, "Can't get rise irq: %d\n", rise_irq);
68
+ if (rise_irq < 0)
6869 return rise_irq;
69
- }
7070
7171 err = devm_request_any_context_irq(&pwr->dev, fall_irq,
7272 pwrkey_fall_irq,
....@@ -106,6 +106,7 @@
106106 };
107107 module_platform_driver(rk805_pwrkey_driver);
108108
109
+MODULE_ALIAS("platform:rk805-pwrkey");
109110 MODULE_AUTHOR("Joseph Chen <chenjh@rock-chips.com>");
110111 MODULE_DESCRIPTION("RK805 PMIC Power Key driver");
111112 MODULE_LICENSE("GPL");