[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <07ecd160-5bb5-4e39-ab5c-9f761e7db0af@linaro.org>
Date: Thu, 29 May 2025 11:59:47 +0100
From: Bryan O'Donoghue <bryan.odonoghue@...aro.org>
To: Anjelique Melendez <anjelique.melendez@....qualcomm.com>,
amitk@...nel.org, thara.gopinath@...il.com, rafael@...nel.org,
daniel.lezcano@...aro.org
Cc: rui.zhang@...el.com, lukasz.luba@....com, david.collins@....qualcomm.com,
srinivas.kandagatla@...aro.org, stefan.schmidt@...aro.org,
quic_tsoni@...cinc.com, linux-arm-msm@...r.kernel.org,
linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
dmitry.baryshkov@...aro.org, dmitry.baryshkov@....qualcomm.com
Subject: Re: [PATCH v4 4/5] thermal: qcom-spmi-temp-alarm: add support for
GEN2 rev 2 PMIC peripherals
On 29/05/2025 00:50, Anjelique Melendez wrote:
> +static int qpnp_tm_gen2_rev2_set_temp_thresh(struct qpnp_tm_chip *chip, int trip, int temp)
> +{
> + int ret, temp_cfg;
> + u8 reg;
> +
> + WARN_ON(!mutex_is_locked(&chip->lock));
> +
> + if (trip < 0 || trip >= STAGE_COUNT) {
trip < 0 can never be true because the value passed to this function
comes from an unsigned int
include/linux/thermal.h:#define THERMAL_TRIP_PRIV_TO_INT(_val_)
(uintptr_t)(_val_)
actually why is it int trip here instead of unsigned int trip ?
> + dev_err(chip->dev, "invalid TEMP_DAC trip = %d\n", trip);
> + return -EINVAL;
> + } else if (temp < TEMP_DAC_MIN || temp > temp_dac_max[trip]) {
> + dev_err(chip->dev, "invalid TEMP_DAC temp = %d\n", temp);
> + return -EINVAL;
> + }
> +
> + reg = TEMP_DAC_TEMP_TO_REG(temp);
> + temp_cfg = TEMP_DAC_REG_TO_TEMP(reg);
> +
> + ret = qpnp_tm_write(chip, QPNP_TM_REG_TEMP_DAC_STG1 + trip, reg);
> + if (ret < 0) {
> + dev_err(chip->dev, "TEMP_DAC_STG write failed, ret=%d\n", ret);
> + return ret;
> + }
> +
> + chip->temp_thresh_map[trip] = temp_cfg;
> +
> + return 0;
> +}
> +
> +static int qpnp_tm_gen2_rev2_set_trip_temp(struct thermal_zone_device *tz,
> + const struct thermal_trip *trip, int temp)
> +{
> + unsigned int trip_index = THERMAL_TRIP_PRIV_TO_INT(trip->priv);
> + struct qpnp_tm_chip *chip = thermal_zone_device_priv(tz);
> + int ret;
> +
> + mutex_lock(&chip->lock);
> + ret = qpnp_tm_gen2_rev2_set_temp_thresh(chip, trip_index, temp);The sign conversion in the integer seems questionable. I see that the
intel code does the same thing but I think that's just an error being
replicated here.
---
bod
Powered by blists - more mailing lists