From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 62813DDEFA for ; Sat, 21 Feb 2009 15:33:33 +1100 (EST) Subject: Re: PCI reading without endian conversion From: Benjamin Herrenschmidt To: Ira Snyder In-Reply-To: <20090220235054.GA27349@ovro.caltech.edu> References: <20090220191108.GA21163@ovro.caltech.edu> <20090220210744.GB21163@ovro.caltech.edu> <20090220235054.GA27349@ovro.caltech.edu> Content-Type: text/plain Date: Sat, 21 Feb 2009 15:33:17 +1100 Message-Id: <1235190797.8805.202.camel@pasglop> Mime-Version: 1.0 Cc: PowerPC dev list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , > > Am I correct in saying that cpu_to_le32 and le32_to_cpu are the > > functions/macros I need to use to do byte swapping to make everything > > go little endian (and back again when I read them back in the kernel)? > > > > Or is there some cleverer way already implemented in the kernel? > > > > I would say that the __raw_readl() reads in cpu order. If you wanted to > convert that to le32, you'd use cpu_to_le32(). Beware that __raw_* forms also don't have memory barriers. In general, you know what byte order your device uses (which is often little endian) and you use the appropriate ioread32{be}. Now, for userspace, you simply need to mimmic those accessors. Ben.