diff options
Diffstat (limited to 'drivers/misc/mic/card/mic_virtio.c')
| -rw-r--r-- | drivers/misc/mic/card/mic_virtio.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/misc/mic/card/mic_virtio.c b/drivers/misc/mic/card/mic_virtio.c index e64794730e21..e486a0c26267 100644 --- a/drivers/misc/mic/card/mic_virtio.c +++ b/drivers/misc/mic/card/mic_virtio.c | |||
| @@ -68,7 +68,7 @@ static inline struct device *mic_dev(struct mic_vdev *mvdev) | |||
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | /* This gets the device's feature bits. */ | 70 | /* This gets the device's feature bits. */ |
| 71 | static u32 mic_get_features(struct virtio_device *vdev) | 71 | static u64 mic_get_features(struct virtio_device *vdev) |
| 72 | { | 72 | { |
| 73 | unsigned int i, bits; | 73 | unsigned int i, bits; |
| 74 | u32 features = 0; | 74 | u32 features = 0; |
| @@ -76,8 +76,7 @@ static u32 mic_get_features(struct virtio_device *vdev) | |||
| 76 | u8 __iomem *in_features = mic_vq_features(desc); | 76 | u8 __iomem *in_features = mic_vq_features(desc); |
| 77 | int feature_len = ioread8(&desc->feature_len); | 77 | int feature_len = ioread8(&desc->feature_len); |
| 78 | 78 | ||
| 79 | bits = min_t(unsigned, feature_len, | 79 | bits = min_t(unsigned, feature_len, sizeof(features)) * 8; |
| 80 | sizeof(vdev->features)) * 8; | ||
| 81 | for (i = 0; i < bits; i++) | 80 | for (i = 0; i < bits; i++) |
| 82 | if (ioread8(&in_features[i / 8]) & (BIT(i % 8))) | 81 | if (ioread8(&in_features[i / 8]) & (BIT(i % 8))) |
| 83 | features |= BIT(i); | 82 | features |= BIT(i); |
| @@ -85,7 +84,7 @@ static u32 mic_get_features(struct virtio_device *vdev) | |||
| 85 | return features; | 84 | return features; |
| 86 | } | 85 | } |
| 87 | 86 | ||
| 88 | static void mic_finalize_features(struct virtio_device *vdev) | 87 | static int mic_finalize_features(struct virtio_device *vdev) |
| 89 | { | 88 | { |
| 90 | unsigned int i, bits; | 89 | unsigned int i, bits; |
| 91 | struct mic_device_desc __iomem *desc = to_micvdev(vdev)->desc; | 90 | struct mic_device_desc __iomem *desc = to_micvdev(vdev)->desc; |
| @@ -97,14 +96,19 @@ static void mic_finalize_features(struct virtio_device *vdev) | |||
| 97 | /* Give virtio_ring a chance to accept features. */ | 96 | /* Give virtio_ring a chance to accept features. */ |
| 98 | vring_transport_features(vdev); | 97 | vring_transport_features(vdev); |
| 99 | 98 | ||
| 99 | /* Make sure we don't have any features > 32 bits! */ | ||
| 100 | BUG_ON((u32)vdev->features != vdev->features); | ||
| 101 | |||
| 100 | memset_io(out_features, 0, feature_len); | 102 | memset_io(out_features, 0, feature_len); |
| 101 | bits = min_t(unsigned, feature_len, | 103 | bits = min_t(unsigned, feature_len, |
| 102 | sizeof(vdev->features)) * 8; | 104 | sizeof(vdev->features)) * 8; |
| 103 | for (i = 0; i < bits; i++) { | 105 | for (i = 0; i < bits; i++) { |
| 104 | if (test_bit(i, vdev->features)) | 106 | if (__virtio_test_bit(vdev, i)) |
| 105 | iowrite8(ioread8(&out_features[i / 8]) | (1 << (i % 8)), | 107 | iowrite8(ioread8(&out_features[i / 8]) | (1 << (i % 8)), |
| 106 | &out_features[i / 8]); | 108 | &out_features[i / 8]); |
| 107 | } | 109 | } |
| 110 | |||
| 111 | return 0; | ||
| 108 | } | 112 | } |
| 109 | 113 | ||
| 110 | /* | 114 | /* |
