linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] include: mm: Adding new inline function vmf_error
@ 2018-04-05 16:22 Souptick Joarder
  2018-04-05 16:52 ` Matthew Wilcox
  2018-04-05 19:53 ` Andrew Morton
  0 siblings, 2 replies; 6+ messages in thread
From: Souptick Joarder @ 2018-04-05 16:22 UTC (permalink / raw)
  To: willy, akpm; +Cc: linux-mm

Many places in drivers/ file systems error was handled
like below -
ret = (ret == -ENOMEM) ? VM_FAULT_OOM : VM_FAULT_SIGBUS;

This new inline function vmf_error() will replace this
and return vm_fault_t type err.

Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
---
 include/linux/mm.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index a4d8853..e283dd8 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2453,6 +2453,18 @@ static inline vm_fault_t vmf_insert_pfn(struct vm_area_struct *vma,
 	return VM_FAULT_NOPAGE;
 }
 
+static inline vm_fault_t vmf_error(int err)
+{
+	vm_fault_t ret;
+
+	if (err == -ENOMEM)
+		ret = VM_FAULT_OOM;
+	else
+		ret = VM_FAULT_SIGBUS;
+
+	return ret;
+}
+
 struct page *follow_page_mask(struct vm_area_struct *vma,
 			      unsigned long address, unsigned int foll_flags,
 			      unsigned int *page_mask);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-05-02 21:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-05 16:22 [PATCH] include: mm: Adding new inline function vmf_error Souptick Joarder
2018-04-05 16:52 ` Matthew Wilcox
2018-04-05 19:53 ` Andrew Morton
2018-04-05 20:26   ` Matthew Wilcox
2018-05-02  6:17     ` Souptick Joarder
2018-05-02 21:12       ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).