@@ -37,6 +37,7 @@ struct system76_data {
3737 union acpi_object * ntmp ;
3838 struct input_dev * input ;
3939 bool has_open_ec ;
40+ int fan_duty ;
4041};
4142
4243static const struct acpi_device_id device_ids [] = {
@@ -498,12 +499,12 @@ static umode_t thermal_is_visible(const void *drvdata, enum hwmon_sensor_types t
498499 const struct system76_data * data = drvdata ;
499500
500501 switch (type ) {
501- case hwmon_fan :
502502 case hwmon_pwm :
503503 if (system76_name (data -> nfan , channel ))
504- return 0444 ;
504+ return 0644 ;
505505 break ;
506506
507+ case hwmon_fan :
507508 case hwmon_temp :
508509 if (system76_name (data -> ntmp , channel ))
509510 return 0444 ;
@@ -560,6 +561,31 @@ static int thermal_read(struct device *dev, enum hwmon_sensor_types type, u32 at
560561 return - EOPNOTSUPP ;
561562}
562563
564+ static int thermal_write (struct device * dev , enum hwmon_sensor_types type , u32 attr ,
565+ int channel , long val )
566+ {
567+ struct system76_data * data = dev_get_drvdata (dev );
568+ int raw ;
569+
570+ switch (type ) {
571+ case hwmon_pwm :
572+ if (attr == hwmon_pwm_input ) {
573+ char method [5 ];
574+ snprintf (method , sizeof method , "SFD%d" , channel );
575+
576+ data -> fan_duty = val ;
577+
578+ return system76_set (data , method , (int )data -> fan_duty );
579+ }
580+ break ;
581+
582+ default :
583+ return - EOPNOTSUPP ;
584+ }
585+
586+ return - EOPNOTSUPP ;
587+ }
588+
563589static int thermal_read_string (struct device * dev , enum hwmon_sensor_types type , u32 attr ,
564590 int channel , const char * * str )
565591{
@@ -593,6 +619,7 @@ static const struct hwmon_ops thermal_ops = {
593619 .is_visible = thermal_is_visible ,
594620 .read = thermal_read ,
595621 .read_string = thermal_read_string ,
622+ .write = thermal_write ,
596623};
597624
598625// Allocate up to 8 fans and temperatures
0 commit comments