Skip to content

Commit d6a8007

Browse files
ukleinekUwe Kleine-König
authored andcommitted
pwm: Simplify pwm_capture()
When pwm_capture() is called, pwm is valid, so the checks for pwm and pwm->chip->ops being NULL can be dropped. Signed-off-by: Uwe Kleine-König <[email protected]> Link: https://lore.kernel.org/r/ee7b3322c7b3e28defdfb886a70b8ba40d298416.1722261050.git.u.kleine-koenig@baylibre.com Signed-off-by: Uwe Kleine-König <[email protected]>
1 parent 75f0cb3 commit d6a8007

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/pwm/core.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,15 +328,15 @@ EXPORT_SYMBOL_GPL(pwm_adjust_config);
328328
static int pwm_capture(struct pwm_device *pwm, struct pwm_capture *result,
329329
unsigned long timeout)
330330
{
331-
if (!pwm || !pwm->chip->ops)
332-
return -EINVAL;
331+
struct pwm_chip *chip = pwm->chip;
332+
const struct pwm_ops *ops = chip->ops;
333333

334-
if (!pwm->chip->ops->capture)
334+
if (!ops->capture)
335335
return -ENOSYS;
336336

337337
guard(mutex)(&pwm_lock);
338338

339-
return pwm->chip->ops->capture(pwm->chip, pwm, result, timeout);
339+
return ops->capture(chip, pwm, result, timeout);
340340
}
341341

342342
static struct pwm_chip *pwmchip_find_by_name(const char *name)

0 commit comments

Comments
 (0)