diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2024-03-10 12:00:59 +0100 |
---|---|---|
committer | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2024-04-26 21:29:17 +0200 |
commit | 7db42aa2b629de0a103f603f41c5b0929c66ccda (patch) | |
tree | bb3666650dfd2715a0ae413fa34e9e7f366af709 /drivers/pwm | |
parent | c0143f68919e6e36a4fa8816ddb49d266f3b21de (diff) |
pwm: sti: Prefer local variable over pointer dereference
While the compiler probably optimizes out the pointer dereference, using
the local variable holding the same value also benefits the human
reader. So simplify accordingly. Also move a loop over all capture lines
into the capture if block to group the operations related to capturing
in .probe().
Link: https://lore.kernel.org/r/a7a81f3838f7ed7f4d6dbee3d646989cc265f676.1710068192.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Diffstat (limited to 'drivers/pwm')
-rw-r--r-- | drivers/pwm/pwm-sti.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/pwm/pwm-sti.c b/drivers/pwm/pwm-sti.c index 7a7d1c622a17..396b52672ce0 100644 --- a/drivers/pwm/pwm-sti.c +++ b/drivers/pwm/pwm-sti.c @@ -600,34 +600,34 @@ static int sti_pwm_probe(struct platform_device *pdev) if (ret) return dev_err_probe(dev, ret, "Failed to initialize regmap fields\n"); - if (pc->pwm_num_devs) { + if (pwm_num_devs) { pc->pwm_clk = devm_clk_get_prepared(dev, "pwm"); if (IS_ERR(pc->pwm_clk)) return dev_err_probe(dev, PTR_ERR(pc->pwm_clk), "failed to get PWM clock\n"); } - if (pc->cpt_num_devs) { + if (cpt_num_devs) { pc->cpt_clk = devm_clk_get_prepared(dev, "capture"); if (IS_ERR(pc->cpt_clk)) return dev_err_probe(dev, PTR_ERR(pc->cpt_clk), "failed to get PWM capture clock\n"); - pc->ddata = devm_kcalloc(dev, pc->cpt_num_devs, + pc->ddata = devm_kcalloc(dev, cpt_num_devs, sizeof(*pc->ddata), GFP_KERNEL); if (!pc->ddata) return -ENOMEM; - } - - chip->ops = &sti_pwm_ops; - for (i = 0; i < pc->cpt_num_devs; i++) { - struct sti_cpt_ddata *ddata = &pc->ddata[i]; + for (i = 0; i < cpt_num_devs; i++) { + struct sti_cpt_ddata *ddata = &pc->ddata[i]; - init_waitqueue_head(&ddata->wait); - mutex_init(&ddata->lock); + init_waitqueue_head(&ddata->wait); + mutex_init(&ddata->lock); + } } + chip->ops = &sti_pwm_ops; + ret = devm_pwmchip_add(dev, chip); if (ret) return dev_err_probe(dev, ret, "Failed to register pwm chip\n"); |