aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/can/janz-ican3.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/can/janz-ican3.c')
-rw-r--r--drivers/net/can/janz-ican3.c65
1 files changed, 31 insertions, 34 deletions
diff --git a/drivers/net/can/janz-ican3.c b/drivers/net/can/janz-ican3.c
index 71594e5676fd..2382c04dc780 100644
--- a/drivers/net/can/janz-ican3.c
+++ b/drivers/net/can/janz-ican3.c
@@ -198,9 +198,6 @@ struct ican3_dev {
198 struct net_device *ndev; 198 struct net_device *ndev;
199 struct napi_struct napi; 199 struct napi_struct napi;
200 200
201 /* Device for printing */
202 struct device *dev;
203
204 /* module number */ 201 /* module number */
205 unsigned int num; 202 unsigned int num;
206 203
@@ -295,7 +292,7 @@ static int ican3_old_recv_msg(struct ican3_dev *mod, struct ican3_msg *msg)
295 xord = locl ^ peer; 292 xord = locl ^ peer;
296 293
297 if ((xord & MSYNC_RB_MASK) == 0x00) { 294 if ((xord & MSYNC_RB_MASK) == 0x00) {
298 dev_dbg(mod->dev, "no mbox for reading\n"); 295 netdev_dbg(mod->ndev, "no mbox for reading\n");
299 return -ENOMEM; 296 return -ENOMEM;
300 } 297 }
301 298
@@ -340,7 +337,7 @@ static int ican3_old_send_msg(struct ican3_dev *mod, struct ican3_msg *msg)
340 xord = locl ^ peer; 337 xord = locl ^ peer;
341 338
342 if ((xord & MSYNC_WB_MASK) == MSYNC_WB_MASK) { 339 if ((xord & MSYNC_WB_MASK) == MSYNC_WB_MASK) {
343 dev_err(mod->dev, "no mbox for writing\n"); 340 netdev_err(mod->ndev, "no mbox for writing\n");
344 return -ENOMEM; 341 return -ENOMEM;
345 } 342 }
346 343
@@ -542,7 +539,7 @@ static int ican3_new_send_msg(struct ican3_dev *mod, struct ican3_msg *msg)
542 memcpy_fromio(&desc, desc_addr, sizeof(desc)); 539 memcpy_fromio(&desc, desc_addr, sizeof(desc));
543 540
544 if (!(desc.control & DESC_VALID)) { 541 if (!(desc.control & DESC_VALID)) {
545 dev_dbg(mod->dev, "%s: no free buffers\n", __func__); 542 netdev_dbg(mod->ndev, "%s: no free buffers\n", __func__);
546 return -ENOMEM; 543 return -ENOMEM;
547 } 544 }
548 545
@@ -573,7 +570,7 @@ static int ican3_new_recv_msg(struct ican3_dev *mod, struct ican3_msg *msg)
573 memcpy_fromio(&desc, desc_addr, sizeof(desc)); 570 memcpy_fromio(&desc, desc_addr, sizeof(desc));
574 571
575 if (!(desc.control & DESC_VALID)) { 572 if (!(desc.control & DESC_VALID)) {
576 dev_dbg(mod->dev, "%s: no buffers to recv\n", __func__); 573 netdev_dbg(mod->ndev, "%s: no buffers to recv\n", __func__);
577 return -ENOMEM; 574 return -ENOMEM;
578 } 575 }
579 576
@@ -883,7 +880,7 @@ static void can_frame_to_ican3(struct ican3_dev *mod,
883 */ 880 */
884static void ican3_handle_idvers(struct ican3_dev *mod, struct ican3_msg *msg) 881static void ican3_handle_idvers(struct ican3_dev *mod, struct ican3_msg *msg)
885{ 882{
886 dev_dbg(mod->dev, "IDVERS response: %s\n", msg->data); 883 netdev_dbg(mod->ndev, "IDVERS response: %s\n", msg->data);
887} 884}
888 885
889static void ican3_handle_msglost(struct ican3_dev *mod, struct ican3_msg *msg) 886static void ican3_handle_msglost(struct ican3_dev *mod, struct ican3_msg *msg)
@@ -899,7 +896,7 @@ static void ican3_handle_msglost(struct ican3_dev *mod, struct ican3_msg *msg)
899 * error frame for userspace 896 * error frame for userspace
900 */ 897 */
901 if (msg->spec == MSG_MSGLOST) { 898 if (msg->spec == MSG_MSGLOST) {
902 dev_err(mod->dev, "lost %d control messages\n", msg->data[0]); 899 netdev_err(mod->ndev, "lost %d control messages\n", msg->data[0]);
903 return; 900 return;
904 } 901 }
905 902
@@ -939,13 +936,13 @@ static int ican3_handle_cevtind(struct ican3_dev *mod, struct ican3_msg *msg)
939 936
940 /* we can only handle the SJA1000 part */ 937 /* we can only handle the SJA1000 part */
941 if (msg->data[1] != CEVTIND_CHIP_SJA1000) { 938 if (msg->data[1] != CEVTIND_CHIP_SJA1000) {
942 dev_err(mod->dev, "unable to handle errors on non-SJA1000\n"); 939 netdev_err(mod->ndev, "unable to handle errors on non-SJA1000\n");
943 return -ENODEV; 940 return -ENODEV;
944 } 941 }
945 942
946 /* check the message length for sanity */ 943 /* check the message length for sanity */
947 if (le16_to_cpu(msg->len) < 6) { 944 if (le16_to_cpu(msg->len) < 6) {
948 dev_err(mod->dev, "error message too short\n"); 945 netdev_err(mod->ndev, "error message too short\n");
949 return -EINVAL; 946 return -EINVAL;
950 } 947 }
951 948
@@ -967,7 +964,7 @@ static int ican3_handle_cevtind(struct ican3_dev *mod, struct ican3_msg *msg)
967 */ 964 */
968 if (isrc == CEVTIND_BEI) { 965 if (isrc == CEVTIND_BEI) {
969 int ret; 966 int ret;
970 dev_dbg(mod->dev, "bus error interrupt\n"); 967 netdev_dbg(mod->ndev, "bus error interrupt\n");
971 968
972 /* TX error */ 969 /* TX error */
973 if (!(ecc & ECC_DIR)) { 970 if (!(ecc & ECC_DIR)) {
@@ -983,7 +980,7 @@ static int ican3_handle_cevtind(struct ican3_dev *mod, struct ican3_msg *msg)
983 */ 980 */
984 ret = ican3_set_buserror(mod, 1); 981 ret = ican3_set_buserror(mod, 1);
985 if (ret) { 982 if (ret) {
986 dev_err(mod->dev, "unable to re-enable bus-error\n"); 983 netdev_err(mod->ndev, "unable to re-enable bus-error\n");
987 return ret; 984 return ret;
988 } 985 }
989 986
@@ -998,7 +995,7 @@ static int ican3_handle_cevtind(struct ican3_dev *mod, struct ican3_msg *msg)
998 995
999 /* data overrun interrupt */ 996 /* data overrun interrupt */
1000 if (isrc == CEVTIND_DOI || isrc == CEVTIND_LOST) { 997 if (isrc == CEVTIND_DOI || isrc == CEVTIND_LOST) {
1001 dev_dbg(mod->dev, "data overrun interrupt\n"); 998 netdev_dbg(mod->ndev, "data overrun interrupt\n");
1002 cf->can_id |= CAN_ERR_CRTL; 999 cf->can_id |= CAN_ERR_CRTL;
1003 cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW; 1000 cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW;
1004 stats->rx_over_errors++; 1001 stats->rx_over_errors++;
@@ -1007,7 +1004,7 @@ static int ican3_handle_cevtind(struct ican3_dev *mod, struct ican3_msg *msg)
1007 1004
1008 /* error warning + passive interrupt */ 1005 /* error warning + passive interrupt */
1009 if (isrc == CEVTIND_EI) { 1006 if (isrc == CEVTIND_EI) {
1010 dev_dbg(mod->dev, "error warning + passive interrupt\n"); 1007 netdev_dbg(mod->ndev, "error warning + passive interrupt\n");
1011 if (status & SR_BS) { 1008 if (status & SR_BS) {
1012 state = CAN_STATE_BUS_OFF; 1009 state = CAN_STATE_BUS_OFF;
1013 cf->can_id |= CAN_ERR_BUSOFF; 1010 cf->can_id |= CAN_ERR_BUSOFF;
@@ -1088,7 +1085,7 @@ static void ican3_handle_inquiry(struct ican3_dev *mod, struct ican3_msg *msg)
1088 complete(&mod->termination_comp); 1085 complete(&mod->termination_comp);
1089 break; 1086 break;
1090 default: 1087 default:
1091 dev_err(mod->dev, "received an unknown inquiry response\n"); 1088 netdev_err(mod->ndev, "received an unknown inquiry response\n");
1092 break; 1089 break;
1093 } 1090 }
1094} 1091}
@@ -1096,7 +1093,7 @@ static void ican3_handle_inquiry(struct ican3_dev *mod, struct ican3_msg *msg)
1096static void ican3_handle_unknown_message(struct ican3_dev *mod, 1093static void ican3_handle_unknown_message(struct ican3_dev *mod,
1097 struct ican3_msg *msg) 1094 struct ican3_msg *msg)
1098{ 1095{
1099 dev_warn(mod->dev, "received unknown message: spec 0x%.2x length %d\n", 1096 netdev_warn(mod->ndev, "received unknown message: spec 0x%.2x length %d\n",
1100 msg->spec, le16_to_cpu(msg->len)); 1097 msg->spec, le16_to_cpu(msg->len));
1101} 1098}
1102 1099
@@ -1105,7 +1102,7 @@ static void ican3_handle_unknown_message(struct ican3_dev *mod,
1105 */ 1102 */
1106static void ican3_handle_message(struct ican3_dev *mod, struct ican3_msg *msg) 1103static void ican3_handle_message(struct ican3_dev *mod, struct ican3_msg *msg)
1107{ 1104{
1108 dev_dbg(mod->dev, "%s: modno %d spec 0x%.2x len %d bytes\n", __func__, 1105 netdev_dbg(mod->ndev, "%s: modno %d spec 0x%.2x len %d bytes\n", __func__,
1109 mod->num, msg->spec, le16_to_cpu(msg->len)); 1106 mod->num, msg->spec, le16_to_cpu(msg->len));
1110 1107
1111 switch (msg->spec) { 1108 switch (msg->spec) {
@@ -1406,7 +1403,7 @@ static int ican3_reset_module(struct ican3_dev *mod)
1406 msleep(10); 1403 msleep(10);
1407 } while (time_before(jiffies, start + HZ / 4)); 1404 } while (time_before(jiffies, start + HZ / 4));
1408 1405
1409 dev_err(mod->dev, "failed to reset CAN module\n"); 1406 netdev_err(mod->ndev, "failed to reset CAN module\n");
1410 return -ETIMEDOUT; 1407 return -ETIMEDOUT;
1411} 1408}
1412 1409
@@ -1425,7 +1422,7 @@ static int ican3_startup_module(struct ican3_dev *mod)
1425 1422
1426 ret = ican3_reset_module(mod); 1423 ret = ican3_reset_module(mod);
1427 if (ret) { 1424 if (ret) {
1428 dev_err(mod->dev, "unable to reset module\n"); 1425 netdev_err(mod->ndev, "unable to reset module\n");
1429 return ret; 1426 return ret;
1430 } 1427 }
1431 1428
@@ -1434,41 +1431,41 @@ static int ican3_startup_module(struct ican3_dev *mod)
1434 1431
1435 ret = ican3_msg_connect(mod); 1432 ret = ican3_msg_connect(mod);
1436 if (ret) { 1433 if (ret) {
1437 dev_err(mod->dev, "unable to connect to module\n"); 1434 netdev_err(mod->ndev, "unable to connect to module\n");
1438 return ret; 1435 return ret;
1439 } 1436 }
1440 1437
1441 ican3_init_new_host_interface(mod); 1438 ican3_init_new_host_interface(mod);
1442 ret = ican3_msg_newhostif(mod); 1439 ret = ican3_msg_newhostif(mod);
1443 if (ret) { 1440 if (ret) {
1444 dev_err(mod->dev, "unable to switch to new-style interface\n"); 1441 netdev_err(mod->ndev, "unable to switch to new-style interface\n");
1445 return ret; 1442 return ret;
1446 } 1443 }
1447 1444
1448 /* default to "termination on" */ 1445 /* default to "termination on" */
1449 ret = ican3_set_termination(mod, true); 1446 ret = ican3_set_termination(mod, true);
1450 if (ret) { 1447 if (ret) {
1451 dev_err(mod->dev, "unable to enable termination\n"); 1448 netdev_err(mod->ndev, "unable to enable termination\n");
1452 return ret; 1449 return ret;
1453 } 1450 }
1454 1451
1455 /* default to "bus errors enabled" */ 1452 /* default to "bus errors enabled" */
1456 ret = ican3_set_buserror(mod, 1); 1453 ret = ican3_set_buserror(mod, 1);
1457 if (ret) { 1454 if (ret) {
1458 dev_err(mod->dev, "unable to set bus-error\n"); 1455 netdev_err(mod->ndev, "unable to set bus-error\n");
1459 return ret; 1456 return ret;
1460 } 1457 }
1461 1458
1462 ican3_init_fast_host_interface(mod); 1459 ican3_init_fast_host_interface(mod);
1463 ret = ican3_msg_fasthostif(mod); 1460 ret = ican3_msg_fasthostif(mod);
1464 if (ret) { 1461 if (ret) {
1465 dev_err(mod->dev, "unable to switch to fast host interface\n"); 1462 netdev_err(mod->ndev, "unable to switch to fast host interface\n");
1466 return ret; 1463 return ret;
1467 } 1464 }
1468 1465
1469 ret = ican3_set_id_filter(mod, true); 1466 ret = ican3_set_id_filter(mod, true);
1470 if (ret) { 1467 if (ret) {
1471 dev_err(mod->dev, "unable to set acceptance filter\n"); 1468 netdev_err(mod->ndev, "unable to set acceptance filter\n");
1472 return ret; 1469 return ret;
1473 } 1470 }
1474 1471
@@ -1487,14 +1484,14 @@ static int ican3_open(struct net_device *ndev)
1487 /* open the CAN layer */ 1484 /* open the CAN layer */
1488 ret = open_candev(ndev); 1485 ret = open_candev(ndev);
1489 if (ret) { 1486 if (ret) {
1490 dev_err(mod->dev, "unable to start CAN layer\n"); 1487 netdev_err(mod->ndev, "unable to start CAN layer\n");
1491 return ret; 1488 return ret;
1492 } 1489 }
1493 1490
1494 /* bring the bus online */ 1491 /* bring the bus online */
1495 ret = ican3_set_bus_state(mod, true); 1492 ret = ican3_set_bus_state(mod, true);
1496 if (ret) { 1493 if (ret) {
1497 dev_err(mod->dev, "unable to set bus-on\n"); 1494 netdev_err(mod->ndev, "unable to set bus-on\n");
1498 close_candev(ndev); 1495 close_candev(ndev);
1499 return ret; 1496 return ret;
1500 } 1497 }
@@ -1518,7 +1515,7 @@ static int ican3_stop(struct net_device *ndev)
1518 /* bring the bus offline, stop receiving packets */ 1515 /* bring the bus offline, stop receiving packets */
1519 ret = ican3_set_bus_state(mod, false); 1516 ret = ican3_set_bus_state(mod, false);
1520 if (ret) { 1517 if (ret) {
1521 dev_err(mod->dev, "unable to set bus-off\n"); 1518 netdev_err(mod->ndev, "unable to set bus-off\n");
1522 return ret; 1519 return ret;
1523 } 1520 }
1524 1521
@@ -1545,7 +1542,7 @@ static int ican3_xmit(struct sk_buff *skb, struct net_device *ndev)
1545 1542
1546 /* check that we can actually transmit */ 1543 /* check that we can actually transmit */
1547 if (!ican3_txok(mod)) { 1544 if (!ican3_txok(mod)) {
1548 dev_err(mod->dev, "BUG: no free descriptors\n"); 1545 netdev_err(mod->ndev, "BUG: no free descriptors\n");
1549 spin_unlock_irqrestore(&mod->lock, flags); 1546 spin_unlock_irqrestore(&mod->lock, flags);
1550 return NETDEV_TX_BUSY; 1547 return NETDEV_TX_BUSY;
1551 } 1548 }
@@ -1597,6 +1594,7 @@ static const struct net_device_ops ican3_netdev_ops = {
1597 .ndo_open = ican3_open, 1594 .ndo_open = ican3_open,
1598 .ndo_stop = ican3_stop, 1595 .ndo_stop = ican3_stop,
1599 .ndo_start_xmit = ican3_xmit, 1596 .ndo_start_xmit = ican3_xmit,
1597 .ndo_change_mtu = can_change_mtu,
1600}; 1598};
1601 1599
1602/* 1600/*
@@ -1657,7 +1655,7 @@ static int ican3_set_mode(struct net_device *ndev, enum can_mode mode)
1657 /* bring the bus online */ 1655 /* bring the bus online */
1658 ret = ican3_set_bus_state(mod, true); 1656 ret = ican3_set_bus_state(mod, true);
1659 if (ret) { 1657 if (ret) {
1660 dev_err(mod->dev, "unable to set bus-on\n"); 1658 netdev_err(ndev, "unable to set bus-on\n");
1661 return ret; 1659 return ret;
1662 } 1660 }
1663 1661
@@ -1682,7 +1680,7 @@ static int ican3_get_berr_counter(const struct net_device *ndev,
1682 1680
1683 ret = wait_for_completion_timeout(&mod->buserror_comp, HZ); 1681 ret = wait_for_completion_timeout(&mod->buserror_comp, HZ);
1684 if (ret == 0) { 1682 if (ret == 0) {
1685 dev_info(mod->dev, "%s timed out\n", __func__); 1683 netdev_info(mod->ndev, "%s timed out\n", __func__);
1686 return -ETIMEDOUT; 1684 return -ETIMEDOUT;
1687 } 1685 }
1688 1686
@@ -1708,7 +1706,7 @@ static ssize_t ican3_sysfs_show_term(struct device *dev,
1708 1706
1709 ret = wait_for_completion_timeout(&mod->termination_comp, HZ); 1707 ret = wait_for_completion_timeout(&mod->termination_comp, HZ);
1710 if (ret == 0) { 1708 if (ret == 0) {
1711 dev_info(mod->dev, "%s timed out\n", __func__); 1709 netdev_info(mod->ndev, "%s timed out\n", __func__);
1712 return -ETIMEDOUT; 1710 return -ETIMEDOUT;
1713 } 1711 }
1714 1712
@@ -1778,7 +1776,6 @@ static int ican3_probe(struct platform_device *pdev)
1778 platform_set_drvdata(pdev, ndev); 1776 platform_set_drvdata(pdev, ndev);
1779 mod = netdev_priv(ndev); 1777 mod = netdev_priv(ndev);
1780 mod->ndev = ndev; 1778 mod->ndev = ndev;
1781 mod->dev = &pdev->dev;
1782 mod->num = pdata->modno; 1779 mod->num = pdata->modno;
1783 netif_napi_add(ndev, &mod->napi, ican3_napi, ICAN3_RX_BUFFERS); 1780 netif_napi_add(ndev, &mod->napi, ican3_napi, ICAN3_RX_BUFFERS);
1784 skb_queue_head_init(&mod->echoq); 1781 skb_queue_head_init(&mod->echoq);