Skip to content

Commit c8e82e3

Browse files
Dawei Limstsirkin
authored andcommitted
virtio: Implementing attribute show with sysfs_emit
Replace sprintf with sysfs_emit or its variants for their built-in PAGE_SIZE awareness. Signed-off-by: Dawei Li <[email protected]> Message-Id: <TYCP286MB23232A999FE7DBDF50BA0FAACA0F9@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent b1d65f7 commit c8e82e3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/virtio/virtio.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,31 @@ static ssize_t device_show(struct device *_d,
1515
struct device_attribute *attr, char *buf)
1616
{
1717
struct virtio_device *dev = dev_to_virtio(_d);
18-
return sprintf(buf, "0x%04x\n", dev->id.device);
18+
return sysfs_emit(buf, "0x%04x\n", dev->id.device);
1919
}
2020
static DEVICE_ATTR_RO(device);
2121

2222
static ssize_t vendor_show(struct device *_d,
2323
struct device_attribute *attr, char *buf)
2424
{
2525
struct virtio_device *dev = dev_to_virtio(_d);
26-
return sprintf(buf, "0x%04x\n", dev->id.vendor);
26+
return sysfs_emit(buf, "0x%04x\n", dev->id.vendor);
2727
}
2828
static DEVICE_ATTR_RO(vendor);
2929

3030
static ssize_t status_show(struct device *_d,
3131
struct device_attribute *attr, char *buf)
3232
{
3333
struct virtio_device *dev = dev_to_virtio(_d);
34-
return sprintf(buf, "0x%08x\n", dev->config->get_status(dev));
34+
return sysfs_emit(buf, "0x%08x\n", dev->config->get_status(dev));
3535
}
3636
static DEVICE_ATTR_RO(status);
3737

3838
static ssize_t modalias_show(struct device *_d,
3939
struct device_attribute *attr, char *buf)
4040
{
4141
struct virtio_device *dev = dev_to_virtio(_d);
42-
return sprintf(buf, "virtio:d%08Xv%08X\n",
42+
return sysfs_emit(buf, "virtio:d%08Xv%08X\n",
4343
dev->id.device, dev->id.vendor);
4444
}
4545
static DEVICE_ATTR_RO(modalias);
@@ -54,9 +54,9 @@ static ssize_t features_show(struct device *_d,
5454
/* We actually represent this as a bitstring, as it could be
5555
* arbitrary length in future. */
5656
for (i = 0; i < sizeof(dev->features)*8; i++)
57-
len += sprintf(buf+len, "%c",
57+
len += sysfs_emit_at(buf, len, "%c",
5858
__virtio_test_bit(dev, i) ? '1' : '0');
59-
len += sprintf(buf+len, "\n");
59+
len += sysfs_emit_at(buf, len, "\n");
6060
return len;
6161
}
6262
static DEVICE_ATTR_RO(features);

0 commit comments

Comments
 (0)