Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)

From: Joe Perches
Date: Fri Sep 30 2016 - 15:42:10 EST


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@xxxxxxx> 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))