From patchwork Thu Nov 6 10:11:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 5240751 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 A5B2CC11AC for ; Thu, 6 Nov 2014 10:12:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D88FA20114 for ; Thu, 6 Nov 2014 10:12:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DCE8A20107 for ; Thu, 6 Nov 2014 10:12:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752082AbaKFKMr (ORCPT ); Thu, 6 Nov 2014 05:12:47 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:19424 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751942AbaKFKM1 (ORCPT ); Thu, 6 Nov 2014 05:12:27 -0500 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NEM00F9W4CPH340@mailout3.samsung.com> for linux-media@vger.kernel.org; Thu, 06 Nov 2014 19:12:25 +0900 (KST) X-AuditID: cbfee61a-f79c06d000004e71-16-545b4989204a Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 8C.FD.20081.9894B545; Thu, 06 Nov 2014 19:12:25 +0900 (KST) Received: from AMDC2362.DIGITAL.local ([106.120.53.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NEM00DZ94BK47N0@mmp2.samsung.com>; Thu, 06 Nov 2014 19:12:25 +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, sakari.ailus@linux.intel.com, kyungmin.park@samsung.com, Jacek Anaszewski Subject: [v4l-utils RFC v3 10/11] mediactl: Close only pipeline sub-devices Date: Thu, 06 Nov 2014 11:11:41 +0100 Message-id: <1415268702-23685-11-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1415268702-23685-1-git-send-email-j.anaszewski@samsung.com> References: <1415268702-23685-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrILMWRmVeSWpSXmKPExsVy+t9jQd1Oz+gQgzsLtSw2zljPajF9yixG iyU/dzFZvDk+ncmi9+pzRouzTW/YLXo2bGW1uLhO3uLTlm9MDpweU35vZPV4OmEyu8e8k4Ee 7/ddZfPo27KK0ePzJrkAtigum5TUnMyy1CJ9uwSujLfd81gK3nFVnFr6k7WBsZ2zi5GTQ0LA RGL76QuMELaYxIV769m6GLk4hASmM0pcvPwCymlnkliw9CUrSBWbgKHEzxevmUBsEQF5iSe9 N8CKmAUeMUo8XfYdbJSwgLdEy87DYEUsAqoSCw/eAbN5BTwlJrxpBqrhAFqnIDFnkg1ImBMo PPvoCXYQW0jAQ2LGhxNsExh5FzAyrGIUTS1ILihOSs811CtOzC0uzUvXS87P3cQIDrhnUjsY VzZYHGIU4GBU4uHdcTQqRIg1say4MvcQowQHs5IIr4JjdIgQb0piZVVqUX58UWlOavEhRmkO FiVx3gOt1oFCAumJJanZqakFqUUwWSYOTqkGxpL0t5ZXoiz5lt04dTtLoCjunWJpcnLqwdPO RZZ7rv8+phy06hCH+N5/rtezE/8Zn2LuXbZ/04SSTkXPsFMBuy9ub0icsEpx0Z4WxmaHeweK nRmFhDX+529+ZZLy5XnFle23MlQk6v4v8bY39y7bKfr7fsJTk+9LDwrUfr/aNrEof/pzX/7z MkosxRmJhlrMRcWJACyXlmc0AgAA Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 75021e7..fe38270 100644 --- a/utils/media-ctl/libmediactl.c +++ b/utils/media-ctl/libmediactl.c @@ -919,13 +919,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->fd != -1) - close(entity->fd); } free(media->entities);