diff options
author | Marc Kleine-Budde <mkl@pengutronix.de> | 2019-08-27 07:53:18 -0400 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2019-09-03 04:28:13 -0400 |
commit | d7bda73070201514d0d254f451c11bcc9b5890f1 (patch) | |
tree | 2c9f6edbf92cdb61486f19618fc97770ddb3c9db | |
parent | ee9a5f5e554d77e13473c2dcf0c672df646d96fd (diff) |
can: dev: avoid long lines
This patch fixes long lines in the generic CAN device infrastructure.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
-rw-r--r-- | drivers/net/can/dev.c | 43 | ||||
-rw-r--r-- | include/linux/can/dev.h | 3 | ||||
-rw-r--r-- | include/linux/can/rx-offload.h | 13 |
3 files changed, 38 insertions, 21 deletions
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c index b6fe39a26a9b..9f58c4f0344d 100644 --- a/drivers/net/can/dev.c +++ b/drivers/net/can/dev.c | |||
@@ -73,10 +73,11 @@ EXPORT_SYMBOL_GPL(can_len2dlc); | |||
73 | * registers of the CAN controller. You can find more information | 73 | * registers of the CAN controller. You can find more information |
74 | * in the header file linux/can/netlink.h. | 74 | * in the header file linux/can/netlink.h. |
75 | */ | 75 | */ |
76 | static int can_update_sample_point(const struct can_bittiming_const *btc, | 76 | static int |
77 | unsigned int sample_point_nominal, unsigned int tseg, | 77 | can_update_sample_point(const struct can_bittiming_const *btc, |
78 | unsigned int *tseg1_ptr, unsigned int *tseg2_ptr, | 78 | unsigned int sample_point_nominal, unsigned int tseg, |
79 | unsigned int *sample_point_error_ptr) | 79 | unsigned int *tseg1_ptr, unsigned int *tseg2_ptr, |
80 | unsigned int *sample_point_error_ptr) | ||
80 | { | 81 | { |
81 | unsigned int sample_point_error, best_sample_point_error = UINT_MAX; | 82 | unsigned int sample_point_error, best_sample_point_error = UINT_MAX; |
82 | unsigned int sample_point, best_sample_point = 0; | 83 | unsigned int sample_point, best_sample_point = 0; |
@@ -84,7 +85,9 @@ static int can_update_sample_point(const struct can_bittiming_const *btc, | |||
84 | int i; | 85 | int i; |
85 | 86 | ||
86 | for (i = 0; i <= 1; i++) { | 87 | for (i = 0; i <= 1; i++) { |
87 | tseg2 = tseg + CAN_CALC_SYNC_SEG - (sample_point_nominal * (tseg + CAN_CALC_SYNC_SEG)) / 1000 - i; | 88 | tseg2 = tseg + CAN_CALC_SYNC_SEG - |
89 | (sample_point_nominal * (tseg + CAN_CALC_SYNC_SEG)) / | ||
90 | 1000 - i; | ||
88 | tseg2 = clamp(tseg2, btc->tseg2_min, btc->tseg2_max); | 91 | tseg2 = clamp(tseg2, btc->tseg2_min, btc->tseg2_max); |
89 | tseg1 = tseg - tseg2; | 92 | tseg1 = tseg - tseg2; |
90 | if (tseg1 > btc->tseg1_max) { | 93 | if (tseg1 > btc->tseg1_max) { |
@@ -92,10 +95,12 @@ static int can_update_sample_point(const struct can_bittiming_const *btc, | |||
92 | tseg2 = tseg - tseg1; | 95 | tseg2 = tseg - tseg1; |
93 | } | 96 | } |
94 | 97 | ||
95 | sample_point = 1000 * (tseg + CAN_CALC_SYNC_SEG - tseg2) / (tseg + CAN_CALC_SYNC_SEG); | 98 | sample_point = 1000 * (tseg + CAN_CALC_SYNC_SEG - tseg2) / |
99 | (tseg + CAN_CALC_SYNC_SEG); | ||
96 | sample_point_error = abs(sample_point_nominal - sample_point); | 100 | sample_point_error = abs(sample_point_nominal - sample_point); |
97 | 101 | ||
98 | if ((sample_point <= sample_point_nominal) && (sample_point_error < best_sample_point_error)) { | 102 | if ((sample_point <= sample_point_nominal) && |
103 | (sample_point_error < best_sample_point_error)) { | ||
99 | best_sample_point = sample_point; | 104 | best_sample_point = sample_point; |
100 | best_sample_point_error = sample_point_error; | 105 | best_sample_point_error = sample_point_error; |
101 | *tseg1_ptr = tseg1; | 106 | *tseg1_ptr = tseg1; |
@@ -160,7 +165,8 @@ static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt, | |||
160 | if (bitrate_error < best_bitrate_error) | 165 | if (bitrate_error < best_bitrate_error) |
161 | best_sample_point_error = UINT_MAX; | 166 | best_sample_point_error = UINT_MAX; |
162 | 167 | ||
163 | can_update_sample_point(btc, sample_point_nominal, tseg / 2, &tseg1, &tseg2, &sample_point_error); | 168 | can_update_sample_point(btc, sample_point_nominal, tseg / 2, |
169 | &tseg1, &tseg2, &sample_point_error); | ||
164 | if (sample_point_error > best_sample_point_error) | 170 | if (sample_point_error > best_sample_point_error) |
165 | continue; | 171 | continue; |
166 | 172 | ||
@@ -189,8 +195,9 @@ static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt, | |||
189 | } | 195 | } |
190 | 196 | ||
191 | /* real sample point */ | 197 | /* real sample point */ |
192 | bt->sample_point = can_update_sample_point(btc, sample_point_nominal, best_tseg, | 198 | bt->sample_point = can_update_sample_point(btc, sample_point_nominal, |
193 | &tseg1, &tseg2, NULL); | 199 | best_tseg, &tseg1, &tseg2, |
200 | NULL); | ||
194 | 201 | ||
195 | v64 = (u64)best_brp * 1000 * 1000 * 1000; | 202 | v64 = (u64)best_brp * 1000 * 1000 * 1000; |
196 | do_div(v64, priv->clock.freq); | 203 | do_div(v64, priv->clock.freq); |
@@ -214,7 +221,8 @@ static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt, | |||
214 | bt->brp = best_brp; | 221 | bt->brp = best_brp; |
215 | 222 | ||
216 | /* real bitrate */ | 223 | /* real bitrate */ |
217 | bt->bitrate = priv->clock.freq / (bt->brp * (CAN_CALC_SYNC_SEG + tseg1 + tseg2)); | 224 | bt->bitrate = priv->clock.freq / |
225 | (bt->brp * (CAN_CALC_SYNC_SEG + tseg1 + tseg2)); | ||
218 | 226 | ||
219 | return 0; | 227 | return 0; |
220 | } | 228 | } |
@@ -267,9 +275,10 @@ static int can_fixup_bittiming(struct net_device *dev, struct can_bittiming *bt, | |||
267 | } | 275 | } |
268 | 276 | ||
269 | /* Checks the validity of predefined bitrate settings */ | 277 | /* Checks the validity of predefined bitrate settings */ |
270 | static int can_validate_bitrate(struct net_device *dev, struct can_bittiming *bt, | 278 | static int |
271 | const u32 *bitrate_const, | 279 | can_validate_bitrate(struct net_device *dev, struct can_bittiming *bt, |
272 | const unsigned int bitrate_const_cnt) | 280 | const u32 *bitrate_const, |
281 | const unsigned int bitrate_const_cnt) | ||
273 | { | 282 | { |
274 | struct can_priv *priv = netdev_priv(dev); | 283 | struct can_priv *priv = netdev_priv(dev); |
275 | unsigned int i; | 284 | unsigned int i; |
@@ -460,7 +469,8 @@ void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, | |||
460 | } | 469 | } |
461 | EXPORT_SYMBOL_GPL(can_put_echo_skb); | 470 | EXPORT_SYMBOL_GPL(can_put_echo_skb); |
462 | 471 | ||
463 | struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr) | 472 | struct sk_buff * |
473 | __can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr) | ||
464 | { | 474 | { |
465 | struct can_priv *priv = netdev_priv(dev); | 475 | struct can_priv *priv = netdev_priv(dev); |
466 | 476 | ||
@@ -569,7 +579,8 @@ restart: | |||
569 | static void can_restart_work(struct work_struct *work) | 579 | static void can_restart_work(struct work_struct *work) |
570 | { | 580 | { |
571 | struct delayed_work *dwork = to_delayed_work(work); | 581 | struct delayed_work *dwork = to_delayed_work(work); |
572 | struct can_priv *priv = container_of(dwork, struct can_priv, restart_work); | 582 | struct can_priv *priv = container_of(dwork, struct can_priv, |
583 | restart_work); | ||
573 | 584 | ||
574 | can_restart(priv->dev); | 585 | can_restart(priv->dev); |
575 | } | 586 | } |
diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h index f01623aef2f7..9b3c720a31b1 100644 --- a/include/linux/can/dev.h +++ b/include/linux/can/dev.h | |||
@@ -169,7 +169,8 @@ void can_change_state(struct net_device *dev, struct can_frame *cf, | |||
169 | 169 | ||
170 | void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, | 170 | void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, |
171 | unsigned int idx); | 171 | unsigned int idx); |
172 | struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr); | 172 | struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx, |
173 | u8 *len_ptr); | ||
173 | unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx); | 174 | unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx); |
174 | void can_free_echo_skb(struct net_device *dev, unsigned int idx); | 175 | void can_free_echo_skb(struct net_device *dev, unsigned int idx); |
175 | 176 | ||
diff --git a/include/linux/can/rx-offload.h b/include/linux/can/rx-offload.h index 9daa1119ea42..01219f2902bf 100644 --- a/include/linux/can/rx-offload.h +++ b/include/linux/can/rx-offload.h | |||
@@ -15,7 +15,8 @@ | |||
15 | struct can_rx_offload { | 15 | struct can_rx_offload { |
16 | struct net_device *dev; | 16 | struct net_device *dev; |
17 | 17 | ||
18 | unsigned int (*mailbox_read)(struct can_rx_offload *offload, struct can_frame *cf, | 18 | unsigned int (*mailbox_read)(struct can_rx_offload *offload, |
19 | struct can_frame *cf, | ||
19 | u32 *timestamp, unsigned int mb); | 20 | u32 *timestamp, unsigned int mb); |
20 | 21 | ||
21 | struct sk_buff_head skb_queue; | 22 | struct sk_buff_head skb_queue; |
@@ -29,9 +30,13 @@ struct can_rx_offload { | |||
29 | bool inc; | 30 | bool inc; |
30 | }; | 31 | }; |
31 | 32 | ||
32 | int can_rx_offload_add_timestamp(struct net_device *dev, struct can_rx_offload *offload); | 33 | int can_rx_offload_add_timestamp(struct net_device *dev, |
33 | int can_rx_offload_add_fifo(struct net_device *dev, struct can_rx_offload *offload, unsigned int weight); | 34 | struct can_rx_offload *offload); |
34 | int can_rx_offload_irq_offload_timestamp(struct can_rx_offload *offload, u64 reg); | 35 | int can_rx_offload_add_fifo(struct net_device *dev, |
36 | struct can_rx_offload *offload, | ||
37 | unsigned int weight); | ||
38 | int can_rx_offload_irq_offload_timestamp(struct can_rx_offload *offload, | ||
39 | u64 reg); | ||
35 | int can_rx_offload_irq_offload_fifo(struct can_rx_offload *offload); | 40 | int can_rx_offload_irq_offload_fifo(struct can_rx_offload *offload); |
36 | int can_rx_offload_queue_sorted(struct can_rx_offload *offload, | 41 | int can_rx_offload_queue_sorted(struct can_rx_offload *offload, |
37 | struct sk_buff *skb, u32 timestamp); | 42 | struct sk_buff *skb, u32 timestamp); |