Debian Codegraph @

src/collection/linux/utils.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/, pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#};
2
3 /// Whether the temperature should *actually* be read during enumeration.
4 /// Will return false if the state is not D0/unknown, or if it does not support
5 /// `device/power_state`.
6 ///
7 /// `path` is a path to the device itself (e.g.
8 /// `/sys/class/hwmon/hwmon1/device`).
9 #[inline]
10 pub fn is_device_awakerust-analyzer cargo bottom 0.14.9 collection/linux/utils/is_device_awake().(device: &Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#) -> bool {
11 // Whether the temperature should *actually* be read during enumeration.
12 // Set to false if the device is in ACPI D3cold.
13 // Documented at https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-devices-power_state
14 let power_state = device.joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("power_state");
15 if power_state.existsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]exists().() {
16 if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(state) = fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::read_to_stringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/read_to_string().(power_state) {
17 let state = state.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().();
18 // The zenpower3 kernel module (incorrectly?) reports "unknown", causing this
19 // check to fail and temperatures to appear as zero instead of
20 // having the file not exist.
21 //
22 // Their self-hosted git instance has disabled sign up, so this bug can't be
23 // reported either.
24 state rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."D0" || state rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."unknown"
25 } else {
26 true
27 }
28 } else {
29 true
30 }
31 }