[PATCH 04/12] mtd: move mtd_oob_mode_t to shared kernel/user space

Artem Bityutskiy dedekind1 at gmail.com
Sun Sep 11 07:57:09 EDT 2011


On Tue, 2011-08-30 at 18:45 -0700, Brian Norris wrote:
> -	mtd_oob_mode_t mode = ops->mode;
> +	uint8_t mode = ops->mode;

...
>  struct mtd_oob_ops {
> -	mtd_oob_mode_t	mode;
> +	uint8_t		mode;
>  	size_t		len;
>  	size_t		retlen;
>  	size_t		ooblen;

It is good to use __u8 in ioctls for this field.

But for internal usage there is no need to make it uint8_t, just use
'int' instead. All modern CPUs will anyway reserve 32 bits for this.

And unnecessary usage of the 8-bits restriction only imposes more
unnecessary limitations to the compiler/CPU. Using 'int' is instead
making CPU/compiler use the native integer type.

BTW, you may also re-arrange this data structure and make it 8-bytes
smaller on 64-bit architectures. Indeed, it has 'size_t' and 'uint8_t *'
fields, which are 64-bits, and it has one 'uint32_t        ooboffs;',
which is 32-bits and is also padded. If you put 'int mode' and 'uint32_t
ooboffs' together, you'll save 2 paddings. But this is optional.


-- 
Best Regards,
Artem Bityutskiy




More information about the linux-mtd mailing list