Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp796097lqj; Mon, 3 Jun 2024 00:21:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX2O9mNDGcEJfNOQKsabfzMwlYCQgSVEkRtxUk3D7TTq8EVO9r/5DrZrmCqJp9PiLnvRFPwF2zyxsobn4ZJobiEaFFnH1zq3oKEC3Mkcg== X-Google-Smtp-Source: AGHT+IFGj59Uw3Wp3clJihVk+6EOJKQQ+U1nLKWknSvJz137G4tMwUZaWldQarrjHerZhJCZU15q X-Received: by 2002:a05:620a:2913:b0:795:823:50a6 with SMTP id af79cd13be357-79508235dfemr309465885a.15.1717399273470; Mon, 03 Jun 2024 00:21:13 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-794f306331fsi793906185a.356.2024.06.03.00.21.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 00:21:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-198703-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@de.bosch.com header.s=selector2 header.b=snF2WXxU; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-198703-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198703-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=de.bosch.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 319A31C21B31 for ; Mon, 3 Jun 2024 07:21:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4E32643AD1; Mon, 3 Jun 2024 07:21:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=de.bosch.com header.i=@de.bosch.com header.b="snF2WXxU" Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2081.outbound.protection.outlook.com [40.107.20.81]) (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 2BB7E3EA95; Mon, 3 Jun 2024 07:20:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.81 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717399263; cv=fail; b=UFzJbBS1PXSH6Qmcj2jdqpBN1LZqsd8gOJCIqBLZNJztqfYz80IdGLEdrtIdrfKMyNFseIRXq5pvcUDD3Ujt1SCkVQkOSirXrdqdpzXYKisONANmgmhXTcTHCJ/R1wG8KbRgCJjOofi3rU2X5JvZ0F16Us8rNCB9Y7sq5Z3OZWE= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717399263; c=relaxed/simple; bh=HJLup6tM/8p1+Lgj0jHfIvKKP/U/l7FUT8QyCj1FnjA=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=nw3M7FFWZj/6EWGSk2TD980HB9nctj0qPKzNmYxErciO3oLZD6397Ws561nqMOVjI64eIH0+CotvlUQN5Zs1gXzXjWlPoM1XLDzLYGvdkbWxzKBqsINEKhkUXVjmF90VW0jdHL8MyzeahAJro5C8W/2FHG1WSMa0ZTDFaaVqbCE= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=de.bosch.com; spf=pass smtp.mailfrom=de.bosch.com; dkim=pass (2048-bit key) header.d=de.bosch.com header.i=@de.bosch.com header.b=snF2WXxU; arc=fail smtp.client-ip=40.107.20.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=de.bosch.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=de.bosch.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ApgnhSQZeR4Y6R1+YBhmPeU9CttG3rTctxpZ5ufdDJKOQ+/5ae/X5HUeAEtIzmqzvPlSXyBxjlH/5Q1Q0zfXeii6ygwlM9YP05ubsbKtGWW+LjAOyCVz1dRf6TX5hLqUQd/ftGp99xKeeR3xkNn9ZLYzcrHMC6Rao9ZZ/ORTygnFqUeGaErb3DsUYx3pqerD9bIh+yj8n81G5u3Lna1knSs4F2X9yIbpybMxTNLwbnQ0zoKFDrqMU6WnFtPY715PYeIPvH164vamHbqD1zXhl55mutIfqrVvfKpySthHlbHlj5nHyj6fWGTG7c8TU70pRjOv+SMNeAEqeT6hBabCWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wG1MhfqiaQzWKQRg2qRN9nneorZpFjD8o0l2KNtEEsY=; b=l0GRDRZvFgOSGtKceb91Bq1e1kRvAWRA+oLHpxkQVn8IMkPuAryZ0tpPnC9Qp/MsuoiLBMsPTbkjaTKF0/ii8KbVdT81tCCJkV9A/G8mvPRMEXcUiN2qaTRbjXglqssmHBoiQQuDT17ltVBr4n6BVE1Kua1N7lGbC/yt8bcwHTELX1QiikO/27BUU9VdGsLWrurXAnPhP+DYR1K/0qH+X6tbFSnoxpDBi4ZElqFNvGs0VNYT9JfRBlJz1PlY/9NdmgL1JASOfsY6G5WpEsyc4vVHEby2mZhov2apXpI2HdAcd/amIZZjZVOIW6LUSYebGBkxThN1yex+rEZPswrG8A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 139.15.153.206) smtp.rcpttodomain=redhat.com smtp.mailfrom=de.bosch.com; dmarc=pass (p=reject sp=none pct=100) action=none header.from=de.bosch.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=de.bosch.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wG1MhfqiaQzWKQRg2qRN9nneorZpFjD8o0l2KNtEEsY=; b=snF2WXxUg1zOqlEo4zSW7xOshI5JlUkGD0v4NpuOrTi9/JdEFwI2U5sPocf/H3VKuOccTnNtb5Uu6InTZoul46PoIF2DIB9QbM2ux/KN1HbmvNrhfoNW/1vK3lWuX7PzV7hwSBt+aQWiqUM2Dhi58Julr2t/Kjrnl7jatfKOC77fCqb+ieRFTKnWXUFzF4RZ2JkppkrHyaeKUyXB/Y7gpMFmMY94H99TQMe46ubJz++Qk1C1M8UL8l0SYt0zVtMaalxb8CSpJz7+Hlmdt8JyOazzjToAZ94xcG2k4/3c2tCCc370F6QhUE2Yh4KJ13UjuZsx7sA+w87DtdC7xJAnGw== Received: from AS8PR04CA0084.eurprd04.prod.outlook.com (2603:10a6:20b:313::29) by DU0PR10MB6703.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:401::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.23; Mon, 3 Jun 2024 07:20:57 +0000 Received: from AM3PEPF00009B9F.eurprd04.prod.outlook.com (2603:10a6:20b:313:cafe::fc) by AS8PR04CA0084.outlook.office365.com (2603:10a6:20b:313::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.28 via Frontend Transport; Mon, 3 Jun 2024 07:20:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 139.15.153.206) smtp.mailfrom=de.bosch.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=de.bosch.com; Received-SPF: Pass (protection.outlook.com: domain of de.bosch.com designates 139.15.153.206 as permitted sender) receiver=protection.outlook.com; client-ip=139.15.153.206; helo=eop.bosch-org.com; pr=C Received: from eop.bosch-org.com (139.15.153.206) by AM3PEPF00009B9F.mail.protection.outlook.com (10.167.16.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Mon, 3 Jun 2024 07:20:57 +0000 Received: from FE-EXCAS2000.de.bosch.com (10.139.217.199) by eop.bosch-org.com (139.15.153.206) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 3 Jun 2024 09:20:42 +0200 Received: from [10.34.222.178] (10.139.217.196) by FE-EXCAS2000.de.bosch.com (10.139.217.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 3 Jun 2024 09:20:42 +0200 Message-ID: Date: Mon, 3 Jun 2024 09:20:09 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 08/11] rust: add devres abstraction To: Danilo Krummrich , , , , , , , , , , , , , , , , , , CC: , , References: <20240520172554.182094-1-dakr@redhat.com> <20240520172554.182094-9-dakr@redhat.com> Content-Language: en-US From: Dirk Behme In-Reply-To: <20240520172554.182094-9-dakr@redhat.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM3PEPF00009B9F:EE_|DU0PR10MB6703:EE_ X-MS-Office365-Filtering-Correlation-Id: de24b80b-4e02-4caa-7bbf-08dc839db690 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|82310400017|7416005|1800799015|376005|921011; X-Microsoft-Antispam-Message-Info: =?utf-8?B?YUFsV2hDZ0Y0dlVYY2ZJb1VuQjA1RUUyWTVFdHhFT2NNOUlIQXJNOW1kTVpj?= =?utf-8?B?UzVabWJQcGtNMDZmQTVDVkZSbFJ4M2dHVDdjTXpEdG92OXdZSnVPdUM1di8y?= =?utf-8?B?bnBCOGYwWk54RTI2a1IwRXBVSEViYzY2amQ4RVJ0TXVlZEJHTW5zeUVJd3ZC?= =?utf-8?B?dzFkOU4xaHMzK1FCV3M0TjVOYjQvV3cyZFZmdUM5MW95WWN5T1BaY1BZd2JT?= =?utf-8?B?WXhJUitVM3RtUlp1VU4yM1F6QTE0S05DNXk2TDd6T0tWUnpmMFAxdkNzaURS?= =?utf-8?B?ekpibWZiTkVYbUJqOWV5dEVJL09vR243aUZraVQxczc2L0kzYTRsV0MvK0lD?= =?utf-8?B?UDdBUkFVTkRqVDAxMytvbHJXQnFkamVuRDMxV1FrVHZodzFYZTE0aGtrSzV2?= =?utf-8?B?eDZUSzR3dWNvK0dwNzd0QzhUdzFwdFB1QWg2WkdmNytuNW1vS3RPYXIzVitm?= =?utf-8?B?QlJiaEtHNE5nYnh4eXJKRWkrWDNrL095TlFqdEtKNDQ0SUhOdHlKRm1wOWN5?= =?utf-8?B?MVFuNVg1N2k1S2Q0TW93UGZuNkJVQ1pNS2t1WjRwSXR4bC85RE9Xai9ERU1H?= =?utf-8?B?T1hBdlE4MHRHdWZOQTFVWkp6dzhoMXdybXJUVk1XYzJ6Nlc4UEszWDdhazlp?= =?utf-8?B?Nk5Nd0hjeEU0alVGd0VCWnBaNUw1VmlJajVQTz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JGdGhpMHo4cVlDcEdtckhFL25oeDVV?= =?utf-8?B?RW81Q1hhZEwzL2hFL1ZSTUwwNWhmVUdaVnBiQTQvdGZjZUszbE8vRkxmZzRS?= =?utf-8?B?Y3hYOVJDN2U1RzBLUDR3MHhWQ0FETXcrdUo5WFlPSkd3dkx3ZzNpTk5GZi9J?= =?utf-8?B?SW1Ba2lucHNMNFBqM3d1WDN3Q0NsS3V4OHEvN3NicVF0ZU9wVG9sMURCRS9w?= =?utf-8?B?RzA3TVNNWUZnekNLZFEwMmVMV2RjR0paTmpwTmUzTzcxKy9jSk9MSitJY0t2?= =?utf-8?Q?tVQDruQLls7oq?= X-Forefront-Antispam-Report: CIP:139.15.153.206;CTRY:DE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:eop.bosch-org.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(36860700004)(82310400017)(7416005)(1800799015)(376005)(921011);DIR:OUT;SFP:1101; X-OriginatorOrg: de.bosch.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2024 07:20:57.4856 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: de24b80b-4e02-4caa-7bbf-08dc839db690 X-MS-Exchange-CrossTenant-Id: 0ae51e19-07c8-4e4b-bb6d-648ee58410f4 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=0ae51e19-07c8-4e4b-bb6d-648ee58410f4;Ip=[139.15.153.206];Helo=[eop.bosch-org.com] X-MS-Exchange-CrossTenant-AuthSource: AM3PEPF00009B9F.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR10MB6703 On 20.05.2024 19:25, Danilo Krummrich wrote: > Add a Rust abstraction for the kernel's devres (device resource > management) implementation. > > The Devres type acts as a container to manage the lifetime and > accessibility of device bound resources. Therefore it registers a > devres callback and revokes access to the resource on invocation. > > Users of the Devres abstraction can simply free the corresponding > resources in their Drop implementation, which is invoked when either the > Devres instance goes out of scope or the devres callback leads to the > resource being revoked, which implies a call to drop_in_place(). > > Co-developed-by: Philipp Stanner > Signed-off-by: Philipp Stanner > Signed-off-by: Danilo Krummrich ... > +impl Devres { > + /// Creates a new [`Devres`] instance of the give data. Typo? give -> given > + pub fn new(dev: ARef, data: T, flags: Flags) -> Result { > + let callback = devres_callback::; > + > + let inner = Box::pin_init( > + pin_init!( DevresInner { > + dev: dev, > + data <- Revocable::new(data), > + }), > + flags, > + )?; > + > + let ret = unsafe { > + bindings::devm_add_action(inner.dev.as_raw(), Some(callback), inner.as_cptr()) > + }; > + > + if ret != 0 { > + return Err(Error::from_errno(ret)); > + } > + > + // We have to store the exact callback function pointer used with > + // `bindings::devm_add_action` for `bindings::devm_remove_action`. There compiler might put Missing 'the'? "There *the* compiler might put ..." Best regards Dirk