Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp993713ybt; Fri, 19 Jun 2020 20:55:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcYRRSzaQvP3ITfZkBr1SdjcBzayHz9+GO1n94CG0+ImBW2txVc+Qt+Bmss2o/+LpU1lIU X-Received: by 2002:a17:906:4b50:: with SMTP id j16mr6902133ejv.415.1592625311655; Fri, 19 Jun 2020 20:55:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592625311; cv=none; d=google.com; s=arc-20160816; b=wTBQwTrIdIFJoNbiLRn0PjKSOnXPQMcLZbeePajMBbx8gZI7QZxS2C96+Gj01S7zTw yyWkkanexzJzktuq9v5hI4dpYiqeoyaBbbeSl+Z1MIsrSgph2zmOOKOQ6pSKraioeXcr Sx4SQ4oSMn/jUXQe71iH+z9QSaZs1jc54JcLJCnPimrRJQRYF81mNCLS2i75V9uGgBzL M+/y+3fbpy1K8bjvKPJyc62okOKErkGcZSXwwvitMwpI9/3cS86z07qEQg8BP/T8goXK M5bkch6Bm/uwsd7jUhdwmjnD+4TmPccrz7CAfmQnoNHaUySkVRLXmAjGBOBil33D9rjj IWmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vk7z6OD8T8q2dHZp6rLvVr4SPRI3UlvwIyArka7TwsU=; b=MjCQ5bDxL36h5BFFEy+0pbqdwjnvx+9dZThdA+PFq/U9jTGCWY+pc2qbWyBjVDOzxp ZaOyAUarICM5sdiLiXcdNL4EuAIveZzzZLfy58UMUC4S8GH9MQJvf4erLHvsCQ6za+7Z xzp+Sb8QRVM9wcCk+ve/n0mGPw87BTmRx/5WEpVIZa05ZK7FX9ermC9yWxIrTWWe70k2 taLbmZv/ozS9O9TbB0flFn9KmobHMrzjUghC7NwpSTB+qh+34vbiDtP3DKEsMGWO+AFx 5eorGdxzxGwpjafqIOiOCgBrE5lnxaBWWXD7PsoPw9iNsjxZNIyrOo6IvkdHJCf2ELxo dvmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hVRIReHS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t13si5149094ejr.37.2020.06.19.20.54.50; Fri, 19 Jun 2020 20:55:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hVRIReHS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391016AbgFSQ0a (ORCPT + 99 others); Fri, 19 Jun 2020 12:26:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:52444 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390187AbgFSO5K (ORCPT ); Fri, 19 Jun 2020 10:57:10 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 959792158C; Fri, 19 Jun 2020 14:57:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592578630; bh=exxlbFL3ah7u9FldBxgwESWLtDWZgTnmtFalUav9Rco=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hVRIReHSJvqFtgirrUYcJWHTSGTegb8YU67yY0IkEhyenr6bTYw3DQ6fWl+j+hngJ 5qxzqn8t5U8J7nIXeAxYLiHAacG3u/2I1qm4X/+a1HPiSUBSUPFkJPxMRt8pEKMsY+ VhkZq4xYwa2LIHWO7Lm1d+Etw/4XGGYjOL82PggY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Brad Love , Sean Young , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.19 096/267] media: si2157: Better check for running tuner in init Date: Fri, 19 Jun 2020 16:31:21 +0200 Message-Id: <20200619141653.469897935@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141648.840376470@linuxfoundation.org> References: <20200619141648.840376470@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Brad Love [ Upstream commit e955f959ac52e145f27ff2be9078b646d0352af0 ] Getting the Xtal trim property to check if running is less error prone. Reset if_frequency if state is unknown. Replaces the previous "garbage check". Signed-off-by: Brad Love Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/tuners/si2157.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c index a08d8fe2bb1b..13770b038048 100644 --- a/drivers/media/tuners/si2157.c +++ b/drivers/media/tuners/si2157.c @@ -84,24 +84,23 @@ static int si2157_init(struct dvb_frontend *fe) struct si2157_cmd cmd; const struct firmware *fw; const char *fw_name; - unsigned int uitmp, chip_id; + unsigned int chip_id, xtal_trim; dev_dbg(&client->dev, "\n"); - /* Returned IF frequency is garbage when firmware is not running */ - memcpy(cmd.args, "\x15\x00\x06\x07", 4); + /* Try to get Xtal trim property, to verify tuner still running */ + memcpy(cmd.args, "\x15\x00\x04\x02", 4); cmd.wlen = 4; cmd.rlen = 4; ret = si2157_cmd_execute(client, &cmd); - if (ret) - goto err; - uitmp = cmd.args[2] << 0 | cmd.args[3] << 8; - dev_dbg(&client->dev, "if_frequency kHz=%u\n", uitmp); + xtal_trim = cmd.args[2] | (cmd.args[3] << 8); - if (uitmp == dev->if_frequency / 1000) + if (ret == 0 && xtal_trim < 16) goto warm; + dev->if_frequency = 0; /* we no longer know current tuner state */ + /* power up */ if (dev->chiptype == SI2157_CHIPTYPE_SI2146) { memcpy(cmd.args, "\xc0\x05\x01\x00\x00\x0b\x00\x00\x01", 9); -- 2.25.1