Re: [PATCH v6] mtd:nor:timeout:fix do_write_buffer() timeout error

From: Brian Norris
Date: Wed Jul 16 2014 - 14:04:33 EST


Hi Bean,

On Wed, Jul 16, 2014 at 09:05:26AM -0700, Bean Huo wrote:
> From: bean huo <beanhuo@xxxxxxxxxxx>
>
> For some Norflashes,the size of the buffer program has been
> increased from 256 bytes to 512 bytes,2ms maximum timeout can
> not adapt to all the different vendor's norflash.There maximum
> timeout information in the CFI area,so the best way is to choose
> the result calculated according to timeout field of struct cfi_ident
> that probed from norflash's CFI aera.This is also a standard defined
> by CFI.If haven't probed this information,or smaller than 2000us,then
> specify a defualt value 2000us.
>
> Tested with Micron JS28F512M29EWx and Micron MT28EW512ABA flash devices.
>
> Signed-off-by: bean huo <beanhuo@xxxxxxxxxxx>
> ---
> v1->v2:Deleted unused parameters in this patch(word_write_time_max and erase_time_max).
> Using usecs_to_jiffies instead of msecs_to_jiffies for convert timeout value into jiffies.
> v2->v3:Removed unnecessary messages form comments and deleted trailing whitespace.
> V3->v4:If haven't probed timeout information,or smaller than 2000us,specify default 2000us.
> v4->v5:Add space before '>='
> v5->v6:Add the same indentation as 'if' at the front of 'else'
>
> drivers/mtd/chips/cfi_cmdset_0002.c | 29 +++++++++++++++++++++++++++--
> 1 file changed, 27 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
> index e21fde9..aed6f9e 100644
> --- a/drivers/mtd/chips/cfi_cmdset_0002.c
> +++ b/drivers/mtd/chips/cfi_cmdset_0002.c
> @@ -628,6 +628,25 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
[...]
> + cfi->chips[i].buffer_write_time_max =
> + ((cfi->chips[i].buffer_write_time_max >= 2000)
> + ? cfi->chips[i].buffer_write_time_max : 2000);

This should just use the 'max()' macro, from <linux/kernel.h>.

> +
> cfi->chips[i].ref_point_counter = 0;
> init_waitqueue_head(&(cfi->chips[i].wq));
> }

I have just fixed up your patch myself, to use max() and to improve some
of the language. Let me know if the below works for you.