module AmdgpuFan::Fan

A mixin to read fan details and validate input

Private Instance Methods

fan_file(type) click to toggle source
# File lib/amdgpu_fan/mixin/fan.rb, line 9
def fan_file(type)
  @fan_file ||= {}
  @fan_file[type] ||= "#{base_hwmon_dir}/fan1_#{type}"
end
fan_mode_file() click to toggle source
# File lib/amdgpu_fan/mixin/fan.rb, line 14
def fan_mode_file
  @fan_mode_file ||= "#{base_hwmon_dir}/pwm1_enable"
end
fan_power_file() click to toggle source
# File lib/amdgpu_fan/mixin/fan.rb, line 18
def fan_power_file
  @fan_power_file ||= "#{base_hwmon_dir}/pwm1"
end
fan_raw_speeds(type) click to toggle source
# File lib/amdgpu_fan/mixin/fan.rb, line 26
def fan_raw_speeds(type)
  @fan_raw_speeds ||= {}
  @fan_raw_speeds[type] ||= File.read(Dir.glob("#{base_card_dir}/**/pwm1_#{type}").first).to_i
end
fan_speed_raw() click to toggle source
# File lib/amdgpu_fan/mixin/fan.rb, line 22
def fan_speed_raw
  File.read(fan_power_file).strip
end
valid_fan_percent_speed?(percent) click to toggle source
# File lib/amdgpu_fan/mixin/fan.rb, line 38
def valid_fan_percent_speed?(percent)
  (1..100.to_i).cover?(percent.to_i)
end
valid_fan_raw_speed?(raw) click to toggle source

Validate the raw fan speed is between the minimum and maximum values read from sysfs.

# File lib/amdgpu_fan/mixin/fan.rb, line 34
def valid_fan_raw_speed?(raw)
  !raw.nil? && (fan_raw_speeds(:min)..fan_raw_speeds(:max)).cover?(raw.to_i)
end