Commit cf4084cb authored by Pavel Pisa's avatar Pavel Pisa

driver: correct more problems reported by checkpatch.pl.

Signed-off-by: Pavel Pisa's avatarPavel Pisa <pisa@cmp.felk.cvut.cz>
parent 178425cc
This diff is collapsed.
...@@ -68,14 +68,12 @@ u32 ctu_can_fd_read32_be(struct ctucanfd_priv *priv, ...@@ -68,14 +68,12 @@ u32 ctu_can_fd_read32_be(struct ctucanfd_priv *priv,
} }
static void ctu_can_fd_write_txt_buf(struct ctucanfd_priv *priv, static void ctu_can_fd_write_txt_buf(struct ctucanfd_priv *priv,
enum ctu_can_fd_can_registers buf_base, enum ctu_can_fd_can_registers buf_base,
u32 offset, u32 val) u32 offset, u32 val)
{ {
priv->write_reg(priv, buf_base + offset, val); priv->write_reg(priv, buf_base + offset, val);
} }
static inline union ctu_can_fd_identifier_w ctu_can_fd_id_to_hwid(canid_t id) static inline union ctu_can_fd_identifier_w ctu_can_fd_id_to_hwid(canid_t id)
{ {
union ctu_can_fd_identifier_w hwid; union ctu_can_fd_identifier_w hwid;
...@@ -87,8 +85,9 @@ static inline union ctu_can_fd_identifier_w ctu_can_fd_id_to_hwid(canid_t id) ...@@ -87,8 +85,9 @@ static inline union ctu_can_fd_identifier_w ctu_can_fd_id_to_hwid(canid_t id)
/* getting lowest 18 bits, replace with sth nicer... */ /* getting lowest 18 bits, replace with sth nicer... */
hwid.s.identifier_ext = (id & 0x3FFFF); hwid.s.identifier_ext = (id & 0x3FFFF);
} else } else {
hwid.s.identifier_base = id & CAN_SFF_MASK; hwid.s.identifier_base = id & CAN_SFF_MASK;
}
return hwid; return hwid;
} }
...@@ -104,19 +103,17 @@ static inline void ctu_can_fd_hwid_to_id(union ctu_can_fd_identifier_w hwid, ...@@ -104,19 +103,17 @@ static inline void ctu_can_fd_hwid_to_id(union ctu_can_fd_identifier_w hwid,
*id |= CAN_EFF_FLAG; *id |= CAN_EFF_FLAG;
*id |= hwid.s.identifier_base << 18; *id |= hwid.s.identifier_base << 18;
*id |= hwid.s.identifier_ext; *id |= hwid.s.identifier_ext;
} else } else {
*id = hwid.s.identifier_base; *id = hwid.s.identifier_base;
}
} }
// TODO: use can_len2dlc
static bool ctu_can_fd_len_to_dlc(u8 len, u8 *dlc) static bool ctu_can_fd_len_to_dlc(u8 len, u8 *dlc)
{ {
*dlc = can_len2dlc(len); *dlc = can_len2dlc(len);
return true; return true;
} }
bool ctu_can_fd_check_access(struct ctucanfd_priv *priv) bool ctu_can_fd_check_access(struct ctucanfd_priv *priv)
{ {
union ctu_can_fd_device_id_version reg; union ctu_can_fd_device_id_version reg;
...@@ -279,14 +276,14 @@ void ctu_can_fd_set_mode(struct ctucanfd_priv *priv, ...@@ -279,14 +276,14 @@ void ctu_can_fd_set_mode(struct ctucanfd_priv *priv,
if (mode->mask & CAN_CTRLMODE_BERR_REPORTING) { if (mode->mask & CAN_CTRLMODE_BERR_REPORTING) {
union ctu_can_fd_int_stat ena, mask; union ctu_can_fd_int_stat ena, mask;
ena.u32 = mask.u32 = 0; ena.u32 = 0;
mask.u32 = 0;
ena.s.bei = !!(mode->flags & CAN_CTRLMODE_ONE_SHOT); ena.s.bei = !!(mode->flags & CAN_CTRLMODE_ONE_SHOT);
mask.s.bei = 1; mask.s.bei = 1;
ctu_can_fd_int_ena(priv, ena, mask); ctu_can_fd_int_ena(priv, ena, mask);
} }
} }
const struct can_bittiming_const ctu_can_fd_bit_timing_max = { const struct can_bittiming_const ctu_can_fd_bit_timing_max = {
.name = "ctu_can_fd", .name = "ctu_can_fd",
.tseg1_min = 2, .tseg1_min = 2,
...@@ -316,8 +313,7 @@ void ctu_can_fd_set_nom_bittiming(struct ctucanfd_priv *priv, ...@@ -316,8 +313,7 @@ void ctu_can_fd_set_nom_bittiming(struct ctucanfd_priv *priv,
{ {
union ctu_can_fd_btr btr; union ctu_can_fd_btr btr;
/* /* The timing calculation functions have only constraints on tseg1,
* The timing calculation functions have only constraints on tseg1,
* which is prop_seg + phase1_seg combined. tseg1 is then split in half * which is prop_seg + phase1_seg combined. tseg1 is then split in half
* and stored into prog_seg and phase_seg1. In CTU CAN FD, PROP is * and stored into prog_seg and phase_seg1. In CTU CAN FD, PROP is
* 7 bits wide but PH1 only 6, so we must re-distribute the values here. * 7 bits wide but PH1 only 6, so we must re-distribute the values here.
...@@ -347,8 +343,7 @@ void ctu_can_fd_set_data_bittiming(struct ctucanfd_priv *priv, ...@@ -347,8 +343,7 @@ void ctu_can_fd_set_data_bittiming(struct ctucanfd_priv *priv,
{ {
union ctu_can_fd_btr_fd btr_fd; union ctu_can_fd_btr_fd btr_fd;
/* /* The timing calculation functions have only constraints on tseg1,
* The timing calculation functions have only constraints on tseg1,
* which is prop_seg + phase1_seg combined. tseg1 is then split in half * which is prop_seg + phase1_seg combined. tseg1 is then split in half
* and stored into prog_seg and phase_seg1. In CTU CAN FD, PROP_FD is * and stored into prog_seg and phase_seg1. In CTU CAN FD, PROP_FD is
* 6 bits wide but PH1_FD only 5, so we must re-distribute the values * 6 bits wide but PH1_FD only 5, so we must re-distribute the values
...@@ -410,10 +405,11 @@ enum can_state ctu_can_fd_read_error_state(struct ctucanfd_priv *priv) ...@@ -410,10 +405,11 @@ enum can_state ctu_can_fd_read_error_state(struct ctucanfd_priv *priv)
return CAN_STATE_ERROR_ACTIVE; return CAN_STATE_ERROR_ACTIVE;
else else
return CAN_STATE_ERROR_WARNING; return CAN_STATE_ERROR_WARNING;
} else if (reg.s.erp) } else if (reg.s.erp) {
return CAN_STATE_ERROR_PASSIVE; return CAN_STATE_ERROR_PASSIVE;
else if (reg.s.bof) } else if (reg.s.bof) {
return CAN_STATE_BUS_OFF; return CAN_STATE_BUS_OFF;
}
WARN(true, "Invalid error state"); WARN(true, "Invalid error state");
return CAN_STATE_ERROR_PASSIVE; return CAN_STATE_ERROR_PASSIVE;
} }
...@@ -435,7 +431,6 @@ void ctu_can_fd_set_err_ctrs(struct ctucanfd_priv *priv, ...@@ -435,7 +431,6 @@ void ctu_can_fd_set_err_ctrs(struct ctucanfd_priv *priv,
priv->write_reg(priv, CTU_CAN_FD_CTR_PRES, reg.u32); priv->write_reg(priv, CTU_CAN_FD_CTR_PRES, reg.u32);
} }
bool ctu_can_fd_get_mask_filter_support(struct ctucanfd_priv *priv, u8 fnum) bool ctu_can_fd_get_mask_filter_support(struct ctucanfd_priv *priv, u8 fnum)
{ {
union ctu_can_fd_filter_control_filter_status reg; union ctu_can_fd_filter_control_filter_status reg;
...@@ -568,8 +563,8 @@ void ctu_can_fd_read_rx_frame(struct ctucanfd_priv *priv, ...@@ -568,8 +563,8 @@ void ctu_can_fd_read_rx_frame(struct ctucanfd_priv *priv,
} }
void ctu_can_fd_read_rx_frame_ffw(struct ctucanfd_priv *priv, void ctu_can_fd_read_rx_frame_ffw(struct ctucanfd_priv *priv,
struct canfd_frame *cf, u64 *ts, struct canfd_frame *cf, u64 *ts,
union ctu_can_fd_frame_form_w ffw) union ctu_can_fd_frame_form_w ffw)
{ {
union ctu_can_fd_identifier_w idw; union ctu_can_fd_identifier_w idw;
unsigned int i; unsigned int i;
...@@ -585,8 +580,9 @@ void ctu_can_fd_read_rx_frame_ffw(struct ctucanfd_priv *priv, ...@@ -585,8 +580,9 @@ void ctu_can_fd_read_rx_frame_ffw(struct ctucanfd_priv *priv,
cf->flags |= CANFD_BRS; cf->flags |= CANFD_BRS;
if (ffw.s.esi_rsv == ESI_ERR_PASIVE) if (ffw.s.esi_rsv == ESI_ERR_PASIVE)
cf->flags |= CANFD_ESI; cf->flags |= CANFD_ESI;
} else if (ffw.s.rtr == RTR_FRAME) } else if (ffw.s.rtr == RTR_FRAME) {
cf->can_id |= CAN_RTR_FLAG; cf->can_id |= CAN_RTR_FLAG;
}
/* DLC */ /* DLC */
if (ffw.s.dlc <= 8) { if (ffw.s.dlc <= 8) {
...@@ -598,7 +594,7 @@ void ctu_can_fd_read_rx_frame_ffw(struct ctucanfd_priv *priv, ...@@ -598,7 +594,7 @@ void ctu_can_fd_read_rx_frame_ffw(struct ctucanfd_priv *priv,
cf->len = 8; cf->len = 8;
} }
ide = (enum ctu_can_fd_frame_form_w_ide) ffw.s.ide; ide = (enum ctu_can_fd_frame_form_w_ide)ffw.s.ide;
ctu_can_fd_hwid_to_id(idw, &cf->can_id, ide); ctu_can_fd_hwid_to_id(idw, &cf->can_id, ide);
/* Timestamp */ /* Timestamp */
...@@ -636,7 +632,7 @@ enum ctu_can_fd_tx_status_tx1s ctu_can_fd_get_tx_status(struct ctucanfd_priv ...@@ -636,7 +632,7 @@ enum ctu_can_fd_tx_status_tx1s ctu_can_fd_get_tx_status(struct ctucanfd_priv
default: default:
status = ~0; status = ~0;
} }
return (enum ctu_can_fd_tx_status_tx1s) status; return (enum ctu_can_fd_tx_status_tx1s)status;
} }
bool ctu_can_fd_is_txt_buf_accessible(struct ctucanfd_priv *priv, u8 buf) bool ctu_can_fd_is_txt_buf_accessible(struct ctucanfd_priv *priv, u8 buf)
...@@ -644,8 +640,8 @@ bool ctu_can_fd_is_txt_buf_accessible(struct ctucanfd_priv *priv, u8 buf) ...@@ -644,8 +640,8 @@ bool ctu_can_fd_is_txt_buf_accessible(struct ctucanfd_priv *priv, u8 buf)
enum ctu_can_fd_tx_status_tx1s buf_status; enum ctu_can_fd_tx_status_tx1s buf_status;
buf_status = ctu_can_fd_get_tx_status(priv, buf); buf_status = ctu_can_fd_get_tx_status(priv, buf);
if (buf_status == TXT_RDY || buf_status == TXT_TRAN if (buf_status == TXT_RDY || buf_status == TXT_TRAN ||
|| buf_status == TXT_ABTP) buf_status == TXT_ABTP)
return false; return false;
return true; return true;
...@@ -780,15 +776,15 @@ u64 ctu_can_fd_read_timestamp(struct ctucanfd_priv *priv) ...@@ -780,15 +776,15 @@ u64 ctu_can_fd_read_timestamp(struct ctucanfd_priv *priv)
union ctu_can_fd_timestamp_high ts_high; union ctu_can_fd_timestamp_high ts_high;
union ctu_can_fd_timestamp_high ts_high_2; union ctu_can_fd_timestamp_high ts_high_2;
ts_high.u32 = priv->read_reg(priv, CTU_CAN_FD_TIMESTAMP_HIGH); ts_high.u32 = priv->read_reg(priv, CTU_CAN_FD_TIMESTAMP_HIGH);
ts_low.u32 = priv->read_reg(priv, CTU_CAN_FD_TIMESTAMP_LOW); ts_low.u32 = priv->read_reg(priv, CTU_CAN_FD_TIMESTAMP_LOW);
ts_high_2.u32 = priv->read_reg(priv, CTU_CAN_FD_TIMESTAMP_HIGH); ts_high_2.u32 = priv->read_reg(priv, CTU_CAN_FD_TIMESTAMP_HIGH);
if (ts_high.u32 != ts_high_2.u32){ if (ts_high.u32 != ts_high_2.u32) {
ts_low.u32 = priv->read_reg(priv, CTU_CAN_FD_TIMESTAMP_LOW); ts_low.u32 = priv->read_reg(priv, CTU_CAN_FD_TIMESTAMP_LOW);
} }
return (( (u64) ts_high_2.u32) << 32) | ( (u64) ts_low.u32); return (((u64)ts_high_2.u32) << 32) | ((u64)ts_low.u32);
} }
// TODO: AL_CAPTURE and ERROR_CAPTURE // TODO: AL_CAPTURE and ERROR_CAPTURE
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment