aboutsummaryrefslogtreecommitdiff
path: root/drivers/net/caif/caif_virtio.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/caif/caif_virtio.c')
-rw-r--r--drivers/net/caif/caif_virtio.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/drivers/net/caif/caif_virtio.c b/drivers/net/caif/caif_virtio.c
index b1e1205e4e2..985608634f8 100644
--- a/drivers/net/caif/caif_virtio.c
+++ b/drivers/net/caif/caif_virtio.c
@@ -1,8 +1,8 @@
/*
* Copyright (C) ST-Ericsson AB 2013
- * Authors: Vicram Arv / vikram.arv@stericsson.com,
- * Dmitry Tarnyagin / dmitry.tarnyagin@stericsson.com
- * Sjur Brendeland / sjur.brandeland@stericsson.com
+ * Authors: Vicram Arv
+ * Dmitry Tarnyagin <dmitry.tarnyagin@lockless.no>
+ * Sjur Brendeland
* License terms: GNU General Public License (GPL) version 2
*/
#include <linux/module.h>
@@ -23,8 +23,8 @@
#include <linux/virtio_config.h>
MODULE_LICENSE("GPL v2");
-MODULE_AUTHOR("Vicram Arv <vikram.arv@stericsson.com>");
-MODULE_AUTHOR("Sjur Brendeland <sjur.brandeland@stericsson.com>");
+MODULE_AUTHOR("Vicram Arv");
+MODULE_AUTHOR("Sjur Brendeland");
MODULE_DESCRIPTION("Virtio CAIF Driver");
/* NAPI schedule quota */
@@ -318,7 +318,7 @@ exit:
/* Really out of patckets? (stolen from virtio_net)*/
napi_complete(napi);
- if (unlikely(vringh_notify_enable_kern(cfv->vr_rx)) &&
+ if (unlikely(!vringh_notify_enable_kern(cfv->vr_rx)) &&
napi_schedule_prep(napi)) {
vringh_notify_disable_kern(cfv->vr_rx);
__napi_schedule(napi);
@@ -424,8 +424,10 @@ static int cfv_create_genpool(struct cfv_info *cfv)
cfv->reserved_size = num_possible_cpus() * cfv->ndev->mtu;
cfv->reserved_mem = gen_pool_alloc(cfv->genpool,
cfv->reserved_size);
- if (!cfv->reserved_mem)
+ if (!cfv->reserved_mem) {
+ err = -ENOMEM;
goto err;
+ }
cfv->watermark_tx = virtqueue_get_vring_size(cfv->vq_tx);
return 0;
@@ -572,8 +574,7 @@ static int cfv_netdev_tx(struct sk_buff *skb, struct net_device *netdev)
goto err;
}
- ret = virtqueue_add_buf(cfv->vq_tx, &sg, 1, 0,
- buf_info, GFP_ATOMIC);
+ ret = virtqueue_add_outbuf(cfv->vq_tx, &sg, 1, buf_info, GFP_ATOMIC);
if (unlikely((ret < 0))) {
/* If flow control works, this shouldn't happen */
netdev_warn(cfv->ndev, "Failed adding buffer to TX vring:%d\n",
@@ -671,6 +672,10 @@ static int cfv_probe(struct virtio_device *vdev)
spin_lock_init(&cfv->tx_lock);
/* Get the RX virtio ring. This is a "host side vring". */
+ err = -ENODEV;
+ if (!vdev->vringh_config || !vdev->vringh_config->find_vrhs)
+ goto err;
+
err = vdev->vringh_config->find_vrhs(vdev, 1, &cfv->vr_rx, &vrh_cbs);
if (err)
goto err;
@@ -681,18 +686,19 @@ static int cfv_probe(struct virtio_device *vdev)
goto err;
/* Get the CAIF configuration from virtio config space, if available */
-#define GET_VIRTIO_CONFIG_OPS(_v, _var, _f) \
- ((_v)->config->get(_v, offsetof(struct virtio_caif_transf_config, _f), \
- &_var, \
- FIELD_SIZEOF(struct virtio_caif_transf_config, _f)))
-
if (vdev->config->get) {
- GET_VIRTIO_CONFIG_OPS(vdev, cfv->tx_hr, headroom);
- GET_VIRTIO_CONFIG_OPS(vdev, cfv->rx_hr, headroom);
- GET_VIRTIO_CONFIG_OPS(vdev, cfv->tx_tr, tailroom);
- GET_VIRTIO_CONFIG_OPS(vdev, cfv->rx_tr, tailroom);
- GET_VIRTIO_CONFIG_OPS(vdev, cfv->mtu, mtu);
- GET_VIRTIO_CONFIG_OPS(vdev, cfv->mru, mtu);
+ virtio_cread(vdev, struct virtio_caif_transf_config, headroom,
+ &cfv->tx_hr);
+ virtio_cread(vdev, struct virtio_caif_transf_config, headroom,
+ &cfv->rx_hr);
+ virtio_cread(vdev, struct virtio_caif_transf_config, tailroom,
+ &cfv->tx_tr);
+ virtio_cread(vdev, struct virtio_caif_transf_config, tailroom,
+ &cfv->rx_tr);
+ virtio_cread(vdev, struct virtio_caif_transf_config, mtu,
+ &cfv->mtu);
+ virtio_cread(vdev, struct virtio_caif_transf_config, mtu,
+ &cfv->mru);
} else {
cfv->tx_hr = CFV_DEF_HEADROOM;
cfv->rx_hr = CFV_DEF_HEADROOM;