lkml.org 
[lkml]   [2015]   [Nov]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v2] USB: serial: cp210x: Add tx_empty()
From
On Wed, Nov 25, 2015 at 2:26 PM, Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Wed, Nov 25, 2015 at 12:28 AM, Konstantin Shkolnyy
> <konstantin.shkolnyy@gmail.com> wrote:

>> +static bool cp210x_tx_empty(struct usb_serial_port *port)
>> +{
>> + int err;
>> + u32 count;
>> +
>> + err = cp210x_get_tx_queue_byte_count(port, &count);
>
>> + if (!err && count)
>> + return false;
>> +
>> + return true;
>
> return err || !count;

To me, expressing it like this is harder to read. The code as I wrote
it, in my mind, reads like this:

if successfully read the counter and it's not 0 then
tx is not empty, return false

> Btw, can be count left uninitialized?

When the function succeeds it assigns a value to count.


\
 
 \ /
  Last update: 2015-11-26 17:41    [W:0.330 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site