From patchwork Sun Aug 30 03:07:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 7096471 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BA297BEEC1 for ; Sun, 30 Aug 2015 03:10:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D681E20831 for ; Sun, 30 Aug 2015 03:10:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 940442082E for ; Sun, 30 Aug 2015 03:10:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753408AbbH3DIK (ORCPT ); Sat, 29 Aug 2015 23:08:10 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:48367 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753238AbbH3DHq (ORCPT ); Sat, 29 Aug 2015 23:07:46 -0400 Received: from [179.181.112.204] (helo=smtp.w2.samsung.com) by bombadil.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZVsy9-0007il-NB; Sun, 30 Aug 2015 03:07:45 +0000 Received: from mchehab by smtp.w2.samsung.com with local (Exim 4.85) (envelope-from ) id 1ZVsxY-0004tT-Mj; Sun, 30 Aug 2015 00:07:08 -0300 From: Mauro Carvalho Chehab To: Linux Media Mailing List Cc: Mauro Carvalho Chehab , Mauro Carvalho Chehab Subject: [PATCH v8 50/55] [media] media-entity: unregister entity links Date: Sun, 30 Aug 2015 00:07:01 -0300 Message-Id: X-Mailer: git-send-email 2.4.3 In-Reply-To: References: In-Reply-To: References: 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.9 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 Add functions to explicitly unregister all entity links. This function is called automatically when an entity link is destroyed. Signed-off-by: Mauro Carvalho Chehab Acked-by: Hans Verkuil diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index c18f4af52771..96303a0ade59 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -903,6 +903,7 @@ EXPORT_SYMBOL_GPL(media_devnode_create); void media_devnode_remove(struct media_intf_devnode *devnode) { + media_remove_intf_links(&devnode->intf); media_gobj_remove(&devnode->intf.graph_obj); kfree(devnode); } @@ -944,3 +945,25 @@ void media_remove_intf_link(struct media_link *link) mutex_unlock(&link->graph_obj.mdev->graph_mutex); } EXPORT_SYMBOL_GPL(media_remove_intf_link); + +void __media_remove_intf_links(struct media_interface *intf) +{ + struct media_link *link, *tmp; + + list_for_each_entry_safe(link, tmp, &intf->links, list) + __media_remove_intf_link(link); + +} +EXPORT_SYMBOL_GPL(__media_remove_intf_links); + +void media_remove_intf_links(struct media_interface *intf) +{ + /* Do nothing if the intf is not registered. */ + if (intf->graph_obj.mdev == NULL) + return; + + mutex_lock(&intf->graph_obj.mdev->graph_mutex); + __media_remove_intf_links(intf); + mutex_unlock(&intf->graph_obj.mdev->graph_mutex); +} +EXPORT_SYMBOL_GPL(media_remove_intf_links); diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 8c344a07636c..0e7e193a6736 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -318,6 +318,9 @@ struct media_link *media_create_intf_link(struct media_entity *entity, struct media_interface *intf, u32 flags); void media_remove_intf_link(struct media_link *link); +void __media_remove_intf_links(struct media_interface *intf); +void media_remove_intf_links(struct media_interface *intf); + #define media_entity_call(entity, operation, args...) \ (((entity)->ops && (entity)->ops->operation) ? \