@@ -215,22 +215,20 @@ static int tpm_poll_for_data_avail(void)
215
215
return STB_TPM_TIMEOUT ;
216
216
}
217
217
218
- static int tpm_read_burst_count (uint8_t * burst_count )
218
+ static int tpm_read_burst_count (void )
219
219
{
220
220
int rc , delay ;
221
- uint8_t bc ;
221
+ uint8_t burst_count ;
222
222
223
+ burst_count = 0 ;
223
224
delay = 0 ;
224
- * burst_count = 0 ;
225
-
226
225
do {
227
226
/* In i2C, burstCount is 1 byte */
228
- rc = tpm_status_read_byte (TPM_BURST_COUNT , & bc );
229
- if (rc == 0 && bc > 0 ) {
230
- DBG ("---- burst_count=%d, delay=%d/%d\n" ,
227
+ rc = tpm_status_read_byte (TPM_BURST_COUNT , & burst_count );
228
+ if (rc == 0 && burst_count > 0 ) {
229
+ DBG ("---- burst_count=%d, delay=%d/%d\n" , burst_count ,
231
230
delay , TPM_TIMEOUT_D );
232
- * burst_count = bc ;
233
- return 0 ;
231
+ return (int ) burst_count ;
234
232
}
235
233
if (rc < 0 ) {
236
234
/**
@@ -261,8 +259,7 @@ static int tpm_read_burst_count(uint8_t* burst_count)
261
259
262
260
static int tpm_write_fifo (uint8_t * buf , size_t buflen )
263
261
{
264
- uint8_t burst_count = 0 ;
265
- int rc ;
262
+ int rc , burst_count ;
266
263
size_t curByte = 0 ;
267
264
uint8_t * bytePtr = buf ;
268
265
uint8_t * curBytePtr = NULL ;
@@ -275,9 +272,9 @@ static int tpm_write_fifo(uint8_t* buf, size_t buflen)
275
272
size_t tx_len = 0 ;
276
273
277
274
do {
278
- rc = tpm_read_burst_count (& burst_count );
279
- if (rc < 0 )
280
- return rc ;
275
+ burst_count = tpm_read_burst_count ();
276
+ if (burst_count < 0 )
277
+ return burst_count ;
281
278
/*
282
279
* Send in some data
283
280
*/
@@ -309,9 +306,9 @@ static int tpm_write_fifo(uint8_t* buf, size_t buflen)
309
306
/*
310
307
* Send the final byte
311
308
*/
312
- rc = tpm_read_burst_count (& burst_count );
313
- if (rc < 0 )
314
- return rc ;
309
+ burst_count = tpm_read_burst_count ();
310
+ if (burst_count < 0 )
311
+ return burst_count ;
315
312
curBytePtr = & (bytePtr [curByte ]);
316
313
rc = tpm_i2c_request_send (tpm_device -> bus_id ,
317
314
tpm_device -> xscom_base ,
@@ -339,8 +336,7 @@ static int tpm_write_fifo(uint8_t* buf, size_t buflen)
339
336
340
337
static int tpm_read_fifo (uint8_t * buf , size_t * buflen )
341
338
{
342
- int rc ;
343
- uint8_t burst_count ;
339
+ int rc , burst_count ;
344
340
size_t curByte = 0 ;
345
341
uint8_t * bytePtr = (uint8_t * )buf ;
346
342
uint8_t * curBytePtr = NULL ;
@@ -350,9 +346,11 @@ static int tpm_read_fifo(uint8_t* buf, size_t* buflen)
350
346
goto error ;
351
347
352
348
do {
353
- rc = tpm_read_burst_count (& burst_count );
354
- if (rc < 0 )
349
+ burst_count = tpm_read_burst_count ();
350
+ if (burst_count < 0 ) {
351
+ rc = burst_count ;
355
352
goto error ;
353
+ }
356
354
/* Buffer overflow check */
357
355
if (curByte + burst_count > * buflen )
358
356
{
0 commit comments