Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

can: bittiming: can_changelink() pass extack down callstack

This is a preparation patch.

In order to pass warning/error messages during netlink calls back to
user space, pass the extack struct down the callstack of
can_changelink(), the actual error messages will be added in the
following ptaches.

Link: https://lore.kernel.org/all/20230202110854.2318594-10-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

+17 -11
+9 -6
drivers/net/can/dev/bittiming.c
··· 12 12 * file linux/can/netlink.h. 13 13 */ 14 14 static int can_fixup_bittiming(const struct net_device *dev, struct can_bittiming *bt, 15 - const struct can_bittiming_const *btc) 15 + const struct can_bittiming_const *btc, 16 + struct netlink_ext_ack *extack) 16 17 { 17 18 const struct can_priv *priv = netdev_priv(dev); 18 19 unsigned int tseg1; ··· 51 50 static int 52 51 can_validate_bitrate(const struct net_device *dev, const struct can_bittiming *bt, 53 52 const u32 *bitrate_const, 54 - const unsigned int bitrate_const_cnt) 53 + const unsigned int bitrate_const_cnt, 54 + struct netlink_ext_ack *extack) 55 55 { 56 56 unsigned int i; 57 57 ··· 67 65 int can_get_bittiming(const struct net_device *dev, struct can_bittiming *bt, 68 66 const struct can_bittiming_const *btc, 69 67 const u32 *bitrate_const, 70 - const unsigned int bitrate_const_cnt) 68 + const unsigned int bitrate_const_cnt, 69 + struct netlink_ext_ack *extack) 71 70 { 72 71 /* Depending on the given can_bittiming parameter structure the CAN 73 72 * timing parameters are calculated based on the provided bitrate OR ··· 76 73 * provided directly which are then checked and fixed up. 77 74 */ 78 75 if (!bt->tq && bt->bitrate && btc) 79 - return can_calc_bittiming(dev, bt, btc); 76 + return can_calc_bittiming(dev, bt, btc, extack); 80 77 if (bt->tq && !bt->bitrate && btc) 81 - return can_fixup_bittiming(dev, bt, btc); 78 + return can_fixup_bittiming(dev, bt, btc, extack); 82 79 if (!bt->tq && bt->bitrate && bitrate_const) 83 80 return can_validate_bitrate(dev, bt, bitrate_const, 84 - bitrate_const_cnt); 81 + bitrate_const_cnt, extack); 85 82 86 83 return -EINVAL; 87 84 }
+1 -1
drivers/net/can/dev/calc_bittiming.c
··· 63 63 } 64 64 65 65 int can_calc_bittiming(const struct net_device *dev, struct can_bittiming *bt, 66 - const struct can_bittiming_const *btc) 66 + const struct can_bittiming_const *btc, struct netlink_ext_ack *extack) 67 67 { 68 68 struct can_priv *priv = netdev_priv(dev); 69 69 unsigned int bitrate; /* current bitrate */
+4 -2
drivers/net/can/dev/netlink.c
··· 215 215 err = can_get_bittiming(dev, &bt, 216 216 priv->bittiming_const, 217 217 priv->bitrate_const, 218 - priv->bitrate_const_cnt); 218 + priv->bitrate_const_cnt, 219 + extack); 219 220 if (err) 220 221 return err; 221 222 ··· 321 320 err = can_get_bittiming(dev, &dbt, 322 321 priv->data_bittiming_const, 323 322 priv->data_bitrate_const, 324 - priv->data_bitrate_const_cnt); 323 + priv->data_bitrate_const_cnt, 324 + extack); 325 325 if (err) 326 326 return err; 327 327
+3 -2
include/linux/can/bittiming.h
··· 116 116 117 117 #ifdef CONFIG_CAN_CALC_BITTIMING 118 118 int can_calc_bittiming(const struct net_device *dev, struct can_bittiming *bt, 119 - const struct can_bittiming_const *btc); 119 + const struct can_bittiming_const *btc, struct netlink_ext_ack *extack); 120 120 121 121 void can_calc_tdco(struct can_tdc *tdc, const struct can_tdc_const *tdc_const, 122 122 const struct can_bittiming *dbt, ··· 141 141 int can_get_bittiming(const struct net_device *dev, struct can_bittiming *bt, 142 142 const struct can_bittiming_const *btc, 143 143 const u32 *bitrate_const, 144 - const unsigned int bitrate_const_cnt); 144 + const unsigned int bitrate_const_cnt, 145 + struct netlink_ext_ack *extack); 145 146 146 147 /* 147 148 * can_bit_time() - Duration of one bit