diff options
author | Christer Beskow <chbe@kvaser.com> | 2019-08-06 09:29:38 +0200 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2019-08-13 16:36:52 +0200 |
commit | 1910cd88539c07abf34a558a0976b506483c377c (patch) | |
tree | 6f0ef3f77b4df9fe2889dbb9c3fb17fdb36413c8 /drivers | |
parent | 53f6f391786e01bf2050c03d8a36d9defdcc2831 (diff) |
can: kvaser_pciefd: kvaser_pciefd_pwm_stop(): remove unnecessary code when setting pwm duty cycle to zero
To set the duty cycle to zero (i.e. pwm_stop), the trigger value shall
be equal to the top value.
This is achieved by reading the value of the top bit field from the pwm
register and then writing back this value to the trigger and top bit
fields.
Addresses-Coverity: ("Logically dead code")
Reported-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Christer Beskow <chbe@kvaser.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/can/kvaser_pciefd.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/drivers/net/can/kvaser_pciefd.c b/drivers/net/can/kvaser_pciefd.c index 3af747cbbde4..ccba42c544a3 100644 --- a/drivers/net/can/kvaser_pciefd.c +++ b/drivers/net/can/kvaser_pciefd.c @@ -643,7 +643,7 @@ static int kvaser_pciefd_bus_on(struct kvaser_pciefd_can *can) static void kvaser_pciefd_pwm_stop(struct kvaser_pciefd_can *can) { - int top, trigger; + u8 top; u32 pwm_ctrl; unsigned long irq; @@ -651,12 +651,8 @@ static void kvaser_pciefd_pwm_stop(struct kvaser_pciefd_can *can) pwm_ctrl = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_PWM_REG); top = (pwm_ctrl >> KVASER_PCIEFD_KCAN_PWM_TOP_SHIFT) & 0xff; - trigger = (100 * top + 50) / 100; - if (trigger < 0) - trigger = 0; - - pwm_ctrl = trigger & 0xff; - pwm_ctrl |= (top & 0xff) << KVASER_PCIEFD_KCAN_PWM_TOP_SHIFT; + /* Set duty cycle to zero */ + pwm_ctrl |= top; iowrite32(pwm_ctrl, can->reg_base + KVASER_PCIEFD_KCAN_PWM_REG); spin_unlock_irqrestore(&can->lock, irq); } |