All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][1/5][resend] floppy.c: Initial (partial) CodingStyle cleanup
@ 2007-03-19 15:10 Jesper Juhl
  2007-03-19 15:31 ` Randy Dunlap
  0 siblings, 1 reply; 5+ messages in thread
From: Jesper Juhl @ 2007-03-19 15:10 UTC (permalink / raw)
  To: Andrew Morton
  Cc: LKML, Andi Kleen, Trent Waddington, Bartlomiej Zolnierkiewicz,
	Alan Cox, Jesper Juhl


    This is a basic CodingStyle cleanup for drivers/block/floppy.c
    
    There are no functional changes in this patch.
    
    Changes made are :
     - remove some blank lines and insers others where it improves readability
     - make comments a bit more similar in style
     - make most lines fit within 80 columns
     - remove some unneeded curly braces
     - remove some trailing newlines
     - add some missing spaces
     - other minor trivialities
    
    The reason for starting with this patch is simply to make the file nicer
    to work with for me and get whitespace changes and such out of the way
    from the beginning (and of course also to make it conform better to the
    CodingStyle document).
    
Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Acked-by: Alan Cox <alan@redhat.com>
Acked-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---

diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 5231ed7..5da54b8 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -5,6 +5,7 @@
  *  Copyright (C) 1993, 1994  Alain Knaff
  *  Copyright (C) 1998 Alan Cox
  */
+
 /*
  * 02.12.91 - Changed to static variables to indicate need for reset
  * and recalibrate. This makes some things easier (output_byte reset
@@ -149,22 +150,23 @@
 #define REALLY_SLOW_IO
 
 #define DEBUGT 2
-#define DCL_DEBUG		/* debug disk change line */
+#define DCL_DEBUG	/* debug disk change line */
 
 /* do print messages for unexpected interrupts */
 static int print_unex = 1;
+
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/fs.h>
 #include <linux/kernel.h>
 #include <linux/timer.h>
 #include <linux/workqueue.h>
+
 #define FDPATCHES
-#include <linux/fdreg.h>
 
+#include <linux/fdreg.h>
 #include <linux/fd.h>
 #include <linux/hdreg.h>
-
 #include <linux/errno.h>
 #include <linux/slab.h>
 #include <linux/mm.h>
@@ -224,7 +226,7 @@ static unsigned short virtual_dma_port = 0x3f0;
 irqreturn_t floppy_interrupt(int irq, void *dev_id);
 static int set_dor(int fdc, char mask, char data);
 
-#define K_64	0x10000		/* 64KB */
+#define K_64	0x10000	/* 64KB */
 
 /* the following is the mask of allowed drives. By default units 2 and
  * 3 of both floppy controllers are disabled, because switching on the
@@ -271,11 +273,11 @@ static inline void fallback_on_nodma_alloc(char **addr, 
size_t l)
 {
 #ifdef FLOPPY_CAN_FALLBACK_ON_NODMA
 	if (*addr)
-		return;		/* we have the memory */
+		return;	/* we have the memory */
 	if (can_use_virtual_dma != 2)
-		return;		/* no fallback allowed */
-	printk
-	    ("DMA memory shortage. Temporarily falling back on virtual DMA\n");
+		return;	/* no fallback allowed */
+	printk("DMA memory shortage. "
+		"Temporarily falling back on virtual DMA\n");
 	*addr = (char *)nodma_mem_alloc(l);
 #else
 	return;
@@ -309,7 +311,8 @@ static int initialising = 1;
 #define USETF(x) set_bit(x##_BIT, &UDRS->flags)
 #define UTESTF(x) test_bit(x##_BIT, &UDRS->flags)
 
-#define DPRINT(format, args...) printk(DEVICE_NAME "%d: " format, 
current_drive , ## args)
+#define DPRINT(format, args...) \
+	printk(DEVICE_NAME "%d: " format, current_drive , ## args)
 
 #define PH_HEAD(floppy,head) (((((floppy)->stretch & 2) >>1) ^ head) << 2)
 #define STRETCH(floppy) ((floppy)->stretch & FD_STRETCH)
@@ -340,14 +343,14 @@ static int initialising = 1;
  * current disk size is unknown.
  * [Now it is rather a minimum]
  */
-#define MAX_DISK_SIZE 4		/* 3984 */
+#define MAX_DISK_SIZE 4	/* 3984 */
 
 /*
  * globals used by 'result()'
  */
 #define MAX_REPLIES 16
 static unsigned char reply_buffer[MAX_REPLIES];
-static int inr;			/* size of reply buffer, when called from interrupt */
+static int inr;	/* size of reply buffer, when called from interrupt */
 #define ST0 (reply_buffer[0])
 #define ST1 (reply_buffer[1])
 #define ST2 (reply_buffer[2])
@@ -357,7 +360,7 @@ static int inr;			/* size of reply buffer, when called 
from interrupt */
 #define R_SECTOR (reply_buffer[5])
 #define R_SIZECODE (reply_buffer[6])
 
-#define SEL_DLY (2*HZ/100)
+#define SEL_DLY (2 * HZ / 100)
 
 /*
  * this struct defines the different floppy drive types.
@@ -539,12 +542,12 @@ static char *floppy_track_buffer;
 static int max_buffer_sectors;
 
 static int *errors;
-typedef void (*done_f) (int);
+typedef void (*done_f)(int);
 static struct cont_t {
-	void (*interrupt) (void);	/* this is called after the interrupt of the
-					 * main command */
-	void (*redo) (void);	/* this is called to retry the operation */
-	void (*error) (void);	/* this is called to tally an error */
+	void (*interrupt)(void);	/* this is called after the interrupt
+					 * of the main command */
+	void (*redo)(void);	/* this is called to retry the operation */
+	void (*error)(void);	/* this is called to tally an error */
 	done_f done;		/* this is called to say if the operation has
 				 * succeeded/failed */
 } *cont;
@@ -565,7 +568,7 @@ static void floppy_release_irq_and_dma(void);
  * reset doesn't need to be tested before sending commands, because
  * output_byte is automatically disabled when reset is set.
  */
-#define CHECK_RESET { if (FDCS->reset){ reset_fdc(); return; } }
+#define CHECK_RESET { if (FDCS->reset) { reset_fdc(); return; } }
 static void reset_fdc(void);
 
 /*
@@ -587,7 +590,7 @@ static int buffer_max = -1;
 
 /* fdc related variables, should end up in a struct */
 static struct floppy_fdc_state fdc_state[N_FDC];
-static int fdc;			/* current fdc */
+static int fdc;	/* current fdc */
 
 static struct floppy_struct *_floppy = floppy_type;
 static unsigned char current_drive;
@@ -625,7 +628,7 @@ static inline void set_debugt(void) { }
 static inline void debugt(const char *message) { }
 #endif /* DEBUGT */
 
-typedef void (*timeout_fn) (unsigned long);
+typedef void (*timeout_fn)(unsigned long);
 static DEFINE_TIMER(fd_timeout, floppy_shutdown, 0, 0);
 
 static const char *timeout_message;
@@ -641,13 +644,13 @@ static void is_alive(const char *message)
 }
 #endif
 
-static void (*do_floppy) (void) = NULL;
+static void (*do_floppy)(void) = NULL;
 
 #ifdef FLOPPY_SANITY_CHECK
 
 #define OLOGSIZE 20
 
-static void (*lasthandler) (void);
+static void (*lasthandler)(void);
 static unsigned long interruptjiffies;
 static unsigned long resultjiffies;
 static int resultsize;
@@ -733,6 +736,7 @@ static void reschedule_timeout(int drive, const char 
*message, int marg)
 static int disk_change(int drive)
 {
 	int fdc = FDC(drive);
+
 #ifdef FLOPPY_SANITY_CHECK
 	if (time_before(jiffies, UDRS->select_date + UDP->select_delay))
 		DPRINT("WARNING disk change called early\n");
@@ -771,7 +775,7 @@ static int disk_change(int drive)
 			floppy_sizes[TOMINOR(drive)] = MAX_DISK_SIZE << 1;
 		}
 
-		/*USETF(FD_DISK_NEWCHANGE); */
+		/* USETF(FD_DISK_NEWCHANGE); */
 		return 1;
 	} else {
 		UDRS->last_checked = jiffies;
@@ -994,7 +998,7 @@ static void empty(void)
 
 static DECLARE_WORK(floppy_work, NULL);
 
-static void schedule_bh(void (*handler) (void))
+static void schedule_bh(void (*handler)(void))
 {
 	PREPARE_WORK(&floppy_work, (work_func_t)handler);
 	schedule_work(&floppy_work);
@@ -1030,7 +1034,7 @@ static void fd_watchdog(void)
 		reset_fdc();
 	} else {
 		del_timer(&fd_timer);
-		fd_timer.function = (timeout_fn) fd_watchdog;
+		fd_timer.function = (timeout_fn)fd_watchdog;
 		fd_timer.expires = jiffies + HZ / 10;
 		add_timer(&fd_timer);
 	}
@@ -1147,6 +1151,7 @@ static void show_floppy(void);
 static int wait_til_ready(void)
 {
 	int counter, status;
+
 	if (FDCS->reset)
 		return -1;
 	for (counter = 0; counter < 10000; counter++) {
@@ -1188,7 +1193,7 @@ static int output_byte(char byte)
 	return -1;
 }
 
-#define LAST_OUT(x) if (output_byte(x)<0){ reset_fdc();return;}
+#define LAST_OUT(x) if (output_byte(x) < 0) { reset_fdc(); return; }
 
 /* gets the response from the fdc */
 static int result(void)
@@ -1226,6 +1231,7 @@ static int result(void)
 static int need_more_output(void)
 {
 	int status;
+
 	if ((status = wait_til_ready()) < 0)
 		return -1;
 	if ((status & (STATUS_READY | STATUS_DIR | STATUS_DMA)) == STATUS_READY)
@@ -1252,8 +1258,8 @@ static inline void perpendicular_mode(void)
 			DPRINT("Invalid data rate for perpendicular mode!\n");
 			cont->done(0);
 			FDCS->reset = 1;	/* convenient way to return to
-						 * redo without to much hassle (deep
-						 * stack et al. */
+						 * redo without too much hassle
+						 * (deep stack et al. */
 			return;
 		}
 	} else
@@ -1319,7 +1325,7 @@ static void fdc_specify(void)
 	if (FDCS->need_configure && FDCS->version >= FDC_82072A) {
 		fdc_configure();
 		FDCS->need_configure = 0;
-		/*DPRINT("FIFO enabled\n"); */
+		/* DPRINT("FIFO enabled\n"); */
 	}
 
 	switch (raw_cmd->rate & 0x03) {
@@ -1351,9 +1357,9 @@ static void fdc_specify(void)
 
 	/* Convert step rate from microseconds to milliseconds and 4 bits */
 	srt = 16 - (DP->srt * scale_dtr / 1000 + NOMINAL_DTR - 1) / NOMINAL_DTR;
-	if (slow_floppy) {
+	if (slow_floppy)
 		srt = srt / 4;
-	}
+
 	SUPBOUND(srt, 0xf);
 	INFBOUND(srt, 0);
 
@@ -1463,12 +1469,11 @@ static int interpret_errors(void)
 					printk("probe failed...");
 			} else if (ST2 & ST2_WC) {	/* seek error */
 				printk("wrong cylinder");
-			} else if (ST2 & ST2_BC) {	/* cylinder marked as bad */
+			} else if (ST2 & ST2_BC) {	/* cylinder marked bad */
 				printk("bad cylinder");
 			} else {
-				printk
-				    ("unknown error. ST[0..2] are: 0x%x 0x%x 0x%x",
-				     ST0, ST1, ST2);
+				printk("unknown error. ST[0..2] are: "
+					"0x%x 0x%x 0x%x", ST0, ST1, ST2);
 				tell_sector();
 			}
 			printk("\n");
@@ -1912,10 +1917,10 @@ static void floppy_shutdown(unsigned long data)
 	is_alive("floppy shutdown");
 }
 
-/*typedef void (*timeout_fn)(unsigned long);*/
+/* typedef void (*timeout_fn)(unsigned long); */
 
 /* start motor, check media-changed condition and write protection */
-static int start_motor(void (*function) (void))
+static int start_motor(void (*function)(void))
 {
 	int mask, data;
 
@@ -2030,7 +2035,7 @@ static struct cont_t intr_cont = {
 	.done		= (done_f) empty
 };
 
-static int wait_til_done(void (*handler) (void), int interruptible)
+static int wait_til_done(void (*handler)(void), int interruptible)
 {
 	int ret;
 
@@ -2052,7 +2057,6 @@ static int wait_til_done(void (*handler) (void), int 
interruptible)
 
 			schedule();
 		}
-
 		set_current_state(TASK_RUNNING);
 		remove_wait_queue(&command_done, &wait);
 	}
@@ -2066,10 +2070,12 @@ static int wait_til_done(void (*handler) (void), int 
interruptible)
 
 	if (FDCS->reset)
 		command_status = FD_COMMAND_ERROR;
+
 	if (command_status == FD_COMMAND_OKAY)
 		ret = 0;
 	else
 		ret = -EIO;
+
 	command_status = FD_COMMAND_NONE;
 	return ret;
 }
@@ -2141,6 +2147,7 @@ static void bad_flp_intr(void)
 static void set_floppy(int drive)
 {
 	int type = ITYPE(UDRS->fd_device);
+
 	if (type)
 		_floppy = floppy_type + type;
 	else
@@ -2179,7 +2186,7 @@ static void setup_format_params(int track)
 	raw_cmd->track = track;
 
 	raw_cmd->flags = FD_RAW_WRITE | FD_RAW_INTR | FD_RAW_SPIN |
-	    FD_RAW_NEED_DISK | FD_RAW_NEED_SEEK;
+				FD_RAW_NEED_DISK | FD_RAW_NEED_SEEK;
 	raw_cmd->rate = _floppy->rate & 0x43;
 	raw_cmd->cmd_count = NR_F;
 	COMMAND = FM_MODE(_floppy, FD_FORMAT);
@@ -2200,7 +2207,7 @@ static void setup_format_params(int track)
 
 	/* position of logical sector 1 on this track */
 	n = (track_shift * format_req.track + head_shift * format_req.head)
-	    % F_SECT_PER_TRACK;
+		% F_SECT_PER_TRACK;
 
 	/* determine interleave */
 	il = 1;
@@ -2276,7 +2283,6 @@ static int do_format(int drive, struct format_descr 
*tmp_format_req)
  * Buffer read/write and support
  * =============================
  */
-
 static void floppy_end_request(struct request *req, int uptodate)
 {
 	unsigned int nr_sectors = current_count_sectors;
@@ -2370,8 +2376,8 @@ static void rw_interrupt(void)
 		heads = 1;
 
 	nr_sectors = (((R_TRACK - TRACK) * heads +
-		       R_HEAD - HEAD) * SECT_PER_TRACK +
-		      R_SECTOR - SECTOR + eoc) << SIZECODE >> 2;
+			R_HEAD - HEAD) * SECT_PER_TRACK +
+			R_SECTOR - SECTOR + eoc) << SIZECODE >> 2;
 
 #ifdef FLOPPY_SANITY_CHECK
 	if (nr_sectors / ssize >
@@ -2450,7 +2456,6 @@ static int buffer_chain_size(void)
 			if (page_address(bv->bv_page) + bv->bv_offset !=
 			    base + size)
 				break;
-
 			size += bv->bv_len;
 		}
 	}
@@ -2509,9 +2514,7 @@ static void copy_buffer(int ssize, int max_sector, int 
max_sector_2)
 #endif
 
 	buffer_max = max(max_sector, buffer_max);
-
 	dma_buffer = floppy_track_buffer + ((fsector_t - buffer_min) << 9);
-
 	size = current_req->current_nr_sectors << 9;
 
 	rq_for_each_bio(bio, current_req) {
@@ -2563,7 +2566,7 @@ static void copy_buffer(int ssize, int max_sector, int 
max_sector_2)
 
 #if 0
 static inline int check_dma_crossing(char *start,
-				     unsigned long length, char *message)
+		unsigned long length, char *message)
 {
 	if (CROSS_64KB(start, length)) {
 		printk("DMA xfer crosses 64KB boundary in %s %p-%p\n",
@@ -2593,12 +2596,12 @@ static void virtualdmabug_workaround(void)
 #ifdef FLOPPY_SANITY_CHECK
 		if (end_sector > SECT_PER_TRACK) {
 			printk("too many sectors %d > %d\n",
-			       end_sector, SECT_PER_TRACK);
+				end_sector, SECT_PER_TRACK);
 			return;
 		}
 #endif
-		SECT_PER_TRACK = end_sector;	/* make sure SECT_PER_TRACK points
-						 * to end of transfer */
+		SECT_PER_TRACK = end_sector;	/* make sure SECT_PER_TRACK
+						 * points to end of transfer */
 	}
 }
 
@@ -2611,7 +2614,6 @@ static void virtualdmabug_workaround(void)
  * allocation on the fly, it should be done here. No other part should need
  * modification.
  */
-
 static int make_raw_rw_request(void)
 {
 	int aligned_sector_t;
@@ -2626,7 +2628,7 @@ static int make_raw_rw_request(void)
 
 	raw_cmd = &default_raw_cmd;
 	raw_cmd->flags = FD_RAW_SPIN | FD_RAW_NEED_DISK | FD_RAW_NEED_DISK |
-	    FD_RAW_NEED_SEEK;
+				FD_RAW_NEED_SEEK;
 	raw_cmd->cmd_count = NR_RW;
 	if (rq_data_dir(current_req) == READ) {
 		raw_cmd->flags |= FD_RAW_READ;
@@ -2682,7 +2684,7 @@ static int make_raw_rw_request(void)
 	CODE2SIZE;
 	SECT_PER_TRACK = _floppy->sect << 2 >> SIZECODE;
 	SECTOR = ((fsector_t % _floppy->sect) << 2 >> SIZECODE) +
-	    ((_floppy->stretch & FD_ZEROBASED) ? 0 : 1);
+			((_floppy->stretch & FD_ZEROBASED) ? 0 : 1);
 
 	/* tracksize describes the size which can be filled up with sectors
 	 * of size ssize.
@@ -2704,12 +2706,11 @@ static int make_raw_rw_request(void)
 			tracksize += ssize;
 		}
 		max_sector = HEAD * _floppy->sect + tracksize;
-	} else if (!TRACK && !HEAD && !(_floppy->rate & FD_2M) && probing) {
+	} else if (!TRACK && !HEAD && !(_floppy->rate & FD_2M) && probing)
 		max_sector = _floppy->sect;
-	} else if (!HEAD && CT(COMMAND) == FD_WRITE) {
+	else if (!HEAD && CT(COMMAND) == FD_WRITE)
 		/* for virtual DMA bug workaround */
 		max_sector = _floppy->sect;
-	}
 
 	in_sector_offset = (fsector_t % _floppy->sect) % ssize;
 	aligned_sector_t = fsector_t - in_sector_offset;
@@ -2742,16 +2743,16 @@ static int make_raw_rw_request(void)
 				  max_buffer_sectors * 2) - fsector_t;
 
 		/*
-		 * Do NOT use minimum() here---MAX_DMA_ADDRESS is 64 bits wide
+		 * Do NOT use minimum() here - MAX_DMA_ADDRESS is 64 bits wide
 		 * on a 64 bit machine!
 		 */
 		max_size = buffer_chain_size();
 		dma_limit =
 		    (MAX_DMA_ADDRESS -
 		     ((unsigned long)current_req->buffer)) >> 9;
-		if ((unsigned long)max_size > dma_limit) {
+		if ((unsigned long)max_size > dma_limit)
 			max_size = dma_limit;
-		}
+
 		/* 64 kb boundaries */
 		if (CROSS_64KB(current_req->buffer, max_size << 9))
 			max_size = (K_64 -
@@ -2765,10 +2766,9 @@ static int make_raw_rw_request(void)
 		 * This means we should be able to read a sector even if there
 		 * are other bad sectors on this track.
 		 */
-		if (!direct ||
-		    (indirect * 2 > direct * 3 &&
+		if (!direct || (indirect * 2 > direct * 3 &&
 		     *errors < DP->max_errors.read_track &&
-		     /*!TESTF(FD_NEED_TWADDLE) && */
+		     /* !TESTF(FD_NEED_TWADDLE) && */
 		     ((!probing
 		       || (DP->read_track & (1 << DRS->probed_format)))))) {
 			max_size = current_req->nr_sectors;
@@ -2776,16 +2776,15 @@ static int make_raw_rw_request(void)
 			raw_cmd->kernel_data = current_req->buffer;
 			raw_cmd->length = current_count_sectors << 9;
 			if (raw_cmd->length == 0) {
-				DPRINT
-				    ("zero dma transfer attempted from make_raw_request\n");
+				DPRINT("zero dma transfer attempted from "
+					"make_raw_request\n");
 				DPRINT("indirect=%d direct=%d fsector_t=%d",
 				       indirect, direct, fsector_t);
 				return 0;
 			}
-/*			check_dma_crossing(raw_cmd->kernel_data, 
-					   raw_cmd->length, 
-					   "end of make_raw_request [1]");*/
-
+			/* check_dma_crossing(raw_cmd->kernel_data,
+					   raw_cmd->length,
+					   "end of make_raw_request [1]"); */
 			virtualdmabug_workaround();
 			return 2;
 		}
@@ -2835,7 +2834,7 @@ static int make_raw_rw_request(void)
 	raw_cmd->length = ((raw_cmd->length - 1) | (ssize - 1)) + 1;
 	raw_cmd->length <<= 9;
 #ifdef FLOPPY_SANITY_CHECK
-	/*check_dma_crossing(raw_cmd->kernel_data, raw_cmd->length, 
+	/*check_dma_crossing(raw_cmd->kernel_data, raw_cmd->length,
 	   "end of make_raw_request"); */
 	if ((raw_cmd->length < current_count_sectors << 9) ||
 	    (raw_cmd->kernel_data != current_req->buffer &&
@@ -2894,14 +2893,13 @@ static int make_raw_rw_request(void)
 		return 0;
 	}
 #endif
-
 	virtualdmabug_workaround();
 	return 2;
 }
 
 static void redo_fd_request(void)
 {
-#define REPEAT {request_done(0); continue; }
+#define REPEAT { request_done(0); continue; }
 	int drive;
 	int tmp;
 
@@ -2981,7 +2979,7 @@ static void process_fd_request(void)
 	schedule_bh(redo_fd_request);
 }
 
-static void do_fd_request(request_queue_t * q)
+static void do_fd_request(request_queue_t *q)
 {
 	if (max_buffer_sectors == 0) {
 		printk("VFS: do_fd_request called on non-open device\n");
@@ -3016,6 +3014,7 @@ static struct cont_t poll_cont = {
 static int poll_drive(int interruptible, int flag)
 {
 	int ret;
+
 	/* no auto-sense, just clear dcl */
 	raw_cmd = &default_raw_cmd;
 	raw_cmd->flags = flag;
@@ -3036,7 +3035,6 @@ static int poll_drive(int interruptible, int flag)
  * User triggered reset
  * ====================
  */
-
 static void reset_intr(void)
 {
 	printk("weird, reset interrupt called\n");
@@ -3080,8 +3078,10 @@ static inline int fd_copyin(void __user *param, void 
*address, unsigned long siz
 	return copy_from_user(address, param, size) ? -EFAULT : 0;
 }
 
-#define _COPYOUT(x) (copy_to_user((void __user *)param, &(x), 
sizeof(x)) ? -EFAULT : 0)
-#define _COPYIN(x) (copy_from_user(&(x), (void __user *)param, 
sizeof(x)) ? -EFAULT : 0)
+#define _COPYOUT(x) \
+	(copy_to_user((void __user *)param, &(x), sizeof(x)) ? -EFAULT : 0)
+#define _COPYIN(x) \
+	(copy_from_user(&(x), (void __user *)param, sizeof(x)) ? -EFAULT : 0)
 
 #define COPYOUT(x) ECALL(_COPYOUT(x))
 #define COPYIN(x) ECALL(_COPYIN(x))
@@ -3343,7 +3343,7 @@ static inline int set_geometry(unsigned int cmd, struct 
floppy_struct *g,
 		LOCK_FDC(drive, 1);
 		if (cmd != FDDEFPRM)
 			/* notice a disk change immediately, else
-			 * we lose our settings immediately*/
+			 * we lose our settings immediately */
 			CALL(poll_drive(1, FD_RAW_NEED_DISK));
 		oldStretch = g->stretch;
 		user_params[drive] = *g;
@@ -3451,7 +3451,7 @@ static int fd_getgeo(struct block_device *bdev, struct 
hd_geometry *geo)
 }
 
 static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
-		    unsigned long param)
+		unsigned long param)
 {
 #define FD_IOCTL_ALLOWED ((filp) && (filp)->private_data)
 #define OUT(c,x) case c: outparam = (const char *) (x); break
@@ -3525,14 +3525,12 @@ static int fd_ioctl(struct inode *inode, struct file 
*filp, unsigned int cmd,
 						  (struct floppy_struct **)
 						  &outparam));
 			break;
-
 		case FDMSGON:
 			UDP->flags |= FTD_MSG;
 			return 0;
 		case FDMSGOFF:
 			UDP->flags &= ~FTD_MSG;
 			return 0;
-
 		case FDFMTBEG:
 			LOCK_FDC(drive, 1);
 			CALL(poll_drive(1, FD_RAW_NEED_DISK));
@@ -3551,39 +3549,31 @@ static int fd_ioctl(struct inode *inode, struct file 
*filp, unsigned int cmd,
 		case FDFLUSH:
 			LOCK_FDC(drive, 1);
 			return invalidate_drive(inode->i_bdev);
-
 		case FDSETEMSGTRESH:
 			UDP->max_errors.reporting =
 			    (unsigned short)(param & 0x0f);
 			return 0;
 			OUT(FDGETMAXERRS, &UDP->max_errors);
 			IN(FDSETMAXERRS, &UDP->max_errors, max_errors);
-
 		case FDGETDRVTYP:
 			outparam = drive_name(type, drive);
 			SUPBOUND(size, strlen(outparam) + 1);
 			break;
-
 			IN(FDSETDRVPRM, UDP, dp);
 			OUT(FDGETDRVPRM, UDP);
-
 		case FDPOLLDRVSTAT:
 			LOCK_FDC(drive, 1);
 			CALL(poll_drive(1, FD_RAW_NEED_DISK));
 			process_fd_request();
 			/* fall through */
 			OUT(FDGETDRVSTAT, UDRS);
-
 		case FDRESET:
 			return user_reset_fdc(drive, (int)param, 1);
-
 			OUT(FDGETFDCSTAT, UFDCS);
-
 		case FDWERRORCLR:
 			CLEARSTRUCT(UDRWE);
 			return 0;
 			OUT(FDWERRORGET, UDRWE);
-
 		case FDRAWCMD:
 			if (type)
 				return -EINVAL;
@@ -3592,13 +3582,11 @@ static int fd_ioctl(struct inode *inode, struct file 
*filp, unsigned int cmd,
 			CALL(i = raw_cmd_ioctl(cmd, (void __user *)param));
 			process_fd_request();
 			return i;
-
 		case FDTWADDLE:
 			LOCK_FDC(drive, 1);
 			twaddle();
 			process_fd_request();
 			return 0;
-
 		default:
 			return -EINVAL;
 		}
@@ -3626,7 +3614,6 @@ static void __init config_types(void)
 
 	/* XXX */
 	/* additional physical CMOS drive detection should go here */
-
 	for (drive = 0; drive < N_DRIVE; drive++) {
 		unsigned int type = UDP->cmos;
 		struct floppy_drive_params *params;
@@ -3816,7 +3803,7 @@ static int check_floppy_change(struct gendisk *disk)
  */
 
 static int floppy_rb0_complete(struct bio *bio, unsigned int bytes_done,
-			       int err)
+		int err)
 {
 	if (bio->bi_size)
 		return 1;
@@ -3965,7 +3952,7 @@ static char __init get_fdc_version(void)
 	r = result();
 	if ((r == 1) && (reply_buffer[0] == 0x80)) {
 		printk(KERN_INFO "FDC %d is a pre-1991 82077\n", fdc);
-		return FDC_82077_ORIG;	/* Pre-1991 82077, doesn't know 
+		return FDC_82077_ORIG;	/* Pre-1991 82077, doesn't know
 					 * LOCK/UNLOCK */
 	}
 	if ((r != 1) || (reply_buffer[0] != 0x00)) {
@@ -3982,11 +3969,11 @@ static char __init get_fdc_version(void)
 	}
 	if (reply_buffer[0] == 0x80) {
 		printk(KERN_INFO "FDC %d is a post-1991 82077\n", fdc);
-		return FDC_82077;	/* Revised 82077AA passes all the tests */
+		return FDC_82077;	/* Revised 82077AA passes all tests */
 	}
 	switch (reply_buffer[0] >> 5) {
 	case 0x0:
-		/* Either a 82078-1 or a 82078SL running at 5Volt */
+		/* Either a 82078-1 or a 82078SL running at 5 Volt */
 		printk(KERN_INFO "FDC %d is an 82078.\n", fdc);
 		return FDC_82078;
 	case 0x1:
@@ -3996,16 +3983,16 @@ static char __init get_fdc_version(void)
 		printk(KERN_INFO "FDC %d is a S82078B\n", fdc);
 		return FDC_S82078B;
 	case 0x3:
-		printk(KERN_INFO "FDC %d is a National Semiconductor PC87306\n",
-		       fdc);
+		printk(KERN_INFO "FDC %d is a National Semiconductor "
+			"PC87306\n", fdc);
 		return FDC_87306;
 	default:
 		printk(KERN_INFO
-		       "FDC %d init: 82078 variant with unknown PARTID=%d.\n",
-		       fdc, reply_buffer[0] >> 5);
+		       "FDC %d init: 82078 variant with unknown "
+		       "PARTID=%d.\n", fdc, reply_buffer[0] >> 5);
 		return FDC_82078_UNKN;
 	}
-}				/* get_fdc_version */
+}	/* get_fdc_version */
 
 /* lilo configuration */
 
@@ -4064,7 +4051,7 @@ static void __init set_cmos(int *ints, int dummy, int 
dummy2)
 
 static struct param_table {
 	const char *name;
-	void (*fn) (int *ints, int param, int param2);
+	void (*fn)(int *ints, int param, int param2);
 	int *var;
 	int def_param;
 	int param2;
@@ -4095,7 +4082,6 @@ static struct param_table {
 	{"unexpected_interrupts", NULL, &print_unex, 1, 0},
 	{"no_unexpected_interrupts", NULL, &print_unex, 0, 0},
 	{"L40SX", NULL, &print_unex, 0, 0}
-
 	EXTRA_FLOPPY_PARAMS
 };
 
@@ -4127,7 +4113,6 @@ static int __init floppy_setup(char *str)
 	}
 	if (str) {
 		DPRINT("unknown floppy option [%s]\n", str);
-
 		DPRINT("allowed options are:");
 		for (i = 0; i < ARRAY_SIZE(config_params); i++)
 			printk(" %s", config_params[i].name);
@@ -4141,7 +4126,7 @@ static int __init floppy_setup(char *str)
 static int have_no_fdc = -ENODEV;
 
 static ssize_t floppy_cmos_show(struct device *dev,
-				struct device_attribute *attr, char *buf)
+		struct device_attribute *attr, char *buf)
 {
 	struct platform_device *p;
 	int drive;
@@ -4230,7 +4215,7 @@ static int __init floppy_init(void)
 		FDCS->dtr = -1;
 		FDCS->dor = 0x4;
 #if defined(__sparc__) || defined(__mc68000__)
-		/*sparcs/sun3x don't have a DOR reset which we can fall back on to */
+		/* sparcs/sun3x don't have a DOR reset to fall back on */
 #ifdef __mc68000__
 		if (MACH_IS_SUN3X)
 #endif
@@ -4249,7 +4234,7 @@ static int __init floppy_init(void)
 	fdc_state[1].address = FDC2;
 #endif
 
-	fdc = 0;		/* reset fdc in case of unexpected interrupt */
+	fdc = 0;	/* reset fdc in case of unexpected interrupt */
 	err = floppy_grab_irq_and_dma();
 	if (err) {
 		del_timer(&fd_timeout);
@@ -4428,8 +4413,8 @@ static int floppy_grab_irq_and_dma(void)
 		if (FDCS->address != -1)
 			fd_outb(FDCS->dor, FD_DOR);
 	/*
-	 *      The driver will try and free resources and relies on us
-	 *      to know if they were allocated or not.
+	 * The driver will try and free resources and relies on us to know if
+	 * they were allocated or not.
 	 */
 	fdc = 0;
 	irqdma_allocated = 1;
@@ -4519,7 +4504,7 @@ static void __init parse_floppy_cfg_string(char *cfg)
 	char *ptr;
 
 	while (*cfg) {
-		for (ptr = cfg; *cfg && *cfg != ' ' && *cfg != '\t'; cfg++) ;
+		for (ptr = cfg; *cfg && *cfg != ' ' && *cfg != '\t'; cfg++);
 		if (*cfg) {
 			*cfg = '\0';
 			cfg++;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH][1/5][resend] floppy.c: Initial (partial) CodingStyle cleanup
  2007-03-19 15:10 [PATCH][1/5][resend] floppy.c: Initial (partial) CodingStyle cleanup Jesper Juhl
@ 2007-03-19 15:31 ` Randy Dunlap
  2007-03-19 18:18   ` Jesper Juhl
  0 siblings, 1 reply; 5+ messages in thread
From: Randy Dunlap @ 2007-03-19 15:31 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: Andrew Morton, LKML, Andi Kleen, Trent Waddington,
	Bartlomiej Zolnierkiewicz, Alan Cox

On Mon, 19 Mar 2007 16:10:13 +0100 Jesper Juhl wrote:

>     This is a basic CodingStyle cleanup for drivers/block/floppy.c
>     
>     There are no functional changes in this patch.
> ---
> 
> diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
> index 5231ed7..5da54b8 100644
> --- a/drivers/block/floppy.c
> +++ b/drivers/block/floppy.c

> @@ -1188,7 +1193,7 @@ static int output_byte(char byte)
>  	return -1;
>  }
>  
> -#define LAST_OUT(x) if (output_byte(x)<0){ reset_fdc();return;}
> +#define LAST_OUT(x) if (output_byte(x) < 0) { reset_fdc(); return; }

Not for a coding style cleanup, but that macro is Bad according to
CodingStyle, so hopefully it will be cleaned up in the future.

Things to avoid when using macros:
1) macros that affect control flow:

>  /* gets the response from the fdc */
>  static int result(void)

> @@ -3816,7 +3803,7 @@ static int check_floppy_change(struct gendisk *disk)
>   */
>  
>  static int floppy_rb0_complete(struct bio *bio, unsigned int bytes_done,
> -			       int err)
> +		int err)

I don't care one way or the other about most of these, but would
you explain that one above (and others like it), please?
It's not an < 80 columns thing.  My <cough> recollection is that
many indented function parameters in Linux are indented more like
the original here, near the opening '(' after the function name,
although I suppose that none of this is in CodingStyle.

>  {
>  	if (bio->bi_size)
>  		return 1;

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][1/5][resend] floppy.c: Initial (partial) CodingStyle cleanup
  2007-03-19 15:31 ` Randy Dunlap
@ 2007-03-19 18:18   ` Jesper Juhl
  2007-03-19 20:20     ` Adrian Bunk
  0 siblings, 1 reply; 5+ messages in thread
From: Jesper Juhl @ 2007-03-19 18:18 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: Andrew Morton, LKML, Andi Kleen, Trent Waddington,
	Bartlomiej Zolnierkiewicz, Alan Cox, jesper.juhl

On Monday 19 March 2007 16:31:59 Randy Dunlap wrote:
> On Mon, 19 Mar 2007 16:10:13 +0100 Jesper Juhl wrote:
> >     This is a basic CodingStyle cleanup for drivers/block/floppy.c
[snip]
> >
> > -#define LAST_OUT(x) if (output_byte(x)<0){ reset_fdc();return;}
> > +#define LAST_OUT(x) if (output_byte(x) < 0) { reset_fdc(); return; }
>
> Not for a coding style cleanup, but that macro is Bad according to
> CodingStyle, so hopefully it will be cleaned up in the future.
>
Looking at each of the (many) macros in there is on my TODO list, but fixing 
macros was not the point of this patch.

[snip]
> > @@ -3816,7 +3803,7 @@ static int check_floppy_change(struct gendisk
> > *disk) */
> >
> >  static int floppy_rb0_complete(struct bio *bio, unsigned int bytes_done,
> > -			       int err)
> > +		int err)
>
> I don't care one way or the other about most of these, but would
> you explain that one above (and others like it), please?

Sure.

> It's not an < 80 columns thing.  My <cough> recollection is that
> many indented function parameters in Linux are indented more like
> the original here, near the opening '(' after the function name,
> although I suppose that none of this is in CodingStyle.
>

The reason behind the change is manyfold.

The first reason is consistency. Function parameters that span over more than 
one line should be indented identical for each such function in the file (and 
preferably across files as well).  The changes made by this patch make all 
such functions the same within floppy.c

The second reason is that indenting two tabs seems to make the most sense for 
a few reasons;  
	a) not indenting at all is ugly, plain and simple.
		void function(int a, int b,
		int c, int d, int e)
		{
			int foo;
			int bar;
		...
		}
	b) indenting only one tab stop puts parameters at the same indent level as
	   variables in the function which is potentially confusing (at least IMHO).
		void function(int a, int b,
			int c, int d, int e)
		{
			int foo;
			int bar;
		...
		}
	c) Indenting so that all parameter lines start at the opening paranthesis 
	   rarely matches up with tabs so you have to use varying amounts of spaces
	   depending on how long the function name is. Not a good solution IMHO.
		void function(int a, int b,
				     int c, int d, int e)
		{
			int foo;
			int bar;
		...
		}
	d) Indenting by two tab stops avoids the problems with a, b & c and also
	   avoids indenting so much so that the number of lines needed (when all
	   need to be kept <80 col) is not increased too much in most cases. 
		void function(int a, int b,
				int c, int d, int e)
		{
			int foo;
			int bar;
		...
		}

I also have a recollection (although I can't find the exact threads atm) that 
in the past the question of how to indent function parameters that span more 
than one line, settled on two tabs.

I hope that explains my reasons for making the change :-)

This should probably go into CodingStyle if some official consensus on this 
can be reached. 


-- 
 Jesper Juhl <jesper.juhl@gmail.com>

 
 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][1/5][resend] floppy.c: Initial (partial) CodingStyle cleanup
  2007-03-19 18:18   ` Jesper Juhl
@ 2007-03-19 20:20     ` Adrian Bunk
  2007-03-19 22:25       ` Jesper Juhl
  0 siblings, 1 reply; 5+ messages in thread
From: Adrian Bunk @ 2007-03-19 20:20 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: Randy Dunlap, Andrew Morton, LKML, Andi Kleen, Trent Waddington,
	Bartlomiej Zolnierkiewicz, Alan Cox

On Mon, Mar 19, 2007 at 07:18:38PM +0100, Jesper Juhl wrote:
>...
> The second reason is that indenting two tabs seems to make the most sense for 
> a few reasons;  
> 	a) not indenting at all is ugly, plain and simple.
> 		void function(int a, int b,
> 		int c, int d, int e)
> 		{
> 			int foo;
> 			int bar;
> 		...
> 		}
> 	b) indenting only one tab stop puts parameters at the same indent level as
> 	   variables in the function which is potentially confusing (at least IMHO).
> 		void function(int a, int b,
> 			int c, int d, int e)
> 		{
> 			int foo;
> 			int bar;
> 		...
> 		}
> 	c) Indenting so that all parameter lines start at the opening paranthesis 
> 	   rarely matches up with tabs so you have to use varying amounts of spaces
> 	   depending on how long the function name is. Not a good solution IMHO.
> 		void function(int a, int b,
> 				     int c, int d, int e)
>...

Your example is wrong, it's:

               void function(int a, int b,
                             int c, int d, int e)


This is the most common convention in the kernel - and except for 
extremely long function names it's the one with the best readability.

Yes, it's a problem with extremely long function names, but they are 
rare in the kernel.

And the "varying amounts of spaces" should be handled automatically by 
your editor.

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][1/5][resend] floppy.c: Initial (partial) CodingStyle cleanup
  2007-03-19 20:20     ` Adrian Bunk
@ 2007-03-19 22:25       ` Jesper Juhl
  0 siblings, 0 replies; 5+ messages in thread
From: Jesper Juhl @ 2007-03-19 22:25 UTC (permalink / raw)
  To: Adrian Bunk
  Cc: Randy Dunlap, Andrew Morton, LKML, Andi Kleen, Trent Waddington,
	Bartlomiej Zolnierkiewicz, Alan Cox

On 19/03/07, Adrian Bunk <bunk@stusta.de> wrote:
> On Mon, Mar 19, 2007 at 07:18:38PM +0100, Jesper Juhl wrote:
> >...
> > The second reason is that indenting two tabs seems to make the most sense for
> > a few reasons;
> >       a) not indenting at all is ugly, plain and simple.
> >               void function(int a, int b,
> >               int c, int d, int e)
> >               {
> >                       int foo;
> >                       int bar;
> >               ...
> >               }
> >       b) indenting only one tab stop puts parameters at the same indent level as
> >          variables in the function which is potentially confusing (at least IMHO).
> >               void function(int a, int b,
> >                       int c, int d, int e)
> >               {
> >                       int foo;
> >                       int bar;
> >               ...
> >               }
> >       c) Indenting so that all parameter lines start at the opening paranthesis
> >          rarely matches up with tabs so you have to use varying amounts of spaces
> >          depending on how long the function name is. Not a good solution IMHO.
> >               void function(int a, int b,
> >                                    int c, int d, int e)
> >...
>
> Your example is wrong, it's:
>
>                void function(int a, int b,
>                              int c, int d, int e)
>
Hmm, thanks, when I wrote it in kmail it looked right. two tabs and
then spaces to make it line up with the starting '('.

>
> This is the most common convention in the kernel - and except for
> extremely long function names it's the one with the best readability.
>
It may be the most common, but I don't agree that it has the best
readability - but I guess that's very much a subjective thing.

> Yes, it's a problem with extremely long function names, but they are
> rare in the kernel.
>
> And the "varying amounts of spaces" should be handled automatically by
> your editor.
>

My editor may handle it initially when writing the code, but then it
gets changed and not updated or spaces and tabs end up getting mixed -
like "<tab><tab><space><tab><space>" or something else - it easily
turns into a mess.

Simply using two tabs makes it easy to see that it's not variables in
the function body and is an easy and simple convention to follow (and
IMHO also very readable).

But I guess we'll have to agree to disagree on this.
In any case, thank you for your input.

-- 
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-03-19 22:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-19 15:10 [PATCH][1/5][resend] floppy.c: Initial (partial) CodingStyle cleanup Jesper Juhl
2007-03-19 15:31 ` Randy Dunlap
2007-03-19 18:18   ` Jesper Juhl
2007-03-19 20:20     ` Adrian Bunk
2007-03-19 22:25       ` Jesper Juhl

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.