hwmon: Use HWMON_CHANNEL_INFO macro
Subsystems (4)
Guenter Roeck
maintainercover hwmon: 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. This series converts all hwmon drivers to use the macro if possible.
The conversion is done automatically with coccinelle. The semantic patch used to make this change is as follows.
@r@
initializer list elements;
identifier i;
@@
-u32 i[] = {
- elements,
- 0
-};
@s@
identifier r.i,j,ty;
@@
-struct hwmon_channel_info j = {
- .type = ty,
- .config = i,
-};
@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)
The conversion does not introduce functional changes.
Many thanks to Julia Lawall for providing the semantic patch.
Guenter Roeck
maintainerPATCH 1/17 hwmon: (adt7411) 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.
@r@
initializer list elements;
identifier i;
@@
-u32 i[] = {
- elements,
- 0
-};
@s@
identifier r.i,j,ty;
@@
-struct hwmon_channel_info j = {
- .type = ty,
- .config = i,
-};
@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 semantic patch.
--- drivers/hwmon/adt7411.c | 48 +++++++++++++++--------------------------------- 1 file changed, 15 insertions(+), 33 deletions(-)
drivers/hwmon/adt7411.c +15 -33
@@ -639,40 +639,22 @@ static int adt7411_init_device(struct adt7411_data *data)return i2c_smbus_write_byte_data (data->client,ADT7411_REG_CFG1 , val); } -static const u32 adt7411_in_config[] = { -HWMON_I_INPUT |HWMON_I_MIN |HWMON_I_MAX |HWMON_I_ALARM , -HWMON_I_INPUT |HWMON_I_MIN |HWMON_I_MAX |HWMON_I_ALARM , -HWMON_I_INPUT |HWMON_I_MIN |HWMON_I_MAX |HWMON_I_ALARM , -HWMON_I_INPUT |HWMON_I_MIN |HWMON_I_MAX |HWMON_I_ALARM , -HWMON_I_INPUT |HWMON_I_MIN |HWMON_I_MAX |HWMON_I_ALARM , -HWMON_I_INPUT |HWMON_I_MIN |HWMON_I_MAX |HWMON_I_ALARM , -HWMON_I_INPUT |HWMON_I_MIN |HWMON_I_MAX |HWMON_I_ALARM , -HWMON_I_INPUT |HWMON_I_MIN |HWMON_I_MAX |HWMON_I_ALARM , -HWMON_I_INPUT |HWMON_I_MIN |HWMON_I_MAX |HWMON_I_ALARM , -0 -}; - -static const struct hwmon_channel_info adt7411_in = { - .type = hwmon_in, - .config = adt7411_in_config, -}; - -static const u32 adt7411_temp_config[] = { -HWMON_T_INPUT |HWMON_T_MIN |HWMON_T_MIN_ALARM | -HWMON_T_MAX |HWMON_T_MAX_ALARM , -HWMON_T_INPUT |HWMON_T_MIN |HWMON_T_MIN_ALARM | -HWMON_T_MAX |HWMON_T_MAX_ALARM |HWMON_T_FAULT , -0 -}; - -static const struct hwmon_channel_info adt7411_temp = { - .type = hwmon_temp, - .config = adt7411_temp_config, -}; -static const struct hwmon_channel_info *adt7411_info[] = { - &adt7411_in, - &adt7411_temp, +HWMON_CHANNEL_INFO (in, +HWMON_I_INPUT |HWMON_I_MIN |HWMON_I_MAX |HWMON_I_ALARM , +HWMON_I_INPUT |HWMON_I_MIN |HWMON_I_MAX |HWMON_I_ALARM , +HWMON_I_INPUT |HWMON_I_MIN |HWMON_I_MAX |HWMON_I_ALARM , +HWMON_I_INPUT |HWMON_I_MIN |HWMON_I_MAX |HWMON_I_ALARM , +HWMON_I_INPUT |HWMON_I_MIN |HWMON_I_MAX |HWMON_I_ALARM , +HWMON_I_INPUT |HWMON_I_MIN |HWMON_I_MAX |HWMON_I_ALARM , +HWMON_I_INPUT |HWMON_I_MIN |HWMON_I_MAX |HWMON_I_ALARM , +HWMON_I_INPUT |HWMON_I_MIN |HWMON_I_MAX |HWMON_I_ALARM , +HWMON_I_INPUT |HWMON_I_MIN |HWMON_I_MAX |HWMON_I_ALARM ), +HWMON_CHANNEL_INFO (temp, +HWMON_T_INPUT |HWMON_T_MIN |HWMON_T_MIN_ALARM | +HWMON_T_MAX |HWMON_T_MAX_ALARM , +HWMON_T_INPUT |HWMON_T_MIN |HWMON_T_MIN_ALARM | +HWMON_T_MAX |HWMON_T_MAX_ALARM |HWMON_T_FAULT ),NULL };
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 2/17 hwmon: (ina3221) Use HWMON_CHANNEL_INFO macro
In reply to Guenter RoeckThe 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.
@r@
initializer list elements;
identifier i;
@@
-u32 i[] = {
- elements,
- 0
-};
@s@
identifier r.i,j,ty;
@@
-struct hwmon_channel_info j = {
- .type = ty,
- .config = i,
-};
@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 semantic patch.
The patch was post-edited to retain comments.
--- drivers/hwmon/ina3221.c | 48 +++++++++++++++--------------------------------- 1 file changed, 15 insertions(+), 33 deletions(-)
drivers/hwmon/ina3221.c +15 -33
@@ -458,44 +458,26 @@ static umode_t ina3221_is_visible(const void *drvdata, } } -static const u32 ina3221_in_config[] = { -/* 0: dummy, skipped in is_visible */ -HWMON_I_INPUT , -/* 1-3: input voltage Channels */ -HWMON_I_INPUT |HWMON_I_ENABLE |HWMON_I_LABEL , -HWMON_I_INPUT |HWMON_I_ENABLE |HWMON_I_LABEL , -HWMON_I_INPUT |HWMON_I_ENABLE |HWMON_I_LABEL , -/* 4-6: shunt voltage Channels */ -HWMON_I_INPUT , -HWMON_I_INPUT , -HWMON_I_INPUT , -0 -}; - -static const struct hwmon_channel_info ina3221_in = { - .type = hwmon_in, - .config = ina3221_in_config, -}; -#define INA3221_HWMON_CURR_CONFIG (HWMON_C_INPUT | \ HWMON_C_CRIT | HWMON_C_CRIT_ALARM | \ HWMON_C_MAX | HWMON_C_MAX_ALARM) -static const u32 ina3221_curr_config[] = { -INA3221_HWMON_CURR_CONFIG , -INA3221_HWMON_CURR_CONFIG , -INA3221_HWMON_CURR_CONFIG , -0 -}; - -static const struct hwmon_channel_info ina3221_curr = { - .type = hwmon_curr, - .config = ina3221_curr_config, -}; -static const struct hwmon_channel_info *ina3221_info[] = { - &ina3221_in, - &ina3221_curr, +HWMON_CHANNEL_INFO (in, +/* 0: dummy, skipped in is_visible */ +HWMON_I_INPUT , +/* 1-3: input voltage Channels */ +HWMON_I_INPUT |HWMON_I_ENABLE |HWMON_I_LABEL , +HWMON_I_INPUT |HWMON_I_ENABLE |HWMON_I_LABEL , +HWMON_I_INPUT |HWMON_I_ENABLE |HWMON_I_LABEL , +/* 4-6: shunt voltage Channels */ +HWMON_I_INPUT , +HWMON_I_INPUT , +HWMON_I_INPUT ), +HWMON_CHANNEL_INFO (curr, +INA3221_HWMON_CURR_CONFIG , +INA3221_HWMON_CURR_CONFIG , +INA3221_HWMON_CURR_CONFIG ),NULL };
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 3/17 hwmon: (jc42) Use HWMON_CHANNEL_INFO macro
In reply to Guenter RoeckThe 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.
@r@
initializer list elements;
identifier i;
@@
-u32 i[] = {
- elements,
- 0
-};
@s@
identifier r.i,j,ty;
@@
-struct hwmon_channel_info j = {
- .type = ty,
- .config = i,
-};
@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 semantic patch.
--- drivers/hwmon/jc42.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-)
drivers/hwmon/jc42.c +5 -13
@@ -451,20 +451,12 @@ static int jc42_detect(struct i2c_client *client, struct i2c_board_info *info)return -ENODEV ; } -static const u32 jc42_temp_config[] = { -HWMON_T_INPUT |HWMON_T_MIN |HWMON_T_MAX |HWMON_T_CRIT | -HWMON_T_MAX_HYST |HWMON_T_CRIT_HYST | -HWMON_T_MIN_ALARM |HWMON_T_MAX_ALARM |HWMON_T_CRIT_ALARM , -0 -}; - -static const struct hwmon_channel_info jc42_temp = { - .type = hwmon_temp, - .config = jc42_temp_config, -}; -static const struct hwmon_channel_info *jc42_info[] = { - &jc42_temp, +HWMON_CHANNEL_INFO (temp, +HWMON_T_INPUT |HWMON_T_MIN |HWMON_T_MAX | +HWMON_T_CRIT |HWMON_T_MAX_HYST | +HWMON_T_CRIT_HYST |HWMON_T_MIN_ALARM | +HWMON_T_MAX_ALARM |HWMON_T_CRIT_ALARM ),NULL };
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 4/17 hwmon: (lm75) Use HWMON_CHANNEL_INFO macro
In reply to Guenter RoeckThe 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.
@r@
initializer list elements;
identifier i;
@@
-u32 i[] = {
- elements,
- 0
-};
@s@
identifier r.i,j,ty;
@@
-struct hwmon_channel_info j = {
- .type = ty,
- .config = i,
-};
@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 semantic patch.
--- drivers/hwmon/lm75.c | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-)
drivers/hwmon/lm75.c +4 -28
@@ -194,35 +194,11 @@ static umode_t lm75_is_visible(const void *data, enum hwmon_sensor_types type,return 0 ; } -/*-----------------------------------------------------------------------*/ - -/* device probe and removal */ - -/* chip configuration */ - -static const u32 lm75_chip_config[] = { -HWMON_C_REGISTER_TZ |HWMON_C_UPDATE_INTERVAL , -0 -}; - -static const struct hwmon_channel_info lm75_chip = { - .type = hwmon_chip, - .config = lm75_chip_config, -}; - -static const u32 lm75_temp_config[] = { -HWMON_T_INPUT |HWMON_T_MAX |HWMON_T_MAX_HYST , -0 -}; - -static const struct hwmon_channel_info lm75_temp = { - .type = hwmon_temp, - .config = lm75_temp_config, -}; -static const struct hwmon_channel_info *lm75_info[] = { - &lm75_chip, - &lm75_temp, +HWMON_CHANNEL_INFO (chip, +HWMON_C_REGISTER_TZ |HWMON_C_UPDATE_INTERVAL ), +HWMON_CHANNEL_INFO (temp, +HWMON_T_INPUT |HWMON_T_MAX |HWMON_T_MAX_HYST ),NULL };
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 5/17 hwmon: (lm90) Use HWMON_CHANNEL_INFO macro
In reply to Guenter RoeckThe 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.
@r@
initializer list elements;
identifier i;
@@
-u32 i[] = {
- elements,
- 0
-};
@s@
identifier r.i,j,ty;
@@
-struct hwmon_channel_info j = {
- .type = ty,
- .config = i,
-};
@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 semantic patch.
--- drivers/hwmon/lm90.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)
drivers/hwmon/lm90.c +2 -11
@@ -1720,16 +1720,6 @@ static void lm90_regulator_disable(void *regulator)regulator_disable (regulator); } -static const u32 lm90_chip_config[] = { -HWMON_C_REGISTER_TZ |HWMON_C_UPDATE_INTERVAL |HWMON_C_ALARMS , -0 -}; - -static const struct hwmon_channel_info lm90_chip_info = { - .type = hwmon_chip, - .config = lm90_chip_config, -}; -static const struct hwmon_ops lm90_ops = { .is_visible = lm90_is_visible,
@@ -1792,7 +1782,8 @@ static int lm90_probe(struct i2c_client *client, data->chip.ops = &lm90_ops; data->chip.info = data->info; - data->info[0 ] = &lm90_chip_info; + data->info[0 ] =HWMON_CHANNEL_INFO (chip, +HWMON_C_REGISTER_TZ |HWMON_C_UPDATE_INTERVAL |HWMON_C_ALARMS ); data->info[1 ] = &data->temp_info; info = &data->temp_info;
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 6/17 hwmon: (lm95241) Use HWMON_CHANNEL_INFO macro
In reply to Guenter RoeckThe 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.
@r@
initializer list elements;
identifier i;
@@
-u32 i[] = {
- elements,
- 0
-};
@s@
identifier r.i,j,ty;
@@
-struct hwmon_channel_info j = {
- .type = ty,
- .config = i,
-};
@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 semantic patch.
--- drivers/hwmon/lm95241.c | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-)
drivers/hwmon/lm95241.c +8 -26
@@ -418,33 +418,15 @@ static void lm95241_init_client(struct i2c_client *client, data->model); } -static const u32 lm95241_chip_config[] = { -HWMON_C_UPDATE_INTERVAL , -0 -}; - -static const struct hwmon_channel_info lm95241_chip = { - .type = hwmon_chip, - .config = lm95241_chip_config, -}; - -static const u32 lm95241_temp_config[] = { -HWMON_T_INPUT , -HWMON_T_INPUT |HWMON_T_MAX |HWMON_T_MIN |HWMON_T_TYPE | -HWMON_T_FAULT , -HWMON_T_INPUT |HWMON_T_MAX |HWMON_T_MIN |HWMON_T_TYPE | -HWMON_T_FAULT , -0 -}; - -static const struct hwmon_channel_info lm95241_temp = { - .type = hwmon_temp, - .config = lm95241_temp_config, -}; -static const struct hwmon_channel_info *lm95241_info[] = { - &lm95241_chip, - &lm95241_temp, +HWMON_CHANNEL_INFO (chip, +HWMON_C_UPDATE_INTERVAL ), +HWMON_CHANNEL_INFO (temp, +HWMON_T_INPUT , +HWMON_T_INPUT |HWMON_T_MAX |HWMON_T_MIN | +HWMON_T_TYPE |HWMON_T_FAULT , +HWMON_T_INPUT |HWMON_T_MAX |HWMON_T_MIN | +HWMON_T_TYPE |HWMON_T_FAULT ),NULL };
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 7/17 hwmon: (lm95245) Use HWMON_CHANNEL_INFO macro
In reply to Guenter RoeckThe 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.
@r@
initializer list elements;
identifier i;
@@
-u32 i[] = {
- elements,
- 0
-};
@s@
identifier r.i,j,ty;
@@
-struct hwmon_channel_info j = {
- .type = ty,
- .config = i,
-};
@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 semantic patch.
--- drivers/hwmon/lm95245.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-)
drivers/hwmon/lm95245.c +9 -25
@@ -545,32 +545,16 @@ static const struct regmap_config lm95245_regmap_config = { .use_single_write = true, }; -static const u32 lm95245_chip_config[] = { -HWMON_C_UPDATE_INTERVAL , -0 -}; - -static const struct hwmon_channel_info lm95245_chip = { - .type = hwmon_chip, - .config = lm95245_chip_config, -}; - -static const u32 lm95245_temp_config[] = { -HWMON_T_INPUT |HWMON_T_CRIT |HWMON_T_CRIT_HYST |HWMON_T_CRIT_ALARM , -HWMON_T_INPUT |HWMON_T_MAX |HWMON_T_MAX_HYST |HWMON_T_CRIT | -HWMON_T_CRIT_HYST |HWMON_T_FAULT |HWMON_T_MAX_ALARM | -HWMON_T_CRIT_ALARM |HWMON_T_TYPE |HWMON_T_OFFSET , -0 -}; - -static const struct hwmon_channel_info lm95245_temp = { - .type = hwmon_temp, - .config = lm95245_temp_config, -}; -static const struct hwmon_channel_info *lm95245_info[] = { - &lm95245_chip, - &lm95245_temp, +HWMON_CHANNEL_INFO (chip, +HWMON_C_UPDATE_INTERVAL ), +HWMON_CHANNEL_INFO (temp, +HWMON_T_INPUT |HWMON_T_CRIT |HWMON_T_CRIT_HYST | +HWMON_T_CRIT_ALARM , +HWMON_T_INPUT |HWMON_T_MAX |HWMON_T_MAX_HYST | +HWMON_T_CRIT |HWMON_T_CRIT_HYST |HWMON_T_FAULT | +HWMON_T_MAX_ALARM |HWMON_T_CRIT_ALARM | +HWMON_T_TYPE |HWMON_T_OFFSET ),NULL };
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 8/17 hwmon: (ltc4245) Use HWMON_CHANNEL_INFO macro
In reply to Guenter RoeckThe 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.
@r@
initializer list elements;
identifier i;
@@
-u32 i[] = {
- elements,
- 0
-};
@s@
identifier r.i,j,ty;
@@
-struct hwmon_channel_info j = {
- .type = ty,
- .config = i,
-};
@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 semantic patch.
--- drivers/hwmon/ltc4245.c | 73 ++++++++++++++++--------------------------------- 1 file changed, 23 insertions(+), 50 deletions(-)
drivers/hwmon/ltc4245.c +23 -50
@@ -390,57 +390,30 @@ static umode_t ltc4245_is_visible(const void *_data, } } -static const u32 ltc4245_in_config[] = { -HWMON_I_INPUT ,/* dummy, skipped in is_visible */ -HWMON_I_INPUT |HWMON_I_MIN_ALARM , -HWMON_I_INPUT |HWMON_I_MIN_ALARM , -HWMON_I_INPUT |HWMON_I_MIN_ALARM , -HWMON_I_INPUT |HWMON_I_MIN_ALARM , -HWMON_I_INPUT |HWMON_I_MIN_ALARM , -HWMON_I_INPUT |HWMON_I_MIN_ALARM , -HWMON_I_INPUT |HWMON_I_MIN_ALARM , -HWMON_I_INPUT |HWMON_I_MIN_ALARM , -HWMON_I_INPUT , -HWMON_I_INPUT , -HWMON_I_INPUT , -0 -}; - -static const struct hwmon_channel_info ltc4245_in = { - .type = hwmon_in, - .config = ltc4245_in_config, -}; - -static const u32 ltc4245_curr_config[] = { -HWMON_C_INPUT |HWMON_C_MAX_ALARM , -HWMON_C_INPUT |HWMON_C_MAX_ALARM , -HWMON_C_INPUT |HWMON_C_MAX_ALARM , -HWMON_C_INPUT |HWMON_C_MAX_ALARM , -0 -}; - -static const struct hwmon_channel_info ltc4245_curr = { - .type = hwmon_curr, - .config = ltc4245_curr_config, -}; - -static const u32 ltc4245_power_config[] = { -HWMON_P_INPUT , -HWMON_P_INPUT , -HWMON_P_INPUT , -HWMON_P_INPUT , -0 -}; - -static const struct hwmon_channel_info ltc4245_power = { - .type = hwmon_power, - .config = ltc4245_power_config, -}; -static const struct hwmon_channel_info *ltc4245_info[] = { - <c4245_in, - <c4245_curr, - <c4245_power, +HWMON_CHANNEL_INFO (in, +HWMON_I_INPUT , +HWMON_I_INPUT |HWMON_I_MIN_ALARM , +HWMON_I_INPUT |HWMON_I_MIN_ALARM , +HWMON_I_INPUT |HWMON_I_MIN_ALARM , +HWMON_I_INPUT |HWMON_I_MIN_ALARM , +HWMON_I_INPUT |HWMON_I_MIN_ALARM , +HWMON_I_INPUT |HWMON_I_MIN_ALARM , +HWMON_I_INPUT |HWMON_I_MIN_ALARM , +HWMON_I_INPUT |HWMON_I_MIN_ALARM , +HWMON_I_INPUT , +HWMON_I_INPUT , +HWMON_I_INPUT ), +HWMON_CHANNEL_INFO (curr, +HWMON_C_INPUT |HWMON_C_MAX_ALARM , +HWMON_C_INPUT |HWMON_C_MAX_ALARM , +HWMON_C_INPUT |HWMON_C_MAX_ALARM , +HWMON_C_INPUT |HWMON_C_MAX_ALARM ), +HWMON_CHANNEL_INFO (power, +HWMON_P_INPUT , +HWMON_P_INPUT , +HWMON_P_INPUT , +HWMON_P_INPUT ),NULL };
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 9/17 hwmon: (ltq-cputemp) Use HWMON_CHANNEL_INFO macro
In reply to Guenter RoeckThe 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.
@r@
initializer list elements;
identifier i;
@@
-u32 i[] = {
- elements,
- 0
-};
@s@
identifier r.i,j,ty;
@@
-struct hwmon_channel_info j = {
- .type = ty,
- .config = i,
-};
@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 semantic patch.
--- drivers/hwmon/ltq-cputemp.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-)
drivers/hwmon/ltq-cputemp.c +4 -22
@@ -77,29 +77,11 @@ static umode_t ltq_is_visible(const void *_data, enum hwmon_sensor_types type, } } -static const u32 ltq_chip_config[] = { -HWMON_C_REGISTER_TZ , -0 -}; - -static const struct hwmon_channel_info ltq_chip = { - .type = hwmon_chip, - .config = ltq_chip_config, -}; - -static const u32 ltq_temp_config[] = { -HWMON_T_INPUT , -0 -}; - -static const struct hwmon_channel_info ltq_temp = { - .type = hwmon_temp, - .config = ltq_temp_config, -}; -static const struct hwmon_channel_info *ltq_info[] = { - <q_chip, - <q_temp, +HWMON_CHANNEL_INFO (chip, +HWMON_C_REGISTER_TZ ), +HWMON_CHANNEL_INFO (temp, +HWMON_T_INPUT ),NULL };
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 10/17 hwmon: (max31790) Use HWMON_CHANNEL_INFO macro
In reply to Guenter RoeckThe 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.
@r@
initializer list elements;
identifier i;
@@
-u32 i[] = {
- elements,
- 0
-};
@s@
identifier r.i,j,ty;
@@
-struct hwmon_channel_info j = {
- .type = ty,
- .config = i,
-};
@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 semantic patch.
--- drivers/hwmon/max31790.c | 58 +++++++++++++++++------------------------------- 1 file changed, 20 insertions(+), 38 deletions(-)
drivers/hwmon/max31790.c +20 -38
@@ -400,45 +400,27 @@ static umode_t max31790_is_visible(const void *data, } } -static const u32 max31790_fan_config[] = { -HWMON_F_INPUT |HWMON_F_TARGET |HWMON_F_FAULT , -HWMON_F_INPUT |HWMON_F_TARGET |HWMON_F_FAULT , -HWMON_F_INPUT |HWMON_F_TARGET |HWMON_F_FAULT , -HWMON_F_INPUT |HWMON_F_TARGET |HWMON_F_FAULT , -HWMON_F_INPUT |HWMON_F_TARGET |HWMON_F_FAULT , -HWMON_F_INPUT |HWMON_F_TARGET |HWMON_F_FAULT , -HWMON_F_INPUT |HWMON_F_FAULT , -HWMON_F_INPUT |HWMON_F_FAULT , -HWMON_F_INPUT |HWMON_F_FAULT , -HWMON_F_INPUT |HWMON_F_FAULT , -HWMON_F_INPUT |HWMON_F_FAULT , -HWMON_F_INPUT |HWMON_F_FAULT , -0 -}; - -static const struct hwmon_channel_info max31790_fan = { - .type = hwmon_fan, - .config = max31790_fan_config, -}; - -static const u32 max31790_pwm_config[] = { -HWMON_PWM_INPUT |HWMON_PWM_ENABLE , -HWMON_PWM_INPUT |HWMON_PWM_ENABLE , -HWMON_PWM_INPUT |HWMON_PWM_ENABLE , -HWMON_PWM_INPUT |HWMON_PWM_ENABLE , -HWMON_PWM_INPUT |HWMON_PWM_ENABLE , -HWMON_PWM_INPUT |HWMON_PWM_ENABLE , -0 -}; - -static const struct hwmon_channel_info max31790_pwm = { - .type = hwmon_pwm, - .config = max31790_pwm_config, -}; -static const struct hwmon_channel_info *max31790_info[] = { - &max31790_fan, - &max31790_pwm, +HWMON_CHANNEL_INFO (fan, +HWMON_F_INPUT |HWMON_F_TARGET |HWMON_F_FAULT , +HWMON_F_INPUT |HWMON_F_TARGET |HWMON_F_FAULT , +HWMON_F_INPUT |HWMON_F_TARGET |HWMON_F_FAULT , +HWMON_F_INPUT |HWMON_F_TARGET |HWMON_F_FAULT , +HWMON_F_INPUT |HWMON_F_TARGET |HWMON_F_FAULT , +HWMON_F_INPUT |HWMON_F_TARGET |HWMON_F_FAULT , +HWMON_F_INPUT |HWMON_F_FAULT , +HWMON_F_INPUT |HWMON_F_FAULT , +HWMON_F_INPUT |HWMON_F_FAULT , +HWMON_F_INPUT |HWMON_F_FAULT , +HWMON_F_INPUT |HWMON_F_FAULT , +HWMON_F_INPUT |HWMON_F_FAULT ), +HWMON_CHANNEL_INFO (pwm, +HWMON_PWM_INPUT |HWMON_PWM_ENABLE , +HWMON_PWM_INPUT |HWMON_PWM_ENABLE , +HWMON_PWM_INPUT |HWMON_PWM_ENABLE , +HWMON_PWM_INPUT |HWMON_PWM_ENABLE , +HWMON_PWM_INPUT |HWMON_PWM_ENABLE , +HWMON_PWM_INPUT |HWMON_PWM_ENABLE ),NULL };
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 11/17 hwmon: (max6621) Use HWMON_CHANNEL_INFO macro
In reply to Guenter RoeckThe 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.
@r@
initializer list elements;
identifier i;
@@
-u32 i[] = {
- elements,
- 0
-};
@s@
identifier r.i,j,ty;
@@
-struct hwmon_channel_info j = {
- .type = ty,
- .config = i,
-};
@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 semantic patch.
--- drivers/hwmon/max6621.c | 42 ++++++++++++------------------------------ 1 file changed, 12 insertions(+), 30 deletions(-)
drivers/hwmon/max6621.c +12 -30
@@ -458,37 +458,19 @@ static const struct regmap_config max6621_regmap_config = { .num_reg_defaults = ARRAY_SIZE(max6621_regmap_default), }; -static u32 max6621_chip_config[] = { -HWMON_C_REGISTER_TZ , -0 -}; - -static const struct hwmon_channel_info max6621_chip = { - .type = hwmon_chip, - .config = max6621_chip_config, -}; - -static const u32 max6621_temp_config[] = { -HWMON_T_INPUT |HWMON_T_LABEL |HWMON_T_OFFSET , -HWMON_T_INPUT |HWMON_T_CRIT |HWMON_T_CRIT_ALARM |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_CRIT |HWMON_T_CRIT_ALARM |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_CRIT |HWMON_T_CRIT_ALARM |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_CRIT |HWMON_T_CRIT_ALARM |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_LABEL , -0 -}; - -static const struct hwmon_channel_info max6621_temp = { - .type = hwmon_temp, - .config = max6621_temp_config, -}; -static const struct hwmon_channel_info *max6621_info[] = { - &max6621_chip, - &max6621_temp, +HWMON_CHANNEL_INFO (chip, +HWMON_C_REGISTER_TZ ), +HWMON_CHANNEL_INFO (temp, +HWMON_T_INPUT |HWMON_T_LABEL |HWMON_T_OFFSET , +HWMON_T_INPUT |HWMON_T_CRIT |HWMON_T_CRIT_ALARM |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_CRIT |HWMON_T_CRIT_ALARM |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_CRIT |HWMON_T_CRIT_ALARM |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_CRIT |HWMON_T_CRIT_ALARM |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_LABEL , +HWMON_T_INPUT |HWMON_T_LABEL ),NULL };
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 12/17 hwmon: (mlxreg-fan) Use HWMON_CHANNEL_INFO macro
In reply to Guenter RoeckThe 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.
@r@
initializer list elements;
identifier i;
@@
-u32 i[] = {
- elements,
- 0
-};
@s@
identifier r.i,j,ty;
@@
-struct hwmon_channel_info j = {
- .type = ty,
- .config = i,
-};
@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 semantic patch.
--- drivers/hwmon/mlxreg-fan.c | 48 +++++++++++++++------------------------------- 1 file changed, 15 insertions(+), 33 deletions(-)
drivers/hwmon/mlxreg-fan.c +15 -33
@@ -229,40 +229,22 @@ mlxreg_fan_is_visible(const void *data, enum hwmon_sensor_types type, u32 attr,return 0 ; } -static const u32 mlxreg_fan_hwmon_fan_config[] = { -HWMON_F_INPUT |HWMON_F_FAULT , -HWMON_F_INPUT |HWMON_F_FAULT , -HWMON_F_INPUT |HWMON_F_FAULT , -HWMON_F_INPUT |HWMON_F_FAULT , -HWMON_F_INPUT |HWMON_F_FAULT , -HWMON_F_INPUT |HWMON_F_FAULT , -HWMON_F_INPUT |HWMON_F_FAULT , -HWMON_F_INPUT |HWMON_F_FAULT , -HWMON_F_INPUT |HWMON_F_FAULT , -HWMON_F_INPUT |HWMON_F_FAULT , -HWMON_F_INPUT |HWMON_F_FAULT , -HWMON_F_INPUT |HWMON_F_FAULT , -0 -}; - -static const struct hwmon_channel_info mlxreg_fan_hwmon_fan = { - .type = hwmon_fan, - .config = mlxreg_fan_hwmon_fan_config, -}; - -static const u32 mlxreg_fan_hwmon_pwm_config[] = { -HWMON_PWM_INPUT , -0 -}; - -static const struct hwmon_channel_info mlxreg_fan_hwmon_pwm = { - .type = hwmon_pwm, - .config = mlxreg_fan_hwmon_pwm_config, -}; -static const struct hwmon_channel_info *mlxreg_fan_hwmon_info[] = { - &mlxreg_fan_hwmon_fan, - &mlxreg_fan_hwmon_pwm, +HWMON_CHANNEL_INFO (fan, +HWMON_F_INPUT |HWMON_F_FAULT , +HWMON_F_INPUT |HWMON_F_FAULT , +HWMON_F_INPUT |HWMON_F_FAULT , +HWMON_F_INPUT |HWMON_F_FAULT , +HWMON_F_INPUT |HWMON_F_FAULT , +HWMON_F_INPUT |HWMON_F_FAULT , +HWMON_F_INPUT |HWMON_F_FAULT , +HWMON_F_INPUT |HWMON_F_FAULT , +HWMON_F_INPUT |HWMON_F_FAULT , +HWMON_F_INPUT |HWMON_F_FAULT , +HWMON_F_INPUT |HWMON_F_FAULT , +HWMON_F_INPUT |HWMON_F_FAULT ), +HWMON_CHANNEL_INFO (pwm, +HWMON_PWM_INPUT ),NULL };
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 13/17 hwmon: (npcm750-pwm-fan) Use HWMON_CHANNEL_INFO macro
In reply to Guenter RoeckThe 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.
@r@
initializer list elements;
identifier i;
@@
-u32 i[] = {
- elements,
- 0
-};
@s@
identifier r.i,j,ty;
@@
-struct hwmon_channel_info j = {
- .type = ty,
- .config = i,
-};
@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 semantic patch.
--- drivers/hwmon/npcm750-pwm-fan.c | 70 +++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 44 deletions(-)
drivers/hwmon/npcm750-pwm-fan.c +26 -44
@@ -629,51 +629,33 @@ static umode_t npcm7xx_is_visible(const void *data, } } -static const u32 npcm7xx_pwm_config[] = { -HWMON_PWM_INPUT , -HWMON_PWM_INPUT , -HWMON_PWM_INPUT , -HWMON_PWM_INPUT , -HWMON_PWM_INPUT , -HWMON_PWM_INPUT , -HWMON_PWM_INPUT , -HWMON_PWM_INPUT , -0 -}; - -static const struct hwmon_channel_info npcm7xx_pwm = { - .type = hwmon_pwm, - .config = npcm7xx_pwm_config, -}; - -static const u32 npcm7xx_fan_config[] = { -HWMON_F_INPUT , -HWMON_F_INPUT , -HWMON_F_INPUT , -HWMON_F_INPUT , -HWMON_F_INPUT , -HWMON_F_INPUT , -HWMON_F_INPUT , -HWMON_F_INPUT , -HWMON_F_INPUT , -HWMON_F_INPUT , -HWMON_F_INPUT , -HWMON_F_INPUT , -HWMON_F_INPUT , -HWMON_F_INPUT , -HWMON_F_INPUT , -HWMON_F_INPUT , -0 -}; - -static const struct hwmon_channel_info npcm7xx_fan = { - .type = hwmon_fan, - .config = npcm7xx_fan_config, -}; -static const struct hwmon_channel_info *npcm7xx_info[] = { - &npcm7xx_pwm, - &npcm7xx_fan, +HWMON_CHANNEL_INFO (pwm, +HWMON_PWM_INPUT , +HWMON_PWM_INPUT , +HWMON_PWM_INPUT , +HWMON_PWM_INPUT , +HWMON_PWM_INPUT , +HWMON_PWM_INPUT , +HWMON_PWM_INPUT , +HWMON_PWM_INPUT ), +HWMON_CHANNEL_INFO (fan, +HWMON_F_INPUT , +HWMON_F_INPUT , +HWMON_F_INPUT , +HWMON_F_INPUT , +HWMON_F_INPUT , +HWMON_F_INPUT , +HWMON_F_INPUT , +HWMON_F_INPUT , +HWMON_F_INPUT , +HWMON_F_INPUT , +HWMON_F_INPUT , +HWMON_F_INPUT , +HWMON_F_INPUT , +HWMON_F_INPUT , +HWMON_F_INPUT , +HWMON_F_INPUT ),NULL };
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 14/17 hwmon: (raspberrypi-hwmon) Use HWMON_CHANNEL_INFO macro
In reply to Guenter RoeckThe 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.
@r@
initializer list elements;
identifier i;
@@
-u32 i[] = {
- elements,
- 0
-};
@s@
identifier r.i,j,ty;
@@
-struct hwmon_channel_info j = {
- .type = ty,
- .config = i,
-};
@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 semantic patch.
--- drivers/hwmon/raspberrypi-hwmon.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)
drivers/hwmon/raspberrypi-hwmon.c +2 -11
@@ -86,18 +86,9 @@ static umode_t rpi_is_visible(const void *_data, enum hwmon_sensor_types type,return 0444 ; } -static const u32 rpi_in_config[] = { -HWMON_I_LCRIT_ALARM , -0 -}; - -static const struct hwmon_channel_info rpi_in = { - .type = hwmon_in, - .config = rpi_in_config, -}; -static const struct hwmon_channel_info *rpi_info[] = { - &rpi_in, +HWMON_CHANNEL_INFO (in, +HWMON_I_LCRIT_ALARM ),NULL };
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 15/17 hwmon: (tmp102) Use HWMON_CHANNEL_INFO macro
In reply to Guenter RoeckThe 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.
@r@
initializer list elements;
identifier i;
@@
-u32 i[] = {
- elements,
- 0
-};
@s@
identifier r.i,j,ty;
@@
-struct hwmon_channel_info j = {
- .type = ty,
- .config = i,
-};
@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 semantic patch.
--- drivers/hwmon/tmp102.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-)
drivers/hwmon/tmp102.c +4 -22
@@ -150,29 +150,11 @@ static umode_t tmp102_is_visible(const void *data, enum hwmon_sensor_types type, } } -static u32 tmp102_chip_config[] = { -HWMON_C_REGISTER_TZ , -0 -}; - -static const struct hwmon_channel_info tmp102_chip = { - .type = hwmon_chip, - .config = tmp102_chip_config, -}; - -static u32 tmp102_temp_config[] = { -HWMON_T_INPUT |HWMON_T_MAX |HWMON_T_MAX_HYST , -0 -}; - -static const struct hwmon_channel_info tmp102_temp = { - .type = hwmon_temp, - .config = tmp102_temp_config, -}; -static const struct hwmon_channel_info *tmp102_info[] = { - &tmp102_chip, - &tmp102_temp, +HWMON_CHANNEL_INFO (chip, +HWMON_C_REGISTER_TZ ), +HWMON_CHANNEL_INFO (temp, +HWMON_T_INPUT |HWMON_T_MAX |HWMON_T_MAX_HYST ),NULL };
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 16/17 hwmon: (tmp108) Use HWMON_CHANNEL_INFO macro
In reply to Guenter RoeckThe 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.
@r@
initializer list elements;
identifier i;
@@
-u32 i[] = {
- elements,
- 0
-};
@s@
identifier r.i,j,ty;
@@
-struct hwmon_channel_info j = {
- .type = ty,
- .config = i,
-};
@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 semantic patch.
--- drivers/hwmon/tmp108.c | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-)
drivers/hwmon/tmp108.c +6 -23
@@ -281,30 +281,13 @@ static umode_t tmp108_is_visible(const void *data, enum hwmon_sensor_types type, } } -static u32 tmp108_chip_config[] = { -HWMON_C_REGISTER_TZ |HWMON_C_UPDATE_INTERVAL , -0 -}; - -static const struct hwmon_channel_info tmp108_chip = { - .type = hwmon_chip, - .config = tmp108_chip_config, -}; - -static u32 tmp108_temp_config[] = { -HWMON_T_INPUT |HWMON_T_MAX |HWMON_T_MIN |HWMON_T_MIN_HYST - |HWMON_T_MAX_HYST |HWMON_T_MIN_ALARM |HWMON_T_MAX_ALARM , -0 -}; - -static const struct hwmon_channel_info tmp108_temp = { - .type = hwmon_temp, - .config = tmp108_temp_config, -}; -static const struct hwmon_channel_info *tmp108_info[] = { - &tmp108_chip, - &tmp108_temp, +HWMON_CHANNEL_INFO (chip, +HWMON_C_REGISTER_TZ |HWMON_C_UPDATE_INTERVAL ), +HWMON_CHANNEL_INFO (temp, +HWMON_T_INPUT |HWMON_T_MAX |HWMON_T_MIN | +HWMON_T_MIN_HYST |HWMON_T_MAX_HYST | +HWMON_T_MIN_ALARM |HWMON_T_MAX_ALARM ),NULL };
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 17/17 hwmon: (w83773g) Use HWMON_CHANNEL_INFO macro
In reply to Guenter RoeckThe 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.
@r@
initializer list elements;
identifier i;
@@
-u32 i[] = {
- elements,
- 0
-};
@s@
identifier r.i,j,ty;
@@
-struct hwmon_channel_info j = {
- .type = ty,
- .config = i,
-};
@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 semantic patch.
--- drivers/hwmon/w83773g.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-)
drivers/hwmon/w83773g.c +6 -24
@@ -237,31 +237,13 @@ static umode_t w83773_is_visible(const void *data, enum hwmon_sensor_types type,return 0 ; } -static const u32 w83773_chip_config[] = { -HWMON_C_REGISTER_TZ |HWMON_C_UPDATE_INTERVAL , -0 -}; - -static const struct hwmon_channel_info w83773_chip = { - .type = hwmon_chip, - .config = w83773_chip_config, -}; - -static const u32 w83773_temp_config[] = { -HWMON_T_INPUT , -HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_OFFSET , -HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_OFFSET , -0 -}; - -static const struct hwmon_channel_info w83773_temp = { - .type = hwmon_temp, - .config = w83773_temp_config, -}; -static const struct hwmon_channel_info *w83773_info[] = { - &w83773_chip, - &w83773_temp, +HWMON_CHANNEL_INFO (chip, +HWMON_C_REGISTER_TZ |HWMON_C_UPDATE_INTERVAL ), +HWMON_CHANNEL_INFO (temp, +HWMON_T_INPUT , +HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_OFFSET , +HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_OFFSET ),NULL };
Signature · 1 line
2.7.4