From patchwork Sat Sep 7 18:19:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Alves X-Patchwork-Id: 13795249 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11olkn2051.outbound.protection.outlook.com [40.92.20.51]) (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 3C899446DC; Sat, 7 Sep 2024 18:19:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.20.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725733147; cv=fail; b=GXiMnjnEsp7mOtyc8RAQ7tXSjLjGc/tPaf8jAutYSrEwRGnf2FhKHdTBS86ozZkMfJeYkxO0R+ZppsxsFuh9LDEwuwVY3WmBb2dhC+WxGPcCKXW6zEDQGmLApgnv34GwJEPLyg+vqr6kCYVcuIEiQwmaCKBC3mm39qEUS74+GRw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725733147; c=relaxed/simple; bh=FQqvZDd7hgT5uQJrcyacnuhbTGJnrFCKMFIOZPDeFXw=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=glYB+6wCLWu5utUpLKMmeR1dXXa6vK/2JkyKoqltBI98ckUL3kHjQ6DGDfw64+toSfzpxlz3qL6fNL9bGjFyW+LuSWiizI6V9VQ4VHPg5byr+itzICnQeiScm+PBSLx7z52LS6JaaJa5vJgjrfZDZKiNLgI3bhVR6VLF5XcvUaA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=live.com; spf=pass smtp.mailfrom=live.com; dkim=pass (2048-bit key) header.d=live.com header.i=@live.com header.b=srBeN+Uu; arc=fail smtp.client-ip=40.92.20.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=live.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=live.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=live.com header.i=@live.com header.b="srBeN+Uu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=R4oxHwYbf6HryvWpTXV3I1nxh1gFDYrt5pC7VHopTcLS5xE5S/g+2azwMfKyQGVu7YC3ls0kazbzm7dPymjSkvJ4DBe02gvglexBCoBVkhCaBZ3G96znzj1p8pJWUd0hqcVUL29P0E86zeI0bJNiz4GSW+CaicvEA16le7fPqibjgr+9xnn13cF7hj1gBeNt9R24XjPil4eBnk1WKim77dvsORtwvm/rsC84j2r4XtXHCVFayqKz1RQGZQo8lcon81dd8d+anPvGK5kQlIx7BgqA6CLhyZxD1NplJMOTri6GzsZ/5JqxWgHhV6OHwKHEyYD+gCux0tQFxPMg1VjPag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=aWwVb0kuuKqXV2YZ22IDGyIHW9GWaZ6tcxHLehnBkek=; b=OqG+qCE8OZY86YDOrjyEQwPN3ERaGk4OJQrDovdldtdhX1/S+xiSgCQugEswbyy7G/I9pmOKB+yoXcEz6ww7zm7WgZMN1gsw8Uo4znEnQeASwmvYi1sNF2S2hFN1PfzvoXW8k3I7ZJni1nQZLRNACXAzwwTvz2Q/o6Xn79j5q6rLZqv2P1DOefUokEmWfHT22gxSFxI/kw3eeydiQYb4fQ0x4jEZQttKVFYFDvVK100YmFYK4FhjBOGbxv2hg0Gk1iRnqVvo2sSVG8QLlntChYa7JX+myk/GNHs2wzvk5LiI1f/+fPVf94SdNbb+fJrSNeIhswi3oHL/iqb7irv+wA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aWwVb0kuuKqXV2YZ22IDGyIHW9GWaZ6tcxHLehnBkek=; b=srBeN+Uu0OsJ9t+LFbKLCmBe7w9NGfuCNfePgIO762UjVbGBrslHa9dtL/Jv3vpu+OINmu7JXlRDsWtnrMTUUjHDraR+b5NtD18iQ6Laav7gAy23z93VPb9p5yJV/3v77htvPc1W4+eiuqG65xv4jfWk/n807B4hNz+Tw3wPYUDasQCKr/JLL4xZgkEZ86WzrICpih1uUgYW5XqgMcAQX78QM3KioAB3hZhCEWewZzpC8E+Lzf9oLE6CgKd0K2BOmgZs/cPjl7QEmHwW50HNKwXk481ToaVLvdfxiKF2KPQboYIYKX1iZN629pJsseA9pEukS/AhgGGYT1Iz0sy/1Q== Received: from DM4PR14MB7276.namprd14.prod.outlook.com (2603:10b6:8:186::13) by MW4PR14MB7458.namprd14.prod.outlook.com (2603:10b6:303:22c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.24; Sat, 7 Sep 2024 18:19:01 +0000 Received: from DM4PR14MB7276.namprd14.prod.outlook.com ([fe80::744f:71ea:aec:9c4d]) by DM4PR14MB7276.namprd14.prod.outlook.com ([fe80::744f:71ea:aec:9c4d%4]) with mapi id 15.20.7918.024; Sat, 7 Sep 2024 18:19:01 +0000 From: Felipe Alves To: "aliceryhl@google.com" , "ojeda@kernel.org" , "alex.gaynor@gmail.com" , "masahiroy@kernel.org" CC: Felipe Alves , "boqun.feng@gmail.com" , "gary@garyguo.net" , "rust-for-linux@vger.kernel.org" , "nathan@kernel.org" , "nicolas@fjasle.eu" , "linux-kbuild@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "patches@lists.linux.dev" Subject: [PATCH] rust: error.rs: Remove dead_code marker and make from_err_ptr, from_result and to_ptr public Thread-Topic: [PATCH] rust: error.rs: Remove dead_code marker and make from_err_ptr, from_result and to_ptr public Thread-Index: AQHbAVIac1ken70rvUuV8u3ED48WGQ== Date: Sat, 7 Sep 2024 18:19:01 +0000 Message-ID: Accept-Language: pt-BR, en-US Content-Language: pt-BR X-MS-Has-Attach: yes X-MS-TNEF-Correlator: msip_labels: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [7x6GlL97dhlrfzVmUGmezja0aETR8ic3FV15Kcdy9A98Qi+0iUIChf3gQLiH7P+Z] x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DM4PR14MB7276:EE_|MW4PR14MB7458:EE_ x-ms-office365-filtering-correlation-id: caea46a7-9300-49fc-c583-08dccf698c75 x-microsoft-antispam: BCL:0;ARA:14566002|19110799003|15080799006|15030799003|8060799006|461199028|6092099012|440099028|102099032|3412199025|1710799026; x-microsoft-antispam-message-info: nvxKjUoaJTZY81zlFkePgIAvngj2NsdNOFcc/t7FGghoM1MN/HWR+A/211LNsAAbw5pWntUtn/Uu9uNseCr7Xhrs6xb21mBjG4Cltc36MAeKjFOzdiGcgF/zf+j+3GmoeYVchnwHMpGPHx8uG+EMiDzfd0BEZjWcJC/mR5QX9rp5z6wwfWSfDvvF7BdEugCCnfaf5XYB1kBAmxlQJ5zPC7C+zHeSkke0pu/oUG/yb8L6PI2qdL7XRs+Gtzmtarqqc4ZvbpGFX7CNB35+ovi1pIL2usRaJXkGGeDf7a2S/tejGWnDjymF92sj2HrMoyjMP6vk12K3dI0tjwwEbjg94jIG9IJjTKxzaWbEelXVVSLBgY2AGR+tDcUCOtVcpSExHr6M/gOKZFeqnzQQQjxSIdLk6awjhszfQpXWJQJ6wuVusmBP9/xAyaBkH/PQSg79h/i9S0o52hLpaaTW4ROQqqKECVqQt2LMzInKyOLkrUgXIzOiL351J0Bk6TuzaJZmxmISRmGknn8Esv95haeUELNHWeOdq5L+fmtEBFnS8u2Px+/c8vbzzfdRy4ckAaMx5B00bj1AsDFSuRxVpk5KDUoc6gkPIL+HftkVmUqOLprIPEuSK6gKxp9MQAcYG2eqYk+SYav+ApaRnarDBs80FMz2NPL4APy2g+mYojRtslvRvcYaGsppXJ516KgRO2IgaHs78qLD6LBbeCmVCfETBJsft6cBw/wM/oE7G3xgbUSHb5NCQ2iPLM4rChNVdYabKOFbgHrAKiek/+COsZ8zlQ== x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?9gI8vf+kV7dYmtM24KMkfSp?= =?iso-8859-1?q?I3bkM5+9tLa9x7yAuuaiFEyT2merCM4L4dRyhYkdUN2TSbW/DQZXCWW5Xs4T?= =?iso-8859-1?q?02+2BUhX2cjtwlBApA3nhx8vNzCC1eH3LqlyscVQpJXYWsVfBTAxAHfDTQJL?= =?iso-8859-1?q?Uhhblk7h/14k0dfnxc83R/H1cvhlfO6edbHtB0qK9ZQ6snbw5xEctuBQJn7x?= =?iso-8859-1?q?IYD86bV4hu9oAnOPelbPoe0JrVdtIcGSPiE47h5jTp0cmJ4PxKXIAc8TOHs4?= =?iso-8859-1?q?fcJgoxm3cYECYB2s9TKeGn/E0jDMrnArSgIG+w47FBdcPIwWzRIKSaXL5q+X?= =?iso-8859-1?q?fI+D+LKhsJeCAifFBp8KsMFF3m5HQEZzIk5fD4zgnswTHLO+18P7184abnm5?= =?iso-8859-1?q?A1SOE7NMj1rhU35xMo/JPteKjTM3scC5ExJSRiUh7sABHvo4yjBx26/OqG3R?= =?iso-8859-1?q?C8ZkyGRyQP3m8lHV+n9AE7i9G3gZTS+7aibaSJYEMJYC0oXF7zzahsqHB9RL?= =?iso-8859-1?q?TX7XyT5J44S2IkGpswjUdiBIsopMRD0uO2M/jKgspndnRrG2NTtyE3xv8MBd?= =?iso-8859-1?q?jBoEvpqIrmb8qL2w2tMOHrITpwbtkxNrG+0x8oOH5yedgDHSke7vAuCzGY9A?= =?iso-8859-1?q?VBds8+wS2VbVuYN+O2wZrZo969+2sbKqBn4qaw1RQs4QxrT0k2Ou7AXbms7f?= =?iso-8859-1?q?gWzzAyKhm8/SgDa857EO7pqY0WWnN1TPr1NFQSLmTDou6+1e3QI58saZBIVj?= =?iso-8859-1?q?tz52pJzrF/WDjtzuWk+fPbaSOki0Q2uZE8aJBKhnfPw9HCMHLsn7rzriJhKJ?= =?iso-8859-1?q?cQ2XCwu+Rlmr9hfKFYFThrG08/qKhE88EubGvIuh4bxFmIP3ABVvByDvnRho?= =?iso-8859-1?q?HsWc2jttkQKZYHJFYp9mjUL0hNDMxd+Gc/kiivPZC+xHJDiMrbuHZjMXYuT8?= =?iso-8859-1?q?ai6cMD53L9IY93/n3pWGTsJEGd5OzkUJdvp4MDGeTSld6fBe+qdkOHHSMI/a?= =?iso-8859-1?q?qC0lC3pW+eV6YUee2WUkbRHBYpVQLZ9rJQjdcQaeIRUCln0H8Yvtt3cayeuv?= =?iso-8859-1?q?jveb4vnrhkL2nKKF5UeqlSu2o9zvIB0/tcWLMa1orlPdC82jDJFbKUUMQMCX?= =?iso-8859-1?q?QwGCo2Xl8zODCFrqmMeaQVY0xfvvcRVjQBkwbALqsA7xy/Y2dZCXZHAuA8RL?= =?iso-8859-1?q?bQg6xNyDDGmfiu9gJd6AMsudF17RfJhZerCTGUiq97AUZEkZTWlOapqHf8FM?= =?iso-8859-1?q?+h0hU9B/ofYMnWn1k9Gzl55DKS4z6OI2Y/L5UWcHxvrdso8tRARb3hR9zejO?= =?iso-8859-1?q?hixGJsK1/SCCqXVDJ3MnlV/lZIkd7xGZAHIPtV7I=3D?= Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-7719-19-msonline-outlook-e4812.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM4PR14MB7276.namprd14.prod.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: caea46a7-9300-49fc-c583-08dccf698c75 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Sep 2024 18:19:01.4790 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR14MB7458 From 93dc3be19450447a3a7090bd1dfb9f3daac3e8d2 Mon Sep 17 00:00:00 2001 From: Filipe Xavier Date: Sat, 7 Sep 2024 14:50:33 +0200 Subject: [PATCH] rust: error.rs: Remove dead_code marker and make from_err_ptr, from_result and to_ptr public Remove dead_code annotation from from_err_ptr, from_result and to_ptr functions in error.rs file and change visibility to public, making it accessible outside the kernel crate(issue #1105). Signed-off-by: Filipe Xavier From 93dc3be19450447a3a7090bd1dfb9f3daac3e8d2 Mon Sep 17 00:00:00 2001 From: Filipe Xavier Date: Sat, 7 Sep 2024 14:50:33 +0200 Subject: [PATCH] rust: error.rs: Remove dead_code marker and make from_err_ptr, from_result and to_ptr public Remove dead_code annotation from from_err_ptr, from_result and to_ptr functions in error.rs file and change visibility to public, making it accessible outside the kernel crate(issue #1105). Signed-off-by: Filipe Xavier --- diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs index 6f1587a2524e..ecfa6aa41034 100644 --- a/rust/kernel/error.rs +++ b/rust/kernel/error.rs @@ -133,8 +133,7 @@ pub(crate) fn to_blk_status(self) -> bindings::blk_status_t { } /// Returns the error encoded as a pointer. - #[allow(dead_code)] - pub(crate) fn to_ptr(self) -> *mut T { + pub fn to_ptr(self) -> *mut T { #[cfg_attr(target_pointer_width = "32", allow(clippy::useless_conversion))] // SAFETY: `self.0` is a valid error due to its invariant. unsafe { @@ -268,9 +267,7 @@ pub fn to_result(err: core::ffi::c_int) -> Result { /// from_err_ptr(unsafe { bindings::devm_platform_ioremap_resource(pdev.to_ptr(), index) }) /// } /// ``` -// TODO: Remove `dead_code` marker once an in-kernel client is available. -#[allow(dead_code)] -pub(crate) fn from_err_ptr(ptr: *mut T) -> Result<*mut T> { +pub fn from_err_ptr(ptr: *mut T) -> Result<*mut T> { // CAST: Casting a pointer to `*const core::ffi::c_void` is always valid. let const_ptr: *const core::ffi::c_void = ptr.cast(); // SAFETY: The FFI function does not deref the pointer. @@ -315,9 +312,7 @@ pub(crate) fn from_err_ptr(ptr: *mut T) -> Result<*mut T> { /// }) /// } /// ``` -// TODO: Remove `dead_code` marker once an in-kernel client is available. -#[allow(dead_code)] -pub(crate) fn from_result(f: F) -> T +pub fn from_result(f: F) -> T where T: From, F: FnOnce() -> Result,