From: Arnd B. <ar...@ar...> - 2007-11-08 15:25:06
|
On Thursday 08 November 2007, Anthony Liguori wrote: > +/* A PCI device has it's own struct device and so does a virtio device so > + * we create a place for the virtio devices to show up in sysfs. =A0I th= ink it > + * would make more sense for virtio to not insist on having it's own dev= ice. */ > +static struct device virtio_pci_root =3D { > +=A0=A0=A0=A0=A0=A0=A0.parent=A0=A0=A0=A0=A0=A0=A0=A0=A0=3D NULL, > +=A0=A0=A0=A0=A0=A0=A0.bus_id=A0=A0=A0=A0=A0=A0=A0=A0=A0=3D "virtio-pci", > +}; > + > +/* Unique numbering for devices under the kvm root */ > +static unsigned int dev_index; > + =2E.. > +/* the PCI probing function */ > +static int __devinit virtio_pci_probe(struct pci_dev *pci_dev, > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0 =A0 =A0 =A0const struct pci_device_id *id) > +{ > +=A0=A0=A0=A0=A0=A0=A0struct virtio_pci_device *vp_dev; > +=A0=A0=A0=A0=A0=A0=A0int err; > + > +=A0=A0=A0=A0=A0=A0=A0/* allocate our structure and fill it out */ > +=A0=A0=A0=A0=A0=A0=A0vp_dev =3D kzalloc(sizeof(struct virtio_pci_device)= , GFP_KERNEL); > +=A0=A0=A0=A0=A0=A0=A0if (vp_dev =3D=3D NULL) > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return -ENOMEM; > + > +=A0=A0=A0=A0=A0=A0=A0vp_dev->pci_dev =3D pci_dev; > +=A0=A0=A0=A0=A0=A0=A0vp_dev->vdev.dev.parent =3D &virtio_pci_root; If you use=20 vp_dev->vdev.dev.parent =3D &pci_dev->dev; Then there is no need for the special kvm root device, and the actual virtio device shows up in a more logical place, under where it is really (virtually) attached. Arnd <>< |