| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) ST-Ericsson AB 2013 |
|---|
| 3 | 4 | * Authors: Vicram Arv |
|---|
| 4 | 5 | * Dmitry Tarnyagin <dmitry.tarnyagin@lockless.no> |
|---|
| 5 | 6 | * Sjur Brendeland |
|---|
| 6 | | - * License terms: GNU General Public License (GPL) version 2 |
|---|
| 7 | 7 | */ |
|---|
| 8 | 8 | #include <linux/module.h> |
|---|
| 9 | 9 | #include <linux/if_arp.h> |
|---|
| .. | .. |
|---|
| 519 | 519 | } |
|---|
| 520 | 520 | |
|---|
| 521 | 521 | /* 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) |
|---|
| 523 | 523 | { |
|---|
| 524 | 524 | struct cfv_info *cfv = netdev_priv(netdev); |
|---|
| 525 | 525 | struct buf_info *buf_info; |
|---|
| .. | .. |
|---|
| 623 | 623 | /* Create debugfs counters for the device */ |
|---|
| 624 | 624 | static inline void debugfs_init(struct cfv_info *cfv) |
|---|
| 625 | 625 | { |
|---|
| 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); |
|---|
| 631 | 627 | |
|---|
| 632 | 628 | debugfs_create_u32("rx-napi-complete", 0400, cfv->debugfs, |
|---|
| 633 | 629 | &cfv->stats.rx_napi_complete); |
|---|
| .. | .. |
|---|
| 656 | 652 | const char *cfv_netdev_name = "cfvrt"; |
|---|
| 657 | 653 | struct net_device *netdev; |
|---|
| 658 | 654 | struct cfv_info *cfv; |
|---|
| 659 | | - int err = -EINVAL; |
|---|
| 655 | + int err; |
|---|
| 660 | 656 | |
|---|
| 661 | 657 | netdev = alloc_netdev(sizeof(struct cfv_info), cfv_netdev_name, |
|---|
| 662 | 658 | NET_NAME_UNKNOWN, cfv_netdev_setup); |
|---|
| .. | .. |
|---|
| 727 | 723 | /* Carrier is off until netdevice is opened */ |
|---|
| 728 | 724 | netif_carrier_off(netdev); |
|---|
| 729 | 725 | |
|---|
| 726 | + /* serialize netdev register + virtio_device_ready() with ndo_open() */ |
|---|
| 727 | + rtnl_lock(); |
|---|
| 728 | + |
|---|
| 730 | 729 | /* register Netdev */ |
|---|
| 731 | | - err = register_netdev(netdev); |
|---|
| 730 | + err = register_netdevice(netdev); |
|---|
| 732 | 731 | if (err) { |
|---|
| 732 | + rtnl_unlock(); |
|---|
| 733 | 733 | dev_err(&vdev->dev, "Unable to register netdev (%d)\n", err); |
|---|
| 734 | 734 | goto err; |
|---|
| 735 | 735 | } |
|---|
| 736 | 736 | |
|---|
| 737 | + virtio_device_ready(vdev); |
|---|
| 738 | + |
|---|
| 739 | + rtnl_unlock(); |
|---|
| 740 | + |
|---|
| 737 | 741 | debugfs_init(cfv); |
|---|
| 738 | 742 | |
|---|
| 739 | 743 | return 0; |
|---|