lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABXOdTc6fA0RM-Osw96Dwwcy0PG1tyq-E07Fs2TJceYOe1ng6A@mail.gmail.com>
Date:   Fri, 30 Sep 2016 13:57:07 -0700
From:   Guenter Roeck <groeck@...gle.com>
To:     Joe Perches <joe@...ches.com>
Cc:     Jun Li <jun.li@....com>, Guenter Roeck <groeck@...omium.org>,
        Felipe Balbi <felipe.balbi@...ux.intel.com>,
        Chandra Sekhar Anagani <chandra.sekhar.anagani@...el.com>,
        Bruce Ashfield <bruce.ashfield@...driver.com>,
        Bin Gao <bin.gao@...el.com>,
        Pranav Tipnis <pranav.tipnis@...el.com>,
        Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>
Subject: Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)

On Fri, Sep 30, 2016 at 12:41 PM, Joe Perches <joe@...ches.com> wrote:
> On Fri, 2016-09-30 at 12:06 -0700, Guenter Roeck wrote:
>> On Thu, Sep 29, 2016 at 11:37 PM, Jun Li <jun.li@....com> wrote:
> []
>> > diff --git a/include/linux/usb/pd.h b/include/linux/usb/pd.h
> []
>> > +#define PDO_VAR(min_mv, max_mv, max_ma)                                      \
>> > +     ((PDO_TYPE_VAR << PDO_TYPE_SHIFT) |                             \
>> > +      ((((min_mv) / 50) & PDO_VAR_MIN_VOLT_MASK) <<                  \
>> > +       PDO_VAR_MIN_VOLT_SHIFT) |                                     \
>> > +      ((((max_mv) / 50) & PDO_VAR_MAX_VOLT_MASK) <<                  \
>> > +       PDO_VAR_MAX_VOLT_SHIFT) |                                     \
>> > +      ((((max_ma) / 50) & PDO_VAR_MAX_CURR_MASK) <<                  \
>>
>>
>> ((((max_ma) / 10) & PDO_VAR_MAX_CURR_MASK) <<                  \
>
> This would be easier to read if laid out differently.
>
> #define PDO_VAR(min_mv, max_mv, max_ma)                                                 \
>         ((PDO_TYPE_VAR << PDO_TYPE_SHIFT) |                                             \
>          ((((min_mv) / 50) & PDO_VAR_MIN_VOLT_MASK) << PDO_VAR_MIN_VOLT_SHIFT) |        \
>          ((((max_mv) / 50) & PDO_VAR_MAX_VOLT_MASK) << PDO_VAR_MAX_VOLT_SHIFT) |        \
>          ((((max_ma) / 10) & PDO_VAR_MAX_CURR_MASK) << PDO_VAR_MAX_CURR_SHIFT))
>

Code now looks as follows.

#define PDO_VAR_MIN_VOLT(mv) ((((mv) / 50) & PDO_VAR_MIN_VOLT_MASK) << \
                              PDO_VAR_MIN_VOLT_SHIFT)
#define PDO_VAR_MAX_VOLT(mv) ((((mv) / 50) & PDO_VAR_MAX_VOLT_MASK) << \
                              PDO_VAR_MAX_VOLT_SHIFT)
#define PDO_VAR_MAX_CURR(ma) ((((ma) / 10) & PDO_VAR_MAX_CURR_MASK) << \
                              PDO_VAR_MAX_CURR_SHIFT)

#define PDO_VAR(min_mv, max_mv, max_ma)                         \
        (PDO_TYPE(PDO_TYPE_VAR) | PDO_VAR_MIN_VOLT(min_mv) |    \
         PDO_VAR_MAX_VOLT(max_mv) | PDO_VAR_MAX_CURR(max_ma))

Though maybe I should just ignore line length limits or use shorter defines.

Guenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ