[PATCH v2 1/2] mtd: Stop directly calling master ->_xxx() hooks from mtdpart code

Boris Brezillon boris.brezillon at free-electrons.com
Tue Jun 27 12:52:00 PDT 2017


Le Tue, 27 Jun 2017 21:19:38 +0200,
Boris Brezillon <boris.brezillon at free-electrons.com> a écrit :

> > 
> > [...]
> > 
> > I was also wondering whether this patch couldn't go a step further, and
> > remove conditions like this:
> > 
> > 	if (parent->_panic_write)
> > 		slave->mtd._panic_write = part_panic_write; 
> > 
> > Since part_panic_write() should call mtd_panic_write() on the parent
> > (master), which would do its own -EOPNOTSUPP check. But then I suppose
> > that might invert the order of the checks, causing (for example) -EINVAL
> > for out-of-bounds panic write instead of -EOPNOTSUPP. So maybe that's
> > better left alone.  
> 
> I considered doing that but was too lazy to check if all helpers were
> properly checking the pointer value before dereferencing it :).

I just checked, and it seems we can unconditionally set part hooks and
rely on default mtd_xxx() helpers to detect when the feature is not
supported by the master.



More information about the linux-mtd mailing list