From patchwork Tue Sep 23 00:30:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 4951521 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 C7015BEEA5 for ; Tue, 23 Sep 2014 00:31:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 03F8220131 for ; Tue, 23 Sep 2014 00:31:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2729920108 for ; Tue, 23 Sep 2014 00:31:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753873AbaIWAbI (ORCPT ); Mon, 22 Sep 2014 20:31:08 -0400 Received: from resqmta-po-11v.sys.comcast.net ([96.114.154.170]:55731 "EHLO resqmta-po-11v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752723AbaIWAbH (ORCPT ); Mon, 22 Sep 2014 20:31:07 -0400 Received: from resomta-po-15v.sys.comcast.net ([96.114.154.239]) by resqmta-po-11v.sys.comcast.net with comcast id uQWl1o0095AAYLo01QX5Sw; Tue, 23 Sep 2014 00:31:05 +0000 Received: from mail.gonehiking.org ([50.134.149.16]) by resomta-po-15v.sys.comcast.net with comcast id uQWx1o00z0MU7Qa01QX46o; Tue, 23 Sep 2014 00:31:05 +0000 Received: from lorien.sisa.samsung.com (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id 0ABFE3FE4A; Mon, 22 Sep 2014 18:30:49 -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 v2] media: tuner xc5000 - release firmwware from xc5000_release() Date: Mon, 22 Sep 2014 18:30:46 -0600 Message-Id: <1411432246-9085-1-git-send-email-shuahkh@osg.samsung.com> X-Mailer: git-send-email 1.9.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1411432265; bh=dj4zCWC4POTmYiKNw6UjZ51kSRaYYOx2e628vCRxZhU=; h=Received:Received:Received:From:To:Subject:Date:Message-Id; b=O94u9qWsYEtLKPEKhkstJ46pZ643zk49C9gViCWIWSndBBqGoceZfzH4C+jnJDN/f M+KogfYrKyoJXDJyWr6UiWlBNnBpFOa3+ComUXP3SmZmE7lpnAamg/Q4mv55QCrkqK 4lr+tRbZ2hKSKbiBqJJxnTtgVOL7C7SQ17N7zS8l5xLKOesW6iAigjvJJwp7Dcz8uy bj97hFcvs8pBgGxIMQeoK7AftHAiYANNP1odpBW5sXaE9WFheL5rf+WatQzd8cJSme jMncMbQlDYQ8PJRYQvIeAchCK1xAqgoSO0UnQk2OVazG6V4XRC2AAFzfdFfoplWL5h pIDPR5GHxnSIQ== 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.8 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 --- patch v2: fixes issues found in patch v1 review 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..b72ec64 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"); + release_firmware(fw); + return -EINVAL; + } + 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);