Skip to content

Commit 3dae106

Browse files
Uwe Kleine-Königthierryreding
authored andcommitted
pwm/tracing: Also record trace events for failed API calls
Record and report an error code for the events. This allows to report about failed calls without ambiguity and so gives a more complete picture. Acked-by: Conor Dooley <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Uwe Kleine-König <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent 6c452cf commit 3dae106

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

drivers/pwm/core.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ static int pwm_device_request(struct pwm_device *pwm, const char *label)
115115
}
116116

117117
if (pwm->chip->ops->get_state) {
118-
pwm->chip->ops->get_state(pwm->chip, pwm, &pwm->state);
119-
trace_pwm_get(pwm, &pwm->state);
118+
err = pwm->chip->ops->get_state(pwm->chip, pwm, &pwm->state);
119+
trace_pwm_get(pwm, &pwm->state, err);
120120

121121
if (IS_ENABLED(CONFIG_PWM_DEBUG))
122122
pwm->last = pwm->state;
@@ -458,8 +458,8 @@ static void pwm_apply_state_debug(struct pwm_device *pwm,
458458
* checks.
459459
*/
460460

461-
chip->ops->get_state(chip, pwm, &s1);
462-
trace_pwm_get(pwm, &s1);
461+
err = chip->ops->get_state(chip, pwm, &s1);
462+
trace_pwm_get(pwm, &s1, err);
463463

464464
/*
465465
* The lowlevel driver either ignored .polarity (which is a bug) or as
@@ -515,16 +515,15 @@ static void pwm_apply_state_debug(struct pwm_device *pwm,
515515

516516
/* reapply the state that the driver reported being configured. */
517517
err = chip->ops->apply(chip, pwm, &s1);
518+
trace_pwm_apply(pwm, &s1, err);
518519
if (err) {
519520
*last = s1;
520521
dev_err(chip->dev, "failed to reapply current setting\n");
521522
return;
522523
}
523524

524-
trace_pwm_apply(pwm, &s1);
525-
526-
chip->ops->get_state(chip, pwm, last);
527-
trace_pwm_get(pwm, last);
525+
err = chip->ops->get_state(chip, pwm, last);
526+
trace_pwm_get(pwm, last, err);
528527

529528
/* reapplication of the current state should give an exact match */
530529
if (s1.enabled != last->enabled ||
@@ -572,11 +571,10 @@ int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state)
572571
return 0;
573572

574573
err = chip->ops->apply(chip, pwm, state);
574+
trace_pwm_apply(pwm, state, err);
575575
if (err)
576576
return err;
577577

578-
trace_pwm_apply(pwm, state);
579-
580578
pwm->state = *state;
581579

582580
/*

include/trace/events/pwm.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@
1010

1111
DECLARE_EVENT_CLASS(pwm,
1212

13-
TP_PROTO(struct pwm_device *pwm, const struct pwm_state *state),
13+
TP_PROTO(struct pwm_device *pwm, const struct pwm_state *state, int err),
1414

15-
TP_ARGS(pwm, state),
15+
TP_ARGS(pwm, state, err),
1616

1717
TP_STRUCT__entry(
1818
__field(struct pwm_device *, pwm)
1919
__field(u64, period)
2020
__field(u64, duty_cycle)
2121
__field(enum pwm_polarity, polarity)
2222
__field(bool, enabled)
23+
__field(int, err)
2324
),
2425

2526
TP_fast_assign(
@@ -28,28 +29,27 @@ DECLARE_EVENT_CLASS(pwm,
2829
__entry->duty_cycle = state->duty_cycle;
2930
__entry->polarity = state->polarity;
3031
__entry->enabled = state->enabled;
32+
__entry->err = err;
3133
),
3234

33-
TP_printk("%p: period=%llu duty_cycle=%llu polarity=%d enabled=%d",
35+
TP_printk("%p: period=%llu duty_cycle=%llu polarity=%d enabled=%d err=%d",
3436
__entry->pwm, __entry->period, __entry->duty_cycle,
35-
__entry->polarity, __entry->enabled)
37+
__entry->polarity, __entry->enabled, __entry->err)
3638

3739
);
3840

3941
DEFINE_EVENT(pwm, pwm_apply,
4042

41-
TP_PROTO(struct pwm_device *pwm, const struct pwm_state *state),
42-
43-
TP_ARGS(pwm, state)
43+
TP_PROTO(struct pwm_device *pwm, const struct pwm_state *state, int err),
4444

45+
TP_ARGS(pwm, state, err)
4546
);
4647

4748
DEFINE_EVENT(pwm, pwm_get,
4849

49-
TP_PROTO(struct pwm_device *pwm, const struct pwm_state *state),
50-
51-
TP_ARGS(pwm, state)
50+
TP_PROTO(struct pwm_device *pwm, const struct pwm_state *state, int err),
5251

52+
TP_ARGS(pwm, state, err)
5353
);
5454

5555
#endif /* _TRACE_PWM_H */

0 commit comments

Comments
 (0)