From owner-freebsd-arm@FreeBSD.ORG Thu Jan 17 03:26:38 2013 Return-Path: Delivered-To: arm@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 9BA07A8D for ; Thu, 17 Jan 2013 03:26:38 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from duck.symmetricom.us (duck.symmetricom.us [206.168.13.214]) by mx1.freebsd.org (Postfix) with ESMTP id 0A3C76F1 for ; Thu, 17 Jan 2013 03:26:34 +0000 (UTC) Received: from damnhippie.dyndns.org (daffy.symmetricom.us [206.168.13.218]) by duck.symmetricom.us (8.14.5/8.14.5) with ESMTP id r0H3QYB2083123 for ; Wed, 16 Jan 2013 20:26:34 -0700 (MST) (envelope-from ian@FreeBSD.org) Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id r0H3QWkd005620; Wed, 16 Jan 2013 20:26:32 -0700 (MST) (envelope-from ian@FreeBSD.org) Subject: Re: bus_space_(write|read)_X cleanup From: Ian Lepore To: Oleksandr Tymoshenko In-Reply-To: <50F70325.5070507@bluezbox.com> References: <50F70325.5070507@bluezbox.com> Content-Type: text/plain; charset="us-ascii" Date: Wed, 16 Jan 2013 20:26:32 -0700 Message-ID: <1358393192.32417.186.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: arm@FreeBSD.org X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jan 2013 03:26:38 -0000 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