[flashrom] [PATCH] Factor out lock functions (print, unlock, lock)

Maciej Pijanka maciej.pijanka at gmail.com
Fri Nov 20 00:05:11 CET 2009


On czw, 19 lis 2009, Carl-Daniel Hailfinger wrote:

> On 20.10.2009 23:38, Carl-Daniel Hailfinger wrote:
> > New version.
> >
> > Chip locking has three actions you can do with it:
> > - Print/read the current locking status
> > - Lock the chip
> > - Unlock the chip.
> >
> > Currently, the code usually does lock printing inside the probe
> > function, and unlocking somewhere in the erase or write function. Only
> > very few chips reactivate the lock after write/erase. Since many chips
> > have identical probe/write/erase functions, but totally different
> > locking, many such functions have been duplicated needlessly.
> > With this patch, it is possible to call the chip-specific locking
> > functions from probe/write/erase functions and unify lots of code.
> >
> > I converted spi.c and pm49fl00x.c to use the internal lock abstractions,
> > but all other files need the same treatment.

How about adding dummy operation to enum and something like

case dummy_op:
default:

in switch clause, first to use 0 value to dummy op, also to make more explicit what
default really is. 

Additionally i didn't saw any routine that lets check if current chip has any lock abilities like
spi_lock(somechip, lock_query) which would return if any locks are available or something that
code may use it to check if locking is available (regardless of presence routine in chip data) 
for this chip. 

Maybe this isn't really needed but we have routine that sets and resets lock, prints info to user
but no routine that could poll status of lock or verify if chip has locking abilities at all.

Best Regards
Maciej

-- 
Maciej Pijanka




More information about the flashrom mailing list