summaryrefslogtreecommitdiff
path: root/packages/linux/linux-2.6.18/mmc-add-bit-manipulating-macros.patch
blob: 544e447580a9e0541310537436a30c6b105d1f26 (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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
Index: linux-2.6.18/drivers/mmc/atmel-mci.c
===================================================================
--- linux-2.6.18.orig/drivers/mmc/atmel-mci.c	2007-01-15 16:36:59.000000000 +0100
+++ linux-2.6.18/drivers/mmc/atmel-mci.c	2007-01-16 13:18:40.000000000 +0100
@@ -45,6 +45,7 @@
 	EVENT_STOP_COMPLETE,
 	EVENT_STOP_ERROR,
 	EVENT_DMA_ERROR,
+	EVENT_CARD_DETECT,
 };
 
 struct atmel_mci_dma {
@@ -572,9 +589,8 @@
 	 * Data might complete before command for very short transfers
 	 * (like READ_SCR)
 	 */
-	if (test_bit(EVENT_CMD_COMPLETE, &host->completed_events)
-	    && (!data->stop
-		|| test_bit(EVENT_STOP_COMPLETE, &host->completed_events)))
+	if (mci_cmd_is_complete(host)
+			&& (!data->stop || mci_stop_is_complete(host)))
 		atmci_request_end(host->mmc, data->mrq);
 }
 
@@ -604,11 +620,11 @@
 		 host->pending_events, host->completed_events,
 		 mci_readl(host, IMR));
 
-	if (test_and_clear_bit(EVENT_CMD_ERROR, &host->pending_events)) {
+	if (mci_clear_cmd_error_is_pending(host)) {
 		struct mmc_command *cmd;
 
-		set_bit(EVENT_CMD_ERROR, &host->completed_events);
-		clear_bit(EVENT_CMD_COMPLETE, &host->pending_events);
+		mci_set_cmd_error_complete(host);
+		mci_clear_cmd_pending(host);
 		cmd = host->mrq->cmd;
 
 		if (cmd->data) {
@@ -620,28 +636,27 @@
 		atmci_command_error(mmc, cmd, host->error_status);
 		atmci_request_end(mmc, cmd->mrq);
 	}
-	if (test_and_clear_bit(EVENT_STOP_ERROR, &host->pending_events)) {
-		set_bit(EVENT_STOP_ERROR, &host->completed_events);
-		clear_bit(EVENT_STOP_COMPLETE, &host->pending_events);
+	if (mci_clear_stop_error_is_pending(host)) {
+		mci_set_stop_error_complete(host);
+		mci_clear_stop_pending(host);
 		atmci_command_error(mmc, host->mrq->stop,
 				    host->error_status);
 		if (!host->data)
 			atmci_request_end(mmc, host->mrq);
 	}
-	if (test_and_clear_bit(EVENT_CMD_COMPLETE, &host->pending_events)) {
-		set_bit(EVENT_CMD_COMPLETE, &host->completed_events);
-		if (!mrq->data
-		    || test_bit(EVENT_DATA_COMPLETE, &host->completed_events))
+	if (mci_clear_cmd_is_pending(host)) {
+		mci_set_cmd_complete(host);
+		if (!mrq->data || mci_data_is_complete(host))
 			atmci_request_end(mmc, mrq);
 	}
-	if (test_and_clear_bit(EVENT_STOP_COMPLETE, &host->pending_events)) {
-		set_bit(EVENT_STOP_COMPLETE, &host->completed_events);
-		if (test_bit(EVENT_DATA_COMPLETE, &host->completed_events))
+	if (mci_clear_stop_is_pending(host)) {
+		mci_set_stop_complete(host);
+		if (mci_data_is_complete(host))
 			atmci_request_end(mmc, mrq);
 	}
-	if (test_and_clear_bit(EVENT_DMA_ERROR, &host->pending_events)) {
-		set_bit(EVENT_DMA_ERROR, &host->completed_events);
-		clear_bit(EVENT_DATA_COMPLETE, &host->pending_events);
+	if (mci_clear_dma_error_is_pending(host)) {
+		mci_set_dma_error_complete(host);
+		mci_clear_data_pending(host);
 
 		/* DMA controller got bus error => invalid address */
 		data->error = MMC_ERR_INVALID;
@@ -650,18 +665,17 @@
 		       mmc_hostname(mmc), host->data->bytes_xfered);
 
 		if (data->stop
-		    && !test_and_set_bit(EVENT_STOP_SENT,
-					 &host->completed_events))
+		    && !mci_set_stop_sent_is_completed(host))
 			/* TODO: Check if card is still present */
 			send_stop_cmd(host->mmc, data, 0);
 
 		atmci_data_complete(host, data);
 	}
-	if (test_and_clear_bit(EVENT_DATA_ERROR, &host->pending_events)) {
+	if (mci_clear_data_error_is_pending(host)) {
 		u32 status = host->error_status;
 
-		set_bit(EVENT_DATA_ERROR, &host->completed_events);
-		clear_bit(EVENT_DATA_COMPLETE, &host->pending_events);
+		mci_set_data_error_complete(host);
+		mci_clear_data_pending(host);
 
 		dma_stop_request(host->dma.req.req.dmac,
 				 host->dma.req.req.channel);
@@ -686,14 +700,14 @@
 		       mmc_hostname(host->mmc), data->bytes_xfered);
 
 		if (data->stop
-		    && !test_and_set_bit(EVENT_STOP_SENT, &host->completed_events))
+		    && !mci_set_stop_sent_is_completed(host))
 			/* TODO: Check if card is still present */
 			send_stop_cmd(host->mmc, data, 0);
 
 		atmci_data_complete(host, data);
 	}
-	if (test_and_clear_bit(EVENT_DATA_COMPLETE, &host->pending_events)) {
-		set_bit(EVENT_DATA_COMPLETE, &host->completed_events);
+	if (mci_clear_data_is_pending(host)) {
+		mci_set_data_complete(host);
 		data->bytes_xfered = data->blocks * data->blksz;
 		atmci_data_complete(host, data);
 	}
@@ -716,10 +761,10 @@
 	mci_writel(host, IDR, MCI_BIT(CMDRDY) | MCI_CMD_ERROR_FLAGS);
 	host->cmd = NULL;
 
-	if (test_bit(EVENT_STOP_SENT, &host->completed_events))
-		set_bit(EVENT_STOP_COMPLETE, &host->pending_events);
+	if (mci_stop_sent_is_complete(host))
+		mci_set_stop_pending(host);
 	else
-		set_bit(EVENT_CMD_COMPLETE, &host->pending_events);
+		mci_set_cmd_pending(host);
 
 	tasklet_schedule(&host->tasklet);
 }
@@ -735,13 +780,12 @@
 	host = container_of(dma, struct atmel_mci, dma);
 	data = host->data;
 
-	if (data->stop && !test_and_set_bit(EVENT_STOP_SENT,
-					    &host->completed_events))
+	if (data->stop && !mci_set_stop_sent_is_completed(host))
 		send_stop_cmd(host->mmc, data, 0);
 
 	if (data->flags & MMC_DATA_READ) {
 		mci_writel(host, IDR, MCI_DATA_ERROR_FLAGS);
-		set_bit(EVENT_DATA_COMPLETE, &host->pending_events);
+		mci_set_data_pending(host);
 		tasklet_schedule(&host->tasklet);
 	} else {
 		/*
@@ -765,7 +809,7 @@
 	mci_writel(host, IDR, (MCI_BIT(NOTBUSY)
 			       | MCI_DATA_ERROR_FLAGS));
 
-	set_bit(EVENT_DMA_ERROR, &host->pending_events);
+	mci_set_dma_error_pending(host);
 	tasklet_schedule(&host->tasklet);
 }
 
@@ -790,10 +834,10 @@
 					       | MCI_DATA_ERROR_FLAGS));
 			host->error_status = status;
 			host->cmd = NULL;
-			if (test_bit(EVENT_STOP_SENT, &host->completed_events))
-				set_bit(EVENT_STOP_ERROR, &host->pending_events);
+			if (mci_stop_sent_is_complete(host))
+				mci_set_stop_error_pending(host);
 			else
-				set_bit(EVENT_CMD_ERROR, &host->pending_events);
+				mci_set_cmd_error_pending(host);
 			tasklet_schedule(&host->tasklet);
 			break;
 		}
@@ -801,7 +845,7 @@
 			mci_writel(host, IDR, (MCI_BIT(NOTBUSY)
 					       | MCI_DATA_ERROR_FLAGS));
 			host->error_status = status;
-			set_bit(EVENT_DATA_ERROR, &host->pending_events);
+			mci_set_data_error_pending(host);
 			tasklet_schedule(&host->tasklet);
 			break;
 		}
@@ -810,7 +854,7 @@
 		if (pending & MCI_BIT(NOTBUSY)) {
 			mci_writel(host, IDR, (MCI_BIT(NOTBUSY)
 					       | MCI_DATA_ERROR_FLAGS));
-			set_bit(EVENT_DATA_COMPLETE, &host->pending_events);
+			mci_set_data_pending(host);
 			tasklet_schedule(&host->tasklet);
 		}
 
Index: linux-2.6.18/drivers/mmc/atmel-mci.h
===================================================================
--- linux-2.6.18.orig/drivers/mmc/atmel-mci.h	2007-01-16 13:22:59.000000000 +0100
+++ linux-2.6.18/drivers/mmc/atmel-mci.h	2007-01-16 13:24:33.000000000 +0100
@@ -189,4 +189,124 @@
 #define mci_writel(port,reg,value)			\
 	__raw_writel((value), (port)->regs + MCI_##reg)
 
+/* Test bit macros for completed events */
+#define mci_cmd_is_complete(host)			\
+	test_bit(EVENT_CMD_COMPLETE, &host->completed_events)
+#define mci_cmd_error_is_complete(host)			\
+	test_bit(EVENT_CMD_ERROR, &host->completed_events)
+#define mci_data_is_complete(host)			\
+	test_bit(EVENT_DATA_COMPLETE, &host->completed_events)
+#define mci_data_error_is_complete(host)		\
+	test_bit(EVENT_DATA_ERROR, &host->completed_events)
+#define mci_stop_sent_is_complete(host)			\
+	test_bit(EVENT_STOP_SENT, &host->completed_events)
+#define mci_stop_is_complete(host)			\
+	test_bit(EVENT_STOP_COMPLETE, &host->completed_events)
+#define mci_stop_error_is_complete(host)		\
+	test_bit(EVENT_STOP_ERROR, &host->completed_events)
+#define mci_dma_error_is_complete(host)			\
+	test_bit(EVENT_DMA_ERROR, &host->completed_events)
+#define mci_card_detect_is_complete(host)			\
+	test_bit(EVENT_CARD_DETECT, &host->completed_events)
+
+/* Test and clear bit macros for pending events */
+#define mci_clear_cmd_is_pending(host)			\
+	test_and_clear_bit(EVENT_CMD_COMPLETE, &host->pending_events)
+#define mci_clear_cmd_error_is_pending(host)		\
+	test_and_clear_bit(EVENT_CMD_ERROR, &host->pending_events)
+#define mci_clear_data_is_pending(host)			\
+	test_and_clear_bit(EVENT_DATA_COMPLETE, &host->pending_events)
+#define mci_clear_data_error_is_pending(host)		\
+	test_and_clear_bit(EVENT_DATA_ERROR, &host->pending_events)
+#define mci_clear_stop_sent_is_pending(host)		\
+	test_and_clear_bit(EVENT_STOP_SENT, &host->pending_events)
+#define mci_clear_stop_is_pending(host)			\
+	test_and_clear_bit(EVENT_STOP_COMPLETE, &host->pending_events)
+#define mci_clear_stop_error_is_pending(host)		\
+	test_and_clear_bit(EVENT_STOP_ERROR, &host->pending_events)
+#define mci_clear_dma_error_is_pending(host)		\
+	test_and_clear_bit(EVENT_DMA_ERROR, &host->pending_events)
+#define mci_clear_card_detect_is_pending(host)		\
+	test_and_clear_bit(EVENT_CARD_DETECT, &host->pending_events)
+
+/* Test and set bit macros for completed events */
+#define mci_set_cmd_is_completed(host)			\
+	test_and_set_bit(EVENT_CMD_COMPLETE, &host->completed_events)
+#define mci_set_cmd_error_is_completed(host)		\
+	test_and_set_bit(EVENT_CMD_ERROR, &host->completed_events)
+#define mci_set_data_is_completed(host)			\
+	test_and_set_bit(EVENT_DATA_COMPLETE, &host->completed_events)
+#define mci_set_data_error_is_completed(host)		\
+	test_and_set_bit(EVENT_DATA_ERROR, &host->completed_events)
+#define mci_set_stop_sent_is_completed(host)		\
+	test_and_set_bit(EVENT_STOP_SENT, &host->completed_events)
+#define mci_set_stop_is_completed(host)			\
+	test_and_set_bit(EVENT_STOP_COMPLETE, &host->completed_events)
+#define mci_set_stop_error_is_completed(host)		\
+	test_and_set_bit(EVENT_STOP_ERROR, &host->completed_events)
+#define mci_set_dma_error_is_completed(host)		\
+	test_and_set_bit(EVENT_DMA_ERROR, &host->completed_events)
+#define mci_set_card_detect_is_completed(host)		\
+	test_and_set_bit(EVENT_CARD_DETECT, &host->completed_events)
+
+/* Set bit macros for completed events */
+#define mci_set_cmd_complete(host)			\
+	set_bit(EVENT_CMD_COMPLETE, &host->completed_events)
+#define mci_set_cmd_error_complete(host)		\
+	set_bit(EVENT_CMD_ERROR, &host->completed_events)
+#define mci_set_data_complete(host)			\
+	set_bit(EVENT_DATA_COMPLETE, &host->completed_events)
+#define mci_set_data_error_complete(host)		\
+	set_bit(EVENT_DATA_ERROR, &host->completed_events)
+#define mci_set_stop_sent_complete(host)		\
+	set_bit(EVENT_STOP_SENT, &host->completed_events)
+#define mci_set_stop_complete(host)			\
+	set_bit(EVENT_STOP_COMPLETE, &host->completed_events)
+#define mci_set_stop_error_complete(host)		\
+	set_bit(EVENT_STOP_ERROR, &host->completed_events)
+#define mci_set_dma_error_complete(host)		\
+	set_bit(EVENT_DMA_ERROR, &host->completed_events)
+#define mci_set_card_detect_complete(host)		\
+	set_bit(EVENT_CARD_DETECT, &host->completed_events)
+
+/* Set bit macros for pending events */
+#define mci_set_cmd_pending(host)			\
+	set_bit(EVENT_CMD_COMPLETE, &host->pending_events)
+#define mci_set_cmd_error_pending(host)			\
+	set_bit(EVENT_CMD_ERROR, &host->pending_events)
+#define mci_set_data_pending(host)			\
+	set_bit(EVENT_DATA_COMPLETE, &host->pending_events)
+#define mci_set_data_error_pending(host)		\
+	set_bit(EVENT_DATA_ERROR, &host->pending_events)
+#define mci_set_stop_sent_pending(host)			\
+	set_bit(EVENT_STOP_SENT, &host->pending_events)
+#define mci_set_stop_pending(host)			\
+	set_bit(EVENT_STOP_COMPLETE, &host->pending_events)
+#define mci_set_stop_error_pending(host)		\
+	set_bit(EVENT_STOP_ERROR, &host->pending_events)
+#define mci_set_dma_error_pending(host)			\
+	set_bit(EVENT_DMA_ERROR, &host->pending_events)
+#define mci_set_card_detect_pending(host)		\
+	set_bit(EVENT_CARD_DETECT, &host->pending_events)
+
+/* Clear bit macros for pending events */
+#define mci_clear_cmd_pending(host)			\
+	clear_bit(EVENT_CMD_COMPLETE, &host->pending_events)
+#define mci_clear_cmd_error_pending(host)		\
+	clear_bit(EVENT_CMD_ERROR, &host->pending_events)
+#define mci_clear_data_pending(host)			\
+	clear_bit(EVENT_DATA_COMPLETE, &host->pending_events)
+#define mci_clear_data_error_pending(host)		\
+	clear_bit(EVENT_DATA_ERROR, &host->pending_events)
+#define mci_clear_stop_sent_pending(host)		\
+	clear_bit(EVENT_STOP_SENT, &host->pending_events)
+#define mci_clear_stop_pending(host)			\
+	clear_bit(EVENT_STOP_COMPLETE, &host->pending_events)
+#define mci_clear_stop_error_pending(host)		\
+	clear_bit(EVENT_STOP_ERROR, &host->pending_events)
+#define mci_clear_dma_error_pending(host)		\
+	clear_bit(EVENT_DMA_ERROR, &host->pending_events)
+#define mci_clear_card_detect_pending(host)		\
+	clear_bit(EVENT_CARD_DETECT, &host->pending_events)
+
 #endif /* __DRIVERS_MMC_ATMEL_MCI_H__ */