public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* another IDE cleanup: kill duplicated code
@ 2002-02-11 22:11 Pavel Machek
  2002-02-12 10:52 ` Martin Dalecki
  2002-02-13  5:52 ` Andre Hedrick
  0 siblings, 2 replies; 53+ messages in thread
From: Pavel Machek @ 2002-02-11 22:11 UTC (permalink / raw)
  To: Jens Axboe, kernel list

Hi!

This is slightly longer but also simple cleanup. It kills code
duplication and removes unneccessary assignments/casts. Please apply,

								Pavel

--- clean-pre3/drivers/ide/ide-disk.c	Sat Feb  9 23:00:02 2002
+++ linux-dm-pre3/drivers/ide/ide-disk.c	Sun Feb 10 00:06:31 2002
@@ -172,6 +167,16 @@
 		return WIN_NOP;
 }
 
+static void fill_args (ide_task_t *args, struct hd_drive_task_hdr *taskfile, struct hd_drive_hob_hdr *hobfile)
+{
+	memcpy(args->tfRegister, taskfile, sizeof(struct hd_drive_task_hdr));
+	memcpy(args->hobRegister, hobfile, sizeof(struct hd_drive_hob_hdr));
+	args->command_type	= ide_cmd_type_parser(args);
+	args->prehandler	= ide_pre_handler_parser(taskfile, hobfile);
+	args->handler		= ide_handler_parser(taskfile, hobfile);
+	args->posthandler	= NULL;
+}
+
 static ide_startstop_t chs_rw_disk (ide_drive_t *drive, struct request *rq, unsigned long block)
 {
 	struct hd_drive_task_hdr	taskfile;
@@ -210,16 +215,10 @@
 	printk("buffer=0x%08lx\n", (unsigned long) rq->buffer);
 #endif
 
-	memcpy(args.tfRegister, &taskfile, sizeof(struct hd_drive_task_hdr));
-	memcpy(args.hobRegister, &hobfile, sizeof(struct hd_drive_hob_hdr));
-	args.command_type	= ide_cmd_type_parser(&args);
-	args.prehandler		= ide_pre_handler_parser(&taskfile, &hobfile);
-	args.handler		= ide_handler_parser(&taskfile, &hobfile);
-	args.posthandler	= NULL;
-	args.rq			= (struct request *) rq;
+	fill_args(&args, &taskfile, &hobfile);
+	args.rq			= rq;
 	args.block		= block;
-	rq->special		= NULL;
-	rq->special		= (ide_task_t *)&args;
+	rq->special		= &args;
 
 	return do_rw_taskfile(drive, &args);
 }
@@ -257,16 +255,10 @@
 	printk("buffer=0x%08lx\n", (unsigned long) rq->buffer);
 #endif
 
-	memcpy(args.tfRegister, &taskfile, sizeof(struct hd_drive_task_hdr));
-	memcpy(args.hobRegister, &hobfile, sizeof(struct hd_drive_hob_hdr));
-	args.command_type	= ide_cmd_type_parser(&args);
-	args.prehandler		= ide_pre_handler_parser(&taskfile, &hobfile);
-	args.handler		= ide_handler_parser(&taskfile, &hobfile);
-	args.posthandler	= NULL;
-	args.rq			= (struct request *) rq;
+	fill_args(&args, &taskfile, &hobfile);
+	args.rq			= rq;
 	args.block		= block;
-	rq->special		= NULL;
-	rq->special		= (ide_task_t *)&args;
+	rq->special		= &args;
 
 	return do_rw_taskfile(drive, &args);
 }
@@ -321,16 +313,10 @@
 	printk("buffer=0x%08lx\n", (unsigned long) rq->buffer);
 #endif
 
-	memcpy(args.tfRegister, &taskfile, sizeof(struct hd_drive_task_hdr));
-	memcpy(args.hobRegister, &hobfile, sizeof(struct hd_drive_hob_hdr));
-	args.command_type	= ide_cmd_type_parser(&args);
-	args.prehandler		= ide_pre_handler_parser(&taskfile, &hobfile);
-	args.handler		= ide_handler_parser(&taskfile, &hobfile);
-	args.posthandler	= NULL;
-	args.rq			= (struct request *) rq;
+	fill_args(&args, &taskfile, &hobfile);
+	args.rq			= rq;
 	args.block		= block;
-	rq->special		= NULL;
-	rq->special		= (ide_task_t *)&args;
+	rq->special		= &args;
 
 	return do_rw_taskfile(drive, &args);
 }

-- 
(about SSSCA) "I don't say this lightly.  However, I really think that the U.S.
no longer is classifiable as a democracy, but rather as a plutocracy." --hpa

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

end of thread, other threads:[~2002-02-14 10:20 UTC | newest]

Thread overview: 53+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-02-11 22:11 another IDE cleanup: kill duplicated code Pavel Machek
2002-02-12 10:52 ` Martin Dalecki
2002-02-12 12:28   ` Vojtech Pavlik
2002-02-12 12:45     ` Martin Dalecki
2002-02-12 12:57       ` Vojtech Pavlik
2002-02-12 13:17         ` Martin Dalecki
2002-02-12 13:43           ` Vojtech Pavlik
2002-02-12 13:58             ` Martin Dalecki
2002-02-12 14:42               ` Vojtech Pavlik
2002-02-12 15:23                 ` Martin Dalecki
2002-02-12 15:28                   ` Vojtech Pavlik
2002-02-12 15:35                     ` Martin Dalecki
2002-02-12 16:56                       ` Jens Axboe
2002-02-13  5:50                     ` Andre Hedrick
2002-02-13  7:28                       ` Vojtech Pavlik
2002-02-13 10:53                         ` Martin Dalecki
2002-02-13 10:35                       ` Martin Dalecki
2002-02-13 10:29                         ` Andre Hedrick
2002-02-13 10:56                           ` Pavel Machek
2002-02-13 11:11                             ` Martin Dalecki
2002-02-13 11:25                               ` Matthias Andree
2002-02-12 18:28                   ` Andreas Dilger
2002-02-13 12:35                     ` Martin Dalecki
2002-02-13 16:24                       ` Andreas Dilger
2002-02-13 16:31                         ` Martin Dalecki
2002-02-12 16:57             ` Jens Axboe
2002-02-13  5:46               ` Andre Hedrick
2002-02-13  6:42                 ` Jens Axboe
2002-02-13  7:30                   ` Andre Hedrick
2002-02-13  7:47                     ` Jens Axboe
2002-02-13  7:44                       ` Andre Hedrick
2002-02-13  7:58                         ` Jens Axboe
2002-02-13 20:38                         ` Rik van Riel
2002-02-13 11:01                       ` Martin Dalecki
2002-02-13 11:03                         ` Jens Axboe
2002-02-13 11:27                           ` Vojtech Pavlik
2002-02-13  7:05                 ` Vojtech Pavlik
2002-02-12 12:50     ` Martin Dalecki
2002-02-12 19:19   ` Roger Larsson
2002-02-13 10:56     ` Martin Dalecki
2002-02-12 20:03   ` Andrew Morton
2002-02-13 10:47     ` Martin Dalecki
2002-02-13 18:52       ` Andrew Morton
2002-02-14 10:04         ` Martin Dalecki
2002-02-14 10:19           ` Andrew Morton
2002-02-13  5:52 ` Andre Hedrick
2002-02-13  7:30   ` Vojtech Pavlik
2002-02-13  7:27     ` Andre Hedrick
2002-02-13 10:39       ` Vojtech Pavlik
2002-02-13 10:46         ` Andre Hedrick
2002-02-13 11:26           ` Vojtech Pavlik
2002-02-13 11:26             ` Andre Hedrick
2002-02-13 11:03   ` Daniel Egger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox