浏览代码

Reduce binary size by factoring out common parameterised calls to

udelay().
tags/v0.9.3
Michael Brown 19 年前
父节点
当前提交
120192e8d1
共有 1 个文件被更改,包括 19 次插入13 次删除
  1. 19
    13
      src/drivers/bus/isapnp.c

+ 19
- 13
src/drivers/bus/isapnp.c 查看文件

@@ -133,11 +133,16 @@ static inline void isapnp_deactivate ( uint8_t logdev ) {
133 133
 	isapnp_write_byte ( ISAPNP_ACTIVATE, 0 );
134 134
 }
135 135
 
136
+static void isapnp_delay ( void ) {
137
+	udelay ( 1000 );
138
+}
139
+
136 140
 /*
137 141
  * The linear feedback shift register as described in Appendix B of
138 142
  * the PnP ISA spec.  The hardware implementation uses eight D-type
139 143
  * latches and two XOR gates.  I think this is probably the smallest
140
- * possible implementation in software.  :)
144
+ * possible implementation in software.  Six instructions when input_bit
145
+ * is a constant 0 (for isapnp_send_key).  :)
141 146
  *
142 147
  */
143 148
 static inline uint8_t isapnp_lfsr_next ( uint8_t lfsr, int input_bit ) {
@@ -156,12 +161,12 @@ static void isapnp_send_key ( void ) {
156 161
 	unsigned int i;
157 162
 	uint8_t lfsr;
158 163
 
159
-	udelay ( 1000 );
164
+	isapnp_delay();
160 165
 	isapnp_write_address ( 0x00 );
161 166
 	isapnp_write_address ( 0x00 );
162 167
 
163 168
 	lfsr = ISAPNP_LFSR_SEED;
164
-	for ( i = 0 ; i < 32 ; i-- ) {
169
+	for ( i = 0 ; i < 32 ; i++ ) {
165 170
 		isapnp_write_address ( lfsr );
166 171
 		lfsr = isapnp_lfsr_next ( lfsr, 0 );
167 172
 	}
@@ -200,7 +205,7 @@ static inline uint8_t isapnp_peek_byte ( void ) {
200 205
 			/* Byte ready - read it */
201 206
 			return isapnp_read_resourcedata();
202 207
 		}
203
-		udelay ( 100 );
208
+		isapnp_delay ();
204 209
 	}
205 210
 	/* Data never became ready - return 0xff */
206 211
 	return 0xff;
@@ -249,7 +254,8 @@ static int isapnp_try_isolate ( void ) {
249 254
 	/* Reset all assigned CSNs */
250 255
 	isapnp_reset_csn ();
251 256
 	isapnp_max_csn = 0;
252
-	udelay ( 2000 );
257
+	isapnp_delay();
258
+	isapnp_delay();
253 259
 	
254 260
 	/* Place all cards into the Isolation state */
255 261
 	isapnp_wait_for_key ();
@@ -258,7 +264,7 @@ static int isapnp_try_isolate ( void ) {
258 264
 	
259 265
 	/* Set the read port */
260 266
 	isapnp_set_read_port ();
261
-	udelay ( 1000 );
267
+	isapnp_delay();
262 268
 
263 269
 	while ( 1 ) {
264 270
 
@@ -269,7 +275,7 @@ static int isapnp_try_isolate ( void ) {
269 275
 
270 276
 		/* Initiate serial isolation */
271 277
 		isapnp_serialisolation ();
272
-		udelay ( 1000 );
278
+		isapnp_delay();
273 279
 
274 280
 		/* Read identifier serially via the ISAPnP read port. */
275 281
 		memset ( &identifier, 0, sizeof ( identifier ) );
@@ -278,9 +284,9 @@ static int isapnp_try_isolate ( void ) {
278 284
 			byte = 0;
279 285
 			for ( j = 0 ; j < 8 ; j++ ) {
280 286
 				data = isapnp_read_data ();
281
-				udelay ( 1000 );
287
+				isapnp_delay();
282 288
 				data = ( data << 8 ) | isapnp_read_data ();
283
-				udelay ( 1000 );
289
+				isapnp_delay();
284 290
 				if ( data == 0x55aa ) {
285 291
 					byte |= 1;
286 292
 				}
@@ -309,13 +315,13 @@ static int isapnp_try_isolate ( void ) {
309 315
 		      identifier.checksum, isapnp_max_csn );
310 316
 		
311 317
 		isapnp_write_csn ( isapnp_max_csn );
312
-		udelay ( 1000 );
318
+		isapnp_delay();
313 319
 
314 320
 		/* Send this card back to Sleep and force all cards
315 321
 		 * without a CSN into Isolation state
316 322
 		 */
317 323
 		isapnp_wake ( 0x00 );
318
-		udelay ( 1000 );
324
+		isapnp_delay();
319 325
 	}
320 326
 
321 327
 	/* Place all cards in Wait for Key state */
@@ -484,7 +490,7 @@ void activate_isapnp_device ( struct isapnp_device *isapnp,
484 490
 
485 491
 	/* Select the specified logical device */
486 492
 	isapnp_activate ( logdev );
487
-	udelay ( 1000 );
493
+	isapnp_delay();
488 494
 	
489 495
 	/* Return all cards to Wait for Key state */
490 496
 	isapnp_wait_for_key ();
@@ -503,7 +509,7 @@ void deactivate_isapnp_device ( struct isapnp_device *isapnp,
503 509
 
504 510
 	/* Select the specified logical device */
505 511
 	isapnp_deactivate ( logdev );
506
-	udelay ( 1000 );
512
+	isapnp_delay();
507 513
 	
508 514
 	/* Return all cards to Wait for Key state */
509 515
 	isapnp_wait_for_key ();

正在加载...
取消
保存