Index: head/sys/dev/hyperv/include/hyperv.h =================================================================== --- head/sys/dev/hyperv/include/hyperv.h +++ head/sys/dev/hyperv/include/hyperv.h @@ -399,24 +399,6 @@ #define HW_MACADDR_LEN 6 -enum { - HV_VMBUS_IVAR_TYPE, - HV_VMBUS_IVAR_INSTANCE, - HV_VMBUS_IVAR_NODE, - HV_VMBUS_IVAR_DEVCTX, - HV_VMBUS_IVAR_CHAN, -}; - -#define HV_VMBUS_ACCESSOR(var, ivar, type) \ - __BUS_ACCESSOR(vmbus, var, HV_VMBUS, ivar, type) - -struct hv_vmbus_channel; - -HV_VMBUS_ACCESSOR(type, TYPE, const char *) -HV_VMBUS_ACCESSOR(devctx, DEVCTX, struct hv_device *) -HV_VMBUS_ACCESSOR(channel, CHAN, struct hv_vmbus_channel *) - - /* * Common defines for Hyper-V ICs */ @@ -538,7 +520,6 @@ } __packed hv_vmbus_connection_id; typedef struct hv_vmbus_channel { - struct hv_device* device; device_t ch_dev; struct vmbus_softc *vmbus_sc; hv_vmbus_channel_state state; @@ -652,15 +633,6 @@ channel->batched_reading = state; } -typedef struct hv_device { - hv_guid class_id; - hv_guid device_id; - device_t device; - hv_vmbus_channel* channel; -} hv_device; - - - int hv_vmbus_channel_recv_packet( hv_vmbus_channel* channel, void* buffer, @@ -742,4 +714,10 @@ return (ret); } +static __inline struct hv_vmbus_channel * +vmbus_get_channel(device_t dev) +{ + return device_get_ivars(dev); +} + #endif /* __HYPERV_H__ */ Index: head/sys/dev/hyperv/vmbus/hv_channel.c =================================================================== --- head/sys/dev/hyperv/vmbus/hv_channel.c +++ head/sys/dev/hyperv/vmbus/hv_channel.c @@ -106,10 +106,10 @@ hv_vmbus_channel* primary_ch = channel->primary_channel; if (primary_ch == NULL) { - dev = channel->device->device; + dev = channel->ch_dev; ch_id = channel->ch_id; } else { - dev = primary_ch->device->device; + dev = primary_ch->ch_dev; ch_id = primary_ch->ch_id; sub_ch_id = channel->ch_subidx; } Index: head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c =================================================================== --- head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c +++ head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c @@ -162,7 +162,6 @@ * It is a sub channel offer, process it. */ new_channel->primary_channel = channel; - new_channel->device = channel->device; new_channel->ch_dev = channel->ch_dev; mtx_lock(&channel->sc_lock); TAILQ_INSERT_TAIL(&channel->sc_list_anchor, @@ -207,13 +206,6 @@ new_channel->state = HV_CHANNEL_OPEN_STATE; /* - * Start the process of binding this offer to the driver - * (We need to set the device field before calling - * hv_vmbus_child_device_add()) - */ - new_channel->device = hv_vmbus_child_device_create(new_channel); - - /* * Add the new device to the bus. This will kick off device-driver * binding which eventually invokes the device driver's AddDevice() * method. Index: head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h =================================================================== --- head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h +++ head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h @@ -212,9 +212,6 @@ void hv_vmbus_release_unattached_channels( struct vmbus_softc *); -struct hv_device* hv_vmbus_child_device_create( - struct hv_vmbus_channel *channel); - int hv_vmbus_child_device_register( struct hv_vmbus_channel *chan); int hv_vmbus_child_device_unregister( Index: head/sys/dev/hyperv/vmbus/vmbus.c =================================================================== --- head/sys/dev/hyperv/vmbus/vmbus.c +++ head/sys/dev/hyperv/vmbus/vmbus.c @@ -960,29 +960,6 @@ static int vmbus_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) { - struct hv_device *child_dev_ctx = device_get_ivars(child); - - switch (index) { - case HV_VMBUS_IVAR_TYPE: - *result = (uintptr_t)&child_dev_ctx->class_id; - return (0); - - case HV_VMBUS_IVAR_INSTANCE: - *result = (uintptr_t)&child_dev_ctx->device_id; - return (0); - - case HV_VMBUS_IVAR_DEVCTX: - *result = (uintptr_t)child_dev_ctx; - return (0); - - case HV_VMBUS_IVAR_NODE: - *result = (uintptr_t)child_dev_ctx->device; - return (0); - - case HV_VMBUS_IVAR_CHAN: - *result = (uintptr_t)child_dev_ctx->channel; - return (0); - } return (ENOENT); } @@ -992,11 +969,11 @@ const struct hv_vmbus_channel *chan; char guidbuf[HYPERV_GUID_STRLEN]; - if (device_get_ivars(child) == NULL) { + chan = vmbus_get_channel(child); + if (chan == NULL) { /* Event timer device, which does not belong to a channel */ return (0); } - chan = vmbus_get_channel(child); strlcat(buf, "classid=", buflen); hyperv_guid2str(&chan->ch_guid_type, guidbuf, sizeof(guidbuf)); @@ -1009,23 +986,6 @@ return (0); } -struct hv_device * -hv_vmbus_child_device_create(struct hv_vmbus_channel *channel) -{ - hv_device *child_dev; - - /* - * Allocate the new child device - */ - child_dev = malloc(sizeof(hv_device), M_DEVBUF, M_WAITOK | M_ZERO); - - child_dev->channel = channel; - child_dev->class_id = channel->ch_guid_type; - child_dev->device_id = channel->ch_guid_inst; - - return (child_dev); -} - int hv_vmbus_child_device_register(struct hv_vmbus_channel *chan) { @@ -1040,8 +1000,7 @@ error = ENXIO; goto done; } - chan->device->device = chan->ch_dev; - device_set_ivars(chan->ch_dev, chan->device); + device_set_ivars(chan->ch_dev, chan); done: /* New device has been/should be added to vmbus. */