Commit 404123c2 authored by Michael S. Tsirkin's avatar Michael S. Tsirkin

virtio: allow drivers to validate features

Some drivers can't support all features in all configurations.  At the
moment we blindly set FEATURES_OK and later FAILED.  Support this better
by adding a callback drivers can use to do some early checks.
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent 2e123b44
...@@ -232,6 +232,12 @@ static int virtio_dev_probe(struct device *_d) ...@@ -232,6 +232,12 @@ static int virtio_dev_probe(struct device *_d)
if (device_features & (1ULL << i)) if (device_features & (1ULL << i))
__virtio_set_bit(dev, i); __virtio_set_bit(dev, i);
if (drv->validate) {
err = drv->validate(dev);
if (err)
goto err;
}
err = virtio_finalize_features(dev); err = virtio_finalize_features(dev);
if (err) if (err)
goto err; goto err;
......
...@@ -167,6 +167,7 @@ struct virtio_driver { ...@@ -167,6 +167,7 @@ struct virtio_driver {
unsigned int feature_table_size; unsigned int feature_table_size;
const unsigned int *feature_table_legacy; const unsigned int *feature_table_legacy;
unsigned int feature_table_size_legacy; unsigned int feature_table_size_legacy;
int (*validate)(struct virtio_device *dev);
int (*probe)(struct virtio_device *dev); int (*probe)(struct virtio_device *dev);
void (*scan)(struct virtio_device *dev); void (*scan)(struct virtio_device *dev);
void (*remove)(struct virtio_device *dev); void (*remove)(struct virtio_device *dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment