Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

virtio: simplify feature bit handling

Now that we use u64 for bits, we can simply & them together.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>




+6 -4
+6 -4
drivers/virtio/virtio.c
··· 160 160 struct virtio_device *dev = dev_to_virtio(_d); 161 161 struct virtio_driver *drv = drv_to_virtio(dev->dev.driver); 162 162 u64 device_features; 163 + u64 driver_features; 163 164 unsigned status; 164 165 165 166 /* We have a driver! */ ··· 169 168 /* Figure out what features the device supports. */ 170 169 device_features = dev->config->get_features(dev); 171 170 172 - /* Features supported by both device and driver into dev->features. */ 173 - dev->features = 0; 171 + /* Figure out what features the driver supports. */ 172 + driver_features = 0; 174 173 for (i = 0; i < drv->feature_table_size; i++) { 175 174 unsigned int f = drv->feature_table[i]; 176 175 BUG_ON(f >= 64); 177 - if (device_features & (1ULL << f)) 178 - __virtio_set_bit(dev, f); 176 + driver_features |= (1ULL << f); 179 177 } 178 + 179 + dev->features = driver_features & device_features; 180 180 181 181 /* Transport features always preserved to pass to finalize_features. */ 182 182 for (i = VIRTIO_TRANSPORT_F_START; i < VIRTIO_TRANSPORT_F_END; i++)