Re: [PATCH 1/6] regulator: consumer driver regulator control framework.

From: David Brownell
Date: Sat Feb 23 2008 - 13:36:55 EST


On Saturday 23 February 2008, Andrew Morton wrote:
> On Wed, 20 Feb 2008 17:08:53 +0000 Liam Girdwood <lg@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> > +#define mV_to_uV(mV) (mV * 1000)
> > +#define uV_to_mV(uV) (uV / 1000)
> > +#define V_to_uV(V) (mV_to_uV(V * 1000))
> > +#define uV_to_V(uV) (uV_to_mV(uV) / 1000)
> > +#define mA_to_uA(mA) (mA * 1000)
> > +#define uA_to_mA(uA) (uA / 1000)
> > +#define A_to_uA(A) (mA_to_uA(A * 1000))
> > +#define uA_to_A(uA) (uA_to_mA(uA) / 1000)
>
> hm. It might be nicer to make these static inline functions. Especially
> if the code is consistent about what C type is used to represent voltage
> and current.

And if not ... then be sure to use e.g. ((mV) * 1000), ((uV) / 1000) etc
so that params like "x + 23" can't cause chaos.

(FWIW oth these points -- use inlines, parenthesize params -- are also
found in Documentation/CodingStyle.)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/