On Wed, Aug 28, 2024 at 10:15:12AM +0530, Raag Jadav wrote: > Add hwmon support for temp1_input attribute, which will expose package > temperature in millidegree Celsius. With this in place we can monitor > package temperature using lm-sensors tool. > > $ sensors > i915-pci-0300 > Adapter: PCI adapter > in0: 990.00 mV > fan1: 1260 RPM > temp1: +45.0°C > power1: N/A (max = 35.00 W) > energy1: 12.62 kJ ... > +static umode_t > +hwm_temp_is_visible(const struct hwm_drvdata *ddat, u32 attr) > +{ > + struct i915_hwmon *hwmon = ddat->hwmon; > + > + if (attr == hwmon_temp_input && i915_mmio_reg_valid(hwmon->rg.pkg_temp)) > + return 0444; > + > + return 0; Just a question (I'm fine with this implementation): is the style in this file to check for correct cases first and return an err/etc at the end? > +} > + > +static int > +hwm_temp_read(struct hwm_drvdata *ddat, u32 attr, long *val) > +{ > + struct i915_hwmon *hwmon = ddat->hwmon; > + intel_wakeref_t wakeref; > + u32 reg_val; > + > + if (attr == hwmon_temp_input) { > + with_intel_runtime_pm(ddat->uncore->rpm, wakeref) > + reg_val = intel_uncore_read(ddat->uncore, hwmon->rg.pkg_temp); > + > + /* HW register value is in degrees, convert to millidegrees. */ > + *val = REG_FIELD_GET(TEMP_MASK, reg_val) * MILLIDEGREE_PER_DEGREE; > + return 0; > + } ...because here we may drop an indentation level by doing it opposite if (x != y) return -E...; ... > + return -EOPNOTSUPP; > +} -- With Best Regards, Andy Shevchenko