From patchwork Sun Sep 6 12:03:11 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: 7131921 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 349C49F695 for ; Sun, 6 Sep 2015 12:05:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 63ECE205BA for ; Sun, 6 Sep 2015 12:05:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 832E9206FA for ; Sun, 6 Sep 2015 12:05:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752709AbbIFMEq (ORCPT ); Sun, 6 Sep 2015 08:04:46 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:54641 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752164AbbIFMD6 (ORCPT ); Sun, 6 Sep 2015 08:03:58 -0400 Received: from 201.86.133.245.dynamic.adsl.gvt.net.br ([201.86.133.245] helo=smtp.w2.samsung.com) by bombadil.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZYYft-0004mP-Vv; Sun, 06 Sep 2015 12:03:58 +0000 Received: from mchehab by smtp.w2.samsung.com with local (Exim 4.85) (envelope-from ) id 1ZYYfF-0001rk-O5; Sun, 06 Sep 2015 09:03:17 -0300 From: Mauro Carvalho Chehab To: Linux Media Mailing List Cc: Mauro Carvalho Chehab Subject: Re: [PATCH v8 51/55] [media] remove interface links at media_entity_unregister() Date: Sun, 6 Sep 2015 09:03:11 -0300 Message-Id: X-Mailer: git-send-email 2.4.3 In-Reply-To: References: In-Reply-To: <36ec2d60b61f769115982c5060d550d35e3ca602.1440902901.git.mchehab@osg.samsung.com> References: <36ec2d60b61f769115982c5060d550d35e3ca602.1440902901.git.mchehab@osg.samsung.com> 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 Interface links connected to an entity should be removed before being able of removing the entity. Signed-off-by: Mauro Carvalho Chehab Acked-by: Hans Verkuil diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 96a476eeb16e..7c37aeab05bb 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -638,14 +638,30 @@ void media_device_unregister_entity(struct media_entity *entity) return; spin_lock(&mdev->lock); + + /* Remove interface links with this entity on it */ + list_for_each_entry_safe(link, tmp, &mdev->links, graph_obj.list) { + if (media_type(link->gobj1) == MEDIA_GRAPH_ENTITY + && link->entity == entity) { + media_gobj_remove(&link->graph_obj); + kfree(link); + } + } + + /* Remove all data links that belong to this entity */ list_for_each_entry_safe(link, tmp, &entity->links, list) { media_gobj_remove(&link->graph_obj); list_del(&link->list); kfree(link); } + + /* Remove all pads that belong to this entity */ for (i = 0; i < entity->num_pads; i++) media_gobj_remove(&entity->pads[i].graph_obj); + + /* Remove the entity */ media_gobj_remove(&entity->graph_obj); + spin_unlock(&mdev->lock); entity->graph_obj.mdev = NULL; }