[PATCH] UBI: Use the bit operation with min_io_size

Artem Bityutskiy dedekind at infradead.org
Thu May 22 06:31:10 EDT 2008


Hi Kyungmin,

you patch looks OK to me and I'll apply it, but with few changes
(see below).

On Thu, 2008-05-22 at 10:32 +0900, Kyungmin Park wrote:
> It already checks the min io size is the power of 2 at io_init.
> 
>         /* Make sure minimal I/O unit is power of 2 */
I will add a comment here that we do not have any fundamental reason
to require this. It is just an optimization which makes it possible
to avoid costly division operations.

> +	n = req->alignment & (ubi->min_io_size - 1);
Probably we could introduce an ubi->min_io_mask variable even. But
this is anyway a subject of a separate change.

> -		ubi_assert(len % ubi->min_io_size == 0);
> +		ubi_assert(len & (ubi->min_io_size - 1) == 0);

Bitwise & has smaller priority than ==, so I think this should be

ubi_assert((len & (ubi->min_io_size - 1)) == 0); or better
ubi_assert(!(len & (ubi->min_io_size - 1)));

> -	ubi_assert(length % ubi->min_io_size == 0);
> +	ubi_assert(length & (ubi->min_io_size - 1) == 0);
Similar.


Thank you!

-- 
Best regards,
Artem Bityutskiy (Битюцкий Артём)




More information about the linux-mtd mailing list