lkml.org 
[lkml]   [2000]   [Feb]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: [PATCH] isa_{read,write}{w,l} fixed
    Date
    Jeff Garzik writes:
    > * You can never directly use a struct to access an offset in MMIO
    > space. To do so is broken and bad bad bad. The only acceptable way is
    >
    > my_struct = ioremap (...);
    > my_reg = readb(&my_struct->foo_register);

    Err, but that's not guaranteed to produce what you expect. Although GCC
    (and ANSI compilers) are not allowed to re-order the elements of a
    structure, they are allowed to add padding (unused bytes) between elements
    of the structure. (Yes, we've encountered this before).

    The only truely portable way of doing this type of thing is to use either
    integer or char arrays.

    > I much prefer to avoid structs, and use macros to access registers
    > instead:
    >
    > my_reg = RTL_R8 (FooRegisterConstant);

    From reading IO-mapping.txt, it appears that the correct way is to:

    char *my_ptr;
    my_ptr = ioremap(...);
    my_reg = readb(my_ptr + reg_offset);

    BTW, isn't it about time this document was updated wrt the isa_* macros?
    It currently implies that it's ok to do:

    reg = readb(0xc0000)

    to read ISA address 0xc0000, which seems it should now be:

    reg = isa_readb(0xc0000)

    at the very least.
    _____
    |_____| ------------------------------------------------- ---+---+-
    | | Russell King rmk@arm.linux.org.uk --- ---
    | | | | http://www.arm.linux.org.uk/~rmk/aboutme.html / / |
    | +-+-+ --- -+-
    / | THE developer of ARM Linux |+| /|\
    / | | | --- |
    +-+-+ ------------------------------------------------- /\\\ |

    -
    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/

    \
     
     \ /
      Last update: 2005-03-22 13:56    [W:4.176 / U:0.460 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site