linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Oliver Hartkopp <socketcan@hartkopp.net>, linux-can@vger.kernel.org
Subject: Re: [PATCH v4 4/5] can: bcm: add support for CAN FD frames
Date: Fri, 17 Jun 2016 12:41:09 +0200	[thread overview]
Message-ID: <d6d31b17-9ec2-6682-f54b-28fec6358154@pengutronix.de> (raw)
In-Reply-To: <5763D2F1.5040408@hartkopp.net>


[-- Attachment #1.1: Type: text/plain, Size: 1420 bytes --]

On 06/17/2016 12:37 PM, Oliver Hartkopp wrote:
> On 06/17/2016 12:23 PM, Marc Kleine-Budde wrote:
>> On 06/04/2016 09:26 PM, Oliver Hartkopp wrote:
> 
>>> -/* easy access to CAN frame payload */
>>> -static inline u64 GET_U64(const struct can_frame *cp)
>>> +/* easy access to the first 64 bit of can(fd)_frame payload */
>>> +static inline u64 GET_U64(const struct canfd_frame *cp, int offset)
>>>   {
>>> -	return *(u64 *)cp->data;
>>> +	return *(u64 *)(cp->data + offset);
>>
>> Can you ensure that offset is always a multiple of 8?
> 
> I would like to put that into a comment, as a check for this helper at 
> runtime is too expensive - and the caller is only in this C-file at two 
> places.

No need to check during runtime, if you know your code and can ensure
that offset is always a multiple of 8 :D

>> Unaligned pointer
>> access will be quite slow on some platforms.
> 
> cp->data is well aligned.

"cp->data + offset" must be aligned properly, this is why offset must be
a multiple of 8.

>> Can you please make this
>> function lower-case (as it's a function not a macro).
> 
> will do.

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

  reply	other threads:[~2016-06-17 10:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-04 19:26 [PATCH v4 0/5] Add support for CAN FD to broadcast manager (CAN_BCM) Oliver Hartkopp
2016-06-04 19:26 ` [PATCH v4 1/5] can: bcm: fix indention and other minor style issues Oliver Hartkopp
2016-06-04 19:26 ` [PATCH v4 2/5] can: bcm: use CAN frame instead of can_frame in comments Oliver Hartkopp
2016-06-04 19:26 ` [PATCH v4 3/5] can: bcm: unify bcm_msg_head handling and prepare function parameters Oliver Hartkopp
2016-06-04 19:26 ` [PATCH v4 4/5] can: bcm: add support for CAN FD frames Oliver Hartkopp
2016-06-17 10:23   ` Marc Kleine-Budde
2016-06-17 10:37     ` Oliver Hartkopp
2016-06-17 10:41       ` Marc Kleine-Budde [this message]
2016-06-04 19:26 ` [PATCH v4 5/5] can: bcm: add documentation for CAN FD support Oliver Hartkopp

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=d6d31b17-9ec2-6682-f54b-28fec6358154@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=linux-can@vger.kernel.org \
    --cc=socketcan@hartkopp.net \
    /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).