Skip to content

Commit

Permalink
can: bittiming: can_get_bittiming(): use direct return and remove unn…
Browse files Browse the repository at this point in the history
…eeded else

Clean up the code flow a bit, don't assign err variable but directly
return. Remove the unneeded else, too.

Link: https://lore.kernel.org/all/20230202110854.2318594-5-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
  • Loading branch information
Marc Kleine-Budde committed Feb 6, 2023
1 parent 5237544 commit 8e0a0b3
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions drivers/net/can/dev/bittiming.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,18 @@ int can_get_bittiming(const struct net_device *dev, struct can_bittiming *bt,
const u32 *bitrate_const,
const unsigned int bitrate_const_cnt)
{
int err;

/* Depending on the given can_bittiming parameter structure the CAN
* timing parameters are calculated based on the provided bitrate OR
* alternatively the CAN timing parameters (tq, prop_seg, etc.) are
* provided directly which are then checked and fixed up.
*/
if (!bt->tq && bt->bitrate && btc)
err = can_calc_bittiming(dev, bt, btc);
else if (bt->tq && !bt->bitrate && btc)
err = can_fixup_bittiming(dev, bt, btc);
else if (!bt->tq && bt->bitrate && bitrate_const)
err = can_validate_bitrate(dev, bt, bitrate_const,
bitrate_const_cnt);
else
err = -EINVAL;
return can_calc_bittiming(dev, bt, btc);
if (bt->tq && !bt->bitrate && btc)
return can_fixup_bittiming(dev, bt, btc);
if (!bt->tq && bt->bitrate && bitrate_const)
return can_validate_bitrate(dev, bt, bitrate_const,
bitrate_const_cnt);

return err;
return -EINVAL;
}

0 comments on commit 8e0a0b3

Please sign in to comment.