Message ID | 20230224-rust-error-v2-0-3900319812da@asahilina.net |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp378885vqo; Wed, 29 Mar 2023 05:37:29 -0700 (PDT) X-Google-Smtp-Source: AKy350ZWt8is+zlIOaa/IGVcx7PiPSMVpB4A5AT5NlpvJP8bIvb+CTpj9xchY+PgcD97SdfEpD0H X-Received: by 2002:a05:6402:8c4:b0:4fc:725:e670 with SMTP id d4-20020a05640208c400b004fc0725e670mr18728045edz.11.1680093449038; Wed, 29 Mar 2023 05:37:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680093449; cv=none; d=google.com; s=arc-20160816; b=W5GlJ8grbyYDAmIsABx8P3CT/JPYucX7ZMzSBhderTObNc4pWZZTVVe1zXB7+vey1/ 3B7YNKY2INDXOh0/ou/4z7vXbAgd9PxP4/6+rkx6BLLgzJ7bIfWrYx7Xv4tljyZdzR74 tlNiy89O4aj5Fh32/gUF0u8TP7qBKLgyc3lNm5hi1Nm7FzeGkOT0IZ/0oDJN2M+RZ6Ru c/sC5ZYFOEphKDD/fFOMTgm3z0YZxGls1+9g4gvOLNm2SCFph4eKLr0h2FUuw93Wopce LQboMsZYnCCsXIytscLdakUe9AWSackpriZEFQzxq4XxrRIw07puPtIBJKHGJ7am6D76 CKJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:content-transfer-encoding:mime-version :message-id:date:subject:from:dkim-signature; bh=8ycA70uZHggaoIyO3uzmflwH+vaeWPw0LKj8pkeeSfY=; b=QR4/HEThM8S7V7p87ak+62c95KcDovVyMSyjAkUPEC7St5859TnJZMCWQTZ67NNUIJ 59v+W9V7C2CsHJJPBvkhMn0W287JZjRQq2p5dK77vvM1L99IkffrL90+HS6xijk26+ty 7niVDcfLz4tgGU0c3/HXu54GP8ybv2HNyn+sXCXWv0q1CqIwmBOl+SQMSYkvu+Mr4pp5 NHijk1K1rrx/Pe6GZh9HI8JfuQWnr9nr5rXxO+45lp64bAjAKGiHJSTNJ56DeADMaRTG vOyBTj4FwRRf94NYTLR6NZJb/CMN6MRpxzSbYK64v13TTpudHB8UIdvGO9zOJsW6f7ee o/AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@asahilina.net header.s=default header.b=RZsZOcVU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=asahilina.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l23-20020a056402125700b004c05692aeeasi31670367edw.221.2023.03.29.05.37.04; Wed, 29 Mar 2023 05:37:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@asahilina.net header.s=default header.b=RZsZOcVU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=asahilina.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229900AbjC2MEt (ORCPT <rfc822;rua109.linux@gmail.com> + 99 others); Wed, 29 Mar 2023 08:04:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229870AbjC2MEr (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 29 Mar 2023 08:04:47 -0400 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1613EC0; Wed, 29 Mar 2023 05:04:44 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: linasend@asahilina.net) by mail.marcansoft.com (Postfix) with ESMTPSA id DAB2E41F46; Wed, 29 Mar 2023 12:04:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=asahilina.net; s=default; t=1680091482; bh=Yfc+fy732lyQt6gGO91ACOiJTuz48vubsBwwxur11wo=; h=From:Subject:Date:To:Cc; b=RZsZOcVUZ0d9GrN3HSV+yS/VF+QXLp1kfu39MoxlhGN/tRe9g3HF5clXxWd5+sQ1D 6l/135hq9v87EpOrWZAlv0m2h4hNj0X2TnveirP86Yjxzdz5c0dJI+q8PrdBfvm9op 54Tfj5rPOtnfESJG8aOIewkmrt4YRKHP076/w6cHbUYHfCzhqXJMewFvU5EJeluIX/ frhEMujTHtLk8RNStmsrS7EdwqCyjyew9dPZGXZbT8IQr0O2rUfcr35BPvS767ZOHJ xEwO8iFFUJVccSY7IspXmc2U/qNwlZIgSxHD8HyhoHImm8ke6w3DQ4iIkMbJQeV1ud sNpQKnmR3sEtQ== From: Asahi Lina <lina@asahilina.net> Subject: [PATCH v2 0/6] rust: error: Add missing wrappers to convert to/from kernel error codes Date: Wed, 29 Mar 2023 21:04:32 +0900 Message-Id: <20230224-rust-error-v2-0-3900319812da@asahilina.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAFApJGQC/22NywrCMBBFf0WydkoeYltX/od0MY0TMyCpTGpQS v/dtGuX514OZ1GZhCmry2FRQoUzT6mCPR6Uj5geBHyvrKy2Tlt7AnnnGUhkEgi2a00Yfa/boKo wYiYYBZOPm1LOjQPxZrteQoE/e+c2VI6c50m+e7aYbf1bKAY0hC702GPXOu2umDHykxM2iWY1r Ov6A000rsTDAAAA To: Miguel Ojeda <ojeda@kernel.org>, Alex Gaynor <alex.gaynor@gmail.com>, Wedson Almeida Filho <wedsonaf@gmail.com>, Boqun Feng <boqun.feng@gmail.com>, Gary Guo <gary@garyguo.net>, =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= <bjorn3_gh@protonmail.com>, Sven Van Asbroeck <thesven73@gmail.com> Cc: Fox Chen <foxhlchen@gmail.com>, Martin Rodriguez Reboredo <yakoyoku@gmail.com>, Andreas Hindborg <a.hindborg@samsung.com>, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, Asahi Lina <lina@asahilina.net> X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1680091478; l=2539; i=lina@asahilina.net; s=20230221; h=from:subject:message-id; bh=Yfc+fy732lyQt6gGO91ACOiJTuz48vubsBwwxur11wo=; b=8VE+1hLmLEQnXlFMHNZhxNihXuC0OkabmAzruuyZSoUBNOiSuZ+ZUQRAg8jRCuemCmMlA2u6y Q+qrzSX3jGGCk8KWS1XACLzHsbSjen8KmmkIl+iBu49gaX4kKzYyUO5 X-Developer-Key: i=lina@asahilina.net; a=ed25519; pk=Qn8jZuOtR1m5GaiDfTrAoQ4NE1XoYVZ/wmt5YtXWFC4= X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761705668079016064?= X-GMAIL-MSGID: =?utf-8?q?1761705668079016064?= |
Series |
rust: error: Add missing wrappers to convert to/from kernel error codes
|
|
Message
Asahi Lina
March 29, 2023, 12:04 p.m. UTC
Hi everyone!
This series is part of the set of dependencies for the drm/asahi
Apple M1/M2 GPU driver.
It adds a bunch of missing wrappers in kernel::error, which are useful
to convert to/from kernel error codes. Since these will be used by many
abstractions coming up soon, I think it makes sense to merge them as
soon as possible instead of bundling them with the first user. Hence,
they have allow() tags to silence dead code warnings. These can be
removed as soon as the first user is in the kernel crate.
Getting this in first allows the subsequent abstractions to be merged in
any order, so we don't have to worry about piecewise rebasing and fixing
conflicts in the Error wrappers. See [1] for a complete tree with the DRM
abstractions and all other miscellaneous work-in-progress prerequisites
rebased on top of mainline.
Most of these have been extracted from the rust-for-linux/rust branch,
with author attribution to the first/primary author and Co-developed-by:
for everyone else who touched the code.
Attribution changes:
- One of the patches had Miguel's old email in the tags, updated that per
his request.
- Wedson's email changed from @google.com to @gmail.com (I understand
this is the current one).
Sven: There is one patch from you in this series, do you want to send it
yourself directly? I understand Wedson and Miguel are okay with me
sending stuff on their behalf.
[1] https://github.com/Rust-for-Linux/linux/pull/969/commits
Signed-off-by: Asahi Lina <lina@asahilina.net>
---
Changes in v2:
- Removed the redundant _kernel from various function names.
- Replaced the from_result!{} macro with a from_result() function taking a closure.
- Link to v1: https://lore.kernel.org/r/20230224-rust-error-v1-0-f8f9a9a87303@asahilina.net
---
Asahi Lina (2):
rust: error: Rename to_kernel_errno() -> to_errno()
rust: error: Add Error::to_ptr()
Miguel Ojeda (1):
rust: error: Add Error::from_errno()
Sven Van Asbroeck (1):
rust: error: Add a helper to convert a C ERR_PTR to a `Result`
Wedson Almeida Filho (2):
rust: error: Add to_result() helper
rust: error: Add from_result() helper
rust/helpers.c | 19 ++++++++
rust/kernel/error.rs | 126 +++++++++++++++++++++++++++++++++++++++++++++++++-
rust/macros/module.rs | 2 +-
3 files changed, 145 insertions(+), 2 deletions(-)
---
base-commit: fe15c26ee26efa11741a7b632e9f23b01aca4cc6
change-id: 20230224-rust-error-f2871fbc907f
Thank you,
~~ Lina