diff mbox

mtd: mtdchar: return expected errors on mmap() call

Message ID 1382976495-1250-1-git-send-email-vladimir_zapolskiy@mentor.com
State Accepted
Commit b99959323732ed0c81da2488252f64c02ad37fbe
Headers show

Commit Message

Vladimir Zapolskiy Oct. 28, 2013, 4:08 p.m. UTC
According both to POSIX.1-2008 and Linux Programmer's Manual mmap()
syscall shouldn't return undocumented ENOSYS, this change replaces
the errno with more appropriate ENODEV and EACCESS.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Cc: David Woodhouse <David.Woodhouse@intel.com>
---
 drivers/mtd/mtdchar.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Brian Norris Nov. 8, 2013, 6:49 p.m. UTC | #1
On Mon, Oct 28, 2013 at 06:08:15PM +0200, Vladimir Zapolskiy wrote:
> According both to POSIX.1-2008 and Linux Programmer's Manual mmap()
> syscall shouldn't return undocumented ENOSYS, this change replaces
> the errno with more appropriate ENODEV and EACCESS.
> 
> Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
> Cc: David Woodhouse <David.Woodhouse@intel.com>

This looks correct to me. While it is technically an ABI breakage
(somebody could have been relying on our non-standard -ENOSYS??), it is
probably better to match POSIX and the Linux Programmer's Manual, to
keep MTD in line with everyone else.

But David, please speak up if you think this is not the right way to go.

> ---
>  drivers/mtd/mtdchar.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
> index 684bfa3..a4c026e 100644
> --- a/drivers/mtd/mtdchar.c
> +++ b/drivers/mtd/mtdchar.c
> @@ -1099,7 +1099,7 @@ static unsigned long mtdchar_get_unmapped_area(struct file *file,
>  		return (unsigned long) -EINVAL;
>  
>  	ret = mtd_get_unmapped_area(mtd, len, offset, flags);
> -	return ret == -EOPNOTSUPP ? -ENOSYS : ret;
> +	return ret == -EOPNOTSUPP ? -ENODEV : ret;
>  }
>  #endif
>  
> @@ -1124,9 +1124,9 @@ static int mtdchar_mmap(struct file *file, struct vm_area_struct *vma)
>  #endif
>  		return vm_iomap_memory(vma, map->phys, map->size);
>  	}
> -	return -ENOSYS;
> +	return -ENODEV;
>  #else
> -	return vma->vm_flags & VM_SHARED ? 0 : -ENOSYS;
> +	return vma->vm_flags & VM_SHARED ? 0 : -EACCES;
>  #endif
>  }
>  

Pushed to l2-mtd.git. Thanks!

Brian
diff mbox

Patch

diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 684bfa3..a4c026e 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -1099,7 +1099,7 @@  static unsigned long mtdchar_get_unmapped_area(struct file *file,
 		return (unsigned long) -EINVAL;
 
 	ret = mtd_get_unmapped_area(mtd, len, offset, flags);
-	return ret == -EOPNOTSUPP ? -ENOSYS : ret;
+	return ret == -EOPNOTSUPP ? -ENODEV : ret;
 }
 #endif
 
@@ -1124,9 +1124,9 @@  static int mtdchar_mmap(struct file *file, struct vm_area_struct *vma)
 #endif
 		return vm_iomap_memory(vma, map->phys, map->size);
 	}
-	return -ENOSYS;
+	return -ENODEV;
 #else
-	return vma->vm_flags & VM_SHARED ? 0 : -ENOSYS;
+	return vma->vm_flags & VM_SHARED ? 0 : -EACCES;
 #endif
 }