From patchwork Thu Jan 11 22:30:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 763237 Received: from pb-smtp21.pobox.com (pb-smtp21.pobox.com [173.228.157.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4DAE6FBEF for ; Thu, 11 Jan 2024 22:30:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fluxnic.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fluxnic.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=pobox.com header.i=@pobox.com header.b="jygcr88l"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=fluxnic.net header.i=@fluxnic.net header.b="tP2ixP3Z" Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id C51321A2A2; Thu, 11 Jan 2024 17:30:38 -0500 (EST) (envelope-from nico@fluxnic.net) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=sasl; bh=jpH9+fshFrqu7tKnviUAmdQyT tSW1R4PhHjUM52TaCo=; b=jygcr88l0tKJXKhnHl5378EG7uZH+u4ZSHHy8PUN0 wh2nvOS+v0dtvlRA71As9mGGHUcvjqwyjDK4I1vahtBewhtk6a9xwrcfzvROj1V2 i2Bw549/yT1E2KFAUMwQ55IzUWLpYs1Ut+spbuvdCNILh/9c3zrZNhZeE3UgmeIV xk= Received: from pb-smtp21.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id BD85B1A2A1; Thu, 11 Jan 2024 17:30:38 -0500 (EST) (envelope-from nico@fluxnic.net) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=fluxnic.net; h=from:to:cc:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=2016-12.pbsmtp; bh=/jeO0GQfGCSAB3tUT5+FJzUI5KuCKQDMsVEPJtMQ9nA=; b=tP2ixP3ZISqzC9QzVN2z4UEqG+CCEj5Q5GYOMn/2rzPe6HMV95dYiygJ7FQZxtOr95B8LMh82RNxoOUWYab5bDQEt/nN9ItdNaOgaXWNcoNiuHhKiAoXb6mk60QkULU+ybKexQ8pyHePum2qZ3FNehB1dvOqEHK9mkAUk7vldao= Received: from yoda.fluxnic.net (unknown [24.201.101.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp21.pobox.com (Postfix) with ESMTPSA id 321EF1A2A0; Thu, 11 Jan 2024 17:30:34 -0500 (EST) (envelope-from nico@fluxnic.net) Received: from xanadu.lan (OpenWrt.lan [192.168.1.1]) by yoda.fluxnic.net (Postfix) with ESMTPSA id 63EFCAD5A6A; Thu, 11 Jan 2024 17:30:31 -0500 (EST) From: Nicolas Pitre To: Daniel Lezcano , linux-pm@vger.kernel.org Cc: Nicolas Pitre Subject: [PATCH 8/9] thermal/drivers/mediatek/lvts_thermal: allow early empty sensor slots Date: Thu, 11 Jan 2024 17:30:05 -0500 Message-ID: <20240111223020.3593558-9-nico@fluxnic.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240111223020.3593558-1-nico@fluxnic.net> References: <20240111223020.3593558-1-nico@fluxnic.net> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Pobox-Relay-ID: 0916D142-B0D1-11EE-8DAF-A19503B9AAD1-78420484!pb-smtp21.pobox.com From: Nicolas Pitre Some systems don't always populate sensor controller slots starting at slot 0. Signed-off-by: Nicolas Pitre --- drivers/thermal/mediatek/lvts_thermal.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c index b20b70fd36..473ef91ea3 100644 --- a/drivers/thermal/mediatek/lvts_thermal.c +++ b/drivers/thermal/mediatek/lvts_thermal.c @@ -112,6 +112,7 @@ struct lvts_ctrl_data { struct lvts_sensor_data lvts_sensor[LVTS_SENSOR_MAX]; int hw_tshut_temp; int num_lvts_sensor; + int skipped_sensors; int offset; int mode; }; @@ -555,6 +556,7 @@ static int lvts_sensor_init(struct device *dev, struct lvts_ctrl *lvts_ctrl, const struct lvts_ctrl_data *lvts_ctrl_data) { struct lvts_sensor *lvts_sensor = lvts_ctrl->sensors; + void __iomem *msr_regs[] = { LVTS_MSR0(lvts_ctrl->base), LVTS_MSR1(lvts_ctrl->base), @@ -569,7 +571,7 @@ static int lvts_sensor_init(struct device *dev, struct lvts_ctrl *lvts_ctrl, LVTS_IMMD3(lvts_ctrl->base) }; - int i; + int i, skip; for (i = 0; i < lvts_ctrl_data->num_lvts_sensor; i++) { @@ -604,8 +606,9 @@ static int lvts_sensor_init(struct device *dev, struct lvts_ctrl *lvts_ctrl, /* * Each sensor has its own register address to read from. */ + skip = lvts_ctrl_data->skipped_sensors; lvts_sensor[i].msr = lvts_ctrl_data->mode == LVTS_MSR_IMMEDIATE_MODE ? - imm_regs[i] : msr_regs[i]; + imm_regs[i + skip] : msr_regs[i + skip]; lvts_sensor[i].low_thresh = INT_MIN; lvts_sensor[i].high_thresh = INT_MIN;