Skip to content

Commit 09e02c8

Browse files
committed
hwmon: (peci/cputemp) Use HWMON_CHANNEL_INFO macro
The HWMON_CHANNEL_INFO macro simplifies the code, reduces the likelihood of errors, and makes the code easier to read. The conversion was done automatically with coccinelle. The semantic patch used to make this change is as follows. @s@ identifier i,j,ty; @@ -struct hwmon_channel_info j = { - .type = ty, - .config = i, -}; @r@ initializer list elements; identifier s.i; @@ -u32 i[] = { - elements, - 0 -}; @script:ocaml t@ ty << s.ty; elements << r.elements; shorter; elems; @@ shorter := make_ident (List.hd(List.rev (Str.split (Str.regexp "_") ty))); elems := make_ident (String.concat "," (List.map (fun x -> Printf.sprintf "\n\t\t\t %s" x) (Str.split (Str.regexp " , ") elements))) @@ identifier s.j,t.shorter; identifier t.elems; @@ - &j + HWMON_CHANNEL_INFO(shorter,elems) This patch does not introduce functional changes. Many thanks to Julia Lawall for providing the coccinelle script. Cc: Iwona Winiarska <iwona.winiarska@intel.com> Reviewed-by: Iwona Winiarska <iwona.winiarska@intel.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent 9070d86 commit 09e02c8

1 file changed

Lines changed: 16 additions & 22 deletions

File tree

drivers/hwmon/peci/cputemp.c

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -447,29 +447,23 @@ static const struct hwmon_ops peci_cputemp_ops = {
447447
.read = cputemp_read,
448448
};
449449

450-
static const u32 peci_cputemp_temp_channel_config[] = {
451-
/* Die temperature */
452-
HWMON_T_LABEL | HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_CRIT | HWMON_T_CRIT_HYST,
453-
/* DTS margin */
454-
HWMON_T_LABEL | HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_CRIT | HWMON_T_CRIT_HYST,
455-
/* Tcontrol temperature */
456-
HWMON_T_LABEL | HWMON_T_INPUT | HWMON_T_CRIT,
457-
/* Tthrottle temperature */
458-
HWMON_T_LABEL | HWMON_T_INPUT,
459-
/* Tjmax temperature */
460-
HWMON_T_LABEL | HWMON_T_INPUT,
461-
/* Core temperature - for all core channels */
462-
[channel_core ... CPUTEMP_CHANNEL_NUMS - 1] = HWMON_T_LABEL | HWMON_T_INPUT,
463-
0
464-
};
465-
466-
static const struct hwmon_channel_info peci_cputemp_temp_channel = {
467-
.type = hwmon_temp,
468-
.config = peci_cputemp_temp_channel_config,
469-
};
470-
471450
static const struct hwmon_channel_info *peci_cputemp_info[] = {
472-
&peci_cputemp_temp_channel,
451+
HWMON_CHANNEL_INFO(temp,
452+
/* Die temperature */
453+
HWMON_T_LABEL | HWMON_T_INPUT | HWMON_T_MAX |
454+
HWMON_T_CRIT | HWMON_T_CRIT_HYST,
455+
/* DTS margin */
456+
HWMON_T_LABEL | HWMON_T_INPUT | HWMON_T_MAX |
457+
HWMON_T_CRIT | HWMON_T_CRIT_HYST,
458+
/* Tcontrol temperature */
459+
HWMON_T_LABEL | HWMON_T_INPUT | HWMON_T_CRIT,
460+
/* Tthrottle temperature */
461+
HWMON_T_LABEL | HWMON_T_INPUT,
462+
/* Tjmax temperature */
463+
HWMON_T_LABEL | HWMON_T_INPUT,
464+
/* Core temperature - for all core channels */
465+
[channel_core ... CPUTEMP_CHANNEL_NUMS - 1] =
466+
HWMON_T_LABEL | HWMON_T_INPUT),
473467
NULL
474468
};
475469

0 commit comments

Comments
 (0)