From patchwork Tue Aug 26 12:09:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 36009 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f198.google.com (mail-qc0-f198.google.com [209.85.216.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C109D2054F for ; Tue, 26 Aug 2014 12:14:17 +0000 (UTC) Received: by mail-qc0-f198.google.com with SMTP id r5sf46312745qcx.1 for ; Tue, 26 Aug 2014 05:14:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=+6kgJAkdyvTcYsR//sNUopDhzrDxNsG/g9smN1j/McI=; b=bzWehaHbrNuwvCaJWUCkZCflu0GRvqLkTcnASUBxTYb8HxgclpvEIr80Jpo8p26quM cYgzcasuOg4+FFUcZVYs5qC6ZSm6Psgz5zHnVHgIJDzn6bmbXWv1zUZBjewhBmq9JKmu CowVeijTp4K0LE2SBfuXSftPoL65WxPmq3dXrtfD3Lk/SKQu2i7IPOcjSm/0P3ihcf7s OxR7zw+GhFB8fiLAIIgSJYaypEPXDhQ+RJsng+55azR9dd9HPUmONTQ9sN60sdnTkZBf jgPdVPRujcRoRx+do5UJnxAFf0iqhONiFYrZ7edNzZk/fv42mU793cC8dvExaRhOEnv3 Es6Q== X-Gm-Message-State: ALoCoQlc1guJSe+oetrpP6nkQqLgHTEZsknNvsd6+QYY/wXoRrtLGwLcwtzYWV1WuSDJnY8akPJN X-Received: by 10.236.28.228 with SMTP id g64mr8781160yha.40.1409055257634; Tue, 26 Aug 2014 05:14:17 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.104.18 with SMTP id z18ls134348qge.0.gmail; Tue, 26 Aug 2014 05:14:17 -0700 (PDT) X-Received: by 10.220.194.130 with SMTP id dy2mr666529vcb.47.1409055257532; Tue, 26 Aug 2014 05:14:17 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id rv5si1236856vdb.95.2014.08.26.05.14.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 26 Aug 2014 05:14:17 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id le20so16762692vcb.14 for ; Tue, 26 Aug 2014 05:14:17 -0700 (PDT) X-Received: by 10.220.190.197 with SMTP id dj5mr23456567vcb.19.1409055257409; Tue, 26 Aug 2014 05:14:17 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp193568vcb; Tue, 26 Aug 2014 05:14:17 -0700 (PDT) X-Received: by 10.224.38.10 with SMTP id z10mr46025163qad.52.1409055256920; Tue, 26 Aug 2014 05:14:16 -0700 (PDT) Received: from ip-10-141-164-156.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id h9si3595175qai.32.2014.08.26.05.14.16 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 26 Aug 2014 05:14:16 -0700 (PDT) Received-SPF: none (google.com: linaro-mm-sig-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-141-164-156.ec2.internal) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XMFdf-0007DG-BF; Tue, 26 Aug 2014 12:14:15 +0000 Received: from mailout1.w1.samsung.com ([210.118.77.11]) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XMFdO-0007C7-1i for linaro-mm-sig@lists.linaro.org; Tue, 26 Aug 2014 12:13:58 +0000 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NAW00CSMY40JH00@mailout1.w1.samsung.com> for linaro-mm-sig@lists.linaro.org; Tue, 26 Aug 2014 13:16:49 +0100 (BST) X-AuditID: cbfec7f5-b7f776d000003e54-08-53fc7a019520 Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 15.35.15956.10A7CF35; Tue, 26 Aug 2014 13:13:53 +0100 (BST) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NAW00F45XYW5O50@eusync4.samsung.com>; Tue, 26 Aug 2014 13:13:53 +0100 (BST) From: Marek Szyprowski To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Date: Tue, 26 Aug 2014 14:09:46 +0200 Message-id: <1409054988-32758-6-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1409054988-32758-1-git-send-email-m.szyprowski@samsung.com> References: <1409054988-32758-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrFLMWRmVeSWpSXmKPExsVy+t/xa7qMVX+CDX7+Yrf4O+kYu8WBPzsY LVZ2N7NZ7Fz3jtHibNMbdovtnTPYLb5cechksenxNVaLy7vmsFn0bNjKajHj/D4mi7VH7rJb LDjewmqxfsZrFgc+j9+/JjF6XO7rZfLoenuFyePOtT1sHpuX1Hvc/veY2WPdn1dMHn1bVjF6 fN4kF8AZxWWTkpqTWZZapG+XwJUxc2VowTu1iidHdrA3MB5W6GLk5JAQMJE43jiPEcIWk7hw bz1bFyMXh5DAUkaJxf0PoJw+JolNN0+DVbEJGEp0ve1iA7FFBLIlfnybzAJiMwssZZaYN0sK xBYWSJC4OKWVFcRmEVCVWHG8kQnE5hXwkDiz5BIzxDY5if8vVwDFOTg4BTwlzk2pBgkLAZVs nP6eZQIj7wJGhlWMoqmlyQXFSem5RnrFibnFpXnpesn5uZsYIeH7dQfj0mNWhxgFOBiVeHgf pP0OFmJNLCuuzD3EKMHBrCTC+yPpT7AQb0piZVVqUX58UWlOavEhRiYOTqkGxvPbnYL+ilmx LZ5sXhEovs9/iZHnu7MJn659172+4FXl5GNf1p35YdL2W0r/V7rUssTa+JyFldGflS6U/Wt1 eHZ+5cT7K/6cOsP98+LWM7/9xOoe7bQU4Zg2e+26WxuOy6eLNOptenhwj1Nky+1JrAZ9c8t/ R3I/jVzzumXLfG0mnfLey5zfVOKVWIozEg21mIuKEwH3avdHPQIAAA== Cc: Arnd Bergmann , Tomasz Figa , Michal Nazarewicz , linaro-mm-sig@lists.linaro.org, Kyungmin Park , Grant Likely , Joonsoo Kim , Josh Cartwright , linux-media@vger.kernel.org Subject: [Linaro-mm-sig] [PATCH 5/7] media: s5p-mfc: replace custom reserved memory init code with generic one X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: linaro-mm-sig-bounces@lists.linaro.org Sender: linaro-mm-sig-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: m.szyprowski@samsung.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 This patch removes custom initialization of reserved memory regions from s5p-mfc driver and adds a new code for handling reserved memory with generic named reserved memory regions read from device tree. s5p-mfc driver now handles two reserved memory regions: "left" and "right", defined by generic reserved memory bindings. Support for non-dt platform has been removed, because all supported platforms have been converted to device tree. Signed-off-by: Marek Szyprowski --- drivers/media/platform/s5p-mfc/s5p_mfc.c | 102 +++++++++++-------------------- 1 file changed, 35 insertions(+), 67 deletions(-) diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c index d35b0418ab37..668e82247a3f 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "s5p_mfc_common.h" #include "s5p_mfc_ctrl.h" @@ -996,55 +997,40 @@ static const struct v4l2_file_operations s5p_mfc_fops = { .mmap = s5p_mfc_mmap, }; -static int match_child(struct device *dev, void *data) +static struct device *s5p_mfc_alloc_memdev(struct device *dev, const char *name) { - if (!dev_name(dev)) - return 0; - return !strcmp(dev_name(dev), (char *)data); -} - -static void *mfc_get_drv_data(struct platform_device *pdev); - -static int s5p_mfc_alloc_memdevs(struct s5p_mfc_dev *dev) -{ - unsigned int mem_info[2] = { }; + struct device *child; + int ret; - dev->mem_dev_l = devm_kzalloc(&dev->plat_dev->dev, - sizeof(struct device), GFP_KERNEL); - if (!dev->mem_dev_l) { - mfc_err("Not enough memory\n"); - return -ENOMEM; - } - device_initialize(dev->mem_dev_l); - of_property_read_u32_array(dev->plat_dev->dev.of_node, - "samsung,mfc-l", mem_info, 2); - if (dma_declare_coherent_memory(dev->mem_dev_l, mem_info[0], - mem_info[0], mem_info[1], - DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE) == 0) { - mfc_err("Failed to declare coherent memory for\n" - "MFC device\n"); - return -ENOMEM; + child = devm_kzalloc(dev, sizeof(struct device), GFP_KERNEL); + if (!child) + return NULL; + + device_initialize(child); + dev_set_name(child, "%s:%s", dev_name(dev), name); + child->parent = dev; + child->bus = dev->bus; + child->coherent_dma_mask = dev->coherent_dma_mask; + child->dma_mask = dev->dma_mask; + + if (device_add(child) == 0) { + ret = of_reserved_mem_device_init(child); + if (ret == 0) + return child; } - dev->mem_dev_r = devm_kzalloc(&dev->plat_dev->dev, - sizeof(struct device), GFP_KERNEL); - if (!dev->mem_dev_r) { - mfc_err("Not enough memory\n"); - return -ENOMEM; - } - device_initialize(dev->mem_dev_r); - of_property_read_u32_array(dev->plat_dev->dev.of_node, - "samsung,mfc-r", mem_info, 2); - if (dma_declare_coherent_memory(dev->mem_dev_r, mem_info[0], - mem_info[0], mem_info[1], - DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE) == 0) { - pr_err("Failed to declare coherent memory for\n" - "MFC device\n"); - return -ENOMEM; - } - return 0; + put_device(child); + return NULL; } +void s5p_mfc_free_memdev(struct device *dev) +{ + of_reserved_mem_device_release(dev); + put_device(dev); +} + +static void *mfc_get_drv_data(struct platform_device *pdev); + /* MFC probe function */ static int s5p_mfc_probe(struct platform_device *pdev) { @@ -1096,26 +1082,8 @@ static int s5p_mfc_probe(struct platform_device *pdev) goto err_res; } - if (pdev->dev.of_node) { - ret = s5p_mfc_alloc_memdevs(dev); - if (ret < 0) - goto err_res; - } else { - dev->mem_dev_l = device_find_child(&dev->plat_dev->dev, - "s5p-mfc-l", match_child); - if (!dev->mem_dev_l) { - mfc_err("Mem child (L) device get failed\n"); - ret = -ENODEV; - goto err_res; - } - dev->mem_dev_r = device_find_child(&dev->plat_dev->dev, - "s5p-mfc-r", match_child); - if (!dev->mem_dev_r) { - mfc_err("Mem child (R) device get failed\n"); - ret = -ENODEV; - goto err_res; - } - } + dev->mem_dev_l = s5p_mfc_alloc_memdev(&dev->plat_dev->dev, "left"); + dev->mem_dev_r = s5p_mfc_alloc_memdev(&dev->plat_dev->dev, "right"); dev->alloc_ctx[0] = vb2_dma_contig_init_ctx(dev->mem_dev_l); if (IS_ERR(dev->alloc_ctx[0])) { @@ -1246,10 +1214,10 @@ static int s5p_mfc_remove(struct platform_device *pdev) s5p_mfc_release_firmware(dev); vb2_dma_contig_cleanup_ctx(dev->alloc_ctx[0]); vb2_dma_contig_cleanup_ctx(dev->alloc_ctx[1]); - if (pdev->dev.of_node) { - put_device(dev->mem_dev_l); - put_device(dev->mem_dev_r); - } + if (dev->mem_dev_l) + s5p_mfc_free_memdev(dev->mem_dev_l); + if (dev->mem_dev_r) + s5p_mfc_free_memdev(dev->mem_dev_r); s5p_mfc_final_pm(dev); return 0;