lkml.org 
[lkml]   [2013]   [May]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [tpmdd-devel] [PATCH 1/1] TPM: STMicroelectronics st33 driver SPI
Date
Hi Matthias:

> Regarding the while loop, I don't see how can I check the number of dummy
> byte differently?


Checking the number of dummy bytes is fine -
in line #144 you check it with a while loop which looks fine
in line #198 you check it with a for loop with an empty body, which in my
opinion looks less nice than the while in #144.

So simply replace the second instance in #198 and I'm happy with that part ;)

Maybe also have a look at memchr_inv

/**
* memchr_inv - Find an unmatching character in an area of memory.
* @start: The memory area
* @c: Find a character other than c
* @bytes: The size of the area.
*
* returns the address of the first character other than @c, or %NULL
* if the whole buffer contains just @c.
*/
void *memchr_inv(const void *start, int c, size_t bytes)



so #198 would look something like:
nbr_dummy_bytes = memchr_inv (xfer.rx_buf+nbr_dummy_bytes,
0,
total_length-nbr_dummy_bytes) - xfer.rx_buf;

But I'm not sure whether that's more readable, maybe give it a try.
I'm also fine with the while loop.


Peter








\
 
 \ /
  Last update: 2013-05-16 21:41    [W:0.045 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site