From patchwork Fri Apr 28 12:10:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cox X-Patchwork-Id: 9704541 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 90CD8602B7 for ; Fri, 28 Apr 2017 12:10:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 820BF285E7 for ; Fri, 28 Apr 2017 12:10:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7729B28681; Fri, 28 Apr 2017 12:10:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBEE4285E7 for ; Fri, 28 Apr 2017 12:10:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1425818AbdD1MKp (ORCPT ); Fri, 28 Apr 2017 08:10:45 -0400 Received: from mga07.intel.com ([134.134.136.100]:33135 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1425815AbdD1MKm (ORCPT ); Fri, 28 Apr 2017 08:10:42 -0400 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP; 28 Apr 2017 05:10:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,388,1488873600"; d="scan'208";a="81761668" Received: from acox1-desk1.ger.corp.intel.com ([10.252.17.169]) by orsmga004.jf.intel.com with ESMTP; 28 Apr 2017 05:10:41 -0700 Subject: [PATCH 8/8] staging: media: atomisp: kmap() can't fail From: Alan Cox To: greg@kroah.com, linux-media@vger.kernel.org Date: Fri, 28 Apr 2017 13:10:39 +0100 Message-ID: <149338143808.2556.11877229471999212854.stgit@acox1-desk1.ger.corp.intel.com> In-Reply-To: <149338135275.2556.7708531564733886566.stgit@acox1-desk1.ger.corp.intel.com> References: <149338135275.2556.7708531564733886566.stgit@acox1-desk1.ger.corp.intel.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Fabian Frederick 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 Signed-off-by: Alan Cox --- .../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 3588723..5729539 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c @@ -333,15 +333,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; @@ -538,14 +530,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;