
From: Alasdair G Kergon <agk@redhat.com>

Some multipath code/formatting cleanups 

Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/drivers/md/dm-emc.c           |   12 +---
 25-akpm/drivers/md/dm-hw-handler.h    |   26 +++------
 25-akpm/drivers/md/dm-mpath.c         |    8 +-
 25-akpm/drivers/md/dm-mpath.h         |    2 
 25-akpm/drivers/md/dm-path-selector.c |    2 
 25-akpm/drivers/md/dm-path-selector.h |   97 ++++++++++++++--------------------
 25-akpm/drivers/md/dm-round-robin.c   |    2 
 7 files changed, 62 insertions(+), 87 deletions(-)

diff -puN drivers/md/dm-emc.c~device-mapper-some-code-formatting-cleanups drivers/md/dm-emc.c
--- 25/drivers/md/dm-emc.c~device-mapper-some-code-formatting-cleanups	2005-02-16 13:46:28.000000000 -0800
+++ 25-akpm/drivers/md/dm-emc.c	2005-02-16 13:46:28.000000000 -0800
@@ -167,11 +167,8 @@ static struct request *emc_trespass_get(
 	page22 = (unsigned char *)bio_data(bio);
 	memset(page22, 0, data_size);
 
-	if (h->short_trespass) {
-		memcpy(page22, short_trespass_pg, data_size);
-	} else {
-		memcpy(page22, long_trespass_pg, data_size);
-	}
+	memcpy(page22, h->short_trespass ?
+		short_trespass_pg : long_trespass_pg, data_size);
 
 	/* get request for block layer packet command */
 	rq = get_failover_req(h, bio, path);
@@ -226,9 +223,8 @@ static struct emc_handler *alloc_emc_han
 {
 	struct emc_handler *h = kmalloc(sizeof(*h), GFP_KERNEL);
 
-	if (h) {
-		h->lock = SPIN_LOCK_UNLOCKED;
-	}
+	if (h)
+		spin_lock_init(&h->lock);
 
 	return h;
 }
diff -puN drivers/md/dm-hw-handler.h~device-mapper-some-code-formatting-cleanups drivers/md/dm-hw-handler.h
--- 25/drivers/md/dm-hw-handler.h~device-mapper-some-code-formatting-cleanups	2005-02-16 13:46:28.000000000 -0800
+++ 25-akpm/drivers/md/dm-hw-handler.h	2005-02-16 13:46:28.000000000 -0800
@@ -22,27 +22,19 @@ struct hw_handler {
 /*
  * Constructs a hardware handler object, takes custom arguments
  */
-typedef int (*hwh_ctr_fn) (struct hw_handler *hwh, unsigned arc, char **argv);
-typedef void (*hwh_dtr_fn) (struct hw_handler *hwh);
-
-typedef void (*hwh_pg_init_fn) (struct hw_handler *hwh, unsigned bypassed,
-				struct path *path);
-typedef unsigned (*hwh_err_fn) (struct hw_handler *hwh, struct bio *bio);
-typedef	int (*hwh_status_fn) (struct hw_handler *hwh,
-			      status_type_t type,
-			      char *result, unsigned int maxlen);
-
 /* Information about a hardware handler type */
 struct hw_handler_type {
 	char *name;
 	struct module *module;
 
-	hwh_ctr_fn ctr;
-	hwh_dtr_fn dtr;
+	int (*ctr) (struct hw_handler *handler, unsigned int argc, char **argv);
+	void (*dtr) (struct hw_handler *hwh);
 
-	hwh_pg_init_fn pg_init;
-	hwh_err_fn err;
-	hwh_status_fn status;
+	void (*pg_init) (struct hw_handler *hwh, unsigned bypassed,
+			 struct path *path);
+	unsigned (*err) (struct hw_handler *hwh, struct bio *bio);
+	int (*status) (struct hw_handler *hwh, status_type_t type,
+		       char *result, unsigned int maxlen);
 };
 
 /* Register a hardware handler */
@@ -57,10 +49,10 @@ struct hw_handler_type *dm_get_hw_handle
 /* Releases a hardware handler  */
 void dm_put_hw_handler(struct hw_handler_type *hwht);
 
-/* Default hwh_err_fn */
+/* Default err function */
 unsigned dm_scsi_err_handler(struct hw_handler *hwh, struct bio *bio);
 
-/* Error flags for hwh_err_fn and dm_pg_init_complete */
+/* Error flags for err and dm_pg_init_complete */
 #define MP_FAIL_PATH 1
 #define MP_BYPASS_PG 2
 #define MP_ERROR_IO  4	/* Don't retry this I/O */
diff -puN drivers/md/dm-mpath.c~device-mapper-some-code-formatting-cleanups drivers/md/dm-mpath.c
--- 25/drivers/md/dm-mpath.c~device-mapper-some-code-formatting-cleanups	2005-02-16 13:46:28.000000000 -0800
+++ 25-akpm/drivers/md/dm-mpath.c	2005-02-16 13:46:28.000000000 -0800
@@ -144,7 +144,7 @@ static void free_pgpaths(struct list_hea
 {
 	struct pgpath *pgpath, *tmp;
 
-	list_for_each_entry_safe (pgpath, tmp, pgpaths, list) {
+	list_for_each_entry_safe(pgpath, tmp, pgpaths, list) {
 		list_del(&pgpath->list);
 		dm_put_device(ti, pgpath->path.dev);
 		free_pgpath(pgpath);
@@ -173,7 +173,7 @@ static struct multipath *alloc_multipath
 	if (m) {
 		memset(m, 0, sizeof(*m));
 		INIT_LIST_HEAD(&m->priority_groups);
-		m->lock = SPIN_LOCK_UNLOCKED;
+		spin_lock_init(&m->lock);
 		m->queue_io = 1;
 		INIT_WORK(&m->process_queued_ios, process_queued_ios, m);
 		INIT_WORK(&m->trigger_event, trigger_event, m);
@@ -193,7 +193,7 @@ static void free_multipath(struct multip
 	struct priority_group *pg, *tmp;
 	struct hw_handler *hwh = &m->hw_handler;
 
-	list_for_each_entry_safe (pg, tmp, &m->priority_groups, list) {
+	list_for_each_entry_safe(pg, tmp, &m->priority_groups, list) {
 		list_del(&pg->list);
 		free_priority_group(pg, m->ti);
 	}
@@ -270,7 +270,7 @@ static void __choose_pgpath(struct multi
 	 * Second time we only try the ones we skipped.
 	 */
 	do {
-		list_for_each_entry (pg, &m->priority_groups, list) {
+		list_for_each_entry(pg, &m->priority_groups, list) {
 			if (pg->bypassed == bypassed)
 				continue;
 			if (!__choose_path_in_pg(m, pg))
diff -puN drivers/md/dm-mpath.h~device-mapper-some-code-formatting-cleanups drivers/md/dm-mpath.h
--- 25/drivers/md/dm-mpath.h~device-mapper-some-code-formatting-cleanups	2005-02-16 13:46:28.000000000 -0800
+++ 25-akpm/drivers/md/dm-mpath.h	2005-02-16 13:46:28.000000000 -0800
@@ -9,7 +9,7 @@
 #ifndef	DM_MPATH_H
 #define	DM_MPATH_H
 
-#include <linux/device-mapper.h>
+struct dm_dev;
 
 struct path {
 	struct dm_dev *dev;	/* Read-only */
diff -puN drivers/md/dm-path-selector.c~device-mapper-some-code-formatting-cleanups drivers/md/dm-path-selector.c
--- 25/drivers/md/dm-path-selector.c~device-mapper-some-code-formatting-cleanups	2005-02-16 13:46:28.000000000 -0800
+++ 25-akpm/drivers/md/dm-path-selector.c	2005-02-16 13:46:28.000000000 -0800
@@ -30,7 +30,7 @@ struct ps_internal *__find_path_selector
 {
 	struct ps_internal *psi;
 
-	list_for_each_entry (psi, &_path_selectors, list) {
+	list_for_each_entry(psi, &_path_selectors, list) {
 		if (!strcmp(name, psi->pst.name))
 			return psi;
 	}
diff -puN drivers/md/dm-path-selector.h~device-mapper-some-code-formatting-cleanups drivers/md/dm-path-selector.h
--- 25/drivers/md/dm-path-selector.h~device-mapper-some-code-formatting-cleanups	2005-02-16 13:46:28.000000000 -0800
+++ 25-akpm/drivers/md/dm-path-selector.h	2005-02-16 13:46:28.000000000 -0800
@@ -26,53 +26,6 @@ struct path_selector {
 	void *context;
 };
 
-/*
- * Constructs a path selector object, takes custom arguments
- */
-typedef int (*ps_ctr_fn) (struct path_selector *ps, unsigned argc, char **argv);
-typedef void (*ps_dtr_fn) (struct path_selector *ps);
-
-/*
- * Add an opaque path object, along with some selector specific
- * path args (eg, path priority).
- */
-typedef	int (*ps_add_path_fn) (struct path_selector *ps, struct path *path,
-			       int argc, char **argv, char **error);
-
-/*
- * Chooses a path for this io, if no paths are available then
- * NULL will be returned.
- *
- * repeat_count is the number of times to use the path before
- * calling the function again.  0 means don't call it again unless
- * the path fails.
- */
-typedef	struct path *(*ps_select_path_fn) (struct path_selector *ps,
-					   unsigned *repeat_count);
-
-/*
- * Notify the selector that a path has failed.
- */
-typedef	void (*ps_fail_path_fn) (struct path_selector *ps,
-				 struct path *p);
-
-/*
- * Ask selector to reinstate a path.
- */
-typedef	int (*ps_reinstate_path_fn) (struct path_selector *ps,
-				     struct path *p);
-
-/*
- * Table content based on parameters added in ps_add_path_fn
- * or path selector status
- */
-typedef	int (*ps_status_fn) (struct path_selector *ps,
-			     struct path *path,
-			     status_type_t type,
-			     char *result, unsigned int maxlen);
-
-typedef int (*ps_end_io_fn) (struct path_selector *ps, struct path *path);
-
 /* Information about a path selector type */
 struct path_selector_type {
 	char *name;
@@ -80,15 +33,49 @@ struct path_selector_type {
 
 	unsigned int table_args;
 	unsigned int info_args;
-	ps_ctr_fn ctr;
-	ps_dtr_fn dtr;
 
-	ps_add_path_fn add_path;
-	ps_fail_path_fn fail_path;
-	ps_reinstate_path_fn reinstate_path;
-	ps_select_path_fn select_path;
-	ps_status_fn status;
-	ps_end_io_fn end_io;
+	/*
+	 * Constructs a path selector object, takes custom arguments
+	 */
+	int (*ctr) (struct path_selector *ps, unsigned argc, char **argv);
+	void (*dtr) (struct path_selector *ps);
+
+	/*
+	 * Add an opaque path object, along with some selector specific
+	 * path args (eg, path priority).
+	 */
+	int (*add_path) (struct path_selector *ps, struct path *path,
+			 int argc, char **argv, char **error);
+
+	/*
+	 * Chooses a path for this io, if no paths are available then
+	 * NULL will be returned.
+	 *
+	 * repeat_count is the number of times to use the path before
+	 * calling the function again.  0 means don't call it again unless
+	 * the path fails.
+	 */
+	struct path *(*select_path) (struct path_selector *ps,
+				     unsigned *repeat_count);
+
+	/*
+	 * Notify the selector that a path has failed.
+	 */
+	void (*fail_path) (struct path_selector *ps, struct path *p);
+
+	/*
+	 * Ask selector to reinstate a path.
+	 */
+	int (*reinstate_path) (struct path_selector *ps, struct path *p);
+
+	/*
+	 * Table content based on parameters added in ps_add_path_fn
+	 * or path selector status
+	 */
+	int (*status) (struct path_selector *ps, struct path *path,
+		       status_type_t type, char *result, unsigned int maxlen);
+
+	int (*end_io) (struct path_selector *ps, struct path *path);
 };
 
 /* Register a path selector */
diff -puN drivers/md/dm-round-robin.c~device-mapper-some-code-formatting-cleanups drivers/md/dm-round-robin.c
--- 25/drivers/md/dm-round-robin.c~device-mapper-some-code-formatting-cleanups	2005-02-16 13:46:28.000000000 -0800
+++ 25-akpm/drivers/md/dm-round-robin.c	2005-02-16 13:46:28.000000000 -0800
@@ -27,7 +27,7 @@ static void free_paths(struct list_head 
 {
 	struct path_info *pi, *next;
 
-	list_for_each_entry_safe (pi, next, paths, list) {
+	list_for_each_entry_safe(pi, next, paths, list) {
 		list_del(&pi->list);
 		kfree(pi);
 	}
_
