From patchwork Thu Aug 14 01:09:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 4721481 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 A7744C0338 for ; Thu, 14 Aug 2014 01:09:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DEB6A201C8 for ; Thu, 14 Aug 2014 01:09:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F37F920107 for ; Thu, 14 Aug 2014 01:09:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753615AbaHNBJb (ORCPT ); Wed, 13 Aug 2014 21:09:31 -0400 Received: from qmta12.emeryville.ca.mail.comcast.net ([76.96.27.227]:49268 "EHLO qmta12.emeryville.ca.mail.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752580AbaHNBJ3 (ORCPT ); Wed, 13 Aug 2014 21:09:29 -0400 Received: from omta09.emeryville.ca.mail.comcast.net ([76.96.30.20]) by qmta12.emeryville.ca.mail.comcast.net with comcast id ePay1o0010S2fkC01R9VEZ; Thu, 14 Aug 2014 01:09:29 +0000 Received: from mail.gonehiking.org ([50.134.149.16]) by omta09.emeryville.ca.mail.comcast.net with comcast id eR9T1o0040MU7Qa8VR9T8L; Thu, 14 Aug 2014 01:09:28 +0000 Received: from lorien.sisa.samsung.com (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id A91BC423FA; Wed, 13 Aug 2014 19:09:26 -0600 (MDT) From: Shuah Khan To: m.chehab@samsung.com, fabf@skynet.be Cc: Shuah Khan , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] media: tuner xc5000 - release firmwware from xc5000_release() Date: Wed, 13 Aug 2014 19:09:23 -0600 Message-Id: X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1407978569; bh=2BxnJ+NqJk4Wo3fryt1xI8D1SRSVTnL3/ikRzDZiWCQ=; h=Received:Received:Received:From:To:Subject:Date:Message-Id; b=UXvhDlFM7X9h6aqDBtPmqBj5dsriJSkc6NmG1VkKRTKZ4EFkWoWbjEbQsXEtnKZlW zPtpZQoVEpgFaSEgJNSTJZnFEPG2WbsaEPRRQxO9bXFn6firtJ7FWlaBAbnO2i7fz1 4FPRI3gkk/GXv5qTgAan3CncdUaZbKEXoF4687f50TMEgfZC3560lGs7sUf2Y/ROZp xeftsIkVCOGuk3dc41oS3l6KTG/RUCzyIwSlm6fOkWEDszxVzLJeGMOXqGx5iFPXe8 XxQ3xct0GkFU8tClDvHvQqbTwx86OAsQieU0AJJou/RfvZlB7omC4IvKvr2RQVXIxi TJQBw4nSYFywg== 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.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 xc5000 releases firmware right after loading it. Change it to save the firmware and release it from xc5000_release(). This helps avoid fecthing firmware when forced firmware load requests come in to change analog tv frequence and when firmware needs to be reloaded after suspend and resume. Signed-off-by: Shuah Khan --- drivers/media/tuners/xc5000.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/media/tuners/xc5000.c b/drivers/media/tuners/xc5000.c index 512fe50..31b1dec 100644 --- a/drivers/media/tuners/xc5000.c +++ b/drivers/media/tuners/xc5000.c @@ -70,6 +70,8 @@ struct xc5000_priv { struct dvb_frontend *fe; struct delayed_work timer_sleep; + + const struct firmware *firmware; }; /* Misc Defines */ @@ -1136,20 +1138,23 @@ static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe, int force) if (!force && xc5000_is_firmware_loaded(fe) == 0) return 0; - ret = request_firmware(&fw, desired_fw->name, - priv->i2c_props.adap->dev.parent); - if (ret) { - printk(KERN_ERR "xc5000: Upload failed. (file not found?)\n"); - return ret; - } - - dprintk(1, "firmware read %Zu bytes.\n", fw->size); + if (!priv->firmware) { + ret = request_firmware(&fw, desired_fw->name, + priv->i2c_props.adap->dev.parent); + if (ret) { + pr_err("xc5000: Upload failed. rc %d\n", ret); + return ret; + } + dprintk(1, "firmware read %Zu bytes.\n", fw->size); - if (fw->size != desired_fw->size) { - printk(KERN_ERR "xc5000: Firmware file with incorrect size\n"); - ret = -EINVAL; - goto err; - } + if (fw->size != desired_fw->size) { + pr_err("xc5000: Firmware file with incorrect size\n"); + ret = -EINVAL; + goto err; + } + priv->firmware = fw; + } else + fw = priv->firmware; /* Try up to 5 times to load firmware */ for (i = 0; i < 5; i++) { @@ -1232,7 +1237,6 @@ err: else printk(KERN_CONT " - too many retries. Giving up\n"); - release_firmware(fw); return ret; } @@ -1316,6 +1320,8 @@ static int xc5000_release(struct dvb_frontend *fe) if (priv) { cancel_delayed_work(&priv->timer_sleep); hybrid_tuner_release_state(priv); + if (priv->firmware) + release_firmware(priv->firmware); } mutex_unlock(&xc5000_list_mutex);