summaryrefslogtreecommitdiffstats
path: root/sys/dev/virtio/virtio.c
diff options
context:
space:
mode:
authorbryanv <bryanv@FreeBSD.org>2013-07-04 17:57:26 +0000
committerbryanv <bryanv@FreeBSD.org>2013-07-04 17:57:26 +0000
commit5cda36b5ac3c30cfb2a0c172471aacfa08583438 (patch)
treeee2ee2f1b022368ac3e2a7f0618fc28ba9d4135c /sys/dev/virtio/virtio.c
parente56d87e5498bf6002856c59cb2e6bc32d5f9a555 (diff)
downloadFreeBSD-src-5cda36b5ac3c30cfb2a0c172471aacfa08583438.zip
FreeBSD-src-5cda36b5ac3c30cfb2a0c172471aacfa08583438.tar.gz
Merge virtio changes from projects/virtio
Contains projects/virtio commits: r245738: virtio: Minor man page tweaks r246060: virtio: Cleanup feature description printing r246306: virtio: Remove old debugging flag r247238: virtio: Remove PRIx64 macros from format strings r247239: virtio: Constify some fields r247240: virtio: Minor code simplifications r249962: virtio: Update to my freebsd.org email address MFC after: 1 month
Diffstat (limited to 'sys/dev/virtio/virtio.c')
-rw-r--r--sys/dev/virtio/virtio.c59
1 files changed, 29 insertions, 30 deletions
diff --git a/sys/dev/virtio/virtio.c b/sys/dev/virtio/virtio.c
index 6c6b0bc..ea2b91a 100644
--- a/sys/dev/virtio/virtio.c
+++ b/sys/dev/virtio/virtio.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2011, Bryan Venteicher <bryanv@daemoninthecloset.org>
+ * Copyright (c) 2011, Bryan Venteicher <bryanv@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -36,7 +36,6 @@ __FBSDID("$FreeBSD$");
#include <machine/bus.h>
#include <machine/resource.h>
-#include <machine/_inttypes.h>
#include <sys/bus.h>
#include <sys/rman.h>
@@ -49,8 +48,8 @@ static int virtio_modevent(module_t, int, void *);
static const char *virtio_feature_name(uint64_t, struct virtio_feature_desc *);
static struct virtio_ident {
- uint16_t devid;
- char *name;
+ uint16_t devid;
+ const char *name;
} virtio_ident_table[] = {
{ VIRTIO_ID_NETWORK, "Network" },
{ VIRTIO_ID_BLOCK, "Block" },
@@ -87,9 +86,29 @@ 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)
+ 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,13 +117,12 @@ virtio_describe(device_t dev, const char *msg,
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: %#jx\n", msg, (uintmax_t) features);
return;
}
sbuf_new(&sb, buf, 512, SBUF_FIXEDLEN);
- sbuf_printf(&sb, "%s features: 0x%"PRIx64, msg, features);
+ sbuf_printf(&sb, "%s features: %#jx", msg, (uintmax_t) features);
for (n = 0, val = 1ULL << 63; val != 0; val >>= 1) {
/*
@@ -119,15 +137,9 @@ virtio_describe(device_t dev, const char *msg,
else
sbuf_cat(&sb, ",");
- name = NULL;
- if (feature_desc != NULL)
- name = virtio_feature_name(val, feature_desc);
+ name = virtio_feature_name(val, desc);
if (name == NULL)
- name = virtio_feature_name(val,
- virtio_common_feature_desc);
-
- if (name == NULL)
- sbuf_printf(&sb, "0x%"PRIx64, val);
+ sbuf_printf(&sb, "%#jx", (uintmax_t) val);
else
sbuf_cat(&sb, name);
}
@@ -147,18 +159,6 @@ virtio_describe(device_t dev, const char *msg,
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.
*/
@@ -251,13 +251,12 @@ virtio_modevent(module_t mod, int type, void *unused)
{
int error;
- error = 0;
-
switch (type) {
case MOD_LOAD:
case MOD_QUIESCE:
case MOD_UNLOAD:
case MOD_SHUTDOWN:
+ error = 0;
break;
default:
error = EOPNOTSUPP;
OpenPOWER on IntegriCloud