From owner-svn-src-head@freebsd.org Mon May 27 00:55:47 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5145615B59AC; Mon, 27 May 2019 00:55:47 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EC3DC75B21; Mon, 27 May 2019 00:55:46 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DB2F423840; Mon, 27 May 2019 00:55:46 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4R0tk3T073403; Mon, 27 May 2019 00:55:46 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4R0tklp073402; Mon, 27 May 2019 00:55:46 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201905270055.x4R0tklp073402@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Mon, 27 May 2019 00:55:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r348295 - head/sys/dev/virtio/random X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: head/sys/dev/virtio/random X-SVN-Commit-Revision: 348295 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: EC3DC75B21 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.965,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 May 2019 00:55:47 -0000 Author: cem Date: Mon May 27 00:55:46 2019 New Revision: 348295 URL: https://svnweb.freebsd.org/changeset/base/348295 Log: virtio_random(4): Remove unneeded reference to device The device_t always references the softc, so we can pass the device and obtain the softc instead of the other way around. Modified: head/sys/dev/virtio/random/virtio_random.c Modified: head/sys/dev/virtio/random/virtio_random.c ============================================================================== --- head/sys/dev/virtio/random/virtio_random.c Mon May 27 00:51:27 2019 (r348294) +++ head/sys/dev/virtio/random/virtio_random.c Mon May 27 00:55:46 2019 (r348295) @@ -46,7 +46,6 @@ __FBSDID("$FreeBSD$"); #include struct vtrnd_softc { - device_t vtrnd_dev; uint64_t vtrnd_features; struct callout vtrnd_callout; struct virtqueue *vtrnd_vq; @@ -58,8 +57,8 @@ static int vtrnd_probe(device_t); static int vtrnd_attach(device_t); static int vtrnd_detach(device_t); -static void vtrnd_negotiate_features(struct vtrnd_softc *); -static int vtrnd_alloc_virtqueue(struct vtrnd_softc *); +static void vtrnd_negotiate_features(device_t); +static int vtrnd_alloc_virtqueue(device_t); static void vtrnd_harvest(struct vtrnd_softc *); static void vtrnd_timer(void *); @@ -129,14 +128,13 @@ vtrnd_attach(device_t dev) int error; sc = device_get_softc(dev); - sc->vtrnd_dev = dev; callout_init(&sc->vtrnd_callout, 1); virtio_set_feature_desc(dev, vtrnd_feature_desc); - vtrnd_negotiate_features(sc); + vtrnd_negotiate_features(dev); - error = vtrnd_alloc_virtqueue(sc); + error = vtrnd_alloc_virtqueue(dev); if (error) { device_printf(dev, "cannot allocate virtqueue\n"); goto fail; @@ -164,24 +162,21 @@ vtrnd_detach(device_t dev) } static void -vtrnd_negotiate_features(struct vtrnd_softc *sc) +vtrnd_negotiate_features(device_t dev) { - device_t dev; - uint64_t features; + struct vtrnd_softc *sc; - dev = sc->vtrnd_dev; - features = VTRND_FEATURES; - - sc->vtrnd_features = virtio_negotiate_features(dev, features); + sc = device_get_softc(dev); + sc->vtrnd_features = virtio_negotiate_features(dev, VTRND_FEATURES); } static int -vtrnd_alloc_virtqueue(struct vtrnd_softc *sc) +vtrnd_alloc_virtqueue(device_t dev) { - device_t dev; + struct vtrnd_softc *sc; struct vq_alloc_info vq_info; - dev = sc->vtrnd_dev; + sc = device_get_softc(dev); VQ_ALLOC_INFO_INIT(&vq_info, 0, NULL, sc, &sc->vtrnd_vq, "%s request", device_get_nameunit(dev));