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; ...@@ -65,8 +65,7 @@ static bool pci_use_second = 1;
module_param(pci_use_second, bool, 0444); module_param(pci_use_second, bool, 0444);
MODULE_PARM_DESC(pci_use_second, "Use the second CAN core on PCIe card. Default: 1 (yes)"); 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 * - when a buffer transitions to empty state, rotate order and priorities
* - if more buffers seem to transition at the same time, rotate * - if more buffers seem to transition at the same time, rotate
* by the number of buffers * by the number of buffers
...@@ -108,15 +107,13 @@ static int ctucan_reset(struct net_device *ndev) ...@@ -108,15 +107,13 @@ static int ctucan_reset(struct net_device *ndev)
for (i = 0; i < 100; ++i) { for (i = 0; i < 100; ++i) {
if (ctu_can_fd_check_access(&priv->p)) if (ctu_can_fd_check_access(&priv->p))
return 0; return 0;
udelay(100); usleep_range(100, 200);
} }
netdev_warn(ndev, "device did not leave reset\n"); netdev_warn(ndev, "device did not leave reset\n");
return -ETIMEDOUT; return -ETIMEDOUT;
} }
/** /**
* ctucan_set_bittiming - CAN set bit timing routine * ctucan_set_bittiming - CAN set bit timing routine
* @ndev: Pointer to net_device structure * @ndev: Pointer to net_device structure
...@@ -133,7 +130,7 @@ static int ctucan_set_bittiming(struct net_device *ndev) ...@@ -133,7 +130,7 @@ static int ctucan_set_bittiming(struct net_device *ndev)
if (ctu_can_fd_is_enabled(&priv->p)) { if (ctu_can_fd_is_enabled(&priv->p)) {
netdev_alert(ndev, netdev_alert(ndev,
"BUG! Cannot set bittiming - CAN is enabled\n"); "BUG! Cannot set bittiming - CAN is enabled\n");
return -EPERM; return -EPERM;
} }
...@@ -143,7 +140,6 @@ static int ctucan_set_bittiming(struct net_device *ndev) ...@@ -143,7 +140,6 @@ static int ctucan_set_bittiming(struct net_device *ndev)
return 0; return 0;
} }
/** /**
* ctucan_set_data_bittiming - CAN set data bit timing routine * ctucan_set_data_bittiming - CAN set data bit timing routine
* @ndev: Pointer to net_device structure * @ndev: Pointer to net_device structure
...@@ -160,7 +156,7 @@ static int ctucan_set_data_bittiming(struct net_device *ndev) ...@@ -160,7 +156,7 @@ static int ctucan_set_data_bittiming(struct net_device *ndev)
if (ctu_can_fd_is_enabled(&priv->p)) { if (ctu_can_fd_is_enabled(&priv->p)) {
netdev_alert(ndev, netdev_alert(ndev,
"BUG! Cannot set bittiming - CAN is enabled\n"); "BUG! Cannot set bittiming - CAN is enabled\n");
return -EPERM; return -EPERM;
} }
...@@ -196,7 +192,6 @@ static int ctucan_chip_start(struct net_device *ndev) ...@@ -196,7 +192,6 @@ static int ctucan_chip_start(struct net_device *ndev)
priv->txb_tail = 0; priv->txb_tail = 0;
priv->p.write_reg(&priv->p, CTU_CAN_FD_TX_PRIORITY, priv->txb_prio); priv->p.write_reg(&priv->p, CTU_CAN_FD_TX_PRIORITY, priv->txb_prio);
err = ctucan_set_bittiming(ndev); err = ctucan_set_bittiming(ndev);
if (err < 0) if (err < 0)
return err; return err;
...@@ -205,7 +200,6 @@ static int ctucan_chip_start(struct net_device *ndev) ...@@ -205,7 +200,6 @@ static int ctucan_chip_start(struct net_device *ndev)
if (err < 0) if (err < 0)
return err; return err;
/* Enable interrupts */ /* Enable interrupts */
int_ena.u32 = 0; int_ena.u32 = 0;
int_ena.s.rbnei = 1; int_ena.s.rbnei = 1;
...@@ -279,7 +273,6 @@ static int ctucan_do_set_mode(struct net_device *ndev, enum can_mode mode) ...@@ -279,7 +273,6 @@ static int ctucan_do_set_mode(struct net_device *ndev, enum can_mode mode)
return ret; return ret;
} }
/** /**
* ctucan_start_xmit - Starts the transmission * ctucan_start_xmit - Starts the transmission
* @skb: sk_buff pointer that contains data to be Txed * @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) ...@@ -302,7 +295,6 @@ static int ctucan_start_xmit(struct sk_buff *skb, struct net_device *ndev)
if (can_dropped_invalid_skb(ndev, skb)) if (can_dropped_invalid_skb(ndev, skb))
return NETDEV_TX_OK; return NETDEV_TX_OK;
/* Check if the TX buffer is full */ /* Check if the TX buffer is full */
if (unlikely(!CTU_CAN_FD_TXTNF(ctu_can_get_status(&priv->p)))) { if (unlikely(!CTU_CAN_FD_TXTNF(ctu_can_get_status(&priv->p)))) {
netif_stop_queue(ndev); netif_stop_queue(ndev);
...@@ -357,7 +349,7 @@ static int ctucan_rx(struct net_device *ndev) ...@@ -357,7 +349,7 @@ static int ctucan_rx(struct net_device *ndev)
if (ffw.s.fdf == FD_CAN) if (ffw.s.fdf == FD_CAN)
skb = alloc_canfd_skb(ndev, &cf); skb = alloc_canfd_skb(ndev, &cf);
else else
skb = alloc_can_skb(ndev, (struct can_frame **) &cf); skb = alloc_can_skb(ndev, (struct can_frame **)&cf);
if (unlikely(!skb)) { if (unlikely(!skb)) {
int i; int i;
...@@ -403,8 +395,7 @@ static void ctucan_err_interrupt(struct net_device *ndev, ...@@ -403,8 +395,7 @@ static void ctucan_err_interrupt(struct net_device *ndev,
skb = alloc_can_err_skb(ndev, &cf); skb = alloc_can_err_skb(ndev, &cf);
/* /* EWI: error warning
* EWI: error warning
* DOI: RX overrun * DOI: RX overrun
* EPI: error passive or bus off * EPI: error passive or bus off
* ALI: arbitration lost (just informative) * ALI: arbitration lost (just informative)
...@@ -489,7 +480,7 @@ err_warning: ...@@ -489,7 +480,7 @@ err_warning:
*/ */
#ifdef DEBUG #ifdef DEBUG
netdev_info(ndev, " DOS=%d after COMMAND[CDR]", netdev_info(ndev, " DOS=%d after COMMAND[CDR]",
ctu_can_get_status(&priv->p).s.dor); ctu_can_get_status(&priv->p).s.dor);
#endif #endif
/* And clear the DOI flag again */ /* And clear the DOI flag again */
...@@ -544,7 +535,7 @@ static int ctucan_rx_poll(struct napi_struct *napi, int quota) ...@@ -544,7 +535,7 @@ static int ctucan_rx_poll(struct napi_struct *napi, int quota)
u32 framecnt = ctu_can_fd_get_rx_frame_count(&priv->p); u32 framecnt = ctu_can_fd_get_rx_frame_count(&priv->p);
netdev_dbg(ndev, "rx_poll: RBNEI set, %d frames in RX FIFO", netdev_dbg(ndev, "rx_poll: RBNEI set, %d frames in RX FIFO",
framecnt); framecnt);
if (framecnt == 0) { if (framecnt == 0) {
netdev_err(ndev, "rx_poll: RBNEI set, but there are no frames in the FIFO!"); netdev_err(ndev, "rx_poll: RBNEI set, but there are no frames in the FIFO!");
break; break;
...@@ -577,7 +568,7 @@ static void ctucan_rotate_txb_prio(struct net_device *ndev) ...@@ -577,7 +568,7 @@ static void ctucan_rotate_txb_prio(struct net_device *ndev)
u32 prio = priv->txb_prio; u32 prio = priv->txb_prio;
u32 nbuffersm1 = priv->txb_mask; /* nbuffers - 1 */ 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", netdev_dbg(ndev, "%s: from 0x%08x to 0x%08x",
__func__, priv->txb_prio, prio); __func__, priv->txb_prio, prio);
priv->txb_prio = prio; priv->txb_prio = prio;
...@@ -599,15 +590,13 @@ static void ctucan_tx_interrupt(struct net_device *ndev) ...@@ -599,15 +590,13 @@ static void ctucan_tx_interrupt(struct net_device *ndev)
netdev_dbg(ndev, "%s", __func__); netdev_dbg(ndev, "%s", __func__);
/* /* read tx_status
* read tx_status
* if txb[n].finished (bit 2) * if txb[n].finished (bit 2)
* if ok -> echo * if ok -> echo
* if error / aborted -> ?? (find how to handle oneshot mode) * if error / aborted -> ?? (find how to handle oneshot mode)
* txb_tail++ * txb_tail++
*/ */
icr.u32 = 0; icr.u32 = 0;
icr.s.txbhci = 1; icr.s.txbhci = 1;
do { do {
...@@ -801,18 +790,12 @@ static int ctucan_open(struct net_device *ndev) ...@@ -801,18 +790,12 @@ static int ctucan_open(struct net_device *ndev)
ret = pm_runtime_get_sync(priv->dev); ret = pm_runtime_get_sync(priv->dev);
if (ret < 0) { if (ret < 0) {
netdev_err(ndev, "%s: pm_runtime_get failed(%d)\n", netdev_err(ndev, "%s: pm_runtime_get failed(%d)\n",
__func__, ret); __func__, ret);
return ret; return ret;
} }
/*
* ret = ctucan_reset(ndev);
* if (ret < 0)
* goto err;
*/
ret = request_irq(ndev->irq, ctucan_interrupt, priv->irq_flags, ret = request_irq(ndev->irq, ctucan_interrupt, priv->irq_flags,
ndev->name, ndev); ndev->name, ndev);
if (ret < 0) { if (ret < 0) {
netdev_err(ndev, "irq allocation for CAN failed\n"); netdev_err(ndev, "irq allocation for CAN failed\n");
goto err; goto err;
...@@ -881,7 +864,7 @@ static int ctucan_close(struct net_device *ndev) ...@@ -881,7 +864,7 @@ static int ctucan_close(struct net_device *ndev)
* Return: 0 on success and failure value on error * Return: 0 on success and failure value on error
*/ */
static int ctucan_get_berr_counter(const struct net_device *ndev, static int ctucan_get_berr_counter(const struct net_device *ndev,
struct can_berr_counter *bec) struct can_berr_counter *bec)
{ {
struct ctucan_priv *priv = netdev_priv(ndev); struct ctucan_priv *priv = netdev_priv(ndev);
int ret; int ret;
...@@ -891,7 +874,7 @@ static int ctucan_get_berr_counter(const struct net_device *ndev, ...@@ -891,7 +874,7 @@ static int ctucan_get_berr_counter(const struct net_device *ndev,
ret = pm_runtime_get_sync(priv->dev); ret = pm_runtime_get_sync(priv->dev);
if (ret < 0) { if (ret < 0) {
netdev_err(ndev, "%s: pm_runtime_get failed(%d)\n", netdev_err(ndev, "%s: pm_runtime_get failed(%d)\n",
__func__, ret); __func__, ret);
return ret; return ret;
} }
...@@ -943,12 +926,10 @@ static __maybe_unused int ctucan_resume(struct device *dev) ...@@ -943,12 +926,10 @@ static __maybe_unused int ctucan_resume(struct device *dev)
return 0; return 0;
} }
static const struct dev_pm_ops ctucan_dev_pm_ops = { static const struct dev_pm_ops ctucan_dev_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(ctucan_suspend, ctucan_resume) SET_SYSTEM_SLEEP_PM_OPS(ctucan_suspend, ctucan_resume)
}; };
/** /**
* ctucan_probe_common - Device type independent registration call * ctucan_probe_common - Device type independent registration call
* *
...@@ -966,9 +947,9 @@ static const struct dev_pm_ops ctucan_dev_pm_ops = { ...@@ -966,9 +947,9 @@ static const struct dev_pm_ops ctucan_dev_pm_ops = {
* Return: 0 on success and failure value on error * Return: 0 on success and failure value on error
*/ */
static int ctucan_probe_common(struct device *dev, void __iomem *addr, static int ctucan_probe_common(struct device *dev, void __iomem *addr,
int irq, unsigned int ntxbufs, unsigned long can_clk_rate, int irq, unsigned int ntxbufs, unsigned long can_clk_rate,
int pm_enable_call, void (*set_drvdata_fnc)(struct device *dev, int pm_enable_call, void (*set_drvdata_fnc)(struct device *dev,
struct net_device *ndev)) struct net_device *ndev))
{ {
struct ctucan_priv *priv; struct ctucan_priv *priv;
struct net_device *ndev; struct net_device *ndev;
...@@ -981,7 +962,7 @@ static int ctucan_probe_common(struct device *dev, void __iomem *addr, ...@@ -981,7 +962,7 @@ static int ctucan_probe_common(struct device *dev, void __iomem *addr,
priv = netdev_priv(ndev); priv = netdev_priv(ndev);
INIT_LIST_HEAD(&priv->peers_on_pdev); INIT_LIST_HEAD(&priv->peers_on_pdev);
priv->txb_mask = ntxbufs-1; priv->txb_mask = ntxbufs - 1;
priv->dev = dev; priv->dev = dev;
priv->can.bittiming_const = &ctu_can_fd_bit_timing_max; priv->can.bittiming_const = &ctu_can_fd_bit_timing_max;
priv->can.data_bittiming_const = &ctu_can_fd_bit_timing_data_max; priv->can.data_bittiming_const = &ctu_can_fd_bit_timing_data_max;
...@@ -1030,7 +1011,7 @@ static int ctucan_probe_common(struct device *dev, void __iomem *addr, ...@@ -1030,7 +1011,7 @@ static int ctucan_probe_common(struct device *dev, void __iomem *addr,
ret = pm_runtime_get_sync(dev); ret = pm_runtime_get_sync(dev);
if (ret < 0) { if (ret < 0) {
netdev_err(ndev, "%s: pm_runtime_get failed(%d)\n", netdev_err(ndev, "%s: pm_runtime_get failed(%d)\n",
__func__, ret); __func__, ret);
goto err_pmdisable; goto err_pmdisable;
} }
...@@ -1064,8 +1045,8 @@ static int ctucan_probe_common(struct device *dev, void __iomem *addr, ...@@ -1064,8 +1045,8 @@ static int ctucan_probe_common(struct device *dev, void __iomem *addr,
pm_runtime_put(dev); pm_runtime_put(dev);
netdev_dbg(ndev, "mem_base=0x%p irq=%d clock=%d, txb mask:%d\n", netdev_dbg(ndev, "mem_base=0x%p irq=%d clock=%d, txb mask:%d\n",
priv->p.mem_base, ndev->irq, priv->can.clock.freq, priv->p.mem_base, ndev->irq, priv->can.clock.freq,
priv->txb_mask); priv->txb_mask);
return 0; return 0;
...@@ -1083,7 +1064,7 @@ err_free: ...@@ -1083,7 +1064,7 @@ err_free:
#ifdef CONFIG_OF #ifdef CONFIG_OF
static void ctucan_platform_set_drvdata(struct device *dev, static void ctucan_platform_set_drvdata(struct device *dev,
struct net_device *ndev) struct net_device *ndev)
{ {
struct platform_device *pdev = container_of(dev, struct platform_device, struct platform_device *pdev = container_of(dev, struct platform_device,
dev); dev);
...@@ -1125,7 +1106,7 @@ static int ctucan_platform_probe(struct platform_device *pdev) ...@@ -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) if (ret < 0)
goto err; goto err;
*/ */
...@@ -1162,7 +1143,6 @@ static int ctucan_platform_remove(struct platform_device *pdev) ...@@ -1162,7 +1143,6 @@ static int ctucan_platform_remove(struct platform_device *pdev)
return 0; return 0;
} }
/* Match table for OF platform binding */ /* Match table for OF platform binding */
static const struct of_device_id ctucan_of_match[] = { static const struct of_device_id ctucan_of_match[] = {
{ .compatible = "ctu,canfd-2", }, { .compatible = "ctu,canfd-2", },
...@@ -1191,7 +1171,8 @@ module_platform_driver(ctucanfd_driver); ...@@ -1191,7 +1171,8 @@ module_platform_driver(ctucanfd_driver);
#ifndef PCI_DEVICE_DATA #ifndef PCI_DEVICE_DATA
#define PCI_DEVICE_DATA(vend, dev, 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, \ .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0, \
.driver_data = (kernel_ulong_t)(data) .driver_data = (kernel_ulong_t)(data)
#endif #endif
...@@ -1223,7 +1204,7 @@ struct ctucan_pci_board_data *ctucan_pci_get_bdata(struct pci_dev *pdev) ...@@ -1223,7 +1204,7 @@ struct ctucan_pci_board_data *ctucan_pci_get_bdata(struct pci_dev *pdev)
} }
static void ctucan_pci_set_drvdata(struct device *dev, static void ctucan_pci_set_drvdata(struct device *dev,
struct net_device *ndev) struct net_device *ndev)
{ {
struct pci_dev *pdev = container_of(dev, struct pci_dev, dev); struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
struct ctucan_priv *priv = netdev_priv(ndev); struct ctucan_priv *priv = netdev_priv(ndev);
...@@ -1282,12 +1263,12 @@ static int ctucan_pci_probe(struct pci_dev *pdev, ...@@ -1282,12 +1263,12 @@ static int ctucan_pci_probe(struct pci_dev *pdev,
} }
dev_info(dev, "ctucan BAR0 0x%08llx 0x%08llx\n", dev_info(dev, "ctucan BAR0 0x%08llx 0x%08llx\n",
(long long)pci_resource_start(pdev, 0), (long long)pci_resource_start(pdev, 0),
(long long)pci_resource_len(pdev, 0)); (long long)pci_resource_len(pdev, 0));
dev_info(dev, "ctucan BAR1 0x%08llx 0x%08llx\n", dev_info(dev, "ctucan BAR1 0x%08llx 0x%08llx\n",
(long long)pci_resource_start(pdev, 1), (long long)pci_resource_start(pdev, 1),
(long long)pci_resource_len(pdev, 1)); (long long)pci_resource_len(pdev, 1));
addr = pci_iomap(pdev, 1, pci_resource_len(pdev, 1)); addr = pci_iomap(pdev, 1, pci_resource_len(pdev, 1));
if (!addr) { if (!addr) {
...@@ -1343,10 +1324,10 @@ static int ctucan_pci_probe(struct pci_dev *pdev, ...@@ -1343,10 +1324,10 @@ static int ctucan_pci_probe(struct pci_dev *pdev,
while (pci_use_second && (core_i < num_cores)) { while (pci_use_second && (core_i < num_cores)) {
addr += 0x4000; addr += 0x4000;
ret = ctucan_probe_common(dev, addr, irq, ntxbufs, 100000000, ret = ctucan_probe_common(dev, addr, irq, ntxbufs, 100000000,
0, ctucan_pci_set_drvdata); 0, ctucan_pci_set_drvdata);
if (ret < 0) { if (ret < 0) {
dev_info(dev, "CTU CAN FD core %d initialization failed\n", dev_info(dev, "CTU CAN FD core %d initialization failed\n",
core_i); core_i);
break; break;
} }
core_i++; core_i++;
...@@ -1409,10 +1390,8 @@ static void ctucan_pci_remove(struct pci_dev *pdev) ...@@ -1409,10 +1390,8 @@ static void ctucan_pci_remove(struct pci_dev *pdev)
if (bdata->cra_base) if (bdata->cra_base)
iowrite32(0, (char *)bdata->cra_base + CYCLONE_IV_CRA_A2P_IE); iowrite32(0, (char *)bdata->cra_base + CYCLONE_IV_CRA_A2P_IE);
while ((priv = list_first_entry_or_null(&bdata->ndev_list_head, while ((priv = list_first_entry_or_null(&bdata->ndev_list_head,
struct ctucan_priv, peers_on_pdev)) != NULL) { struct ctucan_priv, peers_on_pdev)) != NULL) {
ndev = priv->can.dev; ndev = priv->can.dev;
unregister_candev(ndev); unregister_candev(ndev);
...@@ -1448,6 +1427,7 @@ static const struct pci_device_id ctucan_pci_tbl[] = { ...@@ -1448,6 +1427,7 @@ static const struct pci_device_id ctucan_pci_tbl[] = {
CTUCAN_WITH_CTUCAN_ID)}, CTUCAN_WITH_CTUCAN_ID)},
{}, {},
}; };
static struct pci_driver ctucan_pci_driver = { static struct pci_driver ctucan_pci_driver = {
.name = KBUILD_MODNAME, .name = KBUILD_MODNAME,
.id_table = ctucan_pci_tbl, .id_table = ctucan_pci_tbl,
......
...@@ -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;