svn commit: r246060 - projects/virtio/sys/dev/virtio
Bryan Venteicher
bryanv at FreeBSD.org
Tue Jan 29 07:33:41 UTC 2013
Author: bryanv
Date: Tue Jan 29 07:33:40 2013
New Revision: 246060
URL: http://svnweb.freebsd.org/changeset/base/246060
Log:
virtio: Cleanup feature description printing
Approved by: grehan (implicit)
Modified:
projects/virtio/sys/dev/virtio/virtio.c
Modified: projects/virtio/sys/dev/virtio/virtio.c
==============================================================================
--- projects/virtio/sys/dev/virtio/virtio.c Tue Jan 29 07:32:00 2013 (r246059)
+++ projects/virtio/sys/dev/virtio/virtio.c Tue Jan 29 07:33:40 2013 (r246060)
@@ -87,9 +87,30 @@ virtio_device_name(uint16_t devid)
return (NULL);
}
+static const char *
+virtio_feature_name(uint64_t val, struct virtio_feature_desc *desc)
+{
+ int i, j;
+ struct virtio_feature_desc *descs[2] = { desc,
+ virtio_common_feature_desc };
+
+ for (i = 0; i < 2; i++) {
+ if (descs[i] == NULL)
+ continue;
+
+ for (j = 0; descs[i][j].vfd_val != 0; j++) {
+ if (val != descs[i][j].vfd_val)
+ continue;
+ return (descs[i][j].vfd_str);
+ }
+ }
+
+ return (NULL);
+}
+
void
virtio_describe(device_t dev, const char *msg,
- uint64_t features, struct virtio_feature_desc *feature_desc)
+ uint64_t features, struct virtio_feature_desc *desc)
{
struct sbuf sb;
uint64_t val;
@@ -98,8 +119,7 @@ virtio_describe(device_t dev, const char
int n;
if ((buf = malloc(512, M_TEMP, M_NOWAIT)) == NULL) {
- device_printf(dev, "%s features: 0x%"PRIx64"\n", msg,
- features);
+ device_printf(dev, "%s features: 0x%"PRIx64"\n", msg, features);
return;
}
@@ -119,13 +139,7 @@ virtio_describe(device_t dev, const char
else
sbuf_cat(&sb, ",");
- name = NULL;
- if (feature_desc != NULL)
- name = virtio_feature_name(val, feature_desc);
- if (name == NULL)
- name = virtio_feature_name(val,
- virtio_common_feature_desc);
-
+ name = virtio_feature_name(val, desc);
if (name == NULL)
sbuf_printf(&sb, "0x%"PRIx64, val);
else
@@ -147,18 +161,6 @@ virtio_describe(device_t dev, const char
free(buf, M_TEMP);
}
-static const char *
-virtio_feature_name(uint64_t val, struct virtio_feature_desc *feature_desc)
-{
- int i;
-
- for (i = 0; feature_desc[i].vfd_val != 0; i++)
- if (val == feature_desc[i].vfd_val)
- return (feature_desc[i].vfd_str);
-
- return (NULL);
-}
-
/*
* VirtIO bus method wrappers.
*/
More information about the svn-src-projects
mailing list