From patchwork Sun Jan 12 16:24:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Frank_Sch=C3=A4fer?= X-Patchwork-Id: 3472361 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BB0F89F2ED for ; Sun, 12 Jan 2014 16:24:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E3C8C20122 for ; Sun, 12 Jan 2014 16:24:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2B76620121 for ; Sun, 12 Jan 2014 16:24:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751219AbaALQYD (ORCPT ); Sun, 12 Jan 2014 11:24:03 -0500 Received: from mail-ee0-f51.google.com ([74.125.83.51]:39573 "EHLO mail-ee0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751142AbaALQXt (ORCPT ); Sun, 12 Jan 2014 11:23:49 -0500 Received: by mail-ee0-f51.google.com with SMTP id b15so2740750eek.24 for ; Sun, 12 Jan 2014 08:23:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=L7yeOwohcO1T9OdyIunztUy4/upbS+7W/paYWPZaBa4=; b=lCOUiz6zIqKfDpg/em7y5YXzZExyMpKD1ZCDycmevOImM47/fHKyKcvEGUuKbc5UJM TmeeaMt4bb4NyccZKpngRrAVGd5avlh3RoKUsxIV4y53pvHmNydNnWDSJBcR5kSLWQRH pabia4prM6nb6eLnvOYwelYoXT0iMBCrvHuIhrzOyr3sUefnoYokRBa6ySUG49JHKd0P fb+2qx7OvatX+FSOBknu923v0rnvoH5qQqJ3P2ZZcyYb2B61wI5rUDfTGBgpUNSBqktE LD6cP8vmRvPc9AHg0aQMDoWCToqfVmMgnl/pX3DErd/JyV0JIZypFh0Fa5j+ZWPdtnzc RLvA== X-Received: by 10.15.43.10 with SMTP id w10mr22629533eev.13.1389543828105; Sun, 12 Jan 2014 08:23:48 -0800 (PST) Received: from Athlon64X2-5000.site (ip-178-200-114-182.unitymediagroup.de. [178.200.114.182]) by mx.google.com with ESMTPSA id o47sm32222713eem.21.2014.01.12.08.23.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Jan 2014 08:23:46 -0800 (PST) From: =?UTF-8?q?Frank=20Sch=C3=A4fer?= To: m.chehab@samsung.com Cc: linux-media@vger.kernel.org, =?UTF-8?q?Frank=20Sch=C3=A4fer?= Subject: [RFT/RFC PATCH 5/8] em28xx-v4l: move v4l2_ctrl_handler freeing and v4l2_device unregistration to em28xx_v4l2_fini Date: Sun, 12 Jan 2014 17:24:22 +0100 Message-Id: <1389543865-2534-6-git-send-email-fschaefer.oss@googlemail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1389543865-2534-1-git-send-email-fschaefer.oss@googlemail.com> References: <1389543865-2534-1-git-send-email-fschaefer.oss@googlemail.com> MIME-Version: 1.0 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, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 v4l2_ctrl_handler_free() and v4l2_device_unregister() are currently only called when the last user closes the device and the device is already disconnected. But that's wrong, we need to call these functions whenever the em28xx-v4l extension is closed and we can already do this if the device is still opened by some users. Signed-off-by: Frank Schäfer --- drivers/media/usb/em28xx/em28xx-video.c | 7 ++++--- 1 Datei geändert, 4 Zeilen hinzugefügt(+), 3 Zeilen entfernt(-) diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c index 7535762..3ac8700 100644 --- a/drivers/media/usb/em28xx/em28xx-video.c +++ b/drivers/media/usb/em28xx/em28xx-video.c @@ -1923,8 +1923,11 @@ static int em28xx_v4l2_fini(struct em28xx *dev) dev->vdev = NULL; } + v4l2_ctrl_handler_free(&dev->ctrl_handler); + v4l2_device_unregister(&dev->v4l2_dev); + if (dev->users) - em28xx_warn("Device is open ! Deregistration and memory deallocation are deferred on close.\n"); + em28xx_warn("Device is open ! Memory deallocation is deferred on last close.\n"); return 0; } @@ -1951,8 +1954,6 @@ static int em28xx_v4l2_close(struct file *filp) if (dev->disconnected) { em28xx_release_resources(dev); - v4l2_ctrl_handler_free(&dev->ctrl_handler); - v4l2_device_unregister(&dev->v4l2_dev); kfree(dev->alt_max_pkt_size_isoc); goto exit; }