Commit e3353853 authored by Christian Borntraeger's avatar Christian Borntraeger Committed by Rusty Russell

virtio: enhance id_matching for virtio drivers

This patch allows a virtio driver to use VIRTIO_DEV_ANY_ID for the
device id. This will be used by a test module that can be bound to
any virtio device.
Signed-off-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent c89e8016
...@@ -58,7 +58,7 @@ static struct device_attribute virtio_dev_attrs[] = { ...@@ -58,7 +58,7 @@ static struct device_attribute virtio_dev_attrs[] = {
static inline int virtio_id_match(const struct virtio_device *dev, static inline int virtio_id_match(const struct virtio_device *dev,
const struct virtio_device_id *id) const struct virtio_device_id *id)
{ {
if (id->device != dev->id.device) if (id->device != dev->id.device && id->device != VIRTIO_DEV_ANY_ID)
return 0; return 0;
return id->vendor == VIRTIO_DEV_ANY_ID || id->vendor == dev->id.vendor; return id->vendor == VIRTIO_DEV_ANY_ID || id->vendor == dev->id.vendor;
......
...@@ -641,7 +641,7 @@ static int do_virtio_entry(const char *filename, struct virtio_device_id *id, ...@@ -641,7 +641,7 @@ static int do_virtio_entry(const char *filename, struct virtio_device_id *id,
id->vendor = TO_NATIVE(id->vendor); id->vendor = TO_NATIVE(id->vendor);
strcpy(alias, "virtio:"); strcpy(alias, "virtio:");
ADD(alias, "d", 1, id->device); ADD(alias, "d", id->device != VIRTIO_DEV_ANY_ID, id->device);
ADD(alias, "v", id->vendor != VIRTIO_DEV_ANY_ID, id->vendor); ADD(alias, "v", id->vendor != VIRTIO_DEV_ANY_ID, id->vendor);
add_wildcard(alias); add_wildcard(alias);
......
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