new helpers: no_seek_end_llseek{,_size}()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro
2015-12-05 22:04:48 -05:00
parent b808b1d632
commit b25472f9b9
13 changed files with 54 additions and 222 deletions
+1 -30
View File
@@ -277,36 +277,7 @@ static loff_t flash_llseek(struct file *file, loff_t offset, int orig)
printk(KERN_DEBUG "flash_llseek: offset=0x%X, orig=0x%X.\n",
(unsigned int) offset, orig);
switch (orig) {
case 0:
if (offset < 0) {
ret = -EINVAL;
break;
}
if ((unsigned int) offset > gbFlashSize) {
ret = -EINVAL;
break;
}
file->f_pos = (unsigned int) offset;
ret = file->f_pos;
break;
case 1:
if ((file->f_pos + offset) > gbFlashSize) {
ret = -EINVAL;
break;
}
if ((file->f_pos + offset) < 0) {
ret = -EINVAL;
break;
}
file->f_pos += offset;
ret = file->f_pos;
break;
default:
ret = -EINVAL;
}
ret = no_seek_end_llseek_size(file, offset, orig, gbFlashSize);
mutex_unlock(&flash_mutex);
return ret;
}