bus_space_(write|read)_X cleanup

Ian Lepore ian at FreeBSD.org
Thu Jan 17 03:26:38 UTC 2013


On Wed, 2013-01-16 at 11:44 -0800, Oleksandr Tymoshenko wrote:
> Hello,
> 
> One of the practices in ARM codebase that caught my eye recently
> was using bus_space_write_4 (and read) where it's not strictly required.
> 
> The way it usually goes: memory resource is allocated in driver's attach
> method then busspace tag/handle obtained by calling rman_get_bustag
> and rman_get_bushandle, stored in softc and used as a parameters  of
> bus_space calls. No other operations on handle/tag are performed.
> 
> There are bus_read/bus_write wrappers that provide cleaner API
> and reduce code complexity. I believe it might be worth going through
> the code and fixing cases of excessive use of bus_space_  functions.
> 
> Unless I missed something.

I don't think you missed anything, and I totally agree with this.

Something I tried for a while was to extend the shorthand to the next
logical level.  We have 

  bus_space_whatever(sc->restag, sc->reshandle, ...)

then 

  bus_whatever(sc->resource, ...)

so next for me is

  device_whatever(sc, ...)

But I fell back out of the habit pretty quickly.  What I still like best
of all is the RD4() and WR4() macros that Warner used in the at91 code.
They are the same idea as my device_whatever() but with uglier names
(that I still like better despite all the ugly).

-- Ian




More information about the freebsd-arm mailing list