linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Sumit Semwal <sumit.semwal@ti.com>
Cc: linaro-mm-sig@lists.linaro.org, linux-mm@kvack.org
Subject: [PATCH 2/4] dma-buf: Remove unneeded sanity checks
Date: Thu, 26 Jan 2012 12:27:23 +0100	[thread overview]
Message-ID: <1327577245-20354-3-git-send-email-laurent.pinchart@ideasonboard.com> (raw)
In-Reply-To: <1327577245-20354-1-git-send-email-laurent.pinchart@ideasonboard.com>

ops, ops->map_dma_buf and ops->unmap_dma_buf are guaranteed to be
non-NULL by a check in dma_buf_export(). Remove NULL checks on those
variables in the other API functions.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/base/dma-buf.c |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c
index 965833ac..198edd8 100644
--- a/drivers/base/dma-buf.c
+++ b/drivers/base/dma-buf.c
@@ -185,7 +185,7 @@ struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,
 	struct dma_buf_attachment *attach;
 	int ret;
 
-	if (WARN_ON(!dmabuf || !dev || !dmabuf->ops))
+	if (WARN_ON(!dmabuf || !dev))
 		return ERR_PTR(-EINVAL);
 
 	attach = kzalloc(sizeof(struct dma_buf_attachment), GFP_KERNEL);
@@ -224,7 +224,7 @@ EXPORT_SYMBOL_GPL(dma_buf_attach);
  */
 void dma_buf_detach(struct dma_buf *dmabuf, struct dma_buf_attachment *attach)
 {
-	if (WARN_ON(!dmabuf || !attach || !dmabuf->ops))
+	if (WARN_ON(!dmabuf || !attach))
 		return;
 
 	mutex_lock(&dmabuf->lock);
@@ -255,12 +255,11 @@ struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *attach,
 
 	might_sleep();
 
-	if (WARN_ON(!attach || !attach->dmabuf || !attach->dmabuf->ops))
+	if (WARN_ON(!attach || !attach->dmabuf))
 		return ERR_PTR(-EINVAL);
 
 	mutex_lock(&attach->dmabuf->lock);
-	if (attach->dmabuf->ops->map_dma_buf)
-		sg_table = attach->dmabuf->ops->map_dma_buf(attach, direction);
+	sg_table = attach->dmabuf->ops->map_dma_buf(attach, direction);
 	mutex_unlock(&attach->dmabuf->lock);
 
 	return sg_table;
@@ -278,13 +277,11 @@ EXPORT_SYMBOL_GPL(dma_buf_map_attachment);
 void dma_buf_unmap_attachment(struct dma_buf_attachment *attach,
 				struct sg_table *sg_table)
 {
-	if (WARN_ON(!attach || !attach->dmabuf || !sg_table
-			    || !attach->dmabuf->ops))
+	if (WARN_ON(!attach || !attach->dmabuf || !sg_table))
 		return;
 
 	mutex_lock(&attach->dmabuf->lock);
-	if (attach->dmabuf->ops->unmap_dma_buf)
-		attach->dmabuf->ops->unmap_dma_buf(attach, sg_table);
+	attach->dmabuf->ops->unmap_dma_buf(attach, sg_table);
 	mutex_unlock(&attach->dmabuf->lock);
 
 }
-- 
1.7.3.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2012-01-26 11:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-26 11:27 [PATCH 0/4] Miscellaneous dma-buf patches Laurent Pinchart
2012-01-26 11:27 ` [PATCH 1/4] dma-buf: Constify ops argument to dma_buf_export() Laurent Pinchart
2012-01-26 11:32   ` [Linaro-mm-sig] " Daniel Vetter
2012-01-26 11:27 ` Laurent Pinchart [this message]
2012-01-26 11:35   ` [Linaro-mm-sig] [PATCH 2/4] dma-buf: Remove unneeded sanity checks Daniel Vetter
2012-01-26 11:27 ` [PATCH 3/4] dma-buf: Return error instead of using a goto statement when possible Laurent Pinchart
2012-01-26 11:35   ` [Linaro-mm-sig] " Daniel Vetter
2012-01-26 11:27 ` [PATCH 4/4] dma-buf: Move code out of mutex-protected section in dma_buf_attach() Laurent Pinchart
2012-01-26 11:36   ` [Linaro-mm-sig] " Daniel Vetter
2012-01-26 12:11   ` Chris Wilson
2012-01-26 12:37     ` Daniel Vetter
2012-01-27  5:19 ` [PATCH 0/4] Miscellaneous dma-buf patches Sumit Semwal
2012-03-21 11:20   ` Laurent Pinchart
2012-03-21 11:42     ` Sumit Semwal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1327577245-20354-3-git-send-email-laurent.pinchart@ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-mm@kvack.org \
    --cc=sumit.semwal@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox