From patchwork Mon Jun 8 09:02:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 6563701 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5104D9F1C1 for ; Mon, 8 Jun 2015 09:03:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4BAA520458 for ; Mon, 8 Jun 2015 09:03:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1C50E203E6 for ; Mon, 8 Jun 2015 09:03:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753084AbbFHJDR (ORCPT ); Mon, 8 Jun 2015 05:03:17 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:35099 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753079AbbFHJDO (ORCPT ); Mon, 8 Jun 2015 05:03:14 -0400 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NPM00YANBT24K10@mailout1.samsung.com>; Mon, 08 Jun 2015 18:03:02 +0900 (KST) X-AuditID: cbfee61a-f79516d000006302-52-55755a4ba978 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 86.0A.25346.B4A55755; Mon, 8 Jun 2015 18:03:07 +0900 (KST) Received: from AMDC2362.DIGITAL.local ([106.120.53.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NPM001AYBS2ERZ0@mmp2.samsung.com>; Mon, 08 Jun 2015 18:03:07 +0900 (KST) From: Jacek Anaszewski To: linux-leds@vger.kernel.org, linux-media@vger.kernel.org Cc: kyungmin.park@samsung.com, pavel@ucw.cz, cooloney@gmail.com, rpurdie@rpsys.net, sakari.ailus@iki.fi, s.nawrocki@samsung.com, Jacek Anaszewski Subject: [PATCH v10 6/8] exynos4-is: Improve the mechanism of async subdevs verification Date: Mon, 08 Jun 2015 11:02:23 +0200 Message-id: <1433754145-12765-7-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1433754145-12765-1-git-send-email-j.anaszewski@samsung.com> References: <1433754145-12765-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrELMWRmVeSWpSXmKPExsVy+t9jQV3vqNJQgwdXTSyO7pzIZNF79Tmj xdmmN+wWW9+sY7To2bCV1eLuqaNsFrt3PWW1OPymndXizP6VbA6cHjtn3WX3OPx1IYvHnvk/ WD36tqxi9Fix+ju7x+dNcgFsUVw2Kak5mWWpRfp2CVwZXU0v2AqWqlXsbnnN2sA4TaGLkZND QsBE4u/MBhYIW0ziwr31bF2MXBxCAtMZJU69usAM4fxklNizqJMVpIpNwFDi54vXTCC2iIC1 xKxD01lAipgFNjBKXJ7QCDZKWCBK4tjfDmYQm0VAVeLdjfmMIDavgIfE/z+T2bsYOYDWKUjM mWQDEuYU8JTY37yfCSQsBFSyfmLQBEbeBYwMqxhFUwuSC4qT0nMN9YoTc4tL89L1kvNzNzGC Q+6Z1A7GlQ0WhxgFOBiVeHgllpaECrEmlhVX5h5ilOBgVhLhZbIoDRXiTUmsrEotyo8vKs1J LT7EKM3BoiTOezLfJ1RIID2xJDU7NbUgtQgmy8TBKdXAqK36taCxqi92eZ30RFvdS6sf+4Yf Yj0mxZHoleK4s3tdtkvKcYXg2+8mWCz2urtfYEbMZK8fGW8/zP2so+ep5PXC9EH3SY/jNvob lIqT5ViW7qjY8+nKez6ZS9em+fjxB31+vHrTw3kLYtg4Ljx349QMTfXvWHBM6pLkN2l/pvPX /v21vBgxR4mlOCPRUIu5qDgRAKo6rCk1AgAA Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Avoid verifying bound async sensor sub-devices by their of_nodes, which duplicates v4l2-async functionality, in favour of matching them by the corresponding struct v4l2_async_subdev. The structures are now being aggregated in the newly introduced struct fimc_async_subdevs which allows for categorizing async sub-devices by their type upon DT node parsing and recognizing the type easily when they're being bound. Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park Cc: Sylwester Nawrocki Acked-by: Bryan Wu --- drivers/media/platform/exynos4-is/media-dev.c | 34 +++++++++++++++++++------ drivers/media/platform/exynos4-is/media-dev.h | 8 ++++-- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c index 4f5586a..e3d7b70 100644 --- a/drivers/media/platform/exynos4-is/media-dev.c +++ b/drivers/media/platform/exynos4-is/media-dev.c @@ -331,6 +331,8 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd, unsigned int index) { struct fimc_source_info *pd = &fmd->sensor[index].pdata; + struct v4l2_async_notifier *notifier = &fmd->subdev_notifier; + struct v4l2_async_subdev *asd; struct device_node *rem, *ep, *np; struct v4l2_of_endpoint endpoint; @@ -387,9 +389,11 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd, if (WARN_ON(index >= ARRAY_SIZE(fmd->sensor))) return -EINVAL; - fmd->sensor[index].asd.match_type = V4L2_ASYNC_MATCH_OF; - fmd->sensor[index].asd.match.of.node = rem; - fmd->async_subdevs[index] = &fmd->sensor[index].asd; + asd = &fmd->async_subdevs.sensors[index]; + asd->match_type = V4L2_ASYNC_MATCH_OF; + asd->match.of.node = rem; + notifier->subdevs[notifier->num_subdevs++] = asd; + fmd->sensor[index].asd = asd; fmd->num_sensors++; @@ -1272,12 +1276,13 @@ static int subdev_notifier_bound(struct v4l2_async_notifier *notifier, struct v4l2_async_subdev *asd) { struct fimc_md *fmd = notifier_to_fimc_md(notifier); + struct fimc_async_subdevs *async_subdevs = &fmd->async_subdevs; struct fimc_sensor_info *si = NULL; int i; /* Find platform data for this sensor subdev */ - for (i = 0; i < ARRAY_SIZE(fmd->sensor); i++) - if (fmd->sensor[i].asd.match.of.node == subdev->dev->of_node) + for (i = 0; i < ARRAY_SIZE(async_subdevs->sensors); i++) + if (fmd->sensor[i].asd == asd) si = &fmd->sensor[i]; if (si == NULL) @@ -1317,6 +1322,19 @@ unlock: return ret; } +static int fimc_md_register_async_entities(struct fimc_md *fmd) +{ + struct device *dev = fmd->media_dev.dev; + struct v4l2_async_notifier *notifier = &fmd->subdev_notifier; + + notifier->subdevs = devm_kcalloc(dev, FIMC_MAX_SENSORS, + sizeof(*notifier->subdevs), GFP_KERNEL); + if (!notifier->subdevs) + return -ENOMEM; + + return fimc_md_register_sensor_entities(fmd); +} + static int fimc_md_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -1379,7 +1397,7 @@ static int fimc_md_probe(struct platform_device *pdev) goto err_clk; } - ret = fimc_md_register_sensor_entities(fmd); + ret = fimc_md_register_async_entities(fmd); if (ret) { mutex_unlock(&fmd->media_dev.graph_mutex); goto err_m_ent; @@ -1402,8 +1420,6 @@ static int fimc_md_probe(struct platform_device *pdev) } if (fmd->num_sensors > 0) { - fmd->subdev_notifier.subdevs = fmd->async_subdevs; - fmd->subdev_notifier.num_subdevs = fmd->num_sensors; fmd->subdev_notifier.bound = subdev_notifier_bound; fmd->subdev_notifier.complete = subdev_notifier_complete; fmd->num_sensors = 0; @@ -1412,6 +1428,8 @@ static int fimc_md_probe(struct platform_device *pdev) &fmd->subdev_notifier); if (ret) goto err_clk_p; + } else { + devm_kfree(dev, fmd->subdev_notifier.subdevs); } return 0; diff --git a/drivers/media/platform/exynos4-is/media-dev.h b/drivers/media/platform/exynos4-is/media-dev.h index 0321454..ff6d020 100644 --- a/drivers/media/platform/exynos4-is/media-dev.h +++ b/drivers/media/platform/exynos4-is/media-dev.h @@ -88,11 +88,15 @@ struct fimc_camclk_info { */ struct fimc_sensor_info { struct fimc_source_info pdata; - struct v4l2_async_subdev asd; + struct v4l2_async_subdev *asd; struct v4l2_subdev *subdev; struct fimc_dev *host; }; +struct fimc_async_subdevs { + struct v4l2_async_subdev sensors[FIMC_MAX_SENSORS]; +}; + struct cam_clk { struct clk_hw hw; struct fimc_md *fmd; @@ -149,7 +153,7 @@ struct fimc_md { } clk_provider; struct v4l2_async_notifier subdev_notifier; - struct v4l2_async_subdev *async_subdevs[FIMC_MAX_SENSORS]; + struct fimc_async_subdevs async_subdevs; bool user_subdev_api; spinlock_t slock;