summaryrefslogtreecommitdiff
path: root/packages/linux/linux-rp-2.6.24/tosa/0026-I-don-t-think-we-should-check-for-IRQs-when-determin.patch
blob: e1323e4edcece890e8df8024d4992550bdd2948d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
From cbe46408b666983284e8be290950d526dbc0f0a4 Mon Sep 17 00:00:00 2001
From: Dmitry Baryshkov <dbaryshkov@gmail.com>
Date: Wed, 9 Jan 2008 02:08:16 +0300
Subject: [PATCH 26/64] I don't think we should check for IRQs when determining which one
 of power supplies to register. Better use is_{ac,usb}_online
 callbacks, this will not produce an obstacle to implement polling --
 when irqs aren't mandatory. I'll send my two pending patches to show
 the idea.

For this particular issue, I think something like that should work.
If it works for you, I'll commit that version, preserving your
authorship, of course.
---
 drivers/power/pda_power.c |   80 ++++++++++++++++++++++++--------------------
 1 files changed, 44 insertions(+), 36 deletions(-)

diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
index c058f28..d98622f 100644
--- a/drivers/power/pda_power.c
+++ b/drivers/power/pda_power.c
@@ -168,66 +168,74 @@ static int pda_power_probe(struct platform_device *pdev)
 		pda_power_supplies[1].num_supplicants = pdata->num_supplicants;
 	}
 
-	ret = power_supply_register(&pdev->dev, &pda_power_supplies[0]);
-	if (ret) {
-		dev_err(dev, "failed to register %s power supply\n",
-			pda_power_supplies[0].name);
-		goto supply0_failed;
-	}
+	if (pdata->is_ac_online) {
+		ret = power_supply_register(&pdev->dev, &pda_power_supplies[0]);
+		if (ret) {
+			dev_err(dev, "failed to register %s power supply\n",
+				pda_power_supplies[0].name);
+			goto ac_supply_failed;
+		}
 
-	ret = power_supply_register(&pdev->dev, &pda_power_supplies[1]);
-	if (ret) {
-		dev_err(dev, "failed to register %s power supply\n",
-			pda_power_supplies[1].name);
-		goto supply1_failed;
+		if (ac_irq) {
+			ret = request_irq(ac_irq->start, power_changed_isr,
+					  get_irq_flags(ac_irq), ac_irq->name,
+					  &pda_power_supplies[0]);
+			if (ret) {
+				dev_err(dev, "request ac irq failed\n");
+				goto ac_irq_failed;
+			}
+		}
 	}
 
-	if (ac_irq) {
-		ret = request_irq(ac_irq->start, power_changed_isr,
-				  get_irq_flags(ac_irq), ac_irq->name,
-				  &pda_power_supplies[0]);
+	if (pdata->is_usb_online) {
+		ret = power_supply_register(&pdev->dev, &pda_power_supplies[1]);
 		if (ret) {
-			dev_err(dev, "request ac irq failed\n");
-			goto ac_irq_failed;
+			dev_err(dev, "failed to register %s power supply\n",
+				pda_power_supplies[1].name);
+			goto usb_supply_failed;
 		}
-	}
 
-	if (usb_irq) {
-		ret = request_irq(usb_irq->start, power_changed_isr,
-				  get_irq_flags(usb_irq), usb_irq->name,
-				  &pda_power_supplies[1]);
-		if (ret) {
-			dev_err(dev, "request usb irq failed\n");
-			goto usb_irq_failed;
+		if (usb_irq) {
+			ret = request_irq(usb_irq->start, power_changed_isr,
+					  get_irq_flags(usb_irq),
+					  usb_irq->name,
+					  &pda_power_supplies[1]);
+			if (ret) {
+				dev_err(dev, "request usb irq failed\n");
+				goto usb_irq_failed;
+			}
 		}
 	}
 
-	goto success;
+	return 0;
 
 usb_irq_failed:
-	if (ac_irq)
+	if (pdata->is_usb_online)
+		power_supply_unregister(&pda_power_supplies[1]);
+usb_supply_failed:
+	if (pdata->is_ac_online && ac_irq)
 		free_irq(ac_irq->start, &pda_power_supplies[0]);
 ac_irq_failed:
-	power_supply_unregister(&pda_power_supplies[1]);
-supply1_failed:
-	power_supply_unregister(&pda_power_supplies[0]);
-supply0_failed:
+	if (pdata->is_ac_online)
+		power_supply_unregister(&pda_power_supplies[0]);
+ac_supply_failed:
 noirqs:
 wrongid:
-success:
 	return ret;
 }
 
 static int pda_power_remove(struct platform_device *pdev)
 {
-	if (usb_irq)
+	if (pdata->is_usb_online && usb_irq)
 		free_irq(usb_irq->start, &pda_power_supplies[1]);
-	if (ac_irq)
+	if (pdata->is_ac_online && ac_irq)
 		free_irq(ac_irq->start, &pda_power_supplies[0]);
 	del_timer_sync(&charger_timer);
 	del_timer_sync(&supply_timer);
-	power_supply_unregister(&pda_power_supplies[1]);
-	power_supply_unregister(&pda_power_supplies[0]);
+	if (pdata->is_usb_online)
+		power_supply_unregister(&pda_power_supplies[1]);
+	if (pdata->is_ac_online)
+		power_supply_unregister(&pda_power_supplies[0]);
 	return 0;
 }
 
-- 
1.5.3.8