diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2009-09-24 00:26:31 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2009-09-23 08:56:31 -0400 |
commit | 3c1b27d5043086a485f8526353ae9fe37bfa1065 (patch) | |
tree | e3b6eda3c66bcd1fc3af6e7fa6e4e3af77459474 /drivers/char | |
parent | f68d24082e22ccee3077d11aeb6dc5354f0ca7f1 (diff) |
virtio: make add_buf return capacity remaining
This API change means that virtio_net can tell how much capacity
remains for buffers. It's necessarily fuzzy, since
VIRTIO_RING_F_INDIRECT_DESC means we can fit any number of descriptors
in one, *if* we can kmalloc.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: Dinesh Subhraveti <dineshs@us.ibm.com>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/hw_random/virtio-rng.c | 2 | ||||
-rw-r--r-- | drivers/char/virtio_console.c | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c index 32216b623248..b6c24dcc987d 100644 --- a/drivers/char/hw_random/virtio-rng.c +++ b/drivers/char/hw_random/virtio-rng.c | |||
@@ -51,7 +51,7 @@ static void register_buffer(void) | |||
51 | 51 | ||
52 | sg_init_one(&sg, random_data+data_left, RANDOM_DATA_SIZE-data_left); | 52 | sg_init_one(&sg, random_data+data_left, RANDOM_DATA_SIZE-data_left); |
53 | /* There should always be room for one buffer. */ | 53 | /* There should always be room for one buffer. */ |
54 | if (vq->vq_ops->add_buf(vq, &sg, 0, 1, random_data) != 0) | 54 | if (vq->vq_ops->add_buf(vq, &sg, 0, 1, random_data) < 0) |
55 | BUG(); | 55 | BUG(); |
56 | vq->vq_ops->kick(vq); | 56 | vq->vq_ops->kick(vq); |
57 | } | 57 | } |
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index c74dacfa6795..a035ae39a359 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c | |||
@@ -65,7 +65,7 @@ static int put_chars(u32 vtermno, const char *buf, int count) | |||
65 | 65 | ||
66 | /* add_buf wants a token to identify this buffer: we hand it any | 66 | /* add_buf wants a token to identify this buffer: we hand it any |
67 | * non-NULL pointer, since there's only ever one buffer. */ | 67 | * non-NULL pointer, since there's only ever one buffer. */ |
68 | if (out_vq->vq_ops->add_buf(out_vq, sg, 1, 0, (void *)1) == 0) { | 68 | if (out_vq->vq_ops->add_buf(out_vq, sg, 1, 0, (void *)1) >= 0) { |
69 | /* Tell Host to go! */ | 69 | /* Tell Host to go! */ |
70 | out_vq->vq_ops->kick(out_vq); | 70 | out_vq->vq_ops->kick(out_vq); |
71 | /* Chill out until it's done with the buffer. */ | 71 | /* Chill out until it's done with the buffer. */ |
@@ -85,7 +85,7 @@ static void add_inbuf(void) | |||
85 | sg_init_one(sg, inbuf, PAGE_SIZE); | 85 | sg_init_one(sg, inbuf, PAGE_SIZE); |
86 | 86 | ||
87 | /* We should always be able to add one buffer to an empty queue. */ | 87 | /* We should always be able to add one buffer to an empty queue. */ |
88 | if (in_vq->vq_ops->add_buf(in_vq, sg, 0, 1, inbuf) != 0) | 88 | if (in_vq->vq_ops->add_buf(in_vq, sg, 0, 1, inbuf) < 0) |
89 | BUG(); | 89 | BUG(); |
90 | in_vq->vq_ops->kick(in_vq); | 90 | in_vq->vq_ops->kick(in_vq); |
91 | } | 91 | } |