Commit 7ba50cea authored by Federico Vaga's avatar Federico Vaga

kernel: add lock command

I do not think that it is going to be really useful.
I added this, so that if the user unlocks the programming it can locks it back
immediately without re-programming the FPGA.
Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@vaga.pv.it>
parent e3345018
......@@ -542,18 +542,25 @@ static ssize_t svec_afpga_lock_show(struct device *dev,
/**
* It unlocks the AFPGA programming when the user write "unlock"
* It unlocks the AFPGA programming when the user write "unlock" or "lock"
*/
static ssize_t svec_afpga_lock_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct svec_dev *svec = to_svec_dev(dev);
unsigned int lock;
if (strncmp(buf, "unlock" , min(6, (int)count)) != 0)
if (strncmp(buf, "unlock" , min(6, (int)count)) != 0 &&
strncmp(buf, "lock" , min(4, (int)count)) != 0)
return -EINVAL;
lock = (strncmp(buf, "lock" , min(4, (int)count)) == 0);
spin_lock(&svec->lock);
if (lock)
set_bit(SVEC_FLAG_LOCK, svec->flags);
else
clear_bit(SVEC_FLAG_LOCK, svec->flags);
spin_unlock(&svec->lock);
......
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