public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC] Normalizing byteorder/unaligned access API
@ 2008-10-07 21:53 Harvey Harrison
  2008-10-07 22:12 ` James Bottomley
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Harvey Harrison @ 2008-10-07 21:53 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Al Viro, linux-arch, LKML, James Bottomley, Matthew Wilcox,
	linux-scsi, Boaz Harrosh

[related question regarding the SCSI-private endian helper needs at the end]

Currently on the read side, we have (le16 as an example endianness)

le16_to_cpup(__le16 *)
get_unaligned_le16(void *)

And on the write side:

*(__le16)ptr = cpu_to_le16(u16)
put_unaligned_le16(u16, void *);

On the read side, Al said he would have preferred the unaligned version
take the same types as the aligned, rather than void *.  AKPM didn't think
the use of get_ was that great as get/put generally implies some kind of reference
taking in the kernel.

As the le16_to_cpup has been around for so long and is more recognizable, let's
make it the same for the unaligned case and typesafe:

le16_to_cpup(__le16 *)
unaligned_le16_to_cpup(__le16 *)

On the write side, the above get/put and type issues are still there, in addition AKPM felt
that the ordering of the put_unaligned parameters was opposite what was intuitive and that
the pointer should come first.

In this case, as there is currently no aligned helper (other than in some drivers defining macros)
define the api thusly:

Aligned:
write_le16(__le16 *ptr, u16 val)

Unaligned:
unaligned_write_le16(__le16 *ptr, u16 val)

The existing get/put_unaligned macros do not necessarily need to be modified.  It would
present one oddity that the parameter order was different, but that's not a huge issue.

These could be phased in as they do not collide with the current API and the old api converted
over fairly quickly as not many places use the get/put_unaligned_{endian} helpers yet.

In addition, there are some subsystems (scsi) that are looking into some differently sized
endian helpers (be24) and it may be worthwhile to have some agreement whether it is worth
making them common infrastructure and whether they should present a similar API to the
common byteorder/unaligned API.

Is this a worthwhile direction to take?

Cheers,

Harvey


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2008-10-08  7:34 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-07 21:53 [RFC] Normalizing byteorder/unaligned access API Harvey Harrison
2008-10-07 22:12 ` James Bottomley
2008-10-07 22:39   ` Harvey Harrison
2008-10-07 23:33     ` Matthew Wilcox
2008-10-07 23:39       ` Harvey Harrison
2008-10-08  7:15         ` Geert Uytterhoeven
2008-10-07 23:28 ` Matthew Wilcox
2008-10-07 23:35   ` Harvey Harrison
2008-10-07 23:55     ` Matthew Wilcox
2008-10-08  0:02       ` Harvey Harrison
2008-10-08  7:31       ` Marcel Holtmann
2008-10-08  7:13 ` Geert Uytterhoeven
2008-10-08  7:34   ` Harvey Harrison

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox