From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 3B2F0226CF1; Fri, 23 Jan 2026 10:25:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769163923; cv=none; b=qKotXmIlYZdq0jpP8EpdLx+isu0YccgTRNPJspVcb/kgYAfzaDzFseBppztXafXnvZePAYREPrsAmm8hGH1JE5y+9YAk3nHC7HVFBZbGPMwt2ND9Bj0FkLbbCrEFHSRIRa3Ae2v2XJQ31qTVUvXO+FBSQKBQDOqEgDp6EbBYO2c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769163923; c=relaxed/simple; bh=rJ4PnEjQ92Juv7kZRzfOisQ3OCIKnD1ngLkVqecNc9k=; h=Mime-Version:Content-Type:Date:Message-Id:From:Subject:Cc:To: References:In-Reply-To; b=HdpLCjJok82RD/rCRt2m9RXFE9oQNNMEnDhk4PWzQdkVq6LXT2HRjNoqKCO18KuVnEbeu+eKES2VkhsSaaK7twKq5+URydmZM7GJYzIB02cSSRc4ZgNoz8PCHyJJcz0L5gBjYEmNbXMJ0wFWytLLFLqby2AZF40STEwRMnL3gcc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=k0h2SByq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="k0h2SByq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB2C7C4CEF1; Fri, 23 Jan 2026 10:25:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769163922; bh=rJ4PnEjQ92Juv7kZRzfOisQ3OCIKnD1ngLkVqecNc9k=; h=Date:From:Subject:Cc:To:References:In-Reply-To:From; b=k0h2SByq5PfVLciYPhFHNrx7uY5AK0JigWp+8CNZ4ETAiuqQmj8SFs/zYtBJAw0ZA QO9OCJDyziJ2dpVwP95QppS+/yf+vyXVIYff99i/OKJ6wfgGv+7Nn5PJuN/bDtOGYB /CspVsbk73ZO02xc7gqWXpQsGFi6OuQ96PTC+OPNL+fBAuJfSID9Ic+0Dnhg4PkkMB IkrRQxBlzTannrtwvJ9pYIH/qaUb9pDIsQDkmRsEg/OpYYbOIVr5dqXqfTm1EGAi8M SnhJgnSyz0CogxKQ90MEoe4bIMRFXHgPQD9F2d4ctL3IvKm5X4nGqJlz+IfFEE+Uz/ bm1HG0hJwrkWw== Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 23 Jan 2026 11:25:15 +0100 Message-Id: From: "Danilo Krummrich" Subject: Re: [PATCH v3 1/3] rust: clk: use the type-state pattern Cc: "Daniel Almeida" , "Alice Ryhl" , "Rafael J. Wysocki" , "Viresh Kumar" , "Maarten Lankhorst" , "Thomas Zimmermann" , "David Airlie" , "Simona Vetter" , "Drew Fustini" , "Guo Ren" , "Fu Wei" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , "Michael Turquette" , "Stephen Boyd" , "Miguel Ojeda" , "Boqun Feng" , "Gary Guo" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Benno Lossin" , "Andreas Hindborg" , "Trevor Gross" , , , , , , , To: "Maxime Ripard" References: <20260107-clk-type-state-v3-0-77d3e3ee59c2@collabora.com> <20260107-clk-type-state-v3-1-77d3e3ee59c2@collabora.com> <20260108-delectable-fennec-of-sunshine-ffca19@houat> <98CD0BF6-3350-40B9-B8A9-F569AE3E3220@collabora.com> <20260119-thundering-tested-robin-4be817@houat> <518D8B09-B9A1-4DB4-85CD-37A2DD3D5FB1@collabora.com> <20260119-weightless-pelican-of-anger-190db0@houat> <20260122-majestic-masterful-jaguarundi-d0abde@houat> In-Reply-To: <20260122-majestic-masterful-jaguarundi-d0abde@houat> On Thu Jan 22, 2026 at 2:44 PM CET, Maxime Ripard wrote: > On Mon, Jan 19, 2026 at 03:37:17PM +0100, Danilo Krummrich wrote: >> I don't see the issue with devm_regmap_init_mmio_clk()? It takes a refer= ence >> count of the clock and prepares it when called and unprepares the clk in= drops >> its reference in regmap_mmio_free_context() called from the devres callb= ack. >>=20 >> That something we can easily do with the current API, no? > > The current one, yes. Doing that in the API suggested here would involve > some boilerplate in all those drivers they don't have right now. No, I did mean the API suggested here. If you would implement something like devm_regmap_init_mmio_clk() in Rust w= ith this API, you'd have some object like struct RegmapResource { map: Regmap, res: R, } and a concrete instance could have the following type RegmapResource> So, eventually you could have: fn devm_regmap_init_mmio_clk(dev: &Device, name: &CStr, ...) -> ..= . { let clk: Clk =3D Clk::get(dev, name)?; let regmap =3D RegmapResource::new(..., clk); Devres::new(dev, regmap) } Of course, we would never design the API in this way, as we have generic I/= O backends and register abstractions, and we'd also not have devm_regmap_init_mmio_clk() as a constructor for a RegmapResource type, but= you get the idea.