From: Al Viro <viro@zeniv.linux.org.uk>
To: Nicholas Mc Guire <der.herr@hofr.at>
Cc: Sven Van Asbroeck <thesven73@gmail.com>,
Nicholas Mc Guire <hofrat@osadl.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
devel@driverdev.osuosl.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V2] staging: fieldbus: anybus-s: force endiannes annotation
Date: Tue, 30 Apr 2019 05:19:34 +0100 [thread overview]
Message-ID: <20190430041934.GI23075@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20190430033310.GB23144@osadl.at>
On Tue, Apr 30, 2019 at 05:33:10AM +0200, Nicholas Mc Guire wrote:
> ok - my bad thn - I had assumed that using __force is reasonable
> if the handling is correct and its a localized conversoin only
> like var = be16_to_cpu(var) which evaded introducing additinal
> variables just to have different types but no different function.
If compiler can't recognize that in
T1 v1;
T2 v2;
code using v1, but not v2
v2 = f(v1);
code using v2, but not v1
it can use the same memory for v1 and v2, file a bug against the
compiler. Or stop using that toy altogether - that kind of
optimizations is early 60s stuff and any real compiler will
handle that. Both gcc and clang certainly do handle that.
Another thing they handle is figuring out that be16_to_cpu()
et.al. are pure functions, so
f(be16_to_cpu(n));
no modifications of n
g(be16_to_cpu(n));
doesn't need to have le16_to_cpu recalculated. IOW, that particular
code could as well have been
dev_info(dev, "Fieldbus type: %04X", be16_to_cpu(fieldbus_type));
...
cd->client->fieldbus_type = be16_to_cpu(fieldbus_type);
... not that there's much sense keeping ->fieldbus_type in host-endian,
while we are at it.
next prev parent reply other threads:[~2019-04-30 4:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-29 6:05 [PATCH V2] staging: fieldbus: anybus-s: force endiannes annotation Nicholas Mc Guire
2019-04-29 6:05 ` [PATCH V3] staging: fieldbus: anybus-s: consolidate wait_for_completion_timeout return handling Nicholas Mc Guire
2019-04-29 14:01 ` Sven Van Asbroeck
2019-04-29 14:03 ` [PATCH V2] staging: fieldbus: anybus-s: force endiannes annotation Sven Van Asbroeck
2019-04-30 2:22 ` Nicholas Mc Guire
2019-04-30 3:02 ` Al Viro
2019-04-30 3:33 ` Nicholas Mc Guire
2019-04-30 4:19 ` Al Viro [this message]
2019-04-30 13:32 ` Sven Van Asbroeck
2019-04-30 14:03 ` Greg Kroah-Hartman
2019-04-30 14:22 ` Sven Van Asbroeck
2019-04-30 14:26 ` Sven Van Asbroeck
2019-04-30 14:27 ` Al Viro
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=20190430041934.GI23075@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=der.herr@hofr.at \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=hofrat@osadl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=thesven73@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.