From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E40A5270552; Thu, 10 Jul 2025 14:07:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752156438; cv=none; b=qKDBExODVQaq87EhgPRjjBdkX7cMNt83/K10jXzD+5BrZFFATEIWKvyh0uOrtfmlwrnsh37zQSTSSkT8DF+ZGMZ+7redUu8IBM4p1anpc/wNN9B7VmrbUUAfKqRj2fpv0NNr0wFYmiRJNT21twpyEYxGzXQXzvUTIB1xeJ5g0Sc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752156438; c=relaxed/simple; bh=YpUIlnVX18vUrhXKaq83Q1Cvx4LaW7PKMg/2Q6O/gQw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=DFCe/Q1sgmC0OM/hhjU/MOO4ba+rOg3f0fFNoBNk1BWgi/cokch9E3/WWOJilRimA4ttejf81QeCi9QRl9f4FzUIId3kRc2pV5w2kbML6GuImg8pZB/ebRm8P50c00whtvjy7BTNcfP6PIxBHb0Ew59bWi/AzhRs1nlp4y0ZRKQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OOezLADa; arc=none smtp.client-ip=209.85.221.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OOezLADa" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-3a5257748e1so832367f8f.2; Thu, 10 Jul 2025 07:07:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752156435; x=1752761235; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=VkH5D2yTeKtqsP3Kkn65OGOaWxvX3yQ9gDnCFmnTyDk=; b=OOezLADaHA0eZ+utNqqHfzPqkGsARUOmmN/kDWfJa36GEF4EJmke3bH62Vs3TJ54m2 8xTi9rlnFWvAzo9T1Xt/+0+fZfBJxHKhSbKeRz/mxUFqs+j8KTjWOFjwJeH11VIdYXhg IF0/ayxNyDjQw0l4rOEeXJwK+6yNWlZayj2qXt9DQDRlinQFCi1tU4pCALwKvKU5c+os VRda1z2HChSl1FSD+rB4UQ6JlBHL2pgtX2xMjiPDl1wTnCCUbDv5VT2IWdL9XC6zE8JL Bz236vEnfrsEu0C5wHBH8+5seo+JzirNFITyuXQvSjFnFzKix4q3PS88FZ7QFkmqoEGv f/Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752156435; x=1752761235; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=VkH5D2yTeKtqsP3Kkn65OGOaWxvX3yQ9gDnCFmnTyDk=; b=l0FXazlf3mBxmoLy7emkCOh83IpOEEefm5/B5/ac0wx34dOaWR/Qd8Ub22Zacj0WtX JXtDXKKCueF27rs6ZPGCLyhv0iAVRqNLuldMV5+IziRP0Mal9xMDu2Rxbou65vnw6wBA cK615bLkGUKMUR3p+m/oKCudTODry283cJbywUGaW8rG9SJUDc+nw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fvtbUQ== X-Received: by 2002:adf:a394:0:b0:3a4:c8c1:aed8 with SMTP id ffacd0b85a97d-3b5e86c4f5dmr2108836f8f.39.1752156434760; Thu, 10 Jul 2025 07:07:14 -0700 (PDT) Received: from [10.38.1.85] ([188.39.32.4]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-454d50fa9b4sm61706965e9.27.2025.07.10.07.07.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Jul 2025 07:07:14 -0700 (PDT) Message-ID: Date: Thu, 10 Jul 2025 15:04:59 +0100 Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/4] rust: i2c: add basic I2C device and driver abstractions To: Danilo Krummrich Cc: Miguel Ojeda , Alex Gaynor , Wolfram Sang , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Greg Kroah-Hartman , Viresh Kumar , Asahi Lina , Wedson Almeida Filho , Alex Hung , Tamir Duberstein , Xiangfei Ding , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-i2c@vger.kernel.org References: <20250704153332.1193214-1-igor.korotin.linux@gmail.com> <20250704153657.1195687-1-igor.korotin.linux@gmail.com> Content-Language: en-US From: Igor Korotin In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 7/4/25 21:16, Danilo Krummrich wrote: >> + >> + 0 >> + } >> + >> + extern "C" fn remove_callback(pdev: *mut bindings::i2c_client) { >> + // SAFETY: `pdev` is a valid pointer to a `struct i2c_client`. >> + let ptr = unsafe { bindings::i2c_get_clientdata(pdev) }.cast(); >> + >> + // SAFETY: `remove_callback` is only ever called after a successful call to >> + // `probe_callback`, hence it's guaranteed that `ptr` points to a valid and initialized >> + // `KBox` pointer created through `KBox::into_foreign`. >> + let _ = unsafe { KBox::::from_foreign(ptr) }; > > I like to do that as well, but I usually get asked to use drop() instead, let's > do that here as well. :) > Danilo, could you, please, explain this one a little bit more? I see the same pattern for all the implemented subsystems so far: auxiliary, platform, pci. If this pattern for these subsystems is to be changed, then I'm fine. Otherwise I'm not sure I understand the difference between these 3 and I2C Adapter abstraction Thanks Igor