Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp503308rwl; Wed, 29 Mar 2023 05:09:06 -0700 (PDT) X-Google-Smtp-Source: AKy350ZY8oXuEqw3dRGT+a9jNPV2AaUItZqLatNGETm5hGBQggg6H92ivyJVDmikhs17rVmhfdWH X-Received: by 2002:a17:903:2847:b0:19e:bc01:610e with SMTP id kq7-20020a170903284700b0019ebc01610emr17902209plb.33.1680091746379; Wed, 29 Mar 2023 05:09:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680091746; cv=none; d=google.com; s=arc-20160816; b=IX4ljYmSYZ5XgZghpHUVpo/98gb7Rk+MEk6YedGZ+RWRRMPZF+TpQ1j57GlpAF6Qp+ 1hJE0XGrC0TYtj3tQ7zgbr6czcHAg4JTPePXThp4IXEikw3ly7KT9Y63KMaW04U3OiGD beU2899sQetiXQBgDaOQw6BbrwCgwern1Kaaoq5lSYD+dyQd2nBwByvf1OInoBrTgOt7 U2VhrJq3qlwC8UefHtaLMsKFzcYygvK95chw9q91eRqQ7Agf2aVoFdkeIgId7O3KKb8e /b41y2+u7gna+HUIx/KcvEQH/V97Tib3vEmdTWeQ9F3KBKZLgGjUpJ2hbyrnnmXI+LOO oFMA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kp11-20020a170903280b00b001a043389a7asi24247807plb.310.2023.03.29.05.08.52; Wed, 29 Mar 2023 05:09:06 -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 S229846AbjC2MEt (ORCPT + 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 ); 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 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 , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Sven Van Asbroeck Cc: Fox Chen , Martin Rodriguez Reboredo , Andreas Hindborg , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, Asahi Lina 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: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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