Re: [patch-2.4.0-test2]Re: Linux-2.4.0-test2

From: Rogier Wolff (R.E.Wolff@BitWizard.nl)
Date: Sun Jun 25 2000 - 02:08:42 EST


Alan Cox wrote:
> > So all drivers (I'm sure there are a few) that use something like
> >
> > struct foo {
> > u32 a;
> > u32 b;
> > u32 c;
> > u32 d;
> > }
> >
> > to communicate with some hardware (4 32-bit values with addresses in
> > sequence) should be fixed not to make assumptions about the layout of a
> > struct?
 
> You need to be very very careful doing it. Rusty found this out
> recently with netfilter. I had problems in 2.1.x with SYS5fs for
> similar reasons - the m68k packs on 16bit boundaries so all the
> superblocks were the wrong size. Thankfully the author at least
> checked the size and panic()ed on error

... And although I find the code MUCH more readable like this:

        mydevice->dma_addr = addr;
        mydevice->dma_len = len;
        mydevice->control |= CTRL_DMA_ENABLE;

this is not how it's commonly done under Linux: Due to processor
differences you cannot just access a structure through a pointer and
assume the resulting memory access ends up in the right place. There
are macros that you need to call for an IO to get performed on some
architectures, so regretably, this is not the way that you can get
this done.

                                Roger.

-- 
** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2137555 **
*-- BitWizard writes Linux device drivers for any device you may have! --*
*       Common sense is the collection of                                *
******  prejudices acquired by age eighteen.   -- Albert Einstein ********

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Jun 26 2000 - 21:00:06 EST