From patchwork Thu Mar 22 10:02:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 7403 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 7673223DEA for ; Thu, 22 Mar 2012 10:02:27 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 38C89A183EF for ; Thu, 22 Mar 2012 10:02:27 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id e36so3827723iag.11 for ; Thu, 22 Mar 2012 03:02:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to :date:message-id:x-mailer:in-reply-to:references:cc:subject :x-beenthere:x-mailman-version:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:sender:errors-to :x-gm-message-state; bh=AcadUUAjhd+YBGTPk0fNOMZrXcix2U3CqYJ0ZrV660I=; b=FH0U/8tsMFjh+Twvo2E5R6aKV0Exvcm8t/v/LXr225I73Il/xSWHqboprxMcDwkXNK jMs2wE6PDZxXla2UI0cmhbgUgvgHguSOcSo6ahsKzxUs9O/gy89eRkDPX/6YvjM+heDx N7j6f2Jh3HjDavoUNxMYSwDAwjru2LJjoZhLN9uRe6S1Jm0O8es/Pvg1TK4rBIXMAuP2 adG/T9WPPlD8AKoT/vf1PF3WGE4GngJ6qSdd9OCuA4pZyAB+PGm84/T/xL6avlX1E7TL 1ePw4C9uYORq1YIS8Ky9/I8mSlPas5tADPFAUQGOeWH3P16E+Al8Dnw7gOukdEl0BHI7 HqwA== Received: by 10.42.72.130 with SMTP id o2mr4859858icj.8.1332410546965; Thu, 22 Mar 2012 03:02:26 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.203.79 with SMTP id fh15csp43652ibb; Thu, 22 Mar 2012 03:02:26 -0700 (PDT) Received: by 10.180.107.162 with SMTP id hd2mr3512150wib.8.1332410540223; Thu, 22 Mar 2012 03:02:20 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id v2si4573203weq.39.2012.03.22.03.02.18; Thu, 22 Mar 2012 03:02:20 -0700 (PDT) Received-SPF: neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) client-ip=91.189.95.16; Authentication-Results: mx.google.com; spf=neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) smtp.mail=linaro-mm-sig-bounces@lists.linaro.org Received: from localhost ([127.0.0.1] helo=mombin.canonical.com) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SAeqY-0000vb-Bi; Thu, 22 Mar 2012 10:02:18 +0000 Received: from perceval.ideasonboard.com ([95.142.166.194]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SAeqW-0000AN-FJ for linaro-mm-sig@lists.linaro.org; Thu, 22 Mar 2012 10:02:16 +0000 Received: from localhost.localdomain (ptr-91-87-217-68.mobistar.be [91.87.217.68]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 41150362BA; Thu, 22 Mar 2012 11:02:12 +0100 (CET) From: Laurent Pinchart To: Tomasz Stanislawski Date: Thu, 22 Mar 2012 11:02:22 +0100 Message-Id: <1332410543-14433-3-git-send-email-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <5187420.ORugDzE4Gp@avalon> References: <5187420.ORugDzE4Gp@avalon> Cc: sumit.semwal@ti.com, robdclark@gmail.com, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, kyungmin.park@samsung.com, sakari.ailus@iki.fi, Andrzej Pietrasiewicz , airlied@redhat.com, Kamil Debski Subject: [Linaro-mm-sig] [RFCv2 PATCH 2/9 - 3/4] v4l: vb2-dma-contig: Remove unneeded allocation context structure X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Unified memory management interest group." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linaro-mm-sig-bounces@lists.linaro.org Errors-To: linaro-mm-sig-bounces@lists.linaro.org X-Gm-Message-State: ALoCoQk9DCBurKziG6gKfW5w6DMJTsr/7BC+Ri/0lQ3eCJttHYks4KpF3vG3H67jl/TG/O6UqgQ0 vb2-dma-contig returns a vb2_dc_conf structure instance as the vb2 allocation context. That structure only stores a pointer to the physical device. Remove it and use the device pointer directly as the allocation context. Signed-off-by: Laurent Pinchart --- drivers/media/video/videobuf2-dma-contig.c | 29 ++++++--------------------- 1 files changed, 7 insertions(+), 22 deletions(-) diff --git a/drivers/media/video/videobuf2-dma-contig.c b/drivers/media/video/videobuf2-dma-contig.c index 6bc4651..c898e6f 100644 --- a/drivers/media/video/videobuf2-dma-contig.c +++ b/drivers/media/video/videobuf2-dma-contig.c @@ -17,12 +17,8 @@ #include #include -struct vb2_dc_conf { - struct device *dev; -}; - struct vb2_dc_buf { - struct vb2_dc_conf *conf; + struct device *dev; void *vaddr; unsigned long size; dma_addr_t dma_addr; @@ -71,7 +67,7 @@ static void vb2_dc_put(void *buf_priv) struct vb2_dc_buf *buf = buf_priv; if (atomic_dec_and_test(&buf->refcount)) { - dma_free_coherent(buf->conf->dev, buf->size, buf->vaddr, + dma_free_coherent(buf->dev, buf->size, buf->vaddr, buf->dma_addr); kfree(buf); } @@ -79,23 +75,21 @@ static void vb2_dc_put(void *buf_priv) static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size) { - struct vb2_dc_conf *conf = alloc_ctx; + struct device *dev = alloc_ctx; struct vb2_dc_buf *buf; buf = kzalloc(sizeof *buf, GFP_KERNEL); if (!buf) return ERR_PTR(-ENOMEM); - buf->vaddr = dma_alloc_coherent(conf->dev, size, &buf->dma_addr, - GFP_KERNEL); + buf->vaddr = dma_alloc_coherent(dev, size, &buf->dma_addr, GFP_KERNEL); if (!buf->vaddr) { - dev_err(conf->dev, "dma_alloc_coherent of size %ld failed\n", - size); + dev_err(dev, "dma_alloc_coherent of size %ld failed\n", size); kfree(buf); return ERR_PTR(-ENOMEM); } - buf->conf = conf; + buf->dev = dev; buf->size = size; buf->handler.refcount = &buf->refcount; @@ -180,21 +174,12 @@ EXPORT_SYMBOL_GPL(vb2_dma_contig_memops); void *vb2_dma_contig_init_ctx(struct device *dev) { - struct vb2_dc_conf *conf; - - conf = kzalloc(sizeof *conf, GFP_KERNEL); - if (!conf) - return ERR_PTR(-ENOMEM); - - conf->dev = dev; - - return conf; + return dev; } EXPORT_SYMBOL_GPL(vb2_dma_contig_init_ctx); void vb2_dma_contig_cleanup_ctx(void *alloc_ctx) { - kfree(alloc_ctx); } EXPORT_SYMBOL_GPL(vb2_dma_contig_cleanup_ctx);