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 ABD4B338F21; Wed, 15 Oct 2025 17:28:03 +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=1760549283; cv=none; b=IHeXvx41Orf/U4bH65KTlqJck1HR5PInm8caub+PZ/IczC3rFHYRehwa9wSoA71y9rB+bBusixRESInOp/cfGmV7Eh+1vbcCeXFCBJ9QwZ9CTNCxnMUYbwF7jA8+9PIKl3hWWK0Lfm1K9ufWxsz4cEnToAWptIfEGU5bpGjrB2g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760549283; c=relaxed/simple; bh=ygYSReZYoQQfbRjOy+h8AzmtWJKt0WboxvKPa7Hw9C8=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:To:From:Subject: References:In-Reply-To; b=iu+K5Yah6LzoCazl6WbSqAzqJlU1586SfTqcRRdkeT9dMaXrcabB/tA0VbYkFf6ORFGZ13qchrNDItZMftBB//7azuK0ulj56eOYMtgmopBtzuWl3dPAbV4HHmYe9uwMv3sEYIFCicWFjJLQ5C0Gzu9zq40bsR9hC0xIx+o24po= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=C42KKnd+; 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="C42KKnd+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FACCC4CEF8; Wed, 15 Oct 2025 17:27:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760549282; bh=ygYSReZYoQQfbRjOy+h8AzmtWJKt0WboxvKPa7Hw9C8=; h=Date:Cc:To:From:Subject:References:In-Reply-To:From; b=C42KKnd+nGR/z5rWWtWTRKMwIyDtCmvAvMXP14LddLR2sL6+TwO8GN+u29mr1Nkdh 4yajPj7C8oVRQvwMv/WwFRaeMMyx0M6W6sGtzwbmqjCNQfsnKsp9w3txsQKqDe1Dy4 cqcVuloPCf34TxVjHhAfM2YM6rS0DXVLmvj1Ms9dwGdlYBRDPzwbJURQGDdJC1YKwd 617REbHxu3TnQjqno/csNuPZSJ7wmjVFCje28musun5pQKuQH6fUbFuDX29Vii5k3I Z37tgPS39MmqXXoHBmwMJC0ssoc8bGHG15KGTaFSNrsQSODuTVLvTIAo3Jr4v4lZ2u w4osYN5QgxYJA== Precedence: bulk X-Mailing-List: rust-for-linux@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: Wed, 15 Oct 2025 19:27:57 +0200 Message-Id: Cc: "Alice Ryhl" , "Miguel Ojeda" , "Alex Gaynor" , "Lee Jones" , "Pavel Machek" , "Lorenzo Stoakes" , "Vlastimil Babka" , "Liam R. Howlett" , "Uladzislau Rezki" , "Boqun Feng" , "Gary Guo" , , "Benno Lossin" , "Andreas Hindborg" , "Trevor Gross" , , , To: "Markus Probst" From: "Danilo Krummrich" Subject: Re: [PATCH v4 2/2] rust: leds: add basic led classdev abstractions References: <20251012145221.172116-1-markus.probst@posteo.de> <20251012145221.172116-3-markus.probst@posteo.de> <7de58fd25b52dd5195c8ac06ed4df5a1e60e5070.camel@posteo.de> <25f3fd337ce5e58915125c4e2eb85ef4d7af3627.camel@posteo.de> In-Reply-To: <25f3fd337ce5e58915125c4e2eb85ef4d7af3627.camel@posteo.de> On Wed Oct 15, 2025 at 5:02 PM CEST, Markus Probst wrote: > Not necessarily every, like I said `container::Device` itself also > would implement `device::Container` (still allowing &Device). Sure, but eventually we'll need all bus devices to implement it because you= want to be able to use this class device on any bus. > We already know the address of it with the `struct led_classdev`- >`parent` field, we just need to substract the offset from ` Container>::Offset`, and we have the address of the device container > (like `struct i2c_client`). No Box needed. Yeah, that should work. What I still don't like about it (and didn't like back then when I thought = about something similar) is that this provides a publicly accessible unsafe way t= o upcast from a generic device to a bus device. However, I do see the ergonomic advantage for drivers. Even though I'd say = it's minor, it is indeed nice that the class device callbacks can already carry = the actual parent bus device. So, I'm fine giving this a shot. If go for an implementation, please name t= he trait something along the lines of device::IntoBusDevice, device::Container= is too generic. Only bus devices have a DeviceContext.