aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/s3c24xx/patches-2.6.26/1183-fix-pcf50633-use-pcf-not-data-in-probe-for-context.p.patch
blob: 360052aaf0951bfff955567d49d9ed09ffcfd134 (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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
From 22bdcec1c140689c6fce71ca04d7afcaa44d52f0 Mon Sep 17 00:00:00 2001
From: Andy Green <andy@openmoko.com>
Date: Fri, 25 Jul 2008 23:06:15 +0100
Subject: [PATCH] fix-pcf50633-use-pcf-not-data-in-probe-for-context.patch

Everywhere in the sources except the probe function the context
pointer is called "pcf"... in there it's called "data" for some
reason.  This stops confusion by changing it to be "pcf" in there
as well.

Signed-off-by: Andy Green <andy@openmoko.com>
---
 drivers/i2c/chips/pcf50633.c |  117 +++++++++++++++++++++--------------------
 1 files changed, 60 insertions(+), 57 deletions(-)

diff --git a/drivers/i2c/chips/pcf50633.c b/drivers/i2c/chips/pcf50633.c
index 850bf93..4cb333c 100644
--- a/drivers/i2c/chips/pcf50633.c
+++ b/drivers/i2c/chips/pcf50633.c
@@ -2063,7 +2063,7 @@ static void populate_sysfs_group(struct pcf50633_data *pcf)
 static int pcf50633_detect(struct i2c_adapter *adapter, int address, int kind)
 {
 	struct i2c_client *new_client;
-	struct pcf50633_data *data;
+	struct pcf50633_data *pcf;
 	int err = 0;
 	int irq;
 
@@ -2086,23 +2086,24 @@ static int pcf50633_detect(struct i2c_adapter *adapter, int address, int kind)
 		return -EBUSY;
 	}
 
-	if (!(data = kzalloc(sizeof(*data), GFP_KERNEL)))
+	pcf = kzalloc(sizeof(*pcf), GFP_KERNEL);
+	if (!pcf)
 		return -ENOMEM;
 
-	mutex_init(&data->lock);
-	mutex_init(&data->working_lock);
-	mutex_init(&data->working_lock_nobat);
-	mutex_init(&data->working_lock_usb_curlimit);
-	INIT_WORK(&data->work, pcf50633_work);
-	INIT_WORK(&data->work_nobat, pcf50633_work_nobat);
-	INIT_WORK(&data->work_usb_curlimit, pcf50633_work_usbcurlim);
-	data->irq = irq;
-	data->working = 0;
-	data->onkey_seconds = -1;
-	data->pdata = pcf50633_pdev->dev.platform_data;
-
-	new_client = &data->client;
-	i2c_set_clientdata(new_client, data);
+	mutex_init(&pcf->lock);
+	mutex_init(&pcf->working_lock);
+	mutex_init(&pcf->working_lock_nobat);
+	mutex_init(&pcf->working_lock_usb_curlimit);
+	INIT_WORK(&pcf->work, pcf50633_work);
+	INIT_WORK(&pcf->work_nobat, pcf50633_work_nobat);
+	INIT_WORK(&pcf->work_usb_curlimit, pcf50633_work_usbcurlim);
+	pcf->irq = irq;
+	pcf->working = 0;
+	pcf->onkey_seconds = -1;
+	pcf->pdata = pcf50633_pdev->dev.platform_data;
+
+	new_client = &pcf->client;
+	i2c_set_clientdata(new_client, pcf);
 	new_client->addr = address;
 	new_client->adapter = adapter;
 	new_client->driver = &pcf50633_driver;
@@ -2118,11 +2119,11 @@ static int pcf50633_detect(struct i2c_adapter *adapter, int address, int kind)
 		goto exit_free;
 	}
 
-	pcf50633_global = data;
+	pcf50633_global = pcf;
 
-	init_resume_dependency_list(&data->resume_dependency);
+	init_resume_dependency_list(&pcf->resume_dependency);
 
-	populate_sysfs_group(data);
+	populate_sysfs_group(pcf);
 
 	err = sysfs_create_group(&new_client->dev.kobj, &pcf_attr_group);
 	if (err) {
@@ -2135,32 +2136,35 @@ static int pcf50633_detect(struct i2c_adapter *adapter, int address, int kind)
 	/* register power off handler with core power management */
 	pm_power_off = &pcf50633_go_standby;
 
-	data->input_dev = input_allocate_device();
-	if (!data->input_dev)
+	pcf->input_dev = input_allocate_device();
+	if (!pcf->input_dev)
 		goto exit_sysfs;
 
-	data->input_dev->name = "GTA02 PMU events";
-	data->input_dev->phys = "FIXME";
-	data->input_dev->id.bustype = BUS_I2C;
+	pcf->input_dev->name = "GTA02 PMU events";
+	pcf->input_dev->phys = "FIXME";
+	pcf->input_dev->id.bustype = BUS_I2C;
+	pcf->input_dev->cdev.dev = &new_client->dev;
 
-	data->input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_PWR);
-	set_bit(KEY_POWER, data->input_dev->keybit);
-	set_bit(KEY_POWER2, data->input_dev->keybit);
-	set_bit(KEY_BATTERY, data->input_dev->keybit);
+	pcf->input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_PWR);
+	set_bit(KEY_POWER, pcf->input_dev->keybit);
+	set_bit(KEY_POWER2, pcf->input_dev->keybit);
+	set_bit(KEY_BATTERY, pcf->input_dev->keybit);
 
-	err = input_register_device(data->input_dev);
+	err = input_register_device(pcf->input_dev);
 	if (err)
 		goto exit_sysfs;
 
 	/* configure interrupt mask */
-	reg_write(data, PCF50633_REG_INT1M, 0x00); /* we want SECOND to kick */
-	reg_write(data, PCF50633_REG_INT2M, 0x00);
-	reg_write(data, PCF50633_REG_INT3M, 0x00);
-	reg_write(data, PCF50633_REG_INT4M, 0x00);
-	reg_write(data, PCF50633_REG_INT5M, 0x00);
+
+	/* we want SECOND to kick for the coldplug initialisation */
+	reg_write(pcf, PCF50633_REG_INT1M, 0x00);
+	reg_write(pcf, PCF50633_REG_INT2M, 0x00);
+	reg_write(pcf, PCF50633_REG_INT3M, 0x00);
+	reg_write(pcf, PCF50633_REG_INT4M, 0x00);
+	reg_write(pcf, PCF50633_REG_INT5M, 0x00);
 
 	err = request_irq(irq, pcf50633_irq, IRQF_TRIGGER_FALLING,
-			  "pcf50633", data);
+			  "pcf50633", pcf);
 	if (err < 0)
 		goto exit_input;
 
@@ -2168,59 +2172,58 @@ static int pcf50633_detect(struct i2c_adapter *adapter, int address, int kind)
 		dev_err(&new_client->dev, "IRQ %u cannot be enabled as wake-up"
 		        "source in this hardware revision!", irq);
 
-	if (data->pdata->used_features & PCF50633_FEAT_RTC) {
-		data->rtc = rtc_device_register("pcf50633", &new_client->dev,
+	if (pcf->pdata->used_features & PCF50633_FEAT_RTC) {
+		pcf->rtc = rtc_device_register("pcf50633", &new_client->dev,
 						&pcf50633_rtc_ops, THIS_MODULE);
-		if (IS_ERR(data->rtc)) {
-			err = PTR_ERR(data->rtc);
+		if (IS_ERR(pcf->rtc)) {
+			err = PTR_ERR(pcf->rtc);
 			goto exit_irq;
 		}
 	}
 
-	if (data->pdata->used_features & PCF50633_FEAT_PWM_BL) {
-		data->backlight = backlight_device_register("pcf50633-bl",
+	if (pcf->pdata->used_features & PCF50633_FEAT_PWM_BL) {
+		pcf->backlight = backlight_device_register("pcf50633-bl",
 							    &new_client->dev,
-							    data,
+							    pcf,
 							    &pcf50633bl_ops);
-		if (!data->backlight)
+		if (!pcf->backlight)
 			goto exit_rtc;
 		/* FIXME: are we sure we want default == off? */
-		data->backlight->props.max_brightness = 0x3f;
-		data->backlight->props.power = FB_BLANK_UNBLANK;
-		data->backlight->props.fb_blank = FB_BLANK_UNBLANK;
-		data->backlight->props.brightness =
-					data->backlight->props.max_brightness;
-		backlight_update_status(data->backlight);
+		pcf->backlight->props.max_brightness = 0x3f;
+		pcf->backlight->props.power = FB_BLANK_UNBLANK;
+		pcf->backlight->props.fb_blank = FB_BLANK_UNBLANK;
+		pcf->backlight->props.brightness =
+					pcf->backlight->props.max_brightness;
+		backlight_update_status(pcf->backlight);
 	}
 
-	apm_get_power_status = pcf50633_get_power_status;
-	data->probe_completed = 1;
+	pcf->probe_completed = 1;
 
-	if (data->pdata->flag_use_apm_emulation)
+	if (pcf->pdata->flag_use_apm_emulation)
 		apm_get_power_status = pcf50633_get_power_status;
 
 	/* if platform was interested, give him a chance to register
 	 * platform devices that switch power with us as the parent
 	 * at registration time -- ensures suspend / resume ordering
 	 */
-	if (data->pdata->attach_child_devices)
-		(data->pdata->attach_child_devices)(&new_client->dev);
+	if (pcf->pdata->attach_child_devices)
+		(pcf->pdata->attach_child_devices)(&new_client->dev);
 
 	return 0;
 exit_rtc:
-	if (data->pdata->used_features & PCF50633_FEAT_RTC)
+	if (pcf->pdata->used_features & PCF50633_FEAT_RTC)
 		rtc_device_unregister(pcf50633_global->rtc);
 exit_irq:
 	free_irq(pcf50633_global->irq, pcf50633_global);
 exit_input:
-	input_unregister_device(data->input_dev);
+	input_unregister_device(pcf->input_dev);
 exit_sysfs:
 	pm_power_off = NULL;
 	sysfs_remove_group(&new_client->dev.kobj, &pcf_attr_group);
 exit_detach:
 	i2c_detach_client(new_client);
 exit_free:
-	kfree(data);
+	kfree(pcf);
 	pcf50633_global = NULL;
 	return err;
 }
-- 
1.5.6.3