From patchwork Thu Dec 27 23:02:44 2012 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: 1913811 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id BD596DF2A2 for ; Thu, 27 Dec 2012 23:02:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752169Ab2L0XCk (ORCPT ); Thu, 27 Dec 2012 18:02:40 -0500 Received: from mail-ee0-f50.google.com ([74.125.83.50]:40297 "EHLO mail-ee0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751593Ab2L0XCi (ORCPT ); Thu, 27 Dec 2012 18:02:38 -0500 Received: by mail-ee0-f50.google.com with SMTP id b45so5033080eek.37 for ; Thu, 27 Dec 2012 15:02:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=O6DVwDsuAyzKj+KenrvjVcVKZGeaXJFdLrRMUCzNnfI=; b=owaql1kLEOGmB0MyffLxYx6zokbbZI1deb+ONsW/CA3OYlR+lZ7m+xHkJo8c5o9bZ9 0SiNEg21Mn+FYrFeaSAxwv7nNqnSEvlZPcupjDqwHpw6gmtwKgLNg9Wtim0lg9d2lSCN g0y6R/OyOZt/E1QTteDwQ2y0LXGu7VBJTBK1a5OltbLg9Zs6hVttvxidLZ0ig3pXsJFY LTE2hwsm3AJ9SBIn2WzxGdVtzp+u8CDxjexB/+mRtYwITzoLzfuc14kv6hEqQjFw4qrG ZK0C3cA3dih/6VFuyPBZJfYQzfyxLWt37vld+N2eVENjW3S4v2KfICun2N2urB4Yv+ys 7CEQ== X-Received: by 10.14.215.194 with SMTP id e42mr81044371eep.32.1356649357439; Thu, 27 Dec 2012 15:02:37 -0800 (PST) Received: from Athlon64X2-5000.site (ip-37-24-90-62.unitymediagroup.de. [37.24.90.62]) by mx.google.com with ESMTPS id q44sm62258729eep.5.2012.12.27.15.02.35 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Dec 2012 15:02:36 -0800 (PST) From: =?UTF-8?q?Frank=20Sch=C3=A4fer?= To: mchehab@redhat.com Cc: linux-media@vger.kernel.org, =?UTF-8?q?Frank=20Sch=C3=A4fer?= Subject: [PATCH 2/6] em28xx: refactor the code in em28xx_usb_disconnect() Date: Fri, 28 Dec 2012 00:02:44 +0100 Message-Id: <1356649368-5426-3-git-send-email-fschaefer.oss@googlemail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1356649368-5426-1-git-send-email-fschaefer.oss@googlemail.com> References: <1356649368-5426-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 The main purpose of this patch is to move the call of em28xx_release_resources() after the call of em28xx_close_extension(). This is necessary, because some resources might be needed/used by the extensions fini() functions when they get closed. Also mark the device as disconnected earlier in this function and unify the em28xx_uninit_usb_xfer() calls for analog and digital mode. Signed-off-by: Frank Schäfer --- drivers/media/usb/em28xx/em28xx-cards.c | 26 +++++++++++--------------- 1 Datei geändert, 11 Zeilen hinzugefügt(+), 15 Zeilen entfernt(-) diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c index 8496a06..40c3e45 100644 --- a/drivers/media/usb/em28xx/em28xx-cards.c +++ b/drivers/media/usb/em28xx/em28xx-cards.c @@ -3478,6 +3478,8 @@ static void em28xx_usb_disconnect(struct usb_interface *interface) if (!dev) return; + dev->disconnected = 1; + if (dev->is_audio_only) { mutex_lock(&dev->lock); em28xx_close_extension(dev); @@ -3489,32 +3491,26 @@ static void em28xx_usb_disconnect(struct usb_interface *interface) flush_request_modules(dev); - /* wait until all current v4l2 io is finished then deallocate - resources */ mutex_lock(&dev->lock); v4l2_device_disconnect(&dev->v4l2_dev); if (dev->users) { - em28xx_warn - ("device %s is open! Deregistration and memory " - "deallocation are deferred on close.\n", - video_device_node_name(dev->vdev)); + em28xx_warn("device %s is open! Deregistration and memory deallocation are deferred on close.\n", + video_device_node_name(dev->vdev)); - em28xx_uninit_usb_xfer(dev, dev->mode); - dev->disconnected = 1; - } else { - dev->disconnected = 1; - em28xx_release_resources(dev); + em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE); + em28xx_uninit_usb_xfer(dev, EM28XX_DIGITAL_MODE); } - /* free DVB isoc buffers */ - em28xx_uninit_usb_xfer(dev, EM28XX_DIGITAL_MODE); + em28xx_close_extension(dev); + /* NOTE: must be called BEFORE the resources are released */ + + if (!dev->users) + em28xx_release_resources(dev); mutex_unlock(&dev->lock); - em28xx_close_extension(dev); - if (!dev->users) { kfree(dev->alt_max_pkt_size_isoc); kfree(dev);