From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.155 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792585982; b=d2rGJDZmKi3x5/sN3I7qoAC1cTei+kNgjenSh7XfJpBFFaBhQYgLUPRN6cJE83Xnb+P1 N4CsFP5tVkpGGi3YHRfYKTKBOsVGYn6A9XcReYw79XrcWKQs5STM0C/1s2Yq7MzusIPfg sIfCW1AIEKs1Kml18Tbyz+VS9rBc4CJwYl5o9QY8kodCFx7jfmlvnKwoytxLNfaCb8CMR QiU4ls+o9w4bauhJ2p5wHTUik4MDpGnx7IYo3nfo/UTZxTi9n6FxNiS6J5qRoow4YCr92 Dqggc6+sfJ9EvKUtEvuzDghNJCsfAsdQw3LLucONWuXSaV+0C+WDKvY7n7fpnRrQOfQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792585982; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-ID: In-Reply-To:References:Content-Type:Content-Transfer-Encoding: MIME-Version; bh=8UbbgrphgYT4+jqnZZPIAvYrMvoD+fbwUIQvN0A6Pdw=; b=oc48LsOVPTZYBac+w7ZffNWT47JjT++XWdgCYIaqQi+K8UHimslW3Oha9ueRpozO7Q6j x6ivhUQB4Rs3BRVOwGX9uPZQhC9TrGhx5VUKijhsG7eSkcVTFADO/9irTSwi8a7nPprBi C9nj+Y5RskPE8nWV9knpvcxGMOKTmIJhmZKJ1lKdfhkkZQGxPnuA1xy2zUZwFUuir1j+k TrVqw0Xjhae1/dfhS3o7KwKxo8lNUFvGspgcUd5m49K0rRa0F2wwHT+7iPcAFoUa5nirO utSV8C2klYtXs/uO/kMcy3qbLxe/yGPV4pAnCpcEXNgId1Ua0rTP26eA5puCCvZ24jw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=gDWkEoCD; arc=none smtp.remote-ip=91.218.175.155 Received: from mta0.migadu.com (out-155.mta0.migadu.com [91.218.175.155]) (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 B51D2606A322 for ; Wed, 21 Oct 2026 12:33:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B51D2606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=gDWkEoCD X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=8UbbgrphgYT4+jqnZZPIAvYrMvoD+fbwUIQvN0A6Pdw=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1792585978; v=1; x=1793190778; b=gDWkEoCDZ1nVzIf6CKWHdBb5vDQUQ40lHEdp3XFe3s86dnlM4qsV1ZfaZ63JbFKrCuMdawyS Dek7lUMq9jbrsJZNx3UJUs9LRHjgY7gW0Xu2wvLPd7Mv7g1zTc+TA5GIBzudJ4V5OPGNCm2FNqa h0Sp6WwEuCPjvu/gPceiziyY= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 0207a1f2d1931a27; Wed, 21 Oct 2026 12:32:58 +0000 X-Mizu-Trace-ID: 0207a1f2d1931a27 X-Migadu-Flow: FLOW_OUT From: Igor Korotin To: Danilo Krummrich , =?utf-8?q?Nicol=C3=A1s?= Antinori , Georgios Androutsopoulos Cc: Muchamad Coirul Anwar , Jonathan Cameron , Alexandre Courbot , Alice Ryhl , Andreas Hindborg , Benno Lossin , =?utf-8?q?Bj=C3=B6rn?= Roy Baron , Boqun Feng , Brigham Campbell , Daniel Almeida , Gary Guo , Jori Koolstra , Miguel Ojeda , Onur =?utf-8?q?=C3=96zkan?= , Shuah Khan , Tamir Duberstein , Trevor Gross , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel-mentees@lists.linux.dev Subject: Re: [PATCH] rust: i2c: remove TryFrom<&Device> implementation for &I2cClient Date: Wed, 21 Oct 2026 13:32:55 +0100 Message-ID: <179258597583.20422.10358976352101642829@linux.dev> In-Reply-To: <20261019152329.620610-1-nico.antinori.7@gmail.com> References: <20261019152329.620610-1-nico.antinori.7@gmail.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit 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 Hi all, Want to flag something before this lands -- I gave this an Acked-by already, but while reviewing Muchamad's concurrent AS5600/IIO series (Cc'd) I hit a real conflict with it. His IioDriver::read_raw is called by the generic IIO core, which only ever hands the driver a generic &Device -- it has no way to know the device is I2C specifically. To do SMBus I/O there, the driver needs to recover &I2cClient from that generic reference, which is exactly what this TryFrom did. I checked whether storing a handle from probe() instead avoids the need -- it doesn't. AlwaysRefCounted is only implemented for I2cClient (Normal context), not I2cClient, so there's nothing you can hold onto from probe() that still proves "currently bound" later. And there's no way to get back from Normal to Bound (Deref only goes the other way). As_raw() on both Device and I2cClient is private to kernel::i2c, so a driver can't reimplement the conversion itself either. So removing this outright leaves no path for any bus-agnostic subsystem callback (IIO being the concrete case, but this'll recur for SPI, HID, etc.) to ever recover a bus-specific handle after probe. Danilo, you mentioned a fix tying the lifetimes together properly (impl<'a, Ctx> TryFrom<&'a Device> for &'a I2cClient) as an alternative to removal -- given this, I think that's the right call instead of deleting it. It closes the actual soundness hole (output lifetime no longer independent of input) without removing the only way generic callbacks can get back to a specific bus type. I haven't pushed Nicolás's patch to rust-i2c-next yet -- holding off until this is settled. Cheers Igor