Re: [PATCH 02/14] soundwire: Add SoundWire bus type

From: Vinod Koul
Date: Fri Oct 20 2017 - 12:07:35 EST


On Fri, Oct 20, 2017 at 05:50:57PM +0200, Takashi Iwai wrote:
> On Fri, 20 Oct 2017 17:46:49 +0200,
> Vinod Koul wrote:
> > > > > > --- a/include/linux/mod_devicetable.h
> > > > > > +++ b/include/linux/mod_devicetable.h
> > > > > > @@ -228,6 +228,13 @@ struct hda_device_id {
> > > > > > unsigned long driver_data;
> > > > > > };
> > > > > >
> > > > > > +struct sdw_device_id {
> > > > > > + __u16 mfg_id;
> > > > > > + __u16 part_id;
> > > > > > + __u8 class_id;
> > > > > > + kernel_ulong_t driver_data;
> > > > >
> > > > > Better to think of alignment.
> > > >
> > > > sorry not quite clear, do you mind elaborating which ones to align?
> > >
> > > kernel_ulong_t may be aligned to 4 or 8 bytes, depending on
> > > architecture, so there can be a hole between class_id and driver_data.
> > > It's not an ABI, so we don't have to care too much, but it's still
> > > something exposed, hence better to be conscious about alignment.
> >
> > ah :) is that why hda is unsigned long :) Btw doesnt that cause compat
> > issues, should we not do something like u64 here?
>
> Oh, don't take the HD-audio case as a good reference, it's a bad guy
> ;) In the case of hda, the definition isn't really exposed.

Not really it is for ext-hda codecs

> The alignment doesn't matter whether it's unsigned long or
> kernel_ulong_t. It's a generic issue when you define some struct and
> expose it. In a safer side, you can put the enough pad bytes so that
> the long field is aligned in 8 bytes. Or use packed struct. Or you
> can just ignore and let it be so, but aware of the possible holes in
> your code.

that makes sense, I can add some reserved fields for padding here to fix and
retain the kernel_ulong_t then

--
~Vinod