* [RFC PATCH] virtio: add space for device features show
@ 2017-12-26 13:35 weiping zhang
2018-01-08 12:50 ` Cornelia Huck
0 siblings, 1 reply; 2+ messages in thread
From: weiping zhang @ 2017-12-26 13:35 UTC (permalink / raw)
To: cohuck, mst, jasowang; +Cc: virtualization
make features string more readable, add space every 8bit.
example:
00101010 01110000 00000000 00001100
Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
---
drivers/virtio/virtio.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index 59e36ef..d7d2db1 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -50,9 +50,12 @@ static ssize_t features_show(struct device *_d,
/* 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",
+ for (i = 0; i < sizeof(dev->features) * 8; i++) {
+ len += sprintf(buf + len, "%c",
__virtio_test_bit(dev, i) ? '1' : '0');
+ if (i % 8 == 7)
+ len += sprintf(buf + len, " ");
+ }
len += sprintf(buf+len, "\n");
return len;
}
--
2.9.4
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [RFC PATCH] virtio: add space for device features show
2017-12-26 13:35 [RFC PATCH] virtio: add space for device features show weiping zhang
@ 2018-01-08 12:50 ` Cornelia Huck
0 siblings, 0 replies; 2+ messages in thread
From: Cornelia Huck @ 2018-01-08 12:50 UTC (permalink / raw)
To: weiping zhang; +Cc: virtualization, mst
On Tue, 26 Dec 2017 21:35:44 +0800
weiping zhang <zhangweiping@didichuxing.com> wrote:
> make features string more readable, add space every 8bit.
> example:
> 00101010 01110000 00000000 00001100
>
> Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
> ---
> drivers/virtio/virtio.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
> index 59e36ef..d7d2db1 100644
> --- a/drivers/virtio/virtio.c
> +++ b/drivers/virtio/virtio.c
> @@ -50,9 +50,12 @@ static ssize_t features_show(struct device *_d,
>
> /* 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",
> + for (i = 0; i < sizeof(dev->features) * 8; i++) {
> + len += sprintf(buf + len, "%c",
> __virtio_test_bit(dev, i) ? '1' : '0');
> + if (i % 8 == 7)
> + len += sprintf(buf + len, " ");
> + }
> len += sprintf(buf+len, "\n");
> return len;
> }
This might break consumers of this attribute.
I think the better approach is to write a userspace tool that can do
additional helpful stuff (like decoding the feature bits).
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-01-08 12:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-26 13:35 [RFC PATCH] virtio: add space for device features show weiping zhang
2018-01-08 12:50 ` Cornelia Huck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox