From patchwork Sun Aug 10 02:14:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 4703821 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 76EFAC0338 for ; Sun, 10 Aug 2014 02:14:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8B4A02015D for ; Sun, 10 Aug 2014 02:14:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4C71320145 for ; Sun, 10 Aug 2014 02:14:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751874AbaHJCOe (ORCPT ); Sat, 9 Aug 2014 22:14:34 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:56219 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751623AbaHJCOd (ORCPT ); Sat, 9 Aug 2014 22:14:33 -0400 Received: from [187.57.189.12] (helo=smtp.w2.samsung.com) by bombadil.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1XGIeS-0008LT-Va; Sun, 10 Aug 2014 02:14:29 +0000 Received: from mchehab by smtp.w2.samsung.com with local (Exim 4.80.1) (envelope-from ) id 1XGIeO-00054j-0p; Sat, 09 Aug 2014 23:14:24 -0300 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab Subject: [PATCH 2/3] au0828: Fix DVB resume when streaming Date: Sat, 9 Aug 2014 23:14:21 -0300 Message-Id: <1407636862-19394-3-git-send-email-m.chehab@samsung.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1407636862-19394-1-git-send-email-m.chehab@samsung.com> References: <1407636862-19394-1-git-send-email-m.chehab@samsung.com> To: unlisted-recipients:; (no To-header on input) 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.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 When DVB is streaming and suspend is called, it will call au0828_stop_transport(), with will clean the streaming flag. Due to that, stop_urb_transfer() will be called twice, causing an oops. So, we need another flag to be used at resume, telling it to restart DVB. While here, add a logic at stop_urb_transfer() to prevent it of being called twice, and convert the usb_streaming flag into boolean. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/au0828/au0828-dvb.c | 14 +++++++++----- drivers/media/usb/au0828/au0828.h | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/media/usb/au0828/au0828-dvb.c b/drivers/media/usb/au0828/au0828-dvb.c index bc4ea5397e92..821f86e92cde 100644 --- a/drivers/media/usb/au0828/au0828-dvb.c +++ b/drivers/media/usb/au0828/au0828-dvb.c @@ -121,7 +121,7 @@ static void urb_completion(struct urb *purb) return; } - if (dev->urb_streaming == 0) { + if (!dev->urb_streaming) { dprintk(2, "%s: not streaming!\n", __func__); return; } @@ -159,7 +159,10 @@ static int stop_urb_transfer(struct au0828_dev *dev) dprintk(2, "%s()\n", __func__); - dev->urb_streaming = 0; + if (!dev->urb_streaming) + return 0; + + dev->urb_streaming = false; for (i = 0; i < URB_COUNT; i++) { if (dev->urbs[i]) { usb_kill_urb(dev->urbs[i]); @@ -229,7 +232,7 @@ static int start_urb_transfer(struct au0828_dev *dev) } } - dev->urb_streaming = 1; + dev->urb_streaming = true; ret = 0; err: @@ -323,7 +326,7 @@ static void au0828_restart_dvb_streaming(struct work_struct *work) restart_streaming); struct au0828_dvb *dvb = &dev->dvb; - if (dev->urb_streaming == 0) + if (!dev->urb_streaming) return; dprintk(1, "Restarting streaming...!\n"); @@ -628,6 +631,7 @@ void au0828_dvb_suspend(struct au0828_dev *dev) stop_urb_transfer(dev); au0828_stop_transport(dev, 1); mutex_unlock(&dvb->lock); + dev->need_urb_start = 1; } } @@ -635,7 +639,7 @@ void au0828_dvb_resume(struct au0828_dev *dev) { struct au0828_dvb *dvb = &dev->dvb; - if (dvb->frontend && dev->urb_streaming) { + if (dvb->frontend && dev->need_urb_start) { pr_info("resuming DVB\n"); au0828_set_frontend(dvb->frontend); diff --git a/drivers/media/usb/au0828/au0828.h b/drivers/media/usb/au0828/au0828.h index d187129b96b7..a7cc6e397fdd 100644 --- a/drivers/media/usb/au0828/au0828.h +++ b/drivers/media/usb/au0828/au0828.h @@ -267,8 +267,8 @@ struct au0828_dev { char *transfer_buffer[AU0828_MAX_ISO_BUFS];/* transfer buffers for isoc transfer */ - /* USB / URB Related */ - int urb_streaming; + /* DVB USB / URB Related */ + bool urb_streaming, need_urb_start; struct urb *urbs[URB_COUNT]; /* Preallocated transfer digital transfer buffers */