From: Cornelia Huck <cohuck@redhat.com>
To: weiping zhang <zhangweiping@didichuxing.com>
Cc: virtualization@lists.linux-foundation.org, mst@redhat.com
Subject: Re: [RFC PATCH] virtio: add space for device features show
Date: Mon, 8 Jan 2018 13:50:37 +0100 [thread overview]
Message-ID: <20180108135037.5f29c10b.cohuck@redhat.com> (raw)
In-Reply-To: <20171226133539.GA15965@localhost.didichuxing.com>
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).
prev parent reply other threads:[~2018-01-08 12:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-26 13:35 [RFC PATCH] virtio: add space for device features show weiping zhang
2018-01-08 12:50 ` Cornelia Huck [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180108135037.5f29c10b.cohuck@redhat.com \
--to=cohuck@redhat.com \
--cc=mst@redhat.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=zhangweiping@didichuxing.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox