Messages in this thread | | | From | David Brownell <> | Subject | Re: [PATCH 1/6] regulator: consumer driver regulator control framework. | Date | Sat, 23 Feb 2008 10:36:42 -0800 |
| |
On Saturday 23 February 2008, Andrew Morton wrote: > On Wed, 20 Feb 2008 17:08:53 +0000 Liam Girdwood <lg@opensource.wolfsonmicro.com> 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.)
| |