From: Of Sarah Sharp
> From: Hans de Goede <hdego...@redhat.com>
> 
> The iu struct definitions are usb packet definitions, so no alignment should
> happen. Notice that assuming 32 bit alignment this does not make any
> difference at all.
> 
> Signed-off-by: Hans de Goede <hdego...@redhat.com>
> Signed-off-by: Sarah Sharp <sarah.a.sh...@linux.intel.com>
> ---
>  include/linux/usb/uas.h | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/include/linux/usb/uas.h b/include/linux/usb/uas.h
> index 772b66bcdd7d..3fc8e8b9f043 100644
> --- a/include/linux/usb/uas.h
> +++ b/include/linux/usb/uas.h
> @@ -9,7 +9,7 @@ struct iu {
>       __u8 iu_id;
>       __u8 rsvd1;
>       __be16 tag;
> -};
> +} __attribute__((__packed__));

I don't want to block these patches, but the above will make
a difference.

On cpus that don't support misaligned memory transfers the
compiler will have to generate code that does byte accesses
and shifts in order to access 16 and 32 bit members of packed
structures.

So you should really only mark structures as packed if they
will occur on misaligned boundaries.

If a structure has a single field that is misaligned (eg a
64bit field at a 4n+4 offset) then the single field can be
marked with (eg) __attribute__((aligned(4))) that will remove
the padding and only force multiple memory access for that
one member.

        David



--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to