From patchwork Fri Nov 21 16:14:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 5356061 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CEFB6C11AC for ; Fri, 21 Nov 2014 16:15:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 05726201B9 for ; Fri, 21 Nov 2014 16:15:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 758E720176 for ; Fri, 21 Nov 2014 16:15:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932632AbaKUQPe (ORCPT ); Fri, 21 Nov 2014 11:15:34 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:26005 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932620AbaKUQPZ (ORCPT ); Fri, 21 Nov 2014 11:15:25 -0500 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NFE00KTCD5NI260@mailout2.samsung.com> for linux-media@vger.kernel.org; Sat, 22 Nov 2014 01:15:23 +0900 (KST) X-AuditID: cbfee61b-f79d76d0000024d6-15-546f651b3dc5 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 7E.FE.09430.B156F645; Sat, 22 Nov 2014 01:15:23 +0900 (KST) Received: from AMDC2362.DIGITAL.local ([106.120.53.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NFE00IXRD4IRL40@mmp1.samsung.com>; Sat, 22 Nov 2014 01:15:23 +0900 (KST) From: Jacek Anaszewski To: linux-media@vger.kernel.org Cc: m.chehab@samsung.com, gjasny@googlemail.com, hdegoede@redhat.com, hans.verkuil@cisco.com, b.zolnierkie@samsung.com, kyungmin.park@samsung.com, sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com, Jacek Anaszewski Subject: [PATCH/RFC v4 09/11] mediactl: Close only pipeline sub-devices Date: Fri, 21 Nov 2014 17:14:38 +0100 Message-id: <1416586480-19982-10-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1416586480-19982-1-git-send-email-j.anaszewski@samsung.com> References: <1416586480-19982-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrNLMWRmVeSWpSXmKPExsVy+t9jAV3p1PwQg7lb9Sw2zljPajF9yixG iyU/dzFZvDk+ncmi9+pzRouzTW/YLTonLmG36NmwldXi4jp5i09bvjE5cHlM+b2R1ePphMns HrM7ZrJ6zDsZ6PF+31U2j74tqxg9Pm+SC2CP4rJJSc3JLEst0rdL4Mp4OOMKa8EU7oqmm12M DYyrOLsYOTkkBEwkvp28wwZhi0lcuLceyObiEBJYxCgx6eEeFginnUli+tcHrCBVbAKGEj9f vGYCsUUE5CWe9N4A62AWaGWSmNb0gB0kISzgLvH7/CYwm0VAVaJv4iFGEJtXwFPi4+nVQM0c QOsUJOZMsgEJcwKFN1+7B1YuJOAhcW/OdrYJjLwLGBlWMYqmFiQXFCel5xrpFSfmFpfmpesl 5+duYgQH4TPpHYyrGiwOMQpwMCrx8H6YnhcixJpYVlyZe4hRgoNZSYS3XDg/RIg3JbGyKrUo P76oNCe1+BCjNAeLkjjvjZu5IUIC6YklqdmpqQWpRTBZJg5OqQbG0m8Gn9Se/224/SFUWeZt av5a865VZfcY/G0/zWLabsiVnuz36sbCtQHHS0quXZ7VvzZp13kG/fMv9+3iuNqv/afX8bLl 7Btlc5m6XtoefP4rgO/0vJtXyqSCz0ZIr/NT/PWe+cExE52gb8efyj/S/59w8G742eXll/1u 7bqvI8YyX07FxzWsTomlOCPRUIu5qDgRAPMQwpk+AgAA 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 The function media_device_new_by_entity_devname queries media devices available in the system for containment if given media entity. If a verification is negative the media_device is released with media_device_unref. In the previous approach media_device_unref was closing all media entities it contained, which was undesirable behavior as there might exist other initialized plugins which had opened the same media_device and initialized a pipeline. With this patch only the sub-devices that belong to the pipeline of current media_device instance will be closed. Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park --- utils/media-ctl/libmediactl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c index 003902b..9419fb4 100644 --- a/utils/media-ctl/libmediactl.c +++ b/utils/media-ctl/libmediactl.c @@ -917,13 +917,13 @@ void media_device_unref(struct media_device *media) if (media->refcount > 0) return; + media_close_pipeline_subdevs(media); + for (i = 0; i < media->entities_count; ++i) { struct media_entity *entity = &media->entities[i]; free(entity->pads); free(entity->links); - if (entity->sd->fd != -1) - close(entity->sd->fd); free(entity->sd->v4l2_controls); free(entity->sd); }