platform/x86: oxpec: Move fan speed read to separate function
authorAntheas Kapenekakis <lkml@antheas.dev>
Fri, 25 Apr 2025 11:18:15 +0000 (13:18 +0200)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Wed, 30 Apr 2025 11:05:37 +0000 (14:05 +0300)
While not necessary for fixing the ABI hwmon issue, fan speed will be
the only remaining value without a function. Therefore, finish the
refactor by moving it to a separate function.

Reviewed-by: Derek J. Clark <derekjohn.clark@gmail.com>
Reviewed-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Antheas Kapenekakis <lkml@antheas.dev>
Link: https://lore.kernel.org/r/20250425111821.88746-11-lkml@antheas.dev
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/oxpec.c

index 5da8e1d6073d5f8a19f61456d5319e7c9d30206c..918a553bd8969306bf9d7658d288ea620f5e427d 100644 (file)
@@ -599,6 +599,34 @@ static umode_t oxp_ec_hwmon_is_visible(const void *drvdata,
        }
 }
 
+/* Fan speed read function */
+static int oxp_pwm_fan_speed(long *val)
+{
+       switch (board) {
+       case orange_pi_neo:
+               return read_from_ec(ORANGEPI_SENSOR_FAN_REG, 2, val);
+       case oxp_2:
+       case oxp_x1:
+               return read_from_ec(OXP_2_SENSOR_FAN_REG, 2, val);
+       case aok_zoe_a1:
+       case aya_neo_2:
+       case aya_neo_air:
+       case aya_neo_air_1s:
+       case aya_neo_air_plus_mendo:
+       case aya_neo_air_pro:
+       case aya_neo_flip:
+       case aya_neo_geek:
+       case aya_neo_kun:
+       case oxp_fly:
+       case oxp_mini_amd:
+       case oxp_mini_amd_a07:
+       case oxp_mini_amd_pro:
+               return read_from_ec(OXP_SENSOR_FAN_REG, 2, val);
+       default:
+               return -EOPNOTSUPP;
+       }
+}
+
 /* PWM input read/write functions */
 static int oxp_pwm_input_write(long val)
 {
@@ -694,30 +722,7 @@ static int oxp_platform_read(struct device *dev, enum hwmon_sensor_types type,
        case hwmon_fan:
                switch (attr) {
                case hwmon_fan_input:
-                       switch (board) {
-                       case orange_pi_neo:
-                               return read_from_ec(ORANGEPI_SENSOR_FAN_REG, 2, val);
-                       case oxp_2:
-                       case oxp_x1:
-                               return read_from_ec(OXP_2_SENSOR_FAN_REG, 2, val);
-                       case aok_zoe_a1:
-                       case aya_neo_2:
-                       case aya_neo_air:
-                       case aya_neo_air_1s:
-                       case aya_neo_air_plus_mendo:
-                       case aya_neo_air_pro:
-                       case aya_neo_flip:
-                       case aya_neo_geek:
-                       case aya_neo_kun:
-                       case oxp_fly:
-                       case oxp_mini_amd:
-                       case oxp_mini_amd_a07:
-                       case oxp_mini_amd_pro:
-                               return read_from_ec(OXP_SENSOR_FAN_REG, 2, val);
-                       default:
-                               break;
-                       }
-                       break;
+                       return oxp_pwm_fan_speed(val);
                default:
                        break;
                }