Skip to contentSkip to conversation

s390: use klist in cio.

PATCH In review Martin Schwidefsky 1 participant 1 message Jun 21, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/16 s390: use klist in cio.

[patch 2/16] s390: use klist in cio.

From: Cornelia Huck <[email protected]>

Convert the common I/O layer to use the klist interfaces.

diffstat:

 drivers/s390/cio/ccwgroup.c |   30 ++++-----------
 drivers/s390/cio/css.c      |   36 +++++++++---------
 drivers/s390/cio/device.c   |   85 ++++++++++++++++++++++++--------------------
 3 files changed, 74 insertions(+), 77 deletions(-)
drivers/s390/cio/ccwgroup.c +9 -21
diff -urpN linux-2.6/drivers/s390/cio/ccwgroup.c linux-2.6-patched/drivers/s390/cio/ccwgroup.c
@@ -403,34 +403,22 @@ ccwgroup_driver_register (struct ccwgrou
 	return driver_register(&cdriver->driver);
 }
 
-static inline struct device *
-__get_next_ccwgroup_device(struct device_driver *drv)
+static int
+__ccwgroup_driver_unregister_device(struct device *dev, void *data)
 {
-	struct device *dev, *d;
-
-	down_read(&drv->bus->subsys.rwsem);
-	dev = NULL;
-	list_for_each_entry(d, &drv->devices, driver_list) {
-		dev = get_device(d);
-		if (dev)
-			break;
-	}
-	up_read(&drv->bus->subsys.rwsem);
-	return dev;
+	__ccwgroup_remove_symlinks(to_ccwgroupdev(dev));
+	device_unregister(dev);
+	put_device(dev);
+	return 0;
 }
 
 void
 ccwgroup_driver_unregister (struct ccwgroup_driver *cdriver)
 {
-	struct device *dev;
-
 	/* We don't want ccwgroup devices to live longer than their driver. */
 	get_driver(&cdriver->driver);
-	while ((dev = __get_next_ccwgroup_device(&cdriver->driver))) {
-		__ccwgroup_remove_symlinks(to_ccwgroupdev(dev));
-		device_unregister(dev);
-		put_device(dev);
-	};
+	driver_for_each_device(&cdriver->driver, NULL, NULL,
+			       __ccwgroup_driver_unregister_device);
 	put_driver(&cdriver->driver);
 	driver_unregister(&cdriver->driver);
 }
@@ -449,7 +437,7 @@ __ccwgroup_get_gdev_by_cdev(struct ccw_d
 	if (cdev->dev.driver_data) {
 		gdev = (struct ccwgroup_device *)cdev->dev.driver_data;
 		if (get_device(&gdev->dev)) {
-			if (!list_empty(&gdev->dev.node))
+			if (klist_node_attached(&gdev->dev.knode_bus))
 				return gdev;
 			put_device(&gdev->dev);
 		}
drivers/s390/cio/css.c +18 -18
diff -urpN linux-2.6/drivers/s390/cio/css.c linux-2.6-patched/drivers/s390/cio/css.c
@@ -128,34 +128,34 @@ css_probe_device(int irq)
 	return ret;
 }
 
-struct subchannel *
-get_subchannel_by_schid(int irq)
+static int
+check_subchannel(struct device * dev, void * data)
 {
 	struct subchannel *sch;
-	struct list_head *entry;
-	struct device *dev;
+	int irq = (int)data;
 
-	if (!get_bus(&css_bus_type))
-		return NULL;
-	down_read(&css_bus_type.subsys.rwsem);
-	sch = NULL;
-	list_for_each(entry, &css_bus_type.devices.list) {
-		dev = get_device(container_of(entry,
-					      struct device, bus_list));
-		if (!dev)
-			continue;
+	if (get_device(dev)) {
 		sch = to_subchannel(dev);
 		if (sch->irq == irq)
-			break;
+			return 1;
 		put_device(dev);
-		sch = NULL;
+
 	}
-	up_read(&css_bus_type.subsys.rwsem);
-	put_bus(&css_bus_type);
+	return 0;
+}
 
-	return sch;
+struct subchannel *
+get_subchannel_by_schid(int irq)
+{
+	struct device *dev;
+
+	dev = bus_find_device(&css_bus_type, NULL,
+			      (void *)irq, check_subchannel);
+
+	return dev ? to_subchannel(dev) : NULL;
 }
 
+
 static inline int
 css_get_subchannel_status(struct subchannel *sch, int schid)
 {
drivers/s390/cio/device.c +47 -38

120 lines not on this page · raw message