ChangeSet 1.1630 04/03/01 15:48:49 hollis@ambient.ltc.austin.ibm.com +1 -0 export vio_find_node() for vio_unregister_device() callers arch/ppc64/kernel/vio.c 1.9 04/03/01 15:48:42 hollis@ambient.ltc.austin.ibm.com +38 -0 implement and export vio_find_node() implement vio_find_name() until bus_type.devices ksets are fixed (at which point we should use device_find() instead) # This is a BitKeeper generated patch for the following project: # Project Name: Linux kernel tree # This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas: # ChangeSet 1.1629 -> 1.1630 # arch/ppc64/kernel/vio.c 1.8 -> 1.9 # # The following is the BitKeeper ChangeSet Log # -------------------------------------------- # 04/03/01 hollis@ambient.ltc.austin.ibm.com 1.1630 # export vio_find_node() for vio_unregister_device() callers # -------------------------------------------- # diff -Nru a/arch/ppc64/kernel/vio.c b/arch/ppc64/kernel/vio.c --- a/arch/ppc64/kernel/vio.c Mon Mar 1 16:04:41 2004 +++ b/arch/ppc64/kernel/vio.c Mon Mar 1 16:04:41 2004 @@ -29,6 +29,8 @@ #define DBGENTER() pr_debug("%s entered\n", __FUNCTION__) +extern struct subsystem devices_subsys; /* needed for vio_find_name() */ + struct iommu_table *vio_build_iommu_table(struct vio_dev *dev); static int vio_num_address_cells; @@ -297,6 +299,42 @@ return get_property((struct device_node *)vdev->archdata, (char*)which, length); } EXPORT_SYMBOL(vio_get_attribute); + +/* vio_find_name() - internal because only vio.c knows how we formatted the + * kobject name + * XXX once vio_bus_type.devices is actually used as a kset in + * drivers/base/bus.c, this function should be removed in favor of + * "device_find(kobj_name, &vio_bus_type)" + */ +static struct vio_dev *vio_find_name(const char *kobj_name) +{ + struct kobject *found; + + found = kset_find_obj(&devices_subsys.kset, kobj_name); + if (!found) + return NULL; + + return to_vio_dev(container_of(found, struct device, kobj)); +} + +/** + * vio_find_node - find an already-registered vio_dev + * @vnode: device_node of the virtual device we're looking for + */ +struct vio_dev *vio_find_node(struct device_node *vnode) +{ + uint32_t *unit_address; + char kobj_name[BUS_ID_SIZE]; + + /* construct the kobject name from the device node */ + unit_address = (uint32_t *)get_property(vnode, "reg", NULL); + if (!unit_address) + return NULL; + snprintf(kobj_name, BUS_ID_SIZE, "%x", *unit_address); + + return vio_find_name(kobj_name); +} +EXPORT_SYMBOL(vio_find_node); /** * vio_build_iommu_table: - gets the dma information from OF and builds the TCE tree.