Use a constant array MAX_NUM_SENSORS[] for maximum number of sensors per version (v0.1, v1, v2). Signed-off-by: Carlos Bilbao <carlos.bilbao@xxxxxxx> --- drivers/thermal/qcom/tsens-8960.c | 2 +- drivers/thermal/qcom/tsens-v0_1.c | 4 ++-- drivers/thermal/qcom/tsens-v1.c | 2 +- drivers/thermal/qcom/tsens-v2.c | 2 +- drivers/thermal/qcom/tsens.h | 6 ++++++ 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/qcom/tsens-8960.c b/drivers/thermal/qcom/tsens-8960.c index b41ff164e67a..05db9bf0e2c6 100644 --- a/drivers/thermal/qcom/tsens-8960.c +++ b/drivers/thermal/qcom/tsens-8960.c @@ -263,6 +263,6 @@ static const struct tsens_ops ops_8960 = { }; const struct tsens_plat_data data_8960 = { - .num_sensors = 11, + .num_sensors = MAX_NUM_SENSORS[VER_0_1], .ops = &ops_8960, }; diff --git a/drivers/thermal/qcom/tsens-v0_1.c b/drivers/thermal/qcom/tsens-v0_1.c index 6f26fadf4c27..d29046cffc6b 100644 --- a/drivers/thermal/qcom/tsens-v0_1.c +++ b/drivers/thermal/qcom/tsens-v0_1.c @@ -324,7 +324,7 @@ static const struct tsens_features tsens_v0_1_feat = { .crit_int = 0, .adc = 1, .srot_split = 1, - .max_sensors = 11, + .max_sensors = MAX_NUM_SENSORS[VER_0_1], }; static const struct reg_field tsens_v0_1_regfields[MAX_REGFIELDS] = { @@ -374,7 +374,7 @@ static const struct tsens_ops ops_8974 = { }; const struct tsens_plat_data data_8974 = { - .num_sensors = 11, + .num_sensors = MAX_NUM_SENSORS[VER_0_1], .ops = &ops_8974, .feat = &tsens_v0_1_feat, .fields = tsens_v0_1_regfields, diff --git a/drivers/thermal/qcom/tsens-v1.c b/drivers/thermal/qcom/tsens-v1.c index 10b595d4f619..2007deb45723 100644 --- a/drivers/thermal/qcom/tsens-v1.c +++ b/drivers/thermal/qcom/tsens-v1.c @@ -149,7 +149,7 @@ static const struct tsens_features tsens_v1_feat = { .crit_int = 0, .adc = 1, .srot_split = 1, - .max_sensors = 11, + .max_sensors = MAX_NUM_SENSORS[VER_1_X], }; static const struct reg_field tsens_v1_regfields[MAX_REGFIELDS] = { diff --git a/drivers/thermal/qcom/tsens-v2.c b/drivers/thermal/qcom/tsens-v2.c index 0a4f2b8fcab6..002809e6a0b5 100644 --- a/drivers/thermal/qcom/tsens-v2.c +++ b/drivers/thermal/qcom/tsens-v2.c @@ -32,7 +32,7 @@ static const struct tsens_features tsens_v2_feat = { .crit_int = 1, .adc = 0, .srot_split = 1, - .max_sensors = 16, + .max_sensors = MAX_NUM_SENSORS[VER_2_X], }; static const struct reg_field tsens_v2_regfields[MAX_REGFIELDS] = { diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h index 2fd94997245b..39645bbe9f95 100644 --- a/drivers/thermal/qcom/tsens.h +++ b/drivers/thermal/qcom/tsens.h @@ -26,6 +26,12 @@ enum tsens_ver { VER_2_X, }; +static const int MAX_NUM_SENSORS[] = { + [VER_0_1] = 11, + [VER_1_X] = 11, + [VER_2_X] = 16, +}; + /** * struct tsens_sensor - data for each sensor connected to the tsens device * @priv: tsens device instance that this sensor is connected to -- 2.31.1