From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796314346; b=FN/jSycIdGjVaRTyOpwbq+JPiUTkLmehUg0Wkq7PTdlJiyYDTVgj7wtQXh3xyWmukAob 4NPondsIKm9MmhJ+lyHrtB9EcGKJK1EsOUIqmQaovkI/KjZeEdz9xz85Op3a29pRfPRba vh4BbrayPObSepgFHm61U048u+ykW1sQ4UNF5SjtaFrOXf6v2lbAbgaTginHoLQUoBHzg 08KHFpfGelpeFXPHasGJqDuc6Vn+3r9E5Q4ULGMOimfEoiARGF67H0B0NTNExDUQjyI3h iAM0cbMGOKEYAB1jkdEeuc2c1Q2WlAvvGpwgaZBeGASzRJ6T5u/Ah9g9oxe0gLDpKMg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796314346; h=Received:DKIM-Signature:Mime-Version:Content-Transfer-Encoding: Content-Type:Date:Message-Id:Subject:Cc:To:From:References: In-Reply-To; bh=oOl+oMlNEQI4bJwl35hjPGEPuFQj5cQWV9MMW6SL5Es=; b=LGgoSYRwDBVBLJg5ORnLtwNj/mxJVnybOzsX5SuU75oWyu070dBUuTpIxy+rL5bJXu3L TfdRWqc2jhMeUs94lmqbsUlAih9UVqszjchUsweUyz7ApTuaFbF3yqw/G4Fz/Zwx+cbVy UP9wlNZVtTlLzIw9Yos3vNQCNqW0XuzxtJRggpI+4Gx86EjyYwdXTWCdUE3haKEuNySN2 LtRYsu2xFQvxCwgq70OR+TCAY5JNCeL+is4tryJzhS9eFBJJ0v+D95MuYEuCChrSqocbD sT5coDK42CLPbaF2CQK5ppNlrCAIt82Sm78e0nCrxNRouwIdm9uCtaYHKNWM9nT2Nyw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NRal+juJ; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 435E7606A322; Thu, 3 Dec 2026 16:12:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NRal+juJ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34BC91F000C1; Thu, 3 Dec 2026 16:12:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796314345; bh=oOl+oMlNEQI4bJwl35hjPGEPuFQj5cQWV9MMW6SL5Es=; h=Date:Subject:Cc:To:From:References:In-Reply-To; b=NRal+juJ82ux4s3f3Njad4ZeaLbYDqbLWIv+x9JOy31h4sAoU7KMRUg5Od8Db7sKm LHPcEJ7s9byr90FRuIbsot33oyURGK1bLGcH5fTyBBS/OgyqFM64AXBm38LrYLqYK6 PTDjH5SNecma19E7a97HAZiv+wlFuJDZy7AAa0d7NKgRwCVJYVQxzLTJ53HyZzTibk U3wn0l2gAPrttvNPtn6MK0KmkY4P/+91Xtc2D3x5Nb0GnX36C0QOmXm6238pDQ4aUP RcN97AVEITIf5s4gWFq/hZe6fAgnvw021fMoN5und44nS4CteDL/tr5QQ8L1+iu1ol z7d47Av5IIskQ== X-Mailing-List: linux-pwm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Thu, 03 Dec 2026 17:12:17 +0100 Message-Id: Subject: Re: [PATCH v6 5/7] rust: clk: add devres-managed clks Cc: "Jerome Brunet" , "Daniel Almeida" , "Rafael J. Wysocki" , "Viresh Kumar" , "Alice Ryhl" , "David Airlie" , "Simona Vetter" , "Michal Wilczynski" , "Drew Fustini" , "Guo Ren" , "Fu Wei" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , "Stephen Boyd" , "Brian Masney" , "Jerome Brunet" , "Miguel Ojeda" , "Boqun Feng" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Benno Lossin" , "Andreas Hindborg" , "Trevor Gross" , "Tamir Duberstein" , "Alexandre Courbot" , , , , , , , , "Boris Brezillon" , =?utf-8?q?Onur_=C3=96zkan?= , "Maurice Hieronymus" To: "Gary Guo" From: "Danilo Krummrich" References: <20261013-clk-type-state-v6-0-a5e9977b3509@collabora.com> <20261013-clk-type-state-v6-5-a5e9977b3509@collabora.com> <189F36A9-D1C1-478A-A195-F94D037E4376@collabora.com> <179580269373.2809466.3866997464599192193.b4-reply@b4> In-Reply-To: On Fri Nov 27, 2026 at 8:04 PM CET, Gary Guo wrote: > On Fri Nov 27, 2026 at 6:04 PM GMT, Jerome Brunet wrote: >> On 2026-11-18 11:47 -0300, Daniel Almeida wrote: >>>=20 >>>=20 >>> > On 18 Nov 2026, at 11:24, Gary Guo wrote: >>> >=20 >>> > On Tue Oct 13, 2026 at 6:07 PM BST, Daniel Almeida wrote: >>> >> Many drivers only need a clock running for as long as the device is >>> >> bound and never touch it afterwards. In C, devm_clk_get_enabled() an= d >>> >> devm_clk_get_optional_enabled() cover this case. >>> >>=20 >>> >> Add devm_enable(), devm_enable_optional() and >>> >> devm_enable_optional_with_rate(), which wrap the C helpers. They ret= urn >>> >> no handle, so the driver keeps nothing in its data and cannot change= the >>> >> state of the clock. The clock is disabled, unprepared and put when t= he >>> >> device is unbound. >>> >>=20 >>> >> This mirrors regulator::devm_enable() and devm_enable_optional(). >>> >>=20 >>> >> Reviewed-by: Alexandre Courbot >>> >> Signed-off-by: Daniel Almeida >>> >=20 >>> > Given all the device resource lifetime changes, do we still need this= now, or >>> > would putting a guard in driver private data to be dropped automatica= lly upon >>> > unbind be sufficient? >>>=20 >>> I think we should still provide this. Many drivers only care that the c= lock be >>> enabled at a given rate, and do not care about the handle. I think this= has >>> little to do with C or Rust and should be supported in Rust too. >>>=20 >>> =E2=80=94 Daniel >> >> Gary, is this OK with you ? if it is, I can take as it is. > > It's a bit against the trend that we're doing elsewhere where things that= are > managed APIs are changed to become guards that gets embedded in drivers (= so the > lifetime relationship is tracked by the type system). That said, clk/regu= lators > usually don't interact with other device resources, so probably keeping d= evm is > fine, so not a blocking concern from me. > > That said, I'd like to hear Danilo's thought on this one. For clk and regulators specifically it is not a huge concern for me to have devm_* helpers, but in general I don't want to add more of them. I'd rather want to get rid of devres in Rust, as it can lead to subtle orde= ring issues with the lifetime design we have for device resources. So, if we don't think they add a lot of benefit, let's just avoid them so w= e don't give people ideas. :) Independent from that, both the clk and regulator APIs should be constraine= d by the lifetime of their corresponding Device they are associated with. I'm fine if this is done as a follow up though. Thanks, Danilo