forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/drivers/mfd/fsl-imx25-tsadc.c
....@@ -1,9 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2014-2015 Pengutronix, Markus Pargmann <mpa@pengutronix.de>
3
- *
4
- * This program is free software; you can redistribute it and/or modify it under
5
- * the terms of the GNU General Public License version 2 as published by the
6
- * Free Software Foundation.
74 */
85
96 #include <linux/clk.h>
....@@ -72,10 +69,8 @@
7269 int irq;
7370
7471 irq = platform_get_irq(pdev, 0);
75
- if (irq <= 0) {
76
- dev_err(dev, "Failed to get irq\n");
72
+ if (irq < 0)
7773 return irq;
78
- }
7974
8075 tsadc->domain = irq_domain_add_simple(np, 2, 0, &mx25_tsadc_domain_ops,
8176 tsadc);
....@@ -85,6 +80,19 @@
8580 }
8681
8782 irq_set_chained_handler_and_data(irq, mx25_tsadc_irq_handler, tsadc);
83
+
84
+ return 0;
85
+}
86
+
87
+static int mx25_tsadc_unset_irq(struct platform_device *pdev)
88
+{
89
+ struct mx25_tsadc *tsadc = platform_get_drvdata(pdev);
90
+ int irq = platform_get_irq(pdev, 0);
91
+
92
+ if (irq >= 0) {
93
+ irq_set_chained_handler_and_data(irq, NULL, NULL);
94
+ irq_domain_remove(tsadc->domain);
95
+ }
8896
8997 return 0;
9098 }
....@@ -176,18 +184,21 @@
176184
177185 platform_set_drvdata(pdev, tsadc);
178186
179
- return devm_of_platform_populate(dev);
187
+ ret = devm_of_platform_populate(dev);
188
+ if (ret)
189
+ goto err_irq;
190
+
191
+ return 0;
192
+
193
+err_irq:
194
+ mx25_tsadc_unset_irq(pdev);
195
+
196
+ return ret;
180197 }
181198
182199 static int mx25_tsadc_remove(struct platform_device *pdev)
183200 {
184
- struct mx25_tsadc *tsadc = platform_get_drvdata(pdev);
185
- int irq = platform_get_irq(pdev, 0);
186
-
187
- if (irq) {
188
- irq_set_chained_handler_and_data(irq, NULL, NULL);
189
- irq_domain_remove(tsadc->domain);
190
- }
201
+ mx25_tsadc_unset_irq(pdev);
191202
192203 return 0;
193204 }