scmi: enable workspace-wide lints

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
This commit is contained in:
Manos Pitsidianakis 2025-08-01 21:19:44 +03:00 committed by Stefano Garzarella
parent 05b8f3ff06
commit cff16ac802
4 changed files with 14 additions and 11 deletions

View File

@ -24,4 +24,7 @@ vmm-sys-util = "0.14"
[dev-dependencies]
assert_matches = "1.5"
virtio-queue = { version = "0.16", features = ["test-utils"] }
virtio-queue = { version = "0.16", features = ["test-utils"] }
[lints]
workspace = true

View File

@ -442,7 +442,7 @@ impl SensorT for IIOSensor {
return Err(ScmiDeviceError::GenericError);
}
let sample_byte = (scan_type.realbits as f64 / 8_f64).ceil() as usize;
let sample_byte = (f64::from(scan_type.realbits) / 8_f64).ceil() as usize;
let sample_buffer_len = sample_byte * self.axes.len();
let mut buffer = vec![0u8; sample_buffer_len];
let mut file = self.sensor().notify_dev.as_ref().unwrap();
@ -467,7 +467,7 @@ impl SensorT for IIOSensor {
let value =
i16::from_le_bytes(buffer[i * 2..i * 2 + 2].try_into().unwrap());
let value_i64 = self
.deal_axis_raw_data(value as i64, &self.axes[i])
.deal_axis_raw_data(i64::from(value), &self.axes[i])
.unwrap();
let sensor_value_low = (value_i64 & 0xffff_ffff) as i32;
let sensor_value_high = (value_i64 >> 32) as i32;
@ -607,10 +607,10 @@ impl IIOSensor {
custom_exponent -= 1;
// Calculate the resolution of scale
custom_resolution =
(scale * 10i32.pow(-custom_exponent as u32) as f64).trunc() as u64;
(scale * f64::from(10i32.pow(-custom_exponent as u32))).trunc() as u64;
} else {
custom_resolution =
(scale / 10i32.pow(custom_exponent as u32) as f64).trunc() as u64;
(scale / f64::from(10i32.pow(custom_exponent as u32))).trunc() as u64;
}
// The SCMI exponent (unit_exponent + custom_exponent) can have max. 5 bits:
custom_exponent = min(15 - unit_exponent, custom_exponent);

View File

@ -778,9 +778,9 @@ impl ScmiHandler {
// message_type = 0x3 [9:8]
// protocol_id=0x15; [17:10]
// 0x1 | (0x3<<8) | (0x15<<10)
let notify_header: MessageHeader = (SENSOR_UPDATE as u32)
let notify_header: MessageHeader = u32::from(SENSOR_UPDATE)
| ((MessageType::Notification as u32) << 8)
| ((SENSOR_PROTOCOL_ID as u32) << 10);
| (u32::from(SENSOR_PROTOCOL_ID) << 10);
Some(ScmiResponse::from(
notify_header,
@ -1564,12 +1564,12 @@ mod tests {
for iteration in 0..2 {
for sensor_id in 0..2 {
let notification = handler.notify(NOTIFY_ALLOW_START_FD + sensor_id).unwrap();
let notify_header: MessageHeader = (SENSOR_UPDATE as u32)
let notify_header: MessageHeader = u32::from(SENSOR_UPDATE)
| ((MessageType::Notification as u32) << 8)
| ((SENSOR_PROTOCOL_ID as u32) << 10);
| (u32::from(SENSOR_PROTOCOL_ID) << 10);
let mut result = vec![];
result.push(MessageValue::Unsigned(0));
result.push(MessageValue::Unsigned(sensor_id as u32));
result.push(MessageValue::Unsigned(u32::from(sensor_id)));
for i in 0..3 {
result.push(MessageValue::Signed(iteration + 100 * i));
result.push(MessageValue::Signed(0));

View File

@ -158,7 +158,7 @@ impl VuScmiBackend {
let eventfd_list = self.scmi_handler.get_device_eventfd_list();
for (device_notify_fd, device_event) in eventfd_list {
handlers[0]
.register_listener(device_notify_fd, EventSet::IN, device_event as u64)
.register_listener(device_notify_fd, EventSet::IN, u64::from(device_event))
.unwrap();
}
}