Skip to content

Commit

Permalink
virtio: allow drivers to validate features
Browse files Browse the repository at this point in the history
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: Michael S. Tsirkin <[email protected]>
  • Loading branch information
mstsirkin committed Apr 7, 2017
1 parent 2e123b4 commit 404123c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/virtio/virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ static int virtio_dev_probe(struct device *_d)
if (device_features & (1ULL << i))
__virtio_set_bit(dev, i);

if (drv->validate) {
err = drv->validate(dev);
if (err)
goto err;
}

err = virtio_finalize_features(dev);
if (err)
goto err;
Expand Down
1 change: 1 addition & 0 deletions include/linux/virtio.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ struct virtio_driver {
unsigned int feature_table_size;
const unsigned int *feature_table_legacy;
unsigned int feature_table_size_legacy;
int (*validate)(struct virtio_device *dev);
int (*probe)(struct virtio_device *dev);
void (*scan)(struct virtio_device *dev);
void (*remove)(struct virtio_device *dev);
Expand Down

0 comments on commit 404123c

Please sign in to comment.