[linux-usb-devel] Re: need for packed attribute

2006-01-12 Thread Mikael Pettersson
On Fri, 6 Jan 2006 18:38:46 +, Russell King wrote: >> is there any architecture for which packed is required in structures like >> this: >> >> /* All standard descriptors have these 2 fields at the beginning */ >> struct usb_descriptor_header { >> __u8 bLength; >> __u8 bDescriptor

[linux-usb-devel] Re: need for packed attribute

2006-01-12 Thread Russell King
On Thu, Jan 12, 2006 at 01:27:12PM +0100, Mikael Pettersson wrote: > On Fri, 6 Jan 2006 18:38:46 +, Russell King wrote: > >> is there any architecture for which packed is required in structures like > >> this: > >> > >> /* All standard descriptors have these 2 fields at the beginning */ > >>

[linux-usb-devel] Re: need for packed attribute

2006-01-12 Thread Russell King
On Thu, Jan 12, 2006 at 01:47:29PM +, Russell King wrote: > Due to lack of manpower on the Linux side (iow, more or less just me) > this became the ABI of the early ARM Linux a.out toolchain. At that > time, I did not consider this to be a problem - it wasn't a problem > as far as the kernel w

[linux-usb-devel] Re: need for packed attribute

2006-01-12 Thread Mikael Pettersson
Russell King writes: > > As fas as I can tell, the AAPCS document (v2.03 7th Oct 2005) requires > > that a simple "struct foo { unsigned char c; };" should have both size > > and alignment equal to 1, but gcc makes them both 4. Do you have any > > information about why gcc is doing this on ARM/

[linux-usb-devel] Re: need for packed attribute

2006-01-12 Thread Russell King
On Thu, Jan 12, 2006 at 05:30:11PM +0100, Mikael Pettersson wrote: > OK, thanks for this info. It means that GCC is the definitive authority > on calling conventions and data layouts, not the AAPCS; I wasn't aware of > that before. BTW, it's worth noting that the new EABI stuff has it's own set of

[linux-usb-devel] Re: need for packed attribute

2006-01-12 Thread Pete Zaitcev
On Thu, 12 Jan 2006 13:27:12 +0100 (MET), Mikael Pettersson <[EMAIL PROTECTED]> wrote: > [...] Do you have any > information about why gcc is doing this on ARM/Linux? Russell forgot to explain it, but the reason for this weirdness is real. It is so you can do things like this: struct foo {

[linux-usb-devel] Re: need for packed attribute

2006-01-12 Thread Russell King
On Thu, Jan 12, 2006 at 09:20:06AM -0800, Pete Zaitcev wrote: > P.S. I am repeating myself as Katon, but I am yet to see why any of > this matters. Neither Russell nor Oliver ever presented a case where > an unpacked struct caused breakage in USB. If you would like to refresh your memory (which is

[linux-usb-devel] Re: need for packed attribute

2006-01-12 Thread Pete Zaitcev
On Thu, 12 Jan 2006 17:26:17 +, Russell King <[EMAIL PROTECTED]> wrote: > On Thu, Jan 12, 2006 at 09:20:06AM -0800, Pete Zaitcev wrote: > > P.S. I am repeating myself as Katon, but I am yet to see why any of > > this matters. Neither Russell nor Oliver ever presented a case where > > an unpack

[linux-usb-devel] Re: need for packed attribute

2006-01-12 Thread Benjamin LaHaise
On Fri, Jan 06, 2006 at 06:38:46PM +, Russell King wrote: > > /* All standard descriptors have these 2 fields at the beginning */ > > struct usb_descriptor_header { > > __u8 bLength; > > __u8 bDescriptorType; > > }; > > sizeof(struct usb_descriptor_header) will be 4 on ARM. If this

[linux-usb-devel] Re: need for packed attribute

2006-01-06 Thread Russell King
On Fri, Jan 06, 2006 at 07:15:43PM +0100, Oliver Neukum wrote: > Hi, > > is there any architecture for which packed is required in structures like > this: > > /* All standard descriptors have these 2 fields at the beginning */ > struct usb_descriptor_header { > __u8 bLength; > __u8

[linux-usb-devel] Re: need for packed attribute

2006-01-06 Thread Oliver Neukum
Am Freitag, 6. Januar 2006 19:38 schrieb Russell King: > On Fri, Jan 06, 2006 at 07:15:43PM +0100, Oliver Neukum wrote: > > Hi, > > > > is there any architecture for which packed is required in structures like > > this: > > > > /* All standard descriptors have these 2 fields at the beginning */

[linux-usb-devel] Re: need for packed attribute

2006-01-06 Thread Pete Zaitcev
On Fri, 6 Jan 2006 14:33:21 -0500 (EST), Alan Stern <[EMAIL PROTECTED]> wrote: > > > > is there any architecture for which packed is required in structures > > > > like this: > > > > > > > > /* All standard descriptors have these 2 fields at the beginning */ > > > > struct usb_descriptor_header

[linux-usb-devel] Re: need for packed attribute

2006-01-06 Thread Russell King
On Fri, Jan 06, 2006 at 12:23:00PM -0800, Pete Zaitcev wrote: > Also, even if RMK is right, it either happens with some garbage gcc version > or it is just a bug which didn't reach gcc people yet. You're wrong on both counts. It's part of the ABI. > Why do we all have to > suffer because of them

[linux-usb-devel] Re: need for packed attribute

2006-01-06 Thread Pete Zaitcev
On Fri, 6 Jan 2006 22:13:56 +0100, Oliver Neukum <[EMAIL PROTECTED]> wrote: > These data structures are laid out in natural alignment. Is there anything > in the gcc documentation? I find a lot about what packed does, but where > is described what is done without packed? Russell said it's in ABI

[linux-usb-devel] Re: need for packed attribute

2006-01-06 Thread Oliver Neukum
Am Freitag, 6. Januar 2006 22:22 schrieb Pete Zaitcev: > On Fri, 6 Jan 2006 22:13:56 +0100, Oliver Neukum <[EMAIL PROTECTED]> wrote: > > > These data structures are laid out in natural alignment. Is there anything > > in the gcc documentation? I find a lot about what packed does, but where > > is

Re: [linux-usb-devel] Re: need for packed attribute

2006-01-12 Thread David Vrabel
Russell King wrote: > BTW, it's worth noting that the new EABI stuff has it's own set of > problems. We have r0 to r6 to pass 32-bit or 64-bit arguments. > With EABI, 64-bit arguments will be aligned to an _even_ numbered > register. Is there a reason for this alignment requirement? David Vrabel

Re: [linux-usb-devel] Re: need for packed attribute

2006-01-12 Thread Russell King
On Thu, Jan 12, 2006 at 05:22:47PM +, David Vrabel wrote: > Russell King wrote: > > BTW, it's worth noting that the new EABI stuff has it's own set of > > problems. We have r0 to r6 to pass 32-bit or 64-bit arguments. > > With EABI, 64-bit arguments will be aligned to an _even_ numbered > > re

Re: [linux-usb-devel] Re: need for packed attribute

2006-01-12 Thread David Brownell
On Thursday 12 January 2006, Pete Zaitcev wrote (in another snide postscript): > > P.P.S. The USB stack was careful to use correct sizes historically. > One grep of the source will tell you that all this stench emanates from > the newer code, in particular the gadget and its attendant components,

Re: [linux-usb-devel] Re: need for packed attribute

2006-01-06 Thread Alan Stern
On Fri, 6 Jan 2006, Oliver Neukum wrote: > Am Freitag, 6. Januar 2006 19:38 schrieb Russell King: > > On Fri, Jan 06, 2006 at 07:15:43PM +0100, Oliver Neukum wrote: > > > Hi, > > > > > > is there any architecture for which packed is required in structures like > > > this: > > > > > > /* All sta

Re: [linux-usb-devel] Re: need for packed attribute

2006-01-06 Thread Oliver Neukum
Am Freitag, 6. Januar 2006 20:33 schrieb Alan Stern: > On Fri, 6 Jan 2006, Oliver Neukum wrote: > > > Am Freitag, 6. Januar 2006 19:38 schrieb Russell King: > > > On Fri, Jan 06, 2006 at 07:15:43PM +0100, Oliver Neukum wrote: > > > > Hi, > > > > > > > > is there any architecture for which packed

Re: [linux-usb-devel] Re: need for packed attribute

2006-01-06 Thread Oliver Neukum
Am Freitag, 6. Januar 2006 21:23 schrieb Pete Zaitcev: > On Fri, 6 Jan 2006 14:33:21 -0500 (EST), Alan Stern <[EMAIL PROTECTED]> wrote: > > > > > > is there any architecture for which packed is required in structures > > > > > like this: > > > > > > > > > > /* All standard descriptors have these

Re: [linux-usb-devel] Re: need for packed attribute

2006-01-06 Thread Russell King
On Fri, Jan 06, 2006 at 09:46:09PM +0100, Oliver Neukum wrote: > in any case the file is inconsistent. Either all structures there have to > be packed or none. Unless someone can come up with something better > I am afraid an "#ifdef ARM" is needed. Comments? I would suggest ignoring Pete - all re

Re: [linux-usb-devel] Re: need for packed attribute

2006-01-06 Thread Oliver Neukum
Am Freitag, 6. Januar 2006 21:49 schrieb Russell King: > On Fri, Jan 06, 2006 at 09:46:09PM +0100, Oliver Neukum wrote: > > in any case the file is inconsistent. Either all structures there have to > > be packed or none. Unless someone can come up with something better > > I am afraid an "#ifdef AR

Re: [linux-usb-devel] Re: need for packed attribute

2006-01-06 Thread Alan Stern
On Fri, 6 Jan 2006, Oliver Neukum wrote: > > Perhaps you are overreacting. Even though the total size of the structure > > may be 4, I bet that bLength and bDescriptorType still occupy just the > > first two bytes of the structure. Assuming this is so, there's nothing > > wrong with the exist

Re: [linux-usb-devel] Re: need for packed attribute

2006-01-06 Thread Oliver Neukum
Am Freitag, 6. Januar 2006 22:59 schrieb Alan Stern: > On Fri, 6 Jan 2006, Oliver Neukum wrote: > > > > Perhaps you are overreacting. Even though the total size of the > > > structure > > > may be 4, I bet that bLength and bDescriptorType still occupy just the > > > first two bytes of the stru

Re: [linux-usb-devel] Re: need for packed attribute

2006-01-06 Thread Alan Stern
On Fri, 6 Jan 2006, Oliver Neukum wrote: > Am Freitag, 6. Januar 2006 22:59 schrieb Alan Stern: > > On Fri, 6 Jan 2006, Oliver Neukum wrote: > > > > > > Perhaps you are overreacting. Even though the total size of the > > > > structure > > > > may be 4, I bet that bLength and bDescriptorType st

Re: [linux-usb-devel] Re: need for packed attribute

2006-01-06 Thread Pete Zaitcev
On Fri, 6 Jan 2006 23:07:59 +0100, Oliver Neukum <[EMAIL PROTECTED]> wrote: > Sorry. I confused it with usb_device_descriptor which is appended to in > devio.c > WHich is packed. Considering pure alignment it shouldn't be. Yet there seems > to be a problem in arm. Can you shed light on this? You

Re: [linux-usb-devel] Re: need for packed attribute

2006-01-06 Thread Oliver Neukum
Am Freitag, 6. Januar 2006 23:18 schrieb Alan Stern: > I don't know why struct usb_device_descriptor is packed.  In fact, most of > the structures defined in usb_ch9.h are packed for no apparent reason.   > Maybe it's so you can dereference descriptors embedded in the > rawdescriptors array; those

Re: [linux-usb-devel] Re: need for packed attribute

2006-01-06 Thread Alan Cox
On Gwe, 2006-01-06 at 12:23 -0800, Pete Zaitcev wrote: > or it is just a bug which didn't reach gcc people yet. It is dysfunctional > to have structures padded in this way. On all other platforms they are > only padded if they include a member which is bigger than the char. Not true. Maybe for the

Re: [linux-usb-devel] Re: need for packed attribute

2006-01-06 Thread Alan Stern
On Fri, 6 Jan 2006, Oliver Neukum wrote: > Am Freitag, 6. Januar 2006 23:18 schrieb Alan Stern: > > I don't know why struct usb_device_descriptor is packed.  In fact, most of > > the structures defined in usb_ch9.h are packed for no apparent reason.   > > Maybe it's so you can dereference descript

Re: [linux-usb-devel] Re: need for packed attribute

2006-01-06 Thread David Brownell
On Friday 06 January 2006 2:18 pm, Alan Stern wrote: > > I don't know why struct usb_device_descriptor is packed. In fact, most of > the structures defined in usb_ch9.h are packed for no apparent reason. To ensure not just that the protocol formats are strictly adhered to, but that it's obviou

Re: [linux-usb-devel] Re: need for packed attribute

2006-01-06 Thread David Brownell
On Friday 06 January 2006 12:46 pm, Oliver Neukum wrote: > in any case the file is inconsistent. Either all structures there have to > be packed or none. Unless someone can come up with something better > I am afraid an "#ifdef ARM" is needed. Comments? Just pack them all. Your patch looked OK t