From: Johannes Berg <johannes@sipsolutions.net>
To: Michael Buesch <mb@bu3sch.de>
Cc: Tomas Winkler <tomasw@gmail.com>,
"John W. Linville" <linville@tuxdriver.com>,
Dan Williams <dcbw@redhat.com>,
linux-wireless <linux-wireless@vger.kernel.org>,
Zhu Yi <yi.zhu@intel.com>,
Reinette Chatre <reinette.chatre@intel.com>
Subject: Re: coding style lesson: iwlwifi vs. endianness
Date: Mon, 10 Dec 2007 17:18:43 +0100 [thread overview]
Message-ID: <1197303523.6035.92.camel@johannes.berg> (raw)
In-Reply-To: <200712101630.48124.mb@bu3sch.de>
[-- Attachment #1: Type: text/plain, Size: 1600 bytes --]
> my_data = read_drom_device()
> swap_to_cpu(my_data)
> do_whatever(my_data)
> store the data somewhere else in the device structs for
> later use, maybe.
> do_something_else(my_data)
>
> You see that now you have only _one_ place that you have to care about.
> And if you have to write your data back at some point, simply do it
> just before the write.
The thing is that Tomas is saying that because they don't have a
function to "read_from_device()" but that is rather only
"shared_structure->something" it is special and completely different
than regular drivers.
The absolute worst thing imo is in the current radiotap code (before my
patch) where it passes around a value as "u16" but then needs to convert
it to __le16 before accessing bits in it because things are defined as
LE.
Also, let me reiterate the argument that this is not using more
code/run-time-memory size:
Consider
u16 phyflags = le16_to_cpu(shared_struct->phy_flags);
[...]
if (phyflags & ...)
[...]
vs.
[...]
if (shared_struct->phy_flags & ...)
[...]
If you have a LE machine, then the compiler should in both cases emit
the same code. If you have BE machine, you have a *single* "superfluous"
byteswap, and if there are multi-bit fields you have far *fewer*
byteswaps. If you instead wrote
u16 phyflags = le16_to_cpup(&shared_struct->phy_flags);
then most likely the byteswap would be microcoded/done by hardware
during the load.
The actual runtime penalty of byteswaps is insignificant since fetching
the value from memory already takes forever.
johannes
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
next prev parent reply other threads:[~2007-12-10 16:19 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-27 18:44 coding style lesson: iwlwifi vs. endianness Johannes Berg
2007-11-28 18:20 ` Tomas Winkler
2007-11-28 18:50 ` Johannes Berg
2007-11-28 21:43 ` Dan Williams
2007-11-29 0:58 ` John W. Linville
2007-11-29 23:02 ` Tomas Winkler
2007-12-10 11:42 ` Johannes Berg
2007-12-10 14:18 ` Tomas Winkler
2007-12-10 15:18 ` Johannes Berg
2007-12-10 15:30 ` Michael Buesch
2007-12-10 16:18 ` Johannes Berg [this message]
2007-12-10 16:48 ` Michael Buesch
2007-12-10 16:21 ` Tomas Winkler
2007-12-10 16:25 ` Johannes Berg
2007-12-10 21:18 ` Tomas Winkler
2007-12-10 16:10 ` Tomas Winkler
2007-12-10 16:17 ` Johannes Berg
2007-12-10 16:23 ` Johannes Berg
2007-11-29 9:03 ` Holger Schurig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1197303523.6035.92.camel@johannes.berg \
--to=johannes@sipsolutions.net \
--cc=dcbw@redhat.com \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=mb@bu3sch.de \
--cc=reinette.chatre@intel.com \
--cc=tomasw@gmail.com \
--cc=yi.zhu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).