Skip to contentSkip to conversation

s390: introduce for_each_subchannel.

PATCH In review Martin Schwidefsky 1 participant 1 message Dec 9, 2005

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

PATCH 13/17 s390: introduce for_each_subchannel.

From: Cornelia Huck <[email protected]>

[patch 13/17] s390: introduce for_each_subchannel.

for_each_subchannel() is an iterator calling a function for every possible subchannel id until non-zero is returned. Convert the current iterating functions to it.

---

 drivers/s390/cio/blacklist.c |   46 ++---
 drivers/s390/cio/chsc.c      |  372 ++++++++++++++++++++++---------------------
 drivers/s390/cio/cio.c       |   79 ++++-----
 drivers/s390/cio/css.c       |  110 ++++++------
 drivers/s390/cio/css.h       |    1 
 5 files changed, 318 insertions(+), 290 deletions(-)
drivers/s390/cio/blacklist.c +23 -23
diff -urpN linux-2.6/drivers/s390/cio/blacklist.c linux-2.6-patched/drivers/s390/cio/blacklist.c
@@ -219,6 +219,27 @@ is_blacklisted (int devno)
 }
 
 #ifdef CONFIG_PROC_FS
+static int
+__s390_redo_validation(struct subchannel_id schid, void *data)
+{
+	int ret;
+	struct subchannel *sch;
+
+	sch = get_subchannel_by_schid(schid);
+	if (sch) {
+		/* Already known. */
+		put_device(&sch->dev);
+		return 0;
+	}
+	ret = css_probe_device(schid);
+	if (ret == -ENXIO)
+		return ret; /* We're through. */
+	if (ret == -ENOMEM)
+		/* Stop validation for now. Bad, but no need for a panic. */
+		return ret;
+	return 0;
+}
+
 /*
  * Function: s390_redo_validation
  * Look for no longer blacklisted devices
@@ -226,30 +247,9 @@ is_blacklisted (int devno)
 static inline void
 s390_redo_validation (void)
 {
-	struct subchannel_id schid;
-
 	CIO_TRACE_EVENT (0, "redoval");
-	init_subchannel_id(&schid);
-	do {
-		int ret;
-		struct subchannel *sch;
-
-		sch = get_subchannel_by_schid(schid);
-		if (sch) {
-			/* Already known. */
-			put_device(&sch->dev);
-			continue;
-		}
-		ret = css_probe_device(schid);
-		if (ret == -ENXIO)
-			break; /* We're through. */
-		if (ret == -ENOMEM)
-			/*
-			 * Stop validation for now. Bad, but no need for a
-			 * panic.
-			 */
-			break;
-	} while (schid.sch_no++ < __MAX_SUBCHANNEL);
+
+	for_each_subchannel(__s390_redo_validation, NULL);
 }
 
 /*
drivers/s390/cio/chsc.c +193 -179

456 lines not on this page · raw message

drivers/s390/cio/cio.c +43 -36

117 lines not on this page · raw message

drivers/s390/cio/css.c +58 -52

154 lines not on this page · raw message

drivers/s390/cio/css.h +1 -0
diff -urpN linux-2.6/drivers/s390/cio/css.h linux-2.6-patched/drivers/s390/cio/css.h
@@ -126,6 +126,7 @@ extern struct css_driver io_subchannel_d
 extern int css_probe_device(struct subchannel_id);
 extern struct subchannel * get_subchannel_by_schid(struct subchannel_id);
 extern int css_init_done;
+extern int for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *);
 
 #define __MAX_SUBCHANNEL 65535