]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/lguest/lguest_device.c
lguest: update commentry
[linux-2.6-omap-h63xx.git] / drivers / lguest / lguest_device.c
index 1a8de57289eb97e5877b9016855cfe9e99adaac1..a661bbdae3d62f657fc801eceb80d9afefc3e4bf 100644 (file)
@@ -98,16 +98,28 @@ static u32 lg_get_features(struct virtio_device *vdev)
        return features;
 }
 
-static void lg_set_features(struct virtio_device *vdev, u32 features)
+/* The virtio core takes the features the Host offers, and copies the
+ * ones supported by the driver into the vdev->features array.  Once
+ * that's all sorted out, this routine is called so we can tell the
+ * Host which features we understand and accept. */
+static void lg_finalize_features(struct virtio_device *vdev)
 {
-       unsigned int i;
+       unsigned int i, bits;
        struct lguest_device_desc *desc = to_lgdev(vdev)->desc;
        /* Second half of bitmap is features we accept. */
        u8 *out_features = lg_features(desc) + desc->feature_len;
 
+       /* Give virtio_ring a chance to accept features. */
+       vring_transport_features(vdev);
+
+       /* The vdev->feature array is a Linux bitmask: this isn't the
+        * same as a the simple array of bits used by lguest devices
+        * for features.  So we do this slow, manual conversion which is
+        * completely general. */
        memset(out_features, 0, desc->feature_len);
-       for (i = 0; i < min(desc->feature_len * 8, 32); i++) {
-               if (features & (1 << i))
+       bits = min_t(unsigned, desc->feature_len, sizeof(vdev->features)) * 8;
+       for (i = 0; i < bits; i++) {
+               if (test_bit(i, vdev->features))
                        out_features[i / 8] |= (1 << (i % 8));
        }
 }
@@ -297,7 +309,7 @@ static void lg_del_vq(struct virtqueue *vq)
 /* The ops structure which hooks everything together. */
 static struct virtio_config_ops lguest_config_ops = {
        .get_features = lg_get_features,
-       .set_features = lg_set_features,
+       .finalize_features = lg_finalize_features,
        .get = lg_get,
        .set = lg_set,
        .get_status = lg_get_status,