mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 05:04:02 +02:00
i2c: rust: mark I2cAdapter methods as inline
A single cleanup for the Rust I2C abstractions, targeting 7.3. `I2cAdapter::get`, `inc_ref`, and `dec_ref` are trivial wrappers around `i2c_get_adapter`/`i2c_put_adapter` and were showing up as their own symbols in the build. Mark them `#[inline]` so they get folded into their callers instead. Signed-off-by: Igor Korotin <igor.korotin@linux.dev> -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG0Kepq7dYk2deNuvoxQiWQ2T6tUFAmqJieAACgkQoxQiWQ2T 6tW9hA//czk2VpL6UBEBHzmsDw5P6YAGreE4ZXe/VMrPf2ujvtjGwr+Txxd1XehR utSf/nVR5eqb29xdMpt/xigcdVjcS9m3XYg7M3V29xYRbkhEXvTUHFWm6sZRNO+a Y73n9fd+yu3TAeLnKPKa4GZhEfmToaIDcCglSVuSVSlKQ1jwD7Oib13mo0yR5IYE XzqGxednk6Dvce3agjNKBTahJjMuv7baPom2SBHVAroDMc/rhvXM4T/wnyaSXX18 amYfot59ziFwOGaI/SXNEO32xcSrBdqKRVVLccakJ5Dq3Efh4awB4+igG5saqvKD jR2rNOxImghsensmOjfHJcbhLxjT9xm6ra36OkmJ/Z2CgWmXwAtSZFPd7iPnNwdF V/PFz9KQPuLr1/M6B4pfGHvFh/3C5TDimfpdnUg8rKFu0ZKtAdc9tOa6c8Hn7oDG YJHbzKaG2wbe/yrhVoeoctHqYMVwxmezvW71UKybXC15Mxy49slNFQiZbyPe9zNy JiJ72W2MVStg9CSd/TxYqF+AzdwwMBvq5AA/I4RpAKMT8mOrwLPZF9XZUqxsoYVT bhFJZgvERYGJDS3EXNpDlSRyMonTbVWN11R5GhZ0c62dyoGKilIB/5Z62zjGpG6f 2PijqiKvoggq3nq1AENrQUzTWr9rnRM2UYMNTaqO0U1ixr0+z7c= =Xb8D -----END PGP SIGNATURE----- gpgsig -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQScDfrjQa34uOld1VLaeAVmJtMtbgUCaomT7AAKCRDaeAVmJtMt bjyXAQDQUD5cQ3jciewJB0dd4MwLi+g/Ynuv0RMTN+QoOG8/QAD9FYjiffHc2rjn l2jlJeIbJQjv1tmh8tD7uaCyjc0J7wA= =Ucju -----END PGP SIGNATURE----- Merge tag 'rust-i2c-for-7.3' into i2c/i2c i2c: rust: mark I2cAdapter methods as inline A single cleanup for the Rust I2C abstractions, targeting 7.3. `I2cAdapter::get`, `inc_ref`, and `dec_ref` are trivial wrappers around `i2c_get_adapter`/`i2c_put_adapter` and were showing up as their own symbols in the build. Mark them `#[inline]` so they get folded into their callers instead. Signed-off-by: Igor Korotin <igor.korotin@linux.dev> * tag 'rust-i2c-for-7.3': i2c: rust: mark I2cAdapter methods as inline
This commit is contained in:
commit
d576a9561a
|
|
@ -404,6 +404,7 @@ pub fn index(&self) -> i32 {
|
|||
}
|
||||
|
||||
/// Gets pointer to an `i2c_adapter` by index.
|
||||
#[inline]
|
||||
pub fn get(index: i32) -> Result<ARef<Self>> {
|
||||
// SAFETY: `index` must refer to a valid I2C adapter; the kernel
|
||||
// guarantees that `i2c_get_adapter(index)` returns either a valid
|
||||
|
|
@ -425,11 +426,13 @@ pub fn get(index: i32) -> Result<ARef<Self>> {
|
|||
|
||||
// SAFETY: Instances of `I2cAdapter` are always reference-counted.
|
||||
unsafe impl AlwaysRefCounted for I2cAdapter {
|
||||
#[inline]
|
||||
fn inc_ref(&self) {
|
||||
// SAFETY: The existence of a shared reference guarantees that the refcount is non-zero.
|
||||
unsafe { bindings::i2c_get_adapter(self.index()) };
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn dec_ref(obj: NonNull<Self>) {
|
||||
// SAFETY: The safety requirements guarantee that the refcount is non-zero.
|
||||
unsafe { bindings::i2c_put_adapter(obj.as_ref().as_raw()) }
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user