aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/caif
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/caif')
-rw-r--r--drivers/net/caif/caif_hsi.c76
1 files changed, 47 insertions, 29 deletions
diff --git a/drivers/net/caif/caif_hsi.c b/drivers/net/caif/caif_hsi.c
index 1c2bd01e1592..087eb83454c0 100644
--- a/drivers/net/caif/caif_hsi.c
+++ b/drivers/net/caif/caif_hsi.c
@@ -678,8 +678,6 @@ static void cfhsi_rx_done(struct cfhsi *cfhsi)
678 */ 678 */
679 memcpy(rx_buf, (u8 *)piggy_desc, 679 memcpy(rx_buf, (u8 *)piggy_desc,
680 CFHSI_DESC_SHORT_SZ); 680 CFHSI_DESC_SHORT_SZ);
681 /* Mark no embedded frame here */
682 piggy_desc->offset = 0;
683 } 681 }
684 } 682 }
685 683
@@ -720,6 +718,8 @@ static void cfhsi_rx_done(struct cfhsi *cfhsi)
720 /* Extract any payload in piggyback descriptor. */ 718 /* Extract any payload in piggyback descriptor. */
721 if (cfhsi_rx_desc(piggy_desc, cfhsi) < 0) 719 if (cfhsi_rx_desc(piggy_desc, cfhsi) < 0)
722 goto out_of_sync; 720 goto out_of_sync;
721 /* Mark no embedded frame after extracting it */
722 piggy_desc->offset = 0;
723 } 723 }
724 } 724 }
725 725
@@ -1131,7 +1131,51 @@ static void cfhsi_setup(struct net_device *dev)
1131 cfhsi->cfdev.use_stx = false; 1131 cfhsi->cfdev.use_stx = false;
1132 cfhsi->cfdev.use_fcs = false; 1132 cfhsi->cfdev.use_fcs = false;
1133 cfhsi->ndev = dev; 1133 cfhsi->ndev = dev;
1134 cfhsi->cfg = hsi_default_config; 1134}
1135
1136int cfhsi_probe(struct platform_device *pdev)
1137{
1138 struct cfhsi_ops *(*get_ops)(void);
1139 struct cfhsi *cfhsi = NULL;
1140 struct net_device *ndev;
1141 int res;
1142
1143 ndev = alloc_netdev(sizeof(struct cfhsi), "cfhsi%d", cfhsi_setup);
1144 if (!ndev)
1145 return -ENODEV;
1146
1147 cfhsi = netdev_priv(ndev);
1148 cfhsi->ndev = ndev;
1149 cfhsi->pdev = pdev;
1150
1151 get_ops = symbol_get(cfhsi_get_ops);
1152 if (!get_ops) {
1153 pr_err("%s: failed to get the cfhsi_ops\n", __func__);
1154 return -ENODEV;
1155 }
1156
1157 /* Assign the HSI device. */
1158 cfhsi->ops = (*get_ops)();
1159 if (!cfhsi->ops) {
1160 pr_err("%s: failed to get the cfhsi_ops\n", __func__);
1161 goto err;
1162 }
1163
1164 /* Assign the driver to this HSI device. */
1165 cfhsi->ops->cb_ops = &cfhsi->cb_ops;
1166 res = register_netdevice(ndev);
1167 if (res) {
1168 dev_err(&ndev->dev, "%s: Registration error: %d.\n",
1169 __func__, res);
1170 free_netdev(ndev);
1171 }
1172 /* Add CAIF HSI device to list. */
1173 list_add_tail(&cfhsi->list, &cfhsi_list);
1174
1175 return res;
1176err:
1177 symbol_put(cfhsi_get_ops);
1178 return -ENODEV;
1135} 1179}
1136 1180
1137static int cfhsi_open(struct net_device *ndev) 1181static int cfhsi_open(struct net_device *ndev)
@@ -1410,7 +1454,6 @@ static int caif_hsi_newlink(struct net *src_net, struct net_device *dev,
1410 struct nlattr *tb[], struct nlattr *data[]) 1454 struct nlattr *tb[], struct nlattr *data[])
1411{ 1455{
1412 struct cfhsi *cfhsi = NULL; 1456 struct cfhsi *cfhsi = NULL;
1413 struct cfhsi_ops *(*get_ops)(void);
1414 1457
1415 ASSERT_RTNL(); 1458 ASSERT_RTNL();
1416 1459
@@ -1418,32 +1461,7 @@ static int caif_hsi_newlink(struct net *src_net, struct net_device *dev,
1418 cfhsi_netlink_parms(data, cfhsi); 1461 cfhsi_netlink_parms(data, cfhsi);
1419 dev_net_set(cfhsi->ndev, src_net); 1462 dev_net_set(cfhsi->ndev, src_net);
1420 1463
1421 get_ops = symbol_get(cfhsi_get_ops);
1422 if (!get_ops) {
1423 pr_err("%s: failed to get the cfhsi_ops\n", __func__);
1424 return -ENODEV;
1425 }
1426
1427 /* Assign the HSI device. */
1428 cfhsi->ops = (*get_ops)();
1429 if (!cfhsi->ops) {
1430 pr_err("%s: failed to get the cfhsi_ops\n", __func__);
1431 goto err;
1432 }
1433
1434 /* Assign the driver to this HSI device. */
1435 cfhsi->ops->cb_ops = &cfhsi->cb_ops;
1436 if (register_netdevice(dev)) {
1437 pr_warn("%s: caif_hsi device registration failed\n", __func__);
1438 goto err;
1439 }
1440 /* Add CAIF HSI device to list. */
1441 list_add_tail(&cfhsi->list, &cfhsi_list);
1442
1443 return 0; 1464 return 0;
1444err:
1445 symbol_put(cfhsi_get_ops);
1446 return -ENODEV;
1447} 1465}
1448 1466
1449static struct rtnl_link_ops caif_hsi_link_ops __read_mostly = { 1467static struct rtnl_link_ops caif_hsi_link_ops __read_mostly = {