From nobody Sun Dec 14 13:44:16 2025 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63D9E137C2A for ; Thu, 16 Jan 2025 05:26:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737005192; cv=none; b=tephM42iS0fg0edFurGY6VY6xFws2qOqN4rczDOVm6h+m07T9xcRaWNos77DkrMKMJqxyaU9PHTkrlnn7ZpAWngFHg/PKCK9DRIbHw+Xecus5QPpDeh6xglBJIoOvm7+6qZswn4vg8k5xy0dKd9tUUMC8ifj52shvrUUpjmuuEs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737005192; c=relaxed/simple; bh=9TS+koL66f3GotKZ4XO5Qsc/vswyLYIomvI7/0lU2pg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=EGivd8KjmEqNJpC/r8YV+RJvJ+rI+85m2RlqkoXoSH1Rg8FPJ9nxta1hoR6h5AyJ7YB2/mJ0/5FNZNMcpX3B6DOowh39863zmmAA0vF3ucSlUqyTO3gbkSJ2QaEbI3Pw/ctIMVTMgbcoqVzZLkDu8wAgRCSnWCBoHIBny1Cbckw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=WK5Y9iSN; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="WK5Y9iSN" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-216395e151bso8020255ad.0 for ; Wed, 15 Jan 2025 21:26:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737005189; x=1737609989; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=l1RUMYvlMm1lLnQi22sXmfs/EsutO/fQrHWo9t2Ngos=; b=WK5Y9iSNVrParyxLYAbWTdY9pQHJ/DjuZmCmLuQ+PcFMDzISCc6Tw/ZWco7TCS9o+x Kqm0Q5+gMCHzlBF1FFUSSxE7fkwO+7uhA9tB7bSnjrASRGTODqUCPhUoMlhlUIP7z+Zk h5Z3DlV9QvcVSOjpw+mQ18mdAcu1BZdifqb5Y5LFzpsS7HcPdhSCDJ3PXzBtr6ArCo2M BndpzcALxQjrfwLdA27bYNR9YVUUBw4uq0kTMg9cFojhp2OgB4KJ+kemxpU9mukpwWGW dxe5y9Eec6vCMQxjOM3FVgHw7Tr7hYKgAUc35fe+3fqgWL1Vu9qShdla/nwecEQfQfKV WODQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737005189; x=1737609989; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=l1RUMYvlMm1lLnQi22sXmfs/EsutO/fQrHWo9t2Ngos=; b=JaS/7exdJF5I7mgdYXAr1+piJ7U4eyi1KUYPheFlp0gxzUO7dIN80WDdjZcTzITloh y1+3BZbbFbvlVyDKfnHhDVrz/6IZm/TBlqyCUChlAmresgSbyZ9PQL/jUkAZE5XSnobq UV+25dssUvKB8afrEI/aT/L+gPef2M78TlFLuMAVkSaVs5RQ7ikJWU3QUUKGk5p224Dp IxITO1+X5FxsfwGafESocNWyn1W61VRCBPx78edBKbuuB7bMzvchg1iYSSv5I1pzhEZZ QGg6EzAz8O95dvkpuk4hOMQgIW2BgUZTLhxWDrwHmVeqG/QlUfRtqxXWB2RWkgCnCnqt zUiw== X-Forwarded-Encrypted: i=1; AJvYcCUNNVNBSZJlT9kYne2zuKiAQ6IObzfSUyeyjLsQSOpCqgf2bZqbg2VFNV62PRsZyErqltylqEAKIbWlxmo=@vger.kernel.org X-Gm-Message-State: AOJu0YxmCXFgLOYnJTwDEYBEh1x83WViVBWfSlYWbCSSmDXh1GOrQRc2 ZMkAIhnlmdYrvU2Jhp6TGZizBGpfOWfdYaamtqv5bRrsaf2/yyabKDXlgwJCt2g= X-Gm-Gg: ASbGncvboEZY3veQ7FmjYEOxdJG1tnhcxIgXFvDpOLzQlj/jIUpUd/emwg/zzLrq8Je YZ3VGMNKY39UUP1eEic3qMAW2RFjMciT92025+L7uuolLyleYqdxI7UOj+BoJ3rGaRzJOxkYqgP vAOajofQK/ZCCV1aUTEEu4RpRVCWjWbfX8aT/ltlKCF9u/5UxstibNWsQqxfQ6wDEZwKFtqlQv1 xv8Sv/n9mbyQ9ovWriB1gwbWkqPL3NEDbUEMr4xKmmUWel30HEY1mcl8vM= X-Google-Smtp-Source: AGHT+IFvDSRcLamSLgl/ch/NDC2Y927o8MX3Ir8leFHaDj2BX5MRxe7tcJrkYtgA40IUuuMOEMfYig== X-Received: by 2002:a17:902:e54a:b0:215:7287:67bb with SMTP id d9443c01a7336-21befecb4dcmr105848885ad.0.1737005189564; Wed, 15 Jan 2025 21:26:29 -0800 (PST) Received: from localhost ([122.172.84.139]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21a9f254984sm91780035ad.211.2025.01.15.21.26.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jan 2025 21:26:29 -0800 (PST) From: Viresh Kumar To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross Cc: Viresh Kumar , Rob Herring , Dirk Behme , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] rust: device: Replace CString with CStr in property_present() Date: Thu, 16 Jan 2025 10:56:21 +0530 Message-Id: X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The property_present() method expects a &CString currently and will work only with heap allocated C strings. In order to make it work with compile-time string constants too, change the argument type to &CStr. Signed-off-by: Viresh Kumar Reviewed-by: Alice Ryhl --- Adapted with Rob's version a little. rust/kernel/device.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/kernel/device.rs b/rust/kernel/device.rs index e8c4cda5aacc..c775266ae164 100644 --- a/rust/kernel/device.rs +++ b/rust/kernel/device.rs @@ -6,7 +6,7 @@ =20 use crate::{ bindings, - str::CString, + str::CStr, types::{ARef, Opaque}, }; use core::{fmt, ptr}; @@ -183,8 +183,8 @@ unsafe fn printk(&self, klevel: &[u8], msg: fmt::Argume= nts<'_>) { } =20 /// Checks if property is present or not. - pub fn property_present(&self, name: &CString) -> bool { - // SAFETY: By the invariant of `CString`, `name` is null-terminate= d. + pub fn property_present(&self, name: &CStr) -> bool { + // SAFETY: By the invariant of `CStr`, `name` is null-terminated. unsafe { bindings::device_property_present(self.as_raw().cast_cons= t(), name.as_ptr() as *const _) } } } --=20 2.31.1.272.g89b43f80a514