From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796154694; b=UUGx89q5L5i2pkewRpz9E7YtC8/4DkqruAyaPuJruVfqQ+CZtiUbJH0ASBTL1K1KjBFd B2aRmYSu7n5ZWBEfv4q3ZFQMptewMShRgxd1N25gRMnhFi6M7KLCOjs9HQjf3J+gi2mUz 5BuIS74pY/GMgYu56yJ0FlAC4guRntiEuwizL1mFZGOi9tRUikbArdTTcXECe2f7vumVl WZReuX5HwQDsKnlD+iLiO0pp31iXII39Fy7D9qxgbruc6tpi+ncG1L7zwsawpJbnYLd94 Ndp83SCjttiMnvJPFazRMhH14I/o1/Fl/M6PgBGlkJn5UzZtMLdUFgErmcriIK7GsNw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796154694; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=fMR9hIyq9PljcQpkP452kstEemZyqVKbJgCnXKvj5D4=; b=YL/3dWwhimaHiBt9WkA79n/eAvx8wtdbDMlVhKqjDdRyXC5EC4kg9BCPWlxwgoEf6OMF HaqfQy3kPY0Ue/mbAcpSLv4XQr55BrgAUpWXQ+LidUjqirecbzpyCNXXTtqcFf+CrgbSv ncCCRLM1Ljij0fPmA5+//7LvfyTgJ0gV7AsaVb933tjR5WPBu0hbmWe7DuIJr2lD3kR+E MRd9eC/rjHiwngV3I4k2EL/KboJL53v8SXHeK3qn+3/tGsn5wa1c3O7+xceIWZgV+QS/w b7zZOOVbg7iy/y+eVIX00CT/vaiR0fr5oHa6/cM5EbWOFfcryqIgBsiHmunQj6GfhfA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass header.d=baylibre.com header.i=@baylibre.com header.a=rsa-sha256 header.s=google header.b=fCtn9A2z; arc=none smtp.remote-ip=209.85.210.43 Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96C69606A325 for ; Tue, 1 Dec 2026 19:51:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 96C69606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.a=rsa-sha256 header.s=google header.b=fCtn9A2z Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-8451a619da7so7319631a34.1 for ; Tue, 01 Dec 2026 11:51:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1796154692; x=1796759492; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=fMR9hIyq9PljcQpkP452kstEemZyqVKbJgCnXKvj5D4=; b=fCtn9A2zg/gW64i0DbF6TKVTuJhbiFGGNq/0KcB9UejY7way7ISJGvu9n3a3aNalfh uAUdQch3nwTMvlnx5T36kQ/Stiaxm8cC3GZdRhVF/YqJeEI83DUf/MEV/52M3IGRRgok 6JyHKteUgm/haG/kK2f6Q1x34yccKgB9HrRDM51JpSkz5JsFwa25ErkkA8vIgUI5Ct75 PDYY7MY6RdpX2QhhrtFesPixtlKn8Yn7RC0tDhI7assmDmkHFfXb7wIz++sFVeO54N/r 0X3pYg+3lzdjUVn0Y6K9fopCREs7Exqb9JGqXpNzD9b0VqgBYXCDp30VfcdF6TF1E7GO 2Gqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796154692; x=1796759492; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=fMR9hIyq9PljcQpkP452kstEemZyqVKbJgCnXKvj5D4=; b=Zrsaz1VHWvGx+lJD6lU7rAeNt5hu+9/EO8vGLi5PORzTv9m/44zAGv23CBwlVmWE47 PKpJE/WmrO2HJ1ddP8Z2yOoiRWfupwf5GfMx0Rt2P2gZIklVvX+liGfKIeL52ClzeWuz uw2BlKG2YFKdY1oS+OfiEtTBP7GHPaLpera3bo7BlCmIGJo9MBZMx6eLp6cv73W/XSU1 q3Ox3Klswfz9/m3Fo2tLXmQZ/q1CrzRMj+5Lzbiih5fQ0iCypXUU++p11tgjAGWzbPfu FsVOo7Mcs6o8bS/8HsdlKmr5/H97YShyiiwrZ8iDh969Unw+VAKAQb4M2EWBJJ9aukMZ vl0Q== X-Forwarded-Encrypted: i=1; AL+hErFmjq55MNWjXiZHtopoVyflDL4momlPsT7/RfIwV8qq7gGVnjlQgxFaXCk/tCBOV+taIJt13QzdzQaVxGQ=@vger.kernel.org X-Gm-Message-State: APuU4Z+0nF1oEFGqqq+gKlo2YpzhQankdqK4Scpq8cop/Bl0tqEVwztW CJOig+xkBepUjqg8/UdMM/h31yEPOhOWG8M3GLsg1Tr6pCAjgTpckK8BhN0AaBPR6Zg= X-Gm-Gg: AZFdTZc0wNIliGhBIOo9ZOCeBzkwDgqZYsNfdab9LhTyidWMPJoo6GqzK0So1a/W4ag x1LX0OA9C3NS1bTwv79mrTGZQBW+NGAtEYaD1WFaROhrPWuTw5QjJlwYSUc8kb5Hh6+QJZVazhU 2NUJEVV+oJc32rfGgzjZXOQ7GaqfMLwK8LJHGoAld9dvFObFdcACGjzqDJEZMGm9dtfV257yLPj zVHgwVKLqPXxQ1AomRDBPqyGftik2ef6iLtNcXuCcX7EJ7wBKo3fHoobcKjtYZ91an4wTWyWas9 ls6wlkvbjaKBQUPPPN8sRo6VmzZHikvjnbovJfTE39C1G78Jfj3KAOakFVBECM53t/u1abWj6U7 3ywABsjYdpiEjUfHO5RicDBVHjoSeQZOpyHMs6aENGaH2lcSpZi3M1IgDb2+t/p/sqpnevsz0z9 pk3jJF3ffeW/3eD6+i3/jdtT6mdVCoPnPERJqXGxxaa/9F4yFna+FmNU5yb5btEfhzl0qCJ7AKp 5b9l0lqDo5QGB2g8Vuq2AVr9n+LICovfgnW7MF2IRi6CkAFkXJWXNj1ccuqFmv178svGoSimRY4 TzxtrJ/9Oz2V2Ysc4lpPpXAd5BUDXgXBM7w4oy50wEWsoEReGXX1HZh+6OGgOi+3nzkIhplnUn4 = X-Received: by 2002:a05:6830:442a:b0:862:a48e:24c7 with SMTP id 46e09a7af769-86315a868a5mr40875173a34.30.1796154692597; Tue, 01 Dec 2026 11:51:32 -0800 (PST) Received: from ?IPV6:2600:8803:e7e4:500:7f4f:87d:32a2:1768? ([2600:8803:e7e4:500:7f4f:87d:32a2:1768]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-863168f6d33sm26516933a34.18.2026.12.01.11.51.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Dec 2026 11:51:32 -0800 (PST) Message-ID: Date: Tue, 1 Dec 2026 13:51:31 -0600 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] hwmon: (da9052) Tie the tsiref regulator to the hwmon device To: arina.kharlamova@mbzuai.ac.ae, Support Opensource , Guenter Roeck , Liam Girdwood , Mark Brown , Jonathan Cameron Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20261201-s2p-lpr-hwmon-v1-1-c9dacf93eae1@mbzuai.ac.ae> Content-Language: en-US From: David Lechner In-Reply-To: <20261201-s2p-lpr-hwmon-v1-1-c9dacf93eae1@mbzuai.ac.ae> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 12/1/26 1:26 PM, Arina Kharlamova via B4 Relay wrote: > From: Arina Kharlamova > > da9052_hwmon_probe() calls devm_regulator_get_enable_read_voltage() on > the parent MFD device, because the tsiref supply is described in the > PMIC node. The reference and the enable then belong to the parent and > are not dropped when the probe fails later or when the hwmon driver is > unbound. Every new bind enables the regulator once more. > > Look the regulator up on the parent, but enable it with the plain > calls and disable and put it from a devm action of the hwmon device. > > Fixes: d72fd5228c9f ("hwmon: (da9052) Use devm_regulator_get_enable_read_voltage()") > Cc: stable@vger.kernel.org > Signed-off-by: Arina Kharlamova > --- > The tsiref regulator stays enabled after unbind or a failed probe, > and every bind enables it once more. > > I found this with spec2patch. I model-checked the probe and remove paths > of the driver with CBMC against formal specifications of the kernel APIs > it calls. The specifications are checked against the kernel source, and > some of them are proved in Rocq against a transcription of the kernel > code. I also checked lock usage separately. With the help of an AI > coding assistant (Claude); I reviewed the analysis and the fix. > Compile-tested only, not tested on hardware. > --- > drivers/hwmon/da9052-hwmon.c | 37 +++++++++++++++++++++++++++++++++++-- > 1 file changed, 35 insertions(+), 2 deletions(-) > > diff --git a/drivers/hwmon/da9052-hwmon.c b/drivers/hwmon/da9052-hwmon.c > index a795b71c54f6..428da8022695 100644 > --- a/drivers/hwmon/da9052-hwmon.c > +++ b/drivers/hwmon/da9052-hwmon.c > @@ -391,6 +391,40 @@ static irqreturn_t da9052_tsi_datardy_irq(int irq, void *data) > return IRQ_HANDLED; > } > > +static void da9052_tsiref_disable(void *data) > +{ > + struct regulator *tsiref = data; > + > + regulator_disable(tsiref); > + regulator_put(tsiref); > +} > + > +/* > + * The tsiref supply is a property of the parent node, so look it up there, > + * but let this device own the reference and the enable. > + */ > +static int da9052_tsiref_enable_read_voltage(struct device *dev) > +{ > + struct regulator *tsiref; > + int ret; > + Could use a comment similar to the one from devm_regulator_get_enable_read_voltage() to explain why we use optional here (to get -ENODEV here instead of -EINVAL later). It is not actually optional. > + tsiref = regulator_get_optional(dev->parent, "tsiref"); > + if (IS_ERR(tsiref)) > + return PTR_ERR(tsiref); > + > + ret = regulator_enable(tsiref); > + if (ret) { > + regulator_put(tsiref); > + return ret; > + } > + > + ret = devm_add_action_or_reset(dev, da9052_tsiref_disable, tsiref); > + if (ret) > + return ret; > + > + return regulator_get_voltage(tsiref); > +} > + > static int da9052_hwmon_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > @@ -413,8 +447,7 @@ static int da9052_hwmon_probe(struct platform_device *pdev) > device_property_read_bool(pdev->dev.parent, "dlg,tsi-as-adc"); > > if (hwmon->tsi_as_adc) { > - tsiref_uv = devm_regulator_get_enable_read_voltage(dev->parent, > - "tsiref"); > + tsiref_uv = da9052_tsiref_enable_read_voltage(dev); Why not da9052_tsiref_get_enable_read_voltage()? > if (tsiref_uv < 0) > return dev_err_probe(dev, tsiref_uv, > "failed to get tsiref voltage\n"); > > --- > base-commit: 32a9f95f4fd42a0b7c0b750597e68175948fd3d0 > change-id: 20261201-s2p-lpr-hwmon-fb3f04daaa75 > > Best regards, > -- > Arina Kharlamova I made a few suggestions for improvement, but the important parts look correct so... Reviewed-by: David Lechner