]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
staging: unisys: Add visor device find routine
authorDon Zickus <dzickus@redhat.com>
Wed, 13 May 2015 17:22:19 +0000 (13:22 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 24 May 2015 20:28:55 +0000 (13:28 -0700)
If we are going to remove the bus_info structs than we need a way
to find the devices when the *_create/destroy cmds are sent over
the vmchannel.

This function crudely impements what pci has.  It takes a bus_no
and dev_no and finds the matching 'struct visor_device'.

This function can/should be optimzed later once we get our heads
wrapped around its needs.  For now, I am using dev_no=0 to mean
the visorbus itself.

The function is limited to chipset.c only because it is only needed
to do the lookups upon receiving a vmchannel command.  Future patches
will make sure the resulting 'struct visor_device' is used every
where else.

Also allow visorbus_type to be more visible for use.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/unisys/visorbus/visorchipset.c

index b96a40cf91247bd600c7dcefd5625c1eb01601b1..42bf02afb8074111f7a50875fdb71029dcc16caf 100644 (file)
@@ -711,6 +711,45 @@ dev_info_clear(void *v)
        memset(p, 0, sizeof(struct visorchipset_device_info));
 }
 
+struct visor_busdev {
+       u32 bus_no;
+       u32 dev_no;
+};
+
+static int match_visorbus_dev_by_id(struct device *dev, void *data)
+{
+       struct visor_device *vdev = to_visor_device(dev);
+       struct visor_busdev *id = (struct visor_busdev *)data;
+       u32 bus_no = id->bus_no;
+       u32 dev_no = id->dev_no;
+
+       if (((bus_no == -1) || (vdev->chipset_bus_no == bus_no)) &&
+           ((dev_no == -1) || (vdev->chipset_dev_no == dev_no)))
+               return 1;
+
+       return 0;
+}
+struct visor_device *visorbus_get_device_by_id(u32 bus_no, u32 dev_no,
+                                              struct visor_device *from)
+{
+       struct device *dev;
+       struct device *dev_start = NULL;
+       struct visor_device *vdev = NULL;
+       struct visor_busdev id = {
+                       .bus_no = bus_no,
+                       .dev_no = dev_no
+               };
+
+       if (from)
+               dev_start = &from->device;
+       dev = bus_find_device(&visorbus_type, dev_start, (void *)&id,
+                             match_visorbus_dev_by_id);
+       if (dev)
+               vdev = to_visor_device(dev);
+       return vdev;
+}
+EXPORT_SYMBOL(visorbus_get_device_by_id);
+
 static struct visorchipset_bus_info *
 bus_find(struct list_head *list, u32 bus_no)
 {