forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/drivers/net/caif/caif_virtio.c
....@@ -1,9 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) ST-Ericsson AB 2013
34 * Authors: Vicram Arv
45 * Dmitry Tarnyagin <dmitry.tarnyagin@lockless.no>
56 * Sjur Brendeland
6
- * License terms: GNU General Public License (GPL) version 2
77 */
88 #include <linux/module.h>
99 #include <linux/if_arp.h>
....@@ -519,7 +519,7 @@
519519 }
520520
521521 /* Put the CAIF packet on the virtio ring and kick the receiver */
522
-static int cfv_netdev_tx(struct sk_buff *skb, struct net_device *netdev)
522
+static netdev_tx_t cfv_netdev_tx(struct sk_buff *skb, struct net_device *netdev)
523523 {
524524 struct cfv_info *cfv = netdev_priv(netdev);
525525 struct buf_info *buf_info;
....@@ -623,11 +623,7 @@
623623 /* Create debugfs counters for the device */
624624 static inline void debugfs_init(struct cfv_info *cfv)
625625 {
626
- cfv->debugfs =
627
- debugfs_create_dir(netdev_name(cfv->ndev), NULL);
628
-
629
- if (IS_ERR(cfv->debugfs))
630
- return;
626
+ cfv->debugfs = debugfs_create_dir(netdev_name(cfv->ndev), NULL);
631627
632628 debugfs_create_u32("rx-napi-complete", 0400, cfv->debugfs,
633629 &cfv->stats.rx_napi_complete);
....@@ -656,7 +652,7 @@
656652 const char *cfv_netdev_name = "cfvrt";
657653 struct net_device *netdev;
658654 struct cfv_info *cfv;
659
- int err = -EINVAL;
655
+ int err;
660656
661657 netdev = alloc_netdev(sizeof(struct cfv_info), cfv_netdev_name,
662658 NET_NAME_UNKNOWN, cfv_netdev_setup);
....@@ -727,13 +723,21 @@
727723 /* Carrier is off until netdevice is opened */
728724 netif_carrier_off(netdev);
729725
726
+ /* serialize netdev register + virtio_device_ready() with ndo_open() */
727
+ rtnl_lock();
728
+
730729 /* register Netdev */
731
- err = register_netdev(netdev);
730
+ err = register_netdevice(netdev);
732731 if (err) {
732
+ rtnl_unlock();
733733 dev_err(&vdev->dev, "Unable to register netdev (%d)\n", err);
734734 goto err;
735735 }
736736
737
+ virtio_device_ready(vdev);
738
+
739
+ rtnl_unlock();
740
+
737741 debugfs_init(cfv);
738742
739743 return 0;