@@ -245,13 +245,13 @@ static inline void bcm2835_rd_fifo_count(struct bcm2835_spi *bs, int count)
245
245
246
246
bs -> rx_len -= count ;
247
247
248
- while ( count > 0 ) {
248
+ do {
249
249
val = bcm2835_rd (bs , BCM2835_SPI_FIFO );
250
250
len = min (count , 4 );
251
251
memcpy (bs -> rx_buf , & val , len );
252
252
bs -> rx_buf += len ;
253
253
count -= 4 ;
254
- }
254
+ } while ( count > 0 );
255
255
}
256
256
257
257
/**
@@ -271,7 +271,7 @@ static inline void bcm2835_wr_fifo_count(struct bcm2835_spi *bs, int count)
271
271
272
272
bs -> tx_len -= count ;
273
273
274
- while ( count > 0 ) {
274
+ do {
275
275
if (bs -> tx_buf ) {
276
276
len = min (count , 4 );
277
277
memcpy (& val , bs -> tx_buf , len );
@@ -281,7 +281,7 @@ static inline void bcm2835_wr_fifo_count(struct bcm2835_spi *bs, int count)
281
281
}
282
282
bcm2835_wr (bs , BCM2835_SPI_FIFO , val );
283
283
count -= 4 ;
284
- }
284
+ } while ( count > 0 );
285
285
}
286
286
287
287
/**
@@ -310,12 +310,11 @@ static inline void bcm2835_rd_fifo_blind(struct bcm2835_spi *bs, int count)
310
310
count = min (count , bs -> rx_len );
311
311
bs -> rx_len -= count ;
312
312
313
- while ( count ) {
313
+ do {
314
314
val = bcm2835_rd (bs , BCM2835_SPI_FIFO );
315
315
if (bs -> rx_buf )
316
316
* bs -> rx_buf ++ = val ;
317
- count -- ;
318
- }
317
+ } while (-- count );
319
318
}
320
319
321
320
/**
@@ -330,11 +329,10 @@ static inline void bcm2835_wr_fifo_blind(struct bcm2835_spi *bs, int count)
330
329
count = min (count , bs -> tx_len );
331
330
bs -> tx_len -= count ;
332
331
333
- while ( count ) {
332
+ do {
334
333
val = bs -> tx_buf ? * bs -> tx_buf ++ : 0 ;
335
334
bcm2835_wr (bs , BCM2835_SPI_FIFO , val );
336
- count -- ;
337
- }
335
+ } while (-- count );
338
336
}
339
337
340
338
static void bcm2835_spi_reset_hw (struct bcm2835_spi * bs )
0 commit comments