svn commit: r348295 - head/sys/dev/virtio/random
Conrad Meyer
cem at FreeBSD.org
Mon May 27 00:55:47 UTC 2019
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 <dev/virtio/virtqueue.h>
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));
More information about the svn-src-all
mailing list