diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2008-05-02 22:50:50 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2008-05-02 07:50:50 -0400 |
commit | c45a6816c19dee67b8f725e6646d428901a6dc24 (patch) | |
tree | 096e3263fd14e140685bcc3082394ff15f5aeddb /drivers/virtio/virtio_balloon.c | |
parent | 72e61eb40b55dd57031ec5971e810649f82b0259 (diff) |
virtio: explicit advertisement of driver features
A recent proposed feature addition to the virtio block driver revealed
some flaws in the API: in particular, we assume that feature
negotiation is complete once a driver's probe function returns.
There is nothing in the API to require this, however, and even I
didn't notice when it was violated.
So instead, we require the driver to specify what features it supports
in a table, we can then move the feature negotiation into the virtio
core. The intersection of device and driver features are presented in
a new 'features' bitmap in the struct virtio_device.
Note that this highlights the difference between Linux unsigned-long
bitmaps where each unsigned long is in native endian, and a
straight-forward little-endian array of bytes.
Drivers can still remove feature bits in their probe routine if they
really have to.
API changes:
- dev->config->feature() no longer gets and acks a feature.
- drivers should advertise their features in the 'feature_table' field
- use virtio_has_feature() for extra sanity when checking feature bits
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/virtio/virtio_balloon.c')
-rw-r--r-- | drivers/virtio/virtio_balloon.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index fef88d84cef6..bfef604160d1 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c | |||
@@ -227,7 +227,7 @@ static int virtballoon_probe(struct virtio_device *vdev) | |||
227 | } | 227 | } |
228 | 228 | ||
229 | vb->tell_host_first | 229 | vb->tell_host_first |
230 | = vdev->config->feature(vdev, VIRTIO_BALLOON_F_MUST_TELL_HOST); | 230 | = virtio_has_feature(vdev, VIRTIO_BALLOON_F_MUST_TELL_HOST); |
231 | 231 | ||
232 | return 0; | 232 | return 0; |
233 | 233 | ||
@@ -259,7 +259,11 @@ static void virtballoon_remove(struct virtio_device *vdev) | |||
259 | kfree(vb); | 259 | kfree(vb); |
260 | } | 260 | } |
261 | 261 | ||
262 | static unsigned int features[] = { VIRTIO_BALLOON_F_MUST_TELL_HOST }; | ||
263 | |||
262 | static struct virtio_driver virtio_balloon = { | 264 | static struct virtio_driver virtio_balloon = { |
265 | .feature_table = features, | ||
266 | .feature_table_size = ARRAY_SIZE(features), | ||
263 | .driver.name = KBUILD_MODNAME, | 267 | .driver.name = KBUILD_MODNAME, |
264 | .driver.owner = THIS_MODULE, | 268 | .driver.owner = THIS_MODULE, |
265 | .id_table = id_table, | 269 | .id_table = id_table, |