Bladeren bron

Reduce binary size by factoring out common parameterised calls to

udelay().
tags/v0.9.3
Michael Brown 19 jaren geleden
bovenliggende
commit
120192e8d1
1 gewijzigde bestanden met toevoegingen van 19 en 13 verwijderingen
  1. 19
    13
      src/drivers/bus/isapnp.c

+ 19
- 13
src/drivers/bus/isapnp.c Bestand weergeven

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

Laden…
Annuleren
Opslaan