Subject: The FROMBCD macro in dev/clock_subr.h
To: None <tech-kern@netbsd.org>
From: Simon Burge <simonb@wasabisystems.com>
List: tech-kern
Date: 05/07/2003 16:26:42
I noticed that there are lots of users of the FROMBCD macro in
sys/dev/clock_subr.h that are of the form

	some_var = FROMBCD(read_from_rtc_reg_function());

and that the arg to FROMBCD is evaluated twice.  This usually isn't a
big deal, except say for example if you have the RTC behind a slow bus
like smbus or I2C.  By changing the macro to an inline function, in one
I sped up the RTC gettime function from 160ms to 80ms, as well as saving
a couple of hundred bytes of kernel text.

I'd like to change the macros (both FROMBCD and TOBCD) to static inline
functions so that this has the least impact on existing source code.  We
could add these as functions to clock_subr.c, but from a style POV they
should then be renamed to the lower-case equivalents.

Any objections to doing this (not renaming and making static inline)?

Simon.
--
Simon Burge                                   <simonb@wasabisystems.com>
NetBSD Development, Support and Service:   http://www.wasabisystems.com/