From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A1C72E8306B for ; Tue, 3 Feb 2026 09:47:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0343A10E173; Tue, 3 Feb 2026 09:47:38 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="PmdE215r"; dkim-atps=neutral Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id D77F010E173 for ; Tue, 3 Feb 2026 09:47:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1770112055; bh=SJgibaHQ0szc37inrLGCwLbR+73hqXSTWiGCcnfOEc8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=PmdE215r9KrduIfUmhLkRCuOYfk6uHTuy+nhv5COdt4yzi2k0B0QRR6KCcTxXvvAD nQSQ58J6vL4sryTrppeY0+ysfwmJTs9G22I6zMcSDY4F/1e7RYdofbnD/Cq+YhQvqU npqOGJr+/Yl8q4AXszsNLMDZg4HbOUFrxOYPsWEnbI6B3fkf3NqTcDpGYT8I0/GWZ3 SMuVVQgpON9mBztp3Fmz5GVxJojHTbJ0xh85RanMmxEvtYcmOxojIHXU0HXifZ7MYr IPmai1V/XYW1mL2y7z5oDy73AbND3prY1QiZF6z2NnMY1MmvJRNwAaqN2Yw2eUdFAM KZHal4V1/u/kg== Received: from fedora (unknown [IPv6:2a01:e0a:2c:6930:d919:a6e:5ea1:8a9f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbrezillon) by bali.collaboradmins.com (Postfix) with ESMTPSA id 4D55117E1149; Tue, 3 Feb 2026 10:47:34 +0100 (CET) Date: Tue, 3 Feb 2026 10:47:31 +0100 From: Boris Brezillon To: "Gary Guo" Cc: "Daniel Almeida" , "Rafael J. Wysocki" , "Viresh Kumar" , "Danilo Krummrich" , "Alice Ryhl" , "Maarten Lankhorst" , "Maxime Ripard" , "Thomas Zimmermann" , "David Airlie" , "Simona Vetter" , "Drew Fustini" , "Guo Ren" , "Fu Wei" , Uwe =?UTF-8?B?S2xlaW5lLUvDtm5pZw==?= , "Michael Turquette" , "Stephen Boyd" , "Miguel Ojeda" , "Boqun Feng" , =?UTF-8?B?QmrDtnJu?= Roy Baron , "Benno Lossin" , "Andreas Hindborg" , "Trevor Gross" , , , , , , , Subject: Re: [PATCH v3 1/3] rust: clk: use the type-state pattern Message-ID: <20260203104731.1918559a@fedora> In-Reply-To: <20260203100913.6d224657@fedora> References: <20260107-clk-type-state-v3-0-77d3e3ee59c2@collabora.com> <20260107-clk-type-state-v3-1-77d3e3ee59c2@collabora.com> <20260202171038.10e51e18@fedora> <20260203100913.6d224657@fedora> Organization: Collabora X-Mailer: Claws Mail 4.3.1 (GTK 3.24.51; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Tue, 3 Feb 2026 10:09:13 +0100 Boris Brezillon wrote: > Hello Daniel, > > On Mon, 2 Feb 2026 17:10:38 +0100 > Boris Brezillon wrote: > > > > > -#[pin_data(PinnedDrop)] > > > > +#[pin_data] > > > > pub(crate) struct TyrData { > > > > pub(crate) pdev: ARef, > > > > > > > > @@ -92,13 +92,9 @@ fn probe( > > > > pdev: &platform::Device, > > > > _info: Option<&Self::IdInfo>, > > > > ) -> impl PinInit { > > > > - let core_clk = Clk::get(pdev.as_ref(), Some(c_str!("core")))?; > > > > - let stacks_clk = OptionalClk::get(pdev.as_ref(), Some(c_str!("stacks")))?; > > > > - let coregroup_clk = OptionalClk::get(pdev.as_ref(), Some(c_str!("coregroup")))?; > > > > - > > > > - core_clk.prepare_enable()?; > > > > - stacks_clk.prepare_enable()?; > > > > - coregroup_clk.prepare_enable()?; > > > > + let core_clk = Clk::::get(pdev.as_ref(), Some(c_str!("core")))?; > > > > > > Ah, more turbofish.. I'd really want to avoid them if possible. > > > > > > Any disadvantage on just ask the user to chain `.get().prepare_enable()?`? This > > > way it is also clear that some action is performed. > > > > I've just disc > > Sorry, I've hit the reply button before I had finished writing my > answer. So I was about to say that I had started writing something > similar without knowing this series existed, and I feel like we'd don't > really need those prepare_enable() shortcuts that exist in C. We might > has well just go: > > Clk::get(dev, Some(c_str!("core"))).prepare()?.enable()?; If we want this pattern to work, we also need: impl From> for kernel::error::Error { fn from(e: Error) -> kernel::error::Error { e.error } } > > and have the following variant-specofoc functions > > - Clk::get[_optional]() (no get on Prepared and Enabled > variants) > - Clk::prepare() > - Clk::{enable,unprepare}() > - Clk::{disable}() > > Regards, > > Boris >