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
......@@ -65,8 +65,7 @@ static bool pci_use_second = 1;
module_param(pci_use_second, bool, 0444);
MODULE_PARM_DESC(pci_use_second, "Use the second CAN core on PCIe card. Default: 1 (yes)");
/*
* TX buffer rotation:
/* TX buffer rotation:
* - when a buffer transitions to empty state, rotate order and priorities
* - if more buffers seem to transition at the same time, rotate
* by the number of buffers
......@@ -108,15 +107,13 @@ static int ctucan_reset(struct net_device *ndev)
for (i = 0; i < 100; ++i) {
if (ctu_can_fd_check_access(&priv->p))
return 0;
udelay(100);
usleep_range(100, 200);
}
netdev_warn(ndev, "device did not leave reset\n");
return -ETIMEDOUT;
}
/**
* ctucan_set_bittiming - CAN set bit timing routine
* @ndev: Pointer to net_device structure
......@@ -143,7 +140,6 @@ static int ctucan_set_bittiming(struct net_device *ndev)
return 0;
}
/**
* ctucan_set_data_bittiming - CAN set data bit timing routine
* @ndev: Pointer to net_device structure
......@@ -196,7 +192,6 @@ static int ctucan_chip_start(struct net_device *ndev)
priv->txb_tail = 0;
priv->p.write_reg(&priv->p, CTU_CAN_FD_TX_PRIORITY, priv->txb_prio);
err = ctucan_set_bittiming(ndev);
if (err < 0)
return err;
......@@ -205,7 +200,6 @@ static int ctucan_chip_start(struct net_device *ndev)
if (err < 0)
return err;
/* Enable interrupts */
int_ena.u32 = 0;
int_ena.s.rbnei = 1;
......@@ -279,7 +273,6 @@ static int ctucan_do_set_mode(struct net_device *ndev, enum can_mode mode)
return ret;
}
/**
* ctucan_start_xmit - Starts the transmission
* @skb: sk_buff pointer that contains data to be Txed
......@@ -302,7 +295,6 @@ static int ctucan_start_xmit(struct sk_buff *skb, struct net_device *ndev)
if (can_dropped_invalid_skb(ndev, skb))
return NETDEV_TX_OK;
/* Check if the TX buffer is full */
if (unlikely(!CTU_CAN_FD_TXTNF(ctu_can_get_status(&priv->p)))) {
netif_stop_queue(ndev);
......@@ -357,7 +349,7 @@ static int ctucan_rx(struct net_device *ndev)
if (ffw.s.fdf == FD_CAN)
skb = alloc_canfd_skb(ndev, &cf);
else
skb = alloc_can_skb(ndev, (struct can_frame **) &cf);
skb = alloc_can_skb(ndev, (struct can_frame **)&cf);
if (unlikely(!skb)) {
int i;
......@@ -403,8 +395,7 @@ static void ctucan_err_interrupt(struct net_device *ndev,
skb = alloc_can_err_skb(ndev, &cf);
/*
* EWI: error warning
/* EWI: error warning
* DOI: RX overrun
* EPI: error passive or bus off
* ALI: arbitration lost (just informative)
......@@ -577,7 +568,7 @@ static void ctucan_rotate_txb_prio(struct net_device *ndev)
u32 prio = priv->txb_prio;
u32 nbuffersm1 = priv->txb_mask; /* nbuffers - 1 */
prio = (prio << 4) | ((prio >> (nbuffersm1*4)) & 0xF);
prio = (prio << 4) | ((prio >> (nbuffersm1 * 4)) & 0xF);
netdev_dbg(ndev, "%s: from 0x%08x to 0x%08x",
__func__, priv->txb_prio, prio);
priv->txb_prio = prio;
......@@ -599,15 +590,13 @@ static void ctucan_tx_interrupt(struct net_device *ndev)
netdev_dbg(ndev, "%s", __func__);
/*
* read tx_status
/* read tx_status
* if txb[n].finished (bit 2)
* if ok -> echo
* if error / aborted -> ?? (find how to handle oneshot mode)
* txb_tail++
*/
icr.u32 = 0;
icr.s.txbhci = 1;
do {
......@@ -805,12 +794,6 @@ static int ctucan_open(struct net_device *ndev)
return ret;
}
/*
* ret = ctucan_reset(ndev);
* if (ret < 0)
* goto err;
*/
ret = request_irq(ndev->irq, ctucan_interrupt, priv->irq_flags,
ndev->name, ndev);
if (ret < 0) {
......@@ -943,12 +926,10 @@ static __maybe_unused int ctucan_resume(struct device *dev)
return 0;
}
static const struct dev_pm_ops ctucan_dev_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(ctucan_suspend, ctucan_resume)
};
/**
* ctucan_probe_common - Device type independent registration call
*
......@@ -981,7 +962,7 @@ static int ctucan_probe_common(struct device *dev, void __iomem *addr,
priv = netdev_priv(ndev);
INIT_LIST_HEAD(&priv->peers_on_pdev);
priv->txb_mask = ntxbufs-1;
priv->txb_mask = ntxbufs - 1;
priv->dev = dev;
priv->can.bittiming_const = &ctu_can_fd_bit_timing_max;
priv->can.data_bittiming_const = &ctu_can_fd_bit_timing_data_max;
......@@ -1125,7 +1106,7 @@ static int ctucan_platform_probe(struct platform_device *pdev)
}
/*
ret = of_property_read_u32(pdev->dev.of_node, "tx-fifo-depth", &tx_max);
ret = of_property_read_u32(pdev->dev.of_node, "tntxbufs", &ntxbufs);
if (ret < 0)
goto err;
*/
......@@ -1162,7 +1143,6 @@ static int ctucan_platform_remove(struct platform_device *pdev)
return 0;
}
/* Match table for OF platform binding */
static const struct of_device_id ctucan_of_match[] = {
{ .compatible = "ctu,canfd-2", },
......@@ -1191,7 +1171,8 @@ module_platform_driver(ctucanfd_driver);
#ifndef PCI_DEVICE_DATA
#define PCI_DEVICE_DATA(vend, dev, data) \
.vendor = PCI_VENDOR_ID_##vend, .device = PCI_DEVICE_ID_##vend##_##dev, \
.vendor = PCI_VENDOR_ID_##vend, \
.device = PCI_DEVICE_ID_##vend##_##dev, \
.subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0, \
.driver_data = (kernel_ulong_t)(data)
#endif
......@@ -1409,10 +1390,8 @@ static void ctucan_pci_remove(struct pci_dev *pdev)
if (bdata->cra_base)
iowrite32(0, (char *)bdata->cra_base + CYCLONE_IV_CRA_A2P_IE);
while ((priv = list_first_entry_or_null(&bdata->ndev_list_head,
struct ctucan_priv, peers_on_pdev)) != NULL) {
ndev = priv->can.dev;
unregister_candev(ndev);
......@@ -1448,6 +1427,7 @@ static const struct pci_device_id ctucan_pci_tbl[] = {
CTUCAN_WITH_CTUCAN_ID)},
{},
};
static struct pci_driver ctucan_pci_driver = {
.name = KBUILD_MODNAME,
.id_table = ctucan_pci_tbl,
......
......@@ -74,8 +74,6 @@ static void ctu_can_fd_write_txt_buf(struct ctucanfd_priv *priv,
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)
{
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)
/* getting lowest 18 bits, replace with sth nicer... */
hwid.s.identifier_ext = (id & 0x3FFFF);
} else
} else {
hwid.s.identifier_base = id & CAN_SFF_MASK;
}
return 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 |= hwid.s.identifier_base << 18;
*id |= hwid.s.identifier_ext;
} else
} else {
*id = hwid.s.identifier_base;
}
}
// TODO: use can_len2dlc
static bool ctu_can_fd_len_to_dlc(u8 len, u8 *dlc)
{
*dlc = can_len2dlc(len);
return true;
}
bool ctu_can_fd_check_access(struct ctucanfd_priv *priv)
{
union ctu_can_fd_device_id_version reg;
......@@ -279,14 +276,14 @@ void ctu_can_fd_set_mode(struct ctucanfd_priv *priv,
if (mode->mask & CAN_CTRLMODE_BERR_REPORTING) {
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);
mask.s.bei = 1;
ctu_can_fd_int_ena(priv, ena, mask);
}
}
const struct can_bittiming_const ctu_can_fd_bit_timing_max = {
.name = "ctu_can_fd",
.tseg1_min = 2,
......@@ -316,8 +313,7 @@ void ctu_can_fd_set_nom_bittiming(struct ctucanfd_priv *priv,
{
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
* 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.
......@@ -347,8 +343,7 @@ void ctu_can_fd_set_data_bittiming(struct ctucanfd_priv *priv,
{
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
* 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
......@@ -410,10 +405,11 @@ enum can_state ctu_can_fd_read_error_state(struct ctucanfd_priv *priv)
return CAN_STATE_ERROR_ACTIVE;
else
return CAN_STATE_ERROR_WARNING;
} else if (reg.s.erp)
} else if (reg.s.erp) {
return CAN_STATE_ERROR_PASSIVE;
else if (reg.s.bof)
} else if (reg.s.bof) {
return CAN_STATE_BUS_OFF;
}
WARN(true, "Invalid error state");
return CAN_STATE_ERROR_PASSIVE;
}
......@@ -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);
}
bool ctu_can_fd_get_mask_filter_support(struct ctucanfd_priv *priv, u8 fnum)
{
union ctu_can_fd_filter_control_filter_status reg;
......@@ -585,8 +580,9 @@ void ctu_can_fd_read_rx_frame_ffw(struct ctucanfd_priv *priv,
cf->flags |= CANFD_BRS;
if (ffw.s.esi_rsv == ESI_ERR_PASIVE)
cf->flags |= CANFD_ESI;
} else if (ffw.s.rtr == RTR_FRAME)
} else if (ffw.s.rtr == RTR_FRAME) {
cf->can_id |= CAN_RTR_FLAG;
}
/* DLC */
if (ffw.s.dlc <= 8) {
......@@ -598,7 +594,7 @@ void ctu_can_fd_read_rx_frame_ffw(struct ctucanfd_priv *priv,
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);
/* Timestamp */
......@@ -636,7 +632,7 @@ enum ctu_can_fd_tx_status_tx1s ctu_can_fd_get_tx_status(struct ctucanfd_priv
default:
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)
......@@ -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;
buf_status = ctu_can_fd_get_tx_status(priv, buf);
if (buf_status == TXT_RDY || buf_status == TXT_TRAN
|| buf_status == TXT_ABTP)
if (buf_status == TXT_RDY || buf_status == TXT_TRAN ||
buf_status == TXT_ABTP)
return false;
return true;
......@@ -784,11 +780,11 @@ u64 ctu_can_fd_read_timestamp(struct ctucanfd_priv *priv)
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);
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);
}
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
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