Skip to content

Commit 7282d2a

Browse files
committed
hwmon: (pwm-fan) 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. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent 7c399d6 commit 7282d2a

1 file changed

Lines changed: 1 addition & 11 deletions

File tree

drivers/hwmon/pwm-fan.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,6 @@ struct pwm_fan_ctx {
4949
struct hwmon_channel_info fan_channel;
5050
};
5151

52-
static const u32 pwm_fan_channel_config_pwm[] = {
53-
HWMON_PWM_INPUT,
54-
0
55-
};
56-
57-
static const struct hwmon_channel_info pwm_fan_channel_pwm = {
58-
.type = hwmon_pwm,
59-
.config = pwm_fan_channel_config_pwm,
60-
};
61-
6252
/* This handler assumes self resetting edge triggered interrupt. */
6353
static irqreturn_t pulse_handler(int irq, void *dev_id)
6454
{
@@ -387,7 +377,7 @@ static int pwm_fan_probe(struct platform_device *pdev)
387377
if (!channels)
388378
return -ENOMEM;
389379

390-
channels[0] = &pwm_fan_channel_pwm;
380+
channels[0] = HWMON_CHANNEL_INFO(pwm, HWMON_PWM_INPUT);
391381

392382
for (i = 0; i < ctx->tach_count; i++) {
393383
struct pwm_fan_tach *tach = &ctx->tachs[i];

0 commit comments

Comments
 (0)