Fix and enhance virtio device id matching
Subsystems (3)
cover Fix and enhance virtio device id matching
Hello Rusty,
here are two patches that change the device matching of the virtio bus. The patches have been refreshed agains linux-next and should apply to your private virtio tree.
OK for linux-next?
Christian
PATCH 1/2 virtio: fix id_matching for virtio drivers
From: Christian Borntraeger <[email protected]>
This bug never appeared, since all current virtio drivers use VIRTIO_DEV_ANY_ID for the vendor field. If a real vendor would be used, the check in virtio_id_match is wrong - it returns 0 if id->vendor == dev->id.vendor.
--- drivers/virtio/virtio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/virtio/virtio.c +1 -1
@@ -61,7 +61,7 @@ static inline int virtio_id_match(constif (id->device != dev->id.device)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; }/* This looks through all the IDs a driver claims to support. If any of them
PATCH 1/2 virtio: fix id_matching for virtio drivers
In reply to Christian BorntraegerFrom: Christian Borntraeger <[email protected]>
This bug never appeared, since all current virtio drivers use VIRTIO_DEV_ANY_ID for the vendor field. If a real vendor would be used, the check in virtio_id_match is wrong - it returns 0 if id->vendor == dev->id.vendor.
--- drivers/virtio/virtio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/virtio/virtio.c +1 -1
@@ -61,7 +61,7 @@ static inline int virtio_id_match(constif (id->device != dev->id.device)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; }/* This looks through all the IDs a driver claims to support. If any of them
PATCH 2/2 virtio: enhance id_matching for virtio drivers
In reply to Christian BorntraegerFrom: Christian Borntraeger <[email protected]>
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.
--- drivers/virtio/virtio.c | 2 +- scripts/mod/file2alias.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/virtio/virtio.c +1 -1
@@ -58,7 +58,7 @@ static struct device_attribute virtio_destatic inline int virtio_id_match (const struct virtio_device *dev,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 id->vendor ==VIRTIO_DEV_ANY_ID || id->vendor == dev->id.vendor;
scripts/mod/file2alias.c +1 -1
@@ -641,7 +641,7 @@ static int do_virtio_entry(const char *f id->vendor =TO_NATIVE (id->vendor);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_wildcard (alias);
PATCH 2/2 virtio: enhance id_matching for virtio drivers
In reply to Christian BorntraegerFrom: Christian Borntraeger <[email protected]>
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.
--- drivers/virtio/virtio.c | 2 +- scripts/mod/file2alias.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/virtio/virtio.c +1 -1
@@ -58,7 +58,7 @@ static struct device_attribute virtio_destatic inline int virtio_id_match (const struct virtio_device *dev,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 id->vendor ==VIRTIO_DEV_ANY_ID || id->vendor == dev->id.vendor;
scripts/mod/file2alias.c +1 -1
@@ -641,7 +641,7 @@ static int do_virtio_entry(const char *f id->vendor =TO_NATIVE (id->vendor);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_wildcard (alias);
Quoted 7 lines · Christian Borntraeger
Hello Rusty,
here are two patches that change the device matching of the virtio bus. The patches have been refreshed agains linux-next and should apply to your private virtio tree.
OK for linux-next?
Sure, added.
Thanks!
Rusty.
Quoted 7 lines · Christian Borntraeger
Hello Rusty,
here are two patches that change the device matching of the virtio bus. The patches have been refreshed agains linux-next and should apply to your private virtio tree.
OK for linux-next?
Sure, added.
Thanks!
Rusty.