diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2014-10-23 10:57:30 -0400 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2014-12-09 05:05:25 -0500 |
commit | c102659d690d382171bd2e40f35c5c811f0cdcac (patch) | |
tree | 1aa9cae6de46700abd0bccb019a851a0c7bcbbb7 /drivers/virtio | |
parent | cb3f6d9da49929797f806b4e91ec005e6fc2e9c2 (diff) |
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>
Diffstat (limited to 'drivers/virtio')
-rw-r--r-- | drivers/virtio/virtio.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index 9248125d29c9..3e78f4bcfa8e 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c | |||
@@ -160,6 +160,7 @@ static int virtio_dev_probe(struct device *_d) | |||
160 | struct virtio_device *dev = dev_to_virtio(_d); | 160 | struct virtio_device *dev = dev_to_virtio(_d); |
161 | struct virtio_driver *drv = drv_to_virtio(dev->dev.driver); | 161 | struct virtio_driver *drv = drv_to_virtio(dev->dev.driver); |
162 | u64 device_features; | 162 | u64 device_features; |
163 | u64 driver_features; | ||
163 | unsigned status; | 164 | unsigned status; |
164 | 165 | ||
165 | /* We have a driver! */ | 166 | /* We have a driver! */ |
@@ -168,15 +169,16 @@ static int virtio_dev_probe(struct device *_d) | |||
168 | /* Figure out what features the device supports. */ | 169 | /* Figure out what features the device supports. */ |
169 | device_features = dev->config->get_features(dev); | 170 | device_features = dev->config->get_features(dev); |
170 | 171 | ||
171 | /* Features supported by both device and driver into dev->features. */ | 172 | /* Figure out what features the driver supports. */ |
172 | dev->features = 0; | 173 | driver_features = 0; |
173 | for (i = 0; i < drv->feature_table_size; i++) { | 174 | for (i = 0; i < drv->feature_table_size; i++) { |
174 | unsigned int f = drv->feature_table[i]; | 175 | unsigned int f = drv->feature_table[i]; |
175 | BUG_ON(f >= 64); | 176 | BUG_ON(f >= 64); |
176 | if (device_features & (1ULL << f)) | 177 | driver_features |= (1ULL << f); |
177 | __virtio_set_bit(dev, f); | ||
178 | } | 178 | } |
179 | 179 | ||
180 | dev->features = driver_features & device_features; | ||
181 | |||
180 | /* Transport features always preserved to pass to finalize_features. */ | 182 | /* Transport features always preserved to pass to finalize_features. */ |
181 | for (i = VIRTIO_TRANSPORT_F_START; i < VIRTIO_TRANSPORT_F_END; i++) | 183 | for (i = VIRTIO_TRANSPORT_F_START; i < VIRTIO_TRANSPORT_F_END; i++) |
182 | if (device_features & (1ULL << i)) | 184 | if (device_features & (1ULL << i)) |