[PATCH v2] mtd: m25p80: Calculate flash block protect bits based on number of sectors

Marek Vasut marex at denx.de
Wed Apr 16 05:30:39 PDT 2014


On Wednesday, April 16, 2014 at 02:26:41 PM, Austin Boyle wrote:
> On Sun, 13 Apr 2014, Marek Vasut wrote:
> > This portion of code looks like a duplicate of ...
> > 
> > > +	for (lock_bits = 1; lock_bits < 7; lock_bits++) {
> > > +		protected_area_start = flash->mtd.size -
> > > +					get_protected_area(flash, lock_bits);
> > > +		if (offset+len >= protected_area_start)
> > > +			break;
> > > +	}
> > > +	lock_bits--;
> > > +
> > > +	status_new = (status_old & ~SR_BP_BIT_MASK) |
> > > +			((lock_bits << SR_BP_BIT_OFFSET) & SR_BP_BIT_MASK);
> > 
> > ... this here (if you don't consider the lock_bits--) . Why don't we move
> > this into a separate function to avoid the duplication?
> 
> Thanks for reviewing this patch Marek, your suggestions were very
> helpful. I am about to post another version that
> hopefully addresses the issues raised, I would appreciate if you can take
> another look at it.

Actually, thank _you_ for working on this :)

Best regards,
Marek Vasut



More information about the linux-mtd mailing list