mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-07 15:15:29 +00:00
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>
This commit is contained in:
parent
ee9a5f5e55
commit
d7bda73070
3 changed files with 38 additions and 21 deletions
|
@ -73,10 +73,11 @@ EXPORT_SYMBOL_GPL(can_len2dlc);
|
||||||
* registers of the CAN controller. You can find more information
|
* registers of the CAN controller. You can find more information
|
||||||
* in the header file linux/can/netlink.h.
|
* in the header file linux/can/netlink.h.
|
||||||
*/
|
*/
|
||||||
static int can_update_sample_point(const struct can_bittiming_const *btc,
|
static int
|
||||||
unsigned int sample_point_nominal, unsigned int tseg,
|
can_update_sample_point(const struct can_bittiming_const *btc,
|
||||||
unsigned int *tseg1_ptr, unsigned int *tseg2_ptr,
|
unsigned int sample_point_nominal, unsigned int tseg,
|
||||||
unsigned int *sample_point_error_ptr)
|
unsigned int *tseg1_ptr, unsigned int *tseg2_ptr,
|
||||||
|
unsigned int *sample_point_error_ptr)
|
||||||
{
|
{
|
||||||
unsigned int sample_point_error, best_sample_point_error = UINT_MAX;
|
unsigned int sample_point_error, best_sample_point_error = UINT_MAX;
|
||||||
unsigned int sample_point, best_sample_point = 0;
|
unsigned int sample_point, best_sample_point = 0;
|
||||||
|
@ -84,7 +85,9 @@ static int can_update_sample_point(const struct can_bittiming_const *btc,
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i <= 1; i++) {
|
for (i = 0; i <= 1; i++) {
|
||||||
tseg2 = tseg + CAN_CALC_SYNC_SEG - (sample_point_nominal * (tseg + CAN_CALC_SYNC_SEG)) / 1000 - i;
|
tseg2 = tseg + CAN_CALC_SYNC_SEG -
|
||||||
|
(sample_point_nominal * (tseg + CAN_CALC_SYNC_SEG)) /
|
||||||
|
1000 - i;
|
||||||
tseg2 = clamp(tseg2, btc->tseg2_min, btc->tseg2_max);
|
tseg2 = clamp(tseg2, btc->tseg2_min, btc->tseg2_max);
|
||||||
tseg1 = tseg - tseg2;
|
tseg1 = tseg - tseg2;
|
||||||
if (tseg1 > btc->tseg1_max) {
|
if (tseg1 > btc->tseg1_max) {
|
||||||
|
@ -92,10 +95,12 @@ static int can_update_sample_point(const struct can_bittiming_const *btc,
|
||||||
tseg2 = tseg - tseg1;
|
tseg2 = tseg - tseg1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sample_point = 1000 * (tseg + CAN_CALC_SYNC_SEG - tseg2) / (tseg + CAN_CALC_SYNC_SEG);
|
sample_point = 1000 * (tseg + CAN_CALC_SYNC_SEG - tseg2) /
|
||||||
|
(tseg + CAN_CALC_SYNC_SEG);
|
||||||
sample_point_error = abs(sample_point_nominal - sample_point);
|
sample_point_error = abs(sample_point_nominal - sample_point);
|
||||||
|
|
||||||
if ((sample_point <= sample_point_nominal) && (sample_point_error < best_sample_point_error)) {
|
if ((sample_point <= sample_point_nominal) &&
|
||||||
|
(sample_point_error < best_sample_point_error)) {
|
||||||
best_sample_point = sample_point;
|
best_sample_point = sample_point;
|
||||||
best_sample_point_error = sample_point_error;
|
best_sample_point_error = sample_point_error;
|
||||||
*tseg1_ptr = tseg1;
|
*tseg1_ptr = tseg1;
|
||||||
|
@ -160,7 +165,8 @@ static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt,
|
||||||
if (bitrate_error < best_bitrate_error)
|
if (bitrate_error < best_bitrate_error)
|
||||||
best_sample_point_error = UINT_MAX;
|
best_sample_point_error = UINT_MAX;
|
||||||
|
|
||||||
can_update_sample_point(btc, sample_point_nominal, tseg / 2, &tseg1, &tseg2, &sample_point_error);
|
can_update_sample_point(btc, sample_point_nominal, tseg / 2,
|
||||||
|
&tseg1, &tseg2, &sample_point_error);
|
||||||
if (sample_point_error > best_sample_point_error)
|
if (sample_point_error > best_sample_point_error)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -189,8 +195,9 @@ static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* real sample point */
|
/* real sample point */
|
||||||
bt->sample_point = can_update_sample_point(btc, sample_point_nominal, best_tseg,
|
bt->sample_point = can_update_sample_point(btc, sample_point_nominal,
|
||||||
&tseg1, &tseg2, NULL);
|
best_tseg, &tseg1, &tseg2,
|
||||||
|
NULL);
|
||||||
|
|
||||||
v64 = (u64)best_brp * 1000 * 1000 * 1000;
|
v64 = (u64)best_brp * 1000 * 1000 * 1000;
|
||||||
do_div(v64, priv->clock.freq);
|
do_div(v64, priv->clock.freq);
|
||||||
|
@ -214,7 +221,8 @@ static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt,
|
||||||
bt->brp = best_brp;
|
bt->brp = best_brp;
|
||||||
|
|
||||||
/* real bitrate */
|
/* real bitrate */
|
||||||
bt->bitrate = priv->clock.freq / (bt->brp * (CAN_CALC_SYNC_SEG + tseg1 + tseg2));
|
bt->bitrate = priv->clock.freq /
|
||||||
|
(bt->brp * (CAN_CALC_SYNC_SEG + tseg1 + tseg2));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -267,9 +275,10 @@ static int can_fixup_bittiming(struct net_device *dev, struct can_bittiming *bt,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Checks the validity of predefined bitrate settings */
|
/* Checks the validity of predefined bitrate settings */
|
||||||
static int can_validate_bitrate(struct net_device *dev, struct can_bittiming *bt,
|
static int
|
||||||
const u32 *bitrate_const,
|
can_validate_bitrate(struct net_device *dev, struct can_bittiming *bt,
|
||||||
const unsigned int bitrate_const_cnt)
|
const u32 *bitrate_const,
|
||||||
|
const unsigned int bitrate_const_cnt)
|
||||||
{
|
{
|
||||||
struct can_priv *priv = netdev_priv(dev);
|
struct can_priv *priv = netdev_priv(dev);
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
@ -460,7 +469,8 @@ void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(can_put_echo_skb);
|
EXPORT_SYMBOL_GPL(can_put_echo_skb);
|
||||||
|
|
||||||
struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr)
|
struct sk_buff *
|
||||||
|
__can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr)
|
||||||
{
|
{
|
||||||
struct can_priv *priv = netdev_priv(dev);
|
struct can_priv *priv = netdev_priv(dev);
|
||||||
|
|
||||||
|
@ -569,7 +579,8 @@ restart:
|
||||||
static void can_restart_work(struct work_struct *work)
|
static void can_restart_work(struct work_struct *work)
|
||||||
{
|
{
|
||||||
struct delayed_work *dwork = to_delayed_work(work);
|
struct delayed_work *dwork = to_delayed_work(work);
|
||||||
struct can_priv *priv = container_of(dwork, struct can_priv, restart_work);
|
struct can_priv *priv = container_of(dwork, struct can_priv,
|
||||||
|
restart_work);
|
||||||
|
|
||||||
can_restart(priv->dev);
|
can_restart(priv->dev);
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,7 +169,8 @@ void can_change_state(struct net_device *dev, struct can_frame *cf,
|
||||||
|
|
||||||
void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
|
void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
|
||||||
unsigned int idx);
|
unsigned int idx);
|
||||||
struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr);
|
struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx,
|
||||||
|
u8 *len_ptr);
|
||||||
unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx);
|
unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx);
|
||||||
void can_free_echo_skb(struct net_device *dev, unsigned int idx);
|
void can_free_echo_skb(struct net_device *dev, unsigned int idx);
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
struct can_rx_offload {
|
struct can_rx_offload {
|
||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
|
|
||||||
unsigned int (*mailbox_read)(struct can_rx_offload *offload, struct can_frame *cf,
|
unsigned int (*mailbox_read)(struct can_rx_offload *offload,
|
||||||
|
struct can_frame *cf,
|
||||||
u32 *timestamp, unsigned int mb);
|
u32 *timestamp, unsigned int mb);
|
||||||
|
|
||||||
struct sk_buff_head skb_queue;
|
struct sk_buff_head skb_queue;
|
||||||
|
@ -29,9 +30,13 @@ struct can_rx_offload {
|
||||||
bool inc;
|
bool inc;
|
||||||
};
|
};
|
||||||
|
|
||||||
int can_rx_offload_add_timestamp(struct net_device *dev, struct can_rx_offload *offload);
|
int can_rx_offload_add_timestamp(struct net_device *dev,
|
||||||
int can_rx_offload_add_fifo(struct net_device *dev, struct can_rx_offload *offload, unsigned int weight);
|
struct can_rx_offload *offload);
|
||||||
int can_rx_offload_irq_offload_timestamp(struct can_rx_offload *offload, u64 reg);
|
int can_rx_offload_add_fifo(struct net_device *dev,
|
||||||
|
struct can_rx_offload *offload,
|
||||||
|
unsigned int weight);
|
||||||
|
int can_rx_offload_irq_offload_timestamp(struct can_rx_offload *offload,
|
||||||
|
u64 reg);
|
||||||
int can_rx_offload_irq_offload_fifo(struct can_rx_offload *offload);
|
int can_rx_offload_irq_offload_fifo(struct can_rx_offload *offload);
|
||||||
int can_rx_offload_queue_sorted(struct can_rx_offload *offload,
|
int can_rx_offload_queue_sorted(struct can_rx_offload *offload,
|
||||||
struct sk_buff *skb, u32 timestamp);
|
struct sk_buff *skb, u32 timestamp);
|
||||||
|
|
Loading…
Add table
Reference in a new issue