Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2405311rwb; Fri, 2 Dec 2022 09:18:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf6UU3nG1bZK5792/5LnUq0T6/ozf5KG630LNOnTCxkupuER5qlzle7HT41fJJ+4iIw4wO9I X-Received: by 2002:a17:906:6a0c:b0:7ad:9f03:aa46 with SMTP id qw12-20020a1709066a0c00b007ad9f03aa46mr46045259ejc.175.1670001506984; Fri, 02 Dec 2022 09:18:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670001506; cv=none; d=google.com; s=arc-20160816; b=nZ0+qrC6BnXKi0oLX3mas7hMYNdJQg5/BzcoHwadjk2UJXqRt3tKEMfbl2Z9YND4Nt hCZt+emg2sb7Qe6NqCBCUfG7H0XNZ0Dy97f32NxgGyE5XC0eL22hL75SCLQT9wZPSZdQ ob/DOnCJnbj6oOPe63GHWNT11xRcz+TNt1DjivQy6w0mSMvv2nyKPTt+DDYeAZhiRrQp csJD3km5W8WBaBzRoetvZEUVbPhgteAIqFheZxw5rpUTzoFTXG+BWln26D4TOPj4qk32 3X1zOdrrjHC2Jgr/7ME6qgI3bCcROeXGm89NAoYrxcZQk4h1DXntDpXZfvXwxhJ4zaDZ k9HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=A0qpI7EYsSqghJalaKu3MDYcXxwvBLDAou/nUldtk6c=; b=QOeAliA/OabO3La3TqH++K5rusxRj3y1+TXm1vzbJ9IMXD9wDeoAzey/XD97CaLaNr B6FUnrZzyZ2mLCByXP2hmMLeB0HPm+uFUaWQ+ZxV05D5ZlgrKfRt5giVj6oYegqTkbcK S+vycQAS9LkhBHfkd0far1uMWRWPoQH2i6/tSnVUwoyR1LwPnlsp224NIxScC+jGrQl3 3mUQUwbtL9czegazJL8/q8zmo9YSpclBKx4n44Zu9BdSeKnzjhorICFVszjVOqhW0Lmw 4QCXanZPHxs1fL8WYii1//9TStwcLp1M/WwV6RwSUfzZa9ggVl/6qiS1nWEzGHowK5fx Gt4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RV0FORfM; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b15-20020a056402084f00b00469e712cba8si6786777edz.558.2022.12.02.09.18.06; Fri, 02 Dec 2022 09:18:26 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=RV0FORfM; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234000AbiLBQQ7 (ORCPT + 82 others); Fri, 2 Dec 2022 11:16:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233625AbiLBQQ3 (ORCPT ); Fri, 2 Dec 2022 11:16:29 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 680E0CC65A; Fri, 2 Dec 2022 08:16:03 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1E516B821F0; Fri, 2 Dec 2022 16:16:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C939EC43152; Fri, 2 Dec 2022 16:15:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669997760; bh=Fu0cQySj6UrPLD5hDPAQuIBqC91+Uyo9Z9HV2mYAaok=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RV0FORfM/sgu1IT0HI/gc8w6bR0fwFSxo5jG4QS2W+B3fltkS0gl5tZUSXr4MmGGE IDOVl0VTFvK3xbvQuIuhsBU7sWjwn5PW4QKicCEwbD5w9hHZu0p0tqbvlIHhCQulpr ynzBlpngUBX0n6FP2A7TNmAOLKiPRtDTYOhmTtsOoKQJkvOd+VzMhFYKSp8y3YQwwB 1fGmbGvvU0q0vWAmTK4EphZ9H+pKZuqBP+GJPAR6K8JU8ANdyzYHNXidCgJmg1fWwz pTzX65kWdJFhveTMW2GZk6zZobgt2z8MblGS2EmWx4eBVbDXKYa0/hjv93ZXxryUZw WXVDAmk7+p4WQ== From: ojeda@kernel.org To: Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH v2 11/28] rust: prelude: add `error::code::*` constant items Date: Fri, 2 Dec 2022 17:14:42 +0100 Message-Id: <20221202161502.385525-12-ojeda@kernel.org> In-Reply-To: <20221202161502.385525-1-ojeda@kernel.org> References: <20221202161502.385525-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 From: Wedson Almeida Filho It is convenient to have all the `Error` constant items (such as `EINVAL`) available as-is everywhere (i.e. for code using the kernel prelude such as kernel modules). Therefore, add all of them to the prelude. For instance, this allows to write `Err(EINVAL)` to create a kernel `Result`: fn f() -> Result<...> { ... Err(EINVAL) } Signed-off-by: Wedson Almeida Filho Reviewed-by: Gary Guo [Reworded, adapted for upstream and applied latest changes] Signed-off-by: Miguel Ojeda --- rust/kernel/prelude.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/kernel/prelude.rs b/rust/kernel/prelude.rs index 7c4c35bf3c66..1e08b08e9420 100644 --- a/rust/kernel/prelude.rs +++ b/rust/kernel/prelude.rs @@ -19,6 +19,6 @@ pub use macros::{module, vtable}; pub use super::{pr_alert, pr_crit, pr_debug, pr_emerg, pr_err, pr_info, pr_notice, pr_warn}; -pub use super::error::{Error, Result}; +pub use super::error::{code::*, Error, Result}; pub use super::ThisModule; -- 2.38.1