On 1/7/21 8:06 PM, Jakub Kicinski wrote:
> On Thu, 7 Jan 2021 11:00:35 -0800 Jakub Kicinski wrote:
>> On Thu, 7 Jan 2021 10:48:56 +0100 Marc Kleine-Budde wrote:
>>> +struct __packed tcan4x5x_map_buf {
>>> + struct tcan4x5x_buf_cmd cmd;
>>> + u8 data[256 * sizeof(u32)];
>>> +} ____cacheline_aligned;
>>
>> Interesting attribute combo, I must say.
>
> Looking at the rest of the patch I don't really see a reason for
> __packed. Perhaps it can be dropped?
It's the stream of bytes send via SPI to the chip. Here are both structs for
reference:
> +struct __packed tcan4x5x_buf_cmd {
> + u8 cmd;
> + __be16 addr;
> + u8 len;
> +};
This has to be packed, as I assume the compiler would add some space after the
"u8 cmd" to align the __be16 naturally.
> +struct __packed tcan4x5x_map_buf {
> + struct tcan4x5x_buf_cmd cmd;
> + u8 data[256 * sizeof(u32)];
> +} ____cacheline_aligned;
Due to the packing of the struct tcan4x5x_buf_cmd it should have a length of 4
bytes. Without __packed, will the "u8 data" come directly after the cmd?
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
signature.asc
Description: OpenPGP digital signature
