static int vop_finalize_features(struct virtio_device *vdev) { unsigned int i, bits; struct mic_device_desc __iomem *desc = to_vopvdev(vdev)->desc; u8 feature_len = ioread8(&desc->feature_len); /* Second half of bitmap is features we accept. */ u8 __iomem *out_features = _vop_vq_features(desc) + feature_len; /* Give virtio_ring a chance to accept features. */ vring_transport_features(vdev); /* Give virtio_vop a chance to accept features. */ vop_transport_features(vdev); memset_io(out_features, 0, feature_len); bits = min_t(unsigned, feature_len, sizeof(vdev->features)) * 8; for (i = 0; i < bits; i++) { if (__virtio_test_bit(vdev, i)) iowrite8(ioread8(&out_features[i / 8]) | (1 << (i % 8)), &out_features[i / 8]); } return 0; }
static ssize_t features_show(struct device *_d, struct device_attribute *attr, char *buf) { struct virtio_device *dev = dev_to_virtio(_d); unsigned int i; ssize_t len = 0; /* We actually represent this as a bitstring, as it could be * arbitrary length in future. */ for (i = 0; i < sizeof(dev->features)*8; i++) len += sprintf(buf+len, "%c", __virtio_test_bit(dev, i) ? '1' : '0'); len += sprintf(buf+len, "\n"); return len; }