Skip to content

Commit 404123c

Browse files
committed
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: Michael S. Tsirkin <[email protected]>
1 parent 2e123b4 commit 404123c

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

drivers/virtio/virtio.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,12 @@ static int virtio_dev_probe(struct device *_d)
232232
if (device_features & (1ULL << i))
233233
__virtio_set_bit(dev, i);
234234

235+
if (drv->validate) {
236+
err = drv->validate(dev);
237+
if (err)
238+
goto err;
239+
}
240+
235241
err = virtio_finalize_features(dev);
236242
if (err)
237243
goto err;

include/linux/virtio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ struct virtio_driver {
167167
unsigned int feature_table_size;
168168
const unsigned int *feature_table_legacy;
169169
unsigned int feature_table_size_legacy;
170+
int (*validate)(struct virtio_device *dev);
170171
int (*probe)(struct virtio_device *dev);
171172
void (*scan)(struct virtio_device *dev);
172173
void (*remove)(struct virtio_device *dev);

0 commit comments

Comments
 (0)