Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp122143ybg; Mon, 8 Jun 2020 18:13:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0OlGpYKyIEmGAQJWacNZWe85AHq0tm21TFZ1ynIuGe/hp8stOnI9FyfEwZXIR3/gvoSrc X-Received: by 2002:a05:6402:1d96:: with SMTP id dk22mr25234567edb.258.1591665221814; Mon, 08 Jun 2020 18:13:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591665221; cv=none; d=google.com; s=arc-20160816; b=VmvtsKF3KCIAnMOZV+CSQEKor7wMGTA1TLLnPMIcjuMqszT5q/Hlpk19DcDEo9WjQ1 jelSSVB1WqWV57jlnFEyUYJ5WqbLH9NUbwJuaGhUBWpTuroMBJQhb7M+DHiJxZtq5SsK rafD8MXVdDivWbBrDIP1AFWLibdS0/Fpzv6jy4iCR9TQRzALV7JbUJNPDPAmRpVjL6aU kksKTI6A2VtTHn56+yF6mMoHk0pAY7e7XYnS7PjvFNMf1tdD8rjhMm75HgX8jxsuUNVo IIQeCs57lq6dZ/QCnVUZ2XOeyD7UdZy0I9KBt5hZZJHtKyTaKxbKhEdE+ZSE1y4q5kyX c6kA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YRXDtzALTayDAmiAriql4hgQce18Z7bv9hTAvrrT1B4=; b=zNwAHN8bvlexZZJYL79gPDT4GLCL1+FJcXqQJMRLoPxanLQv3qp4yABvhMFv+vLO1M l01zmkbN4bTTdEdEl8ZPjTe0PgBqzzPiJhRynfYuHzy+ObfkRHveZOoT3UD8HoX/XK+M 1XeFFanu0A65ks8WZ4mU8GgtqXYk/hbHQcKImGHWRUOwi7Kx/+KazLlYd3U8ZPPxk+v7 nHp0Q3wyKeDCEvWfI0iCEU1nWKQ+RAFt0idzu81MjTnuuFS+89V+ICpF/2hythiTqV4q 5+tadx2HuqzsKC8xnKjCVLSlcfoEeXdqVsasHZ4eg71gC+hFymJRLcjwFVOLl7uzNQ5w oMuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BAp05Yrt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n4si9852898eje.267.2020.06.08.18.13.19; Mon, 08 Jun 2020 18:13:41 -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=BAp05Yrt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728145AbgFIBJm (ORCPT + 99 others); Mon, 8 Jun 2020 21:09:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:49462 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726976AbgFHXGZ (ORCPT ); Mon, 8 Jun 2020 19:06:25 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8CAF620814; Mon, 8 Jun 2020 23:06:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657584; bh=vvdsUyh4/pxM07iiVjNfdaPg3hzQ8TBXAqWOytNYNZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BAp05Yrtry9XFo0YIoK6HH977ZVW5CRPqOxv66ii1M9w7ej6LoT9/6x7Jgd8qWD3M QX5fo8xTWhhXgGpBZM8u87HNkpMFakXQ9R1aRazWfL/npV63ng4Hqt4z14eoJ2qJKn 4cpE12qLfJOAhaYMIxflvQ/etT6QlpZzCEQpZ4B4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Brad Love , Sean Young , Mauro Carvalho Chehab , Sasha Levin , linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 5.7 013/274] media: si2157: Better check for running tuner in init Date: Mon, 8 Jun 2020 19:01:46 -0400 Message-Id: <20200608230607.3361041-13-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 898e0f9f8b70..20487b25fbe1 100644 --- a/drivers/media/tuners/si2157.c +++ b/drivers/media/tuners/si2157.c @@ -75,24 +75,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