virtio: sandbox: Fix device features bitfield
authorAndrew Scull <ascull@google.com>
Mon, 16 May 2022 10:41:34 +0000 (10:41 +0000)
committerTom Rini <trini@konsulko.com>
Wed, 8 Jun 2022 13:24:03 +0000 (09:24 -0400)
The virtio sandbox transport was setting the device features value to
the bit index rather than shifting a bit to the right index. Fix this
using the bit manipulation macros.

Signed-off-by: Andrew Scull <ascull@google.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
drivers/virtio/virtio_sandbox.c
test/dm/virtio.c

index aafb7be..a73b123 100644 (file)
@@ -160,7 +160,7 @@ static int virtio_sandbox_probe(struct udevice *udev)
        struct virtio_dev_priv *uc_priv = dev_get_uclass_priv(udev);
 
        /* fake some information for testing */
-       priv->device_features = VIRTIO_F_VERSION_1;
+       priv->device_features = BIT_ULL(VIRTIO_F_VERSION_1);
        uc_priv->device = VIRTIO_ID_BLOCK;
        uc_priv->vendor = ('u' << 24) | ('b' << 16) | ('o' << 8) | 't';
 
index adef105..aa4e3d7 100644 (file)
@@ -77,7 +77,7 @@ static int dm_test_virtio_all_ops(struct unit_test_state *uts)
        ut_assertok(virtio_get_status(dev, &status));
        ut_asserteq(0, status);
        ut_assertok(virtio_get_features(dev, &features));
-       ut_asserteq(VIRTIO_F_VERSION_1, features);
+       ut_asserteq_64(BIT_ULL(VIRTIO_F_VERSION_1), features);
        ut_assertok(virtio_set_features(dev));
        ut_assertok(virtio_find_vqs(dev, nvqs, vqs));
        ut_assertok(virtio_del_vqs(dev));