Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1631663 > unrolled thread

[PATCH V2 linux-next] staging: media: atomisp: kmap() can't fail

Started byFabian Frederick <fabf@skynet.be>
First post2017-04-26 20:50 +0200
Last post2017-04-27 01:10 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH V2 linux-next] staging: media: atomisp: kmap() can't fail Fabian Frederick <fabf@skynet.be> - 2017-04-26 20:50 +0200
    Re: [PATCH V2 linux-next] staging: media: atomisp: kmap() can't fail Alan Cox <alan@linux.intel.com> - 2017-04-27 01:10 +0200

#1631663 — [PATCH V2 linux-next] staging: media: atomisp: kmap() can't fail

FromFabian Frederick <fabf@skynet.be>
Date2017-04-26 20:50 +0200
Subject[PATCH V2 linux-next] staging: media: atomisp: kmap() can't fail
Message-ID<tAAaJ-64N-1@gated-at.bofh.it>
There's no need to check kmap() return value because it won't fail.
If it's highmem mapping, it will receive virtual address
or a new one; if it's lowmem, all kernel pages are already being mapped.

(Thanks to Jan Kara for explanations)

Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
V2: Verbose description (suggested by Greg Kroah-Hartman)

 drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c
index 151abf0..7d2f8d9 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c
@@ -328,15 +328,7 @@ static int load_and_flush_by_kmap(ia_css_ptr virt, void *data, unsigned int byte
 		idx = (virt - bo->start) >> PAGE_SHIFT;
 		offset = (virt - bo->start) - (idx << PAGE_SHIFT);
 
-		src = (char *)kmap(bo->page_obj[idx].page);
-		if (!src) {
-			dev_err(atomisp_dev,
-				    "kmap buffer object page failed: "
-				    "pg_idx = %d\n", idx);
-			return -EINVAL;
-		}
-
-		src += offset;
+		src = (char *)kmap(bo->page_obj[idx].page) + offset;
 
 		if ((bytes + offset) >= PAGE_SIZE) {
 			len = PAGE_SIZE - offset;
@@ -533,14 +525,7 @@ int hmm_set(ia_css_ptr virt, int c, unsigned int bytes)
 		idx = (virt - bo->start) >> PAGE_SHIFT;
 		offset = (virt - bo->start) - (idx << PAGE_SHIFT);
 
-		des = (char *)kmap(bo->page_obj[idx].page);
-		if (!des) {
-			dev_err(atomisp_dev,
-				    "kmap buffer object page failed: "
-				    "pg_idx = %d\n", idx);
-			return -EINVAL;
-		}
-		des += offset;
+		des = (char *)kmap(bo->page_obj[idx].page) + offset;
 
 		if ((bytes + offset) >= PAGE_SIZE) {
 			len = PAGE_SIZE - offset;
-- 
2.9.3

[toc] | [next] | [standalone]


#1631790

FromAlan Cox <alan@linux.intel.com>
Date2017-04-27 01:10 +0200
Message-ID<tAEem-EN-1@gated-at.bofh.it>
In reply to#1631663
On Wed, 2017-04-26 at 20:44 +0200, Fabian Frederick wrote:
> There's no need to check kmap() return value because it won't fail.
> If it's highmem mapping, it will receive virtual address
> or a new one; if it's lowmem, all kernel pages are already being
> mapped.
> 
> (Thanks to Jan Kara for explanations)
> 

Thanks - queued.

Alan

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web