[PATCH v8 05/12] rust: use cv! to build Bounded values from constants

Eliot Courtney <[email protected]>
Newsgroups dev.linux.lists.nova-gpu,org.freedesktop.lists.dri-devel,org.kernel.vger.linux-kernel,org.kernel.vger.rust-for-linux
Message-ID <[email protected]>
There are some locations which use Bounded::new() which can use the new
cv! macro, so convert them.

Signed-off-by: Eliot Courtney <[email protected]>
---
 drivers/gpu/nova-core/num.rs | 3 +--
 rust/kernel/bitfield.rs      | 8 ++++----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/nova-core/num.rs b/drivers/gpu/nova-core/num.rs
index 6eb174d136ab..03a7e7b3ff8e 100644
--- a/drivers/gpu/nova-core/num.rs
+++ b/drivers/gpu/nova-core/num.rs
@@ -240,8 +240,7 @@ macro_rules! bounded_enum {
         impl core::convert::From<$enum_type> for kernel::num::Bounded<$width, $length> {
             fn from(value: $enum_type) -> Self {
                 match value {
-                    $($enum_type::$variant =>
-                        kernel::num::Bounded::<$width, _>::new::<{ $value }>()),*
+                    $($enum_type::$variant => kernel::num::cv!($value)),*
                 }
             }
         }
diff --git a/rust/kernel/bitfield.rs b/rust/kernel/bitfield.rs
index 35ede53f2b8e..5331df986579 100644
--- a/rust/kernel/bitfield.rs
+++ b/rust/kernel/bitfield.rs
@@ -21,7 +21,7 @@
 //! }
 //!
 //! // Valid value for the `blue` field.
-//! let blue = Bounded::<u16, 5>::new::<0x18>();
+//! let blue: Bounded<u16, 5> = cv!(0x18);
 //!
 //! // Setters can be chained. Values ranges are checked at compile-time.
 //! let color = Rgb::zeroed()
@@ -229,9 +229,9 @@
 //! impl From<Mode> for Bounded<u32, 2> {
 //!     fn from(m: Mode) -> Self {
 //!         match m {
-//!             Mode::Low => Bounded::<u32, _>::new::<0>(),
-//!             Mode::High => Bounded::<u32, _>::new::<1>(),
-//!             Mode::Auto => Bounded::<u32, _>::new::<2>(),
+//!             Mode::Low => cv!(0),
+//!             Mode::High => cv!(1),
+//!             Mode::Auto => cv!(2),
 //!         }
 //!     }
 //! }

-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.