[PATCH] mtd: cfi_cmdset_0002: Initialize datum before calling map_word_load_partial

Brian Norris computersforpeace at gmail.com
Thu May 7 00:02:56 PDT 2015


On Tue, Mar 31, 2015 at 11:29:22PM +0200, Christian Riesch wrote:
> In do_otp_write we must initialize the variable datum before calling
> map_word_load_partial. Otherwise the upper bits of datum may be undefined,
> which later causes problems in chip_good called by do_write_oneword.

Hmm, are you sure this is actually the problem? It looks to me like the
logic for the "partial write of a word, load old contents" block means
that we *will* initialize datum with old contents, if we're not aligned.
So your initialization actually looks redundant.

Or please help explain, if I'm wrong.

Brian

> Signed-off-by: Christian Riesch <christian.riesch at omicron.at>
> ---
>  drivers/mtd/chips/cfi_cmdset_0002.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
> index c50d8cf..c3624eb 100644
> --- a/drivers/mtd/chips/cfi_cmdset_0002.c
> +++ b/drivers/mtd/chips/cfi_cmdset_0002.c
> @@ -1295,7 +1295,7 @@ static int do_otp_write(struct map_info *map, struct flchip *chip, loff_t adr,
>  		unsigned long bus_ofs = adr & ~(map_bankwidth(map)-1);
>  		int gap = adr - bus_ofs;
>  		int n = min_t(int, len, map_bankwidth(map) - gap);
> -		map_word datum;
> +		map_word datum = map_word_ff(map);
>  
>  		if (n != map_bankwidth(map)) {
>  			/* partial write of a word, load old contents */
> -- 
> 1.7.9.5
> 



More information about the linux-mtd mailing list