Date: Wed, 16 Jan 2013 20:26:32 -0700 From: Ian Lepore <ian@FreeBSD.org> To: Oleksandr Tymoshenko <gonzo@bluezbox.com> Cc: arm@FreeBSD.org Subject: Re: bus_space_(write|read)_X cleanup Message-ID: <1358393192.32417.186.camel@revolution.hippie.lan> In-Reply-To: <50F70325.5070507@bluezbox.com> References: <50F70325.5070507@bluezbox.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1358393192.32417.186.camel>