[PATCH] mtd: spi-nor: Check the return value from read_sr()

Brian Norris computersforpeace at gmail.com
Thu Nov 19 14:58:11 PST 2015


On Thu, Nov 19, 2015 at 08:48:23PM -0200, Fabio Estevam wrote:
> On Thu, Nov 19, 2015 at 7:54 PM, Brian Norris
> <computersforpeace at gmail.com> wrote:
> 
> > Hmm, by changing status_old from u8 to int, do we propagate any
> > sign-extension issues in this function? What if BIT(7) is set? If I
> 
> If the value returned by read_sr() has BIT(7) set then it is not an
> error, right?
> 
> read_sr() can return negative on error and u8 on success.
> 
> Not sure I understand your concern.

I guess my comment was based on my misplaced uncertainty on whether u8
would sign-extend or zero-extend when converted to int. It appears the
standard says that unsigned values get zero-extended. i.e.:

	u8 val = BIT(7); // 0x80

gets zero-extended to:

	return val; // that is, 0x00000080, not 0xffffff80

If we stick with u8, then it doesn't really matter which one it is.

The only remaining concern is over the mild awkwardness of comparing and
manipulating status_old and status_new, where one is int and the other
is u8. But I guess there are no issues yet, AFAICT.

Brian



More information about the linux-mtd mailing list