From owner-svn-src-projects@FreeBSD.ORG Tue Jan 29 07:33:41 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 8B9BB577; Tue, 29 Jan 2013 07:33:41 +0000 (UTC) (envelope-from bryanv@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 5356DCE5; Tue, 29 Jan 2013 07:33:41 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0T7XfSM007496; Tue, 29 Jan 2013 07:33:41 GMT (envelope-from bryanv@svn.freebsd.org) Received: (from bryanv@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0T7XfnC007495; Tue, 29 Jan 2013 07:33:41 GMT (envelope-from bryanv@svn.freebsd.org) Message-Id: <201301290733.r0T7XfnC007495@svn.freebsd.org> From: Bryan Venteicher Date: Tue, 29 Jan 2013 07:33:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r246060 - projects/virtio/sys/dev/virtio X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Jan 2013 07:33:41 -0000 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. */