none
Convert endianness?

    Question

  • Hello,
    I read data from the SAS controller chip in my Windows7 driver. When I examine the values of the data that is read from the chip on Windbg watch window and compare it with the Linux "dmesg" command output for the same controller card, the values match.
    But in the Linux driver code for this controller, when they read the data from the chip, for some values, they use le32_to_cpu before it is saved onto variables in the kernel space.

    Both my Windows driver and the Linux driver are meant to be loaded on x86 PCs.
    So, in my Win 7 driver, do I have to convert the endianness of the value read from the chip before saving to kernel variables ?

    Thanks.
    Friday, February 9, 2018 11:44 PM

Answers

  • Both my Windows driver and the Linux driver are meant to be loaded on x86 PCs

    The Linux driver is meant to be portable and run on all kinds of architectures whether or not it makes sense. 

    But all Windows machines are little endian. If you enjoy extra layers of annoying macros, by all means define all these "le32_to_cpu" as no-op and preserve them in your source.

    -- pa

    • Marked as answer by P Krish Saturday, February 10, 2018 12:11 AM
    Saturday, February 10, 2018 12:09 AM

All replies

  • Both my Windows driver and the Linux driver are meant to be loaded on x86 PCs

    The Linux driver is meant to be portable and run on all kinds of architectures whether or not it makes sense. 

    But all Windows machines are little endian. If you enjoy extra layers of annoying macros, by all means define all these "le32_to_cpu" as no-op and preserve them in your source.

    -- pa

    • Marked as answer by P Krish Saturday, February 10, 2018 12:11 AM
    Saturday, February 10, 2018 12:09 AM
  • Thanks.
    • Marked as answer by P Krish Saturday, February 10, 2018 12:11 AM
    • Unmarked as answer by P Krish Saturday, February 10, 2018 12:11 AM
    Saturday, February 10, 2018 12:11 AM