Commit d2943cb4 authored by Alessandro Rubini's avatar Alessandro Rubini

fmc-fakedev: provide a validate method

fmc-fakedev fakes removal and re-plugging when the eepromo is overwritten.
Thus, fmc-write-eeprom would match again and again, rewriting every two
seconds, forever.

By offsering ops->validate, the carrier prevents further matches.
To only write the first time, you can use the following, since
identifiers in fakedev start from 0xf001 ("fool").

   insmod fmc-write-eeprom busid=0xf001

The Identifier is increased avery time, so a 4-slot instance will
have identifiers 0xf001-0xf004 the first time and 0xf005-0xf008 the
next one.

This merhod allows fmc-write-eeprom to not match the busid
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 7f523503
......@@ -210,6 +210,21 @@ void ff_writel(struct fmc_device *fmc, uint32_t value, int offset)
return;
}
/* validate is useful so fmc-write-eeprom will not reprogram every 2 seconds */
static int ff_validate(struct fmc_device *fmc, struct fmc_driver *drv)
{
int i;
if (!drv->busid_n)
return 0; /* everyhing is valid */
for (i = 0; i < drv->busid_n; i++)
if (drv->busid_val[i] == fmc->device_id)
return i;
return -ENOENT;
}
static struct fmc_operations ff_fmc_operations = {
.readl = ff_readl,
.writel = ff_writel,
......@@ -217,6 +232,7 @@ static struct fmc_operations ff_fmc_operations = {
.irq_request = ff_irq_request,
.read_ee = ff_read_ee,
.write_ee = ff_write_ee,
.validate = ff_validate,
};
/* This device is kmalloced: release it */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment