Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3422235imm; Tue, 29 May 2018 07:02:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrIVogxMa7fkihqGbittcCBqVm5Vo0aItY5TmlJjmn8HIcg0RzciKAiNplXM2OAsNWV0Jr8 X-Received: by 2002:a62:9696:: with SMTP id s22-v6mr17427267pfk.191.1527602568943; Tue, 29 May 2018 07:02:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527602568; cv=none; d=google.com; s=arc-20160816; b=sflDexIWp+tqOof6PL0radZGDuNHYnq1sDuT5gU5gLMgCGwzlhWQqkStnUNCKJEX7y d2NXNtYpA31l2hckZ4qmSwgwtNFhBOkiY+7GAbVsvxr1qfyxiSBvkve5Vq70Lbhy9mEj jlmeXkEuPW/ZWTbfog/OPLCzndeivh9azdh9Hi0n6Q5Z6hfH1eWJEaNU4b9JUBhSLYtS R1qw1H7WnHyWwmozsqmAHRjh/9HdUQuPUpQs3HinabvyQANJH+9/NojlnU6HLK0aQHEk I1EXWkxlFroBGc/IeHUboZYdNxGZBX79KUguVtPbS5EwNUXe2UPjtsBT0IUeyVWCGOMR 9wxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=7Vnb2VDTilypjfAfDdOYRkp89lSpz9IFXAfP1alAtNo=; b=idlHw+yiiFA4MVt8h5PLkK4yg+ZgmKWUdPboqd/V9AWLMOUfroE/PLCT6IiPArRE/v QAI7YKfotS2yRxCAcTK8RjrguZAy1MSlaNRLjcLM+S8JWIiktUMlBUTTcaE0RbAuxTFP EeDAM0HxH8aTVLI/oyc7L4CBcss2yqHVvoVxN9lN29zj5NsQ7T3yp+ODkAr3ZDwSQG37 speKzOLIOzz2KimTibzLoU3AUTC7xJ44lVXEyWZGuxV8uP/If5djMseoQOoQ6ZGWzpHi j7U9WVxWt7mv5MjX/RIww+dU1CHjZzayisAqkHPgWxxPIEw7kgrlAzQ4iRZcEWv2TPTN NHfg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o11-v6si19805299pgp.331.2018.05.29.07.02.34; Tue, 29 May 2018 07:02:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934583AbeE2OBC (ORCPT + 99 others); Tue, 29 May 2018 10:01:02 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:36598 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934764AbeE2N7h (ORCPT ); Tue, 29 May 2018 09:59:37 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 20B367D668; Tue, 29 May 2018 13:59:36 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-13.ams2.redhat.com [10.36.117.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C28E2315C; Tue, 29 May 2018 13:59:33 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id DA37D998; Tue, 29 May 2018 15:59:32 +0200 (CEST) From: Gerd Hoffmann To: dri-devel@lists.freedesktop.org Cc: Gerd Hoffmann , Daniel Vetter , Sumit Semwal , linux-media@vger.kernel.org (open list:DMA BUFFER SHARING FRAMEWORK), linaro-mm-sig@lists.linaro.org (moderated list:DMA BUFFER SHARING FRAMEWORK), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] dma-buf: make map_atomic and map function pointers optional Date: Tue, 29 May 2018 15:59:18 +0200 Message-Id: <20180529135918.19729-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 29 May 2018 13:59:36 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 29 May 2018 13:59:36 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kraxel@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org So drivers don't need dummy functions just returning NULL. Cc: Daniel Vetter Signed-off-by: Gerd Hoffmann --- include/linux/dma-buf.h | 4 ++-- drivers/dma-buf/dma-buf.c | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h index 085db2fee2..88917fa796 100644 --- a/include/linux/dma-buf.h +++ b/include/linux/dma-buf.h @@ -39,12 +39,12 @@ struct dma_buf_attachment; /** * struct dma_buf_ops - operations possible on struct dma_buf - * @map_atomic: maps a page from the buffer into kernel address + * @map_atomic: [optional] maps a page from the buffer into kernel address * space, users may not block until the subsequent unmap call. * This callback must not sleep. * @unmap_atomic: [optional] unmaps a atomically mapped page from the buffer. * This Callback must not sleep. - * @map: maps a page from the buffer into kernel address space. + * @map: [optional] maps a page from the buffer into kernel address space. * @unmap: [optional] unmaps a page from the buffer. * @vmap: [optional] creates a virtual mapping for the buffer into kernel * address space. Same restrictions as for vmap and friends apply. diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index d78d5fc173..4c45e31258 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -872,6 +872,8 @@ void *dma_buf_kmap_atomic(struct dma_buf *dmabuf, unsigned long page_num) { WARN_ON(!dmabuf); + if (!dmabuf->ops->map_atomic) + return NULL; return dmabuf->ops->map_atomic(dmabuf, page_num); } EXPORT_SYMBOL_GPL(dma_buf_kmap_atomic); @@ -907,6 +909,8 @@ void *dma_buf_kmap(struct dma_buf *dmabuf, unsigned long page_num) { WARN_ON(!dmabuf); + if (!dmabuf->ops->map) + return NULL; return dmabuf->ops->map(dmabuf, page_num); } EXPORT_SYMBOL_GPL(dma_buf_kmap); -- 2.9.3