Re: [RFC 2.6] Rework memory allocation in i2c chip drivers

From: Geert Uytterhoeven
Date: Sat Apr 03 2004 - 14:10:03 EST


On Sat, 3 Apr 2004, Jean Delvare wrote:
> Some times ago, Ralf Roesch reported that the memory allocation scheme
> used in the i2c eeprom driver was causing trouble on MIPS architecture:
>
> http://archives.andrew.net.au/lm-sensors/msg07233.html
>
> The cause of the problems is that we do allocate two structures with a
> single kmalloc, which breaks alignment. This doesn't seem to be a
> problem on x86, but is on mips and probably on other architectures as
> well. It happens that all other chip drivers work the same way too, so
> they all would need to be fixed.
>
> Here comes my proposal to fix the problem. A few notes:

Alternatively, define a new struct containing the two structs

struct combined {
struct part1 part1;
struct part2 part2;
};

and allocate a struct combined, and the C compiler will take care of alignment.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/