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.
This commit is contained in:
Conrad Meyer 2019-05-27 00:55:46 +00:00
parent b1adb000cd
commit af8f74ad14
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=348295

View File

@ -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));