mirror of
https://github.com/rust-vmm/vhost-device.git
synced 2025-12-26 06:32:44 +00:00
scmi: refactor function read_axis
In function read_axis, there are two steps. The first is reading number for sysfs file. The second is reading offset and scales. And the second step can be reused in notification, therefore we separate it into two functions. Signed-off-by: Junnan Wu <junnan01.wu@samsung.com>
This commit is contained in:
parent
67274cf5dd
commit
fade33c618
@ -453,8 +453,12 @@ impl IIOSensor {
|
||||
|
||||
fn read_axis(&self, axis: &Axis) -> Result<i64, ScmiDeviceError> {
|
||||
let path_result = axis.path.clone().into_string();
|
||||
let mut value: i64 =
|
||||
let value: i64 =
|
||||
read_number_from_file(Path::new(&(path_result.unwrap() + "_raw")))?.unwrap();
|
||||
self.deal_axis_raw_data(value, axis)
|
||||
}
|
||||
|
||||
fn deal_axis_raw_data(&self, mut value: i64, axis: &Axis) -> Result<i64, ScmiDeviceError> {
|
||||
let offset: Option<i64> = self.read_axis_offset(&axis.path)?;
|
||||
if let Some(offset_value) = offset {
|
||||
match value.checked_add(offset_value) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user