Skip to contentSkip to conversation

floppy98.c: use kernel min/max

PATCH In review Randy.Dunlap 3 participants 9 messages Apr 19, 2004 2 messages not in the archive Block layer

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 floppy98.c: use kernel min/max

Convert floppy98.c to use kernel min/max, like floppy.c.

diffstat:=

 drivers/block/floppy98.c |   28 ++++++----------------------
 1 files changed, 6 insertions(+), 22 deletions(-)
drivers/block/floppy98.c renamed from drivers/block/floppy98.c~fd98_minmax +6 -22
diff -Naurp ./drivers/block/floppy98.c~fd98_minmax ./drivers/block/floppy98.c
@@ -720,25 +720,9 @@ static void reschedule_timeout(int drive
 	timeout_message = message;
 }
 
-static int maximum(int a, int b)
-{
-	if (a > b)
-		return a;
-	else
-		return b;
-}
-
-#define INFBOUND(a,b) (a)=maximum((a),(b));
-
-static int minimum(int a, int b)
-{
-	if (a < b)
-		return a;
-	else
-		return b;
-}
+#define INFBOUND(a,b) (a)=max_t(int, a, b)
 
-#define SUPBOUND(a,b) (a)=minimum((a),(b));
+#define SUPBOUND(a,b) (a)=min_t(int, a, b)
 
 /*
  * Bottom half floppy driver.
@@ -2556,12 +2540,12 @@ static void copy_buffer(int ssize, int m
 	int size, i;
 
 	max_sector = transfer_size(ssize,
-				   minimum(max_sector, max_sector_2),
+				   min(max_sector, max_sector_2),
 				   current_req->nr_sectors);
 
 	if (current_count_sectors <= 0 && CT(COMMAND) == FD_WRITE &&
 	    buffer_max > fsector_t + current_req->nr_sectors)
-		current_count_sectors = minimum(buffer_max - fsector_t,
+		current_count_sectors = min_t(int, buffer_max - fsector_t,
 						current_req->nr_sectors);
 
 	remaining = current_count_sectors << 9;
@@ -2580,7 +2564,7 @@ static void copy_buffer(int ssize, int m
 	}
 #endif
 
-	buffer_max = maximum(max_sector, buffer_max);
+	buffer_max = max(max_sector, buffer_max);
 
 	dma_buffer = floppy_track_buffer + ((fsector_t - buffer_min) << 9);
 
@@ -2733,7 +2717,7 @@ static int make_raw_rw_request(void)
 		max_sector = 2 * _floppy->sect / 3;
 		if (fsector_t >= max_sector) {
 			current_count_sectors =
-			    minimum(_floppy->sect - fsector_t,
+			    min_t(int, _floppy->sect - fsector_t,
 				    current_req->nr_sectors);
 			return 1;
 		}

--
~Randy

#2 lore raw

Hi Randy,

I wonder if PC9800 fixes are worth the hassle as PC9800 merge (AFAIR first patch went into 2.5.50!) was never finished.

I think somebody should fix it or we should just remove it completely.

Cheers,
Bartlomiej

Quoted 75 lines · Randy.Dunlap

Convert floppy98.c to use kernel min/max, like floppy.c.

diffstat:=

 drivers/block/floppy98.c |   28 ++++++----------------------
 1 files changed, 6 insertions(+), 22 deletions(-)

diff -Naurp ./drivers/block/floppy98.c~fd98_minmax ./drivers/block/floppy98.c ---
./drivers/block/floppy98.c~fd98_minmax 2004-04-18 17:54:42.000000000 -0700
+++ ./drivers/block/floppy98.c 2004-04-18 18:12:38.000000000 -0700 @@
-720,25 +720,9 @@ static void reschedule_timeout(int drive

drivers/block/floppy98.c renamed from drivers/block/floppy98.c~fd98_minmax +6 -23
 	timeout_message = message;
 }
 
-static int maximum(int a, int b)
-{
-	if (a > b)
-		return a;
-	else
-		return b;
-}
-
-#define INFBOUND(a,b) (a)=maximum((a),(b));
-
-static int minimum(int a, int b)
-{
-	if (a < b)
-		return a;
-	else
-		return b;
-}
+#define INFBOUND(a,b) (a)=max_t(int, a, b)
 
-#define SUPBOUND(a,b) (a)=minimum((a),(b));
+#define SUPBOUND(a,b) (a)=min_t(int, a, b)
 
 /*
  * Bottom half floppy driver.
@@ -2556,12 +2540,12 @@ static void copy_buffer(int ssize, int m
 	int size, i;
 
 	max_sector = transfer_size(ssize,
-				   minimum(max_sector, max_sector_2),
+				   min(max_sector, max_sector_2),
 				   current_req->nr_sectors);
 
 	if (current_count_sectors <= 0 && CT(COMMAND) == FD_WRITE &&
 	    buffer_max > fsector_t + current_req->nr_sectors)
-		current_count_sectors = minimum(buffer_max - fsector_t,
+		current_count_sectors = min_t(int, buffer_max - fsector_t,
 						current_req->nr_sectors);
 
 	remaining = current_count_sectors << 9;
@@ -2580,7 +2564,7 @@ static void copy_buffer(int ssize, int m
 	}
 #endif
 
-	buffer_max = maximum(max_sector, buffer_max);
+	buffer_max = max(max_sector, buffer_max);
 
 	dma_buffer = floppy_track_buffer + ((fsector_t - buffer_min) << 9);
 
@@ -2733,7 +2717,7 @@ static int make_raw_rw_request(void)
 		max_sector = 2 * _floppy->sect / 3;
 		if (fsector_t >= max_sector) {
 			current_count_sectors =
-			    minimum(_floppy->sect - fsector_t,
+			    min_t(int, _floppy->sect - fsector_t,
 				    current_req->nr_sectors);
 			return 1;
 		}
--

~Randy

#3 lore raw

On Mon, 19 Apr 2004 14:14:15 +0200 Bartlomiej Zolnierkiewicz wrote:

| 
| Hi Randy,
| 
| I wonder if PC9800 fixes are worth the hassle as PC9800 merge
| (AFAIR first patch went into 2.5.50!) was never finished.
| 
| I think somebody should fix it or we should just remove it completely.

I agree -- completely, on all counts, and I'm trying to take that up with Osamu Tomita, but he hasn't replied to my emails.

BTW, I have fixes for about 95% of all of the PC-9800 modules and can successfully build a PC-9800 kernel, with IDE, SCSI, speaker, etc. However, I can't test it. So I think that it is fixable, but if it's been abandoned, it can also be removed.

--
~Randy

#4 lore raw
Quoted 10 lines · Randy.Dunlap

On Mon, 19 Apr 2004 14:14:15 +0200 Bartlomiej Zolnierkiewicz wrote:

| Hi Randy,
|
| I wonder if PC9800 fixes are worth the hassle as PC9800 merge
| (AFAIR first patch went into 2.5.50!) was never finished.
|
| I think somebody should fix it or we should just remove it completely.

I agree -- completely, on all counts, and I'm trying to take that up with Osamu Tomita, but he hasn't replied to my emails.

:-(

Quoted 2 lines

BTW, I have fixes for about 95% of all of the PC-9800 modules and can successfully build a PC-9800 kernel, with IDE, SCSI,

Cool, do you also have these patches?
http://www.uwsg.iu.edu/hypermail/linux/kernel/0303.1/2045.html

BTW at least PC9800 IDE support needs reworking - it is one BIG hack

Quoted 2 lines

speaker, etc. However, I can't test it. So I think that it is fixable, but if it's been abandoned, it can also be removed.

Yep, somebody needs to maintain it or at least report when it breaks.

Cheers,
Bartlomiej

#5 lore raw
Quoted 1 line · Bartlomiej Zolnierkiewicz

BTW at least PC9800 IDE support needs reworking - it is one BIG hack

Please just kill it then. PC9800 wasn't completly merged ever and there haven't been atempts for ages. No need to stall development because of it.

#6 lore raw

On Mon, 19 Apr 2004 18:05:22 +0100 Christoph Hellwig wrote:

| On Mon, Apr 19, 2004 at 06:59:29PM +0200, Bartlomiej Zolnierkiewicz wrote:
| > BTW at least PC9800 IDE support needs reworking - it is one BIG hack
| 
| Please just kill it then.  PC9800 wasn't completly merged ever and there
| haven't been atempts for ages.  No need to stall development because of it.

Is some development stalled because of it?

The current (status quo) isn't good.
It either needs to be fixed or removed.

--
~Randy

#7 lore raw
Quoted 9 lines · Randy.Dunlap

On Mon, 19 Apr 2004 18:05:22 +0100 Christoph Hellwig wrote:

| On Mon, Apr 19, 2004 at 06:59:29PM +0200, Bartlomiej Zolnierkiewicz wrote:
| > BTW at least PC9800 IDE support needs reworking - it is one BIG hack
|
| Please just kill it then.  PC9800 wasn't completly merged ever and there
| haven't been atempts for ages.  No need to stall development because of
| it.

Is some development stalled because of it?

Well, for IDE there are bigger problems than PC9800... ;-)

Quoted 2 lines

The current (status quo) isn't good.
It either needs to be fixed or removed.

Yep, there is no doubt that it slow downs development, i.e. recent i386 standard resources fixups/cleanups.

Bartlomiej

#8 lore raw
In reply to Bartlomiej Zolnierkiewicz

On Mon, 19 Apr 2004 18:59:29 +0200 Bartlomiej Zolnierkiewicz wrote:

| On Monday 19 of April 2004 17:51, Randy.Dunlap wrote:
| > On Mon, 19 Apr 2004 14:14:15 +0200 Bartlomiej Zolnierkiewicz wrote:
| > | Hi Randy,
| > |
| > | I wonder if PC9800 fixes are worth the hassle as PC9800 merge
| > | (AFAIR first patch went into 2.5.50!) was never finished.
| > |
| > | I think somebody should fix it or we should just remove it completely.
| >
| > I agree -- completely, on all counts, and I'm trying to take that up
| > with Osamu Tomita, but he hasn't replied to my emails.
| 
| :-(
| 
| > BTW, I have fixes for about 95% of all of the PC-9800 modules
| > and can successfully build a PC-9800 kernel, with IDE, SCSI,
| 
| Cool, do you also have these patches?
| http://www.uwsg.iu.edu/hypermail/linux/kernel/0303.1/2045.html

I saw that, but I began with the latest linux98 tarball that I could find at http://sourceforge.jp/projects/linux98/, for 2.5.67-bk9. There are still lots of build issues with that tarball, but I have most of them fixed.

| BTW at least PC9800 IDE support needs reworking - it is one BIG hack

Not a surprise.

| > speaker, etc.  However, I can't test it.  So I think that it is
| > fixable, but if it's been abandoned, it can also be removed.
| 
| Yep, somebody needs to maintain it or at least report when it breaks.

Yup.

--
~Randy

A message that is not in the archive (sent off-list or not yet received): [email protected]

#10 lore raw

PATCH 1/1 floppy98.c: use C99 struct initializers

Convert (most of) floppy98.c to use C99 struct initializers, like floppy.c.

diffstat:=

 drivers/block/floppy98.c |   60 +++++++++++++++++++++++------------------------
 1 files changed, 30 insertions(+), 30 deletions(-)
drivers/block/floppy98.c renamed from drivers/block/floppy98.c~fd98_c99 +30 -30
diff -Naurp ./drivers/block/floppy98.c~fd98_c99 ./drivers/block/floppy98.c
@@ -907,9 +907,9 @@ static void motor_off_callback(unsigned 
 }
 
 static struct timer_list motor_off_timer[N_FDC] = {
-      {data: 0, function: motor_off_callback},
+      {.data = 0, .function = motor_off_callback},
 #if N_FDC > 1
-      {data: 1, function: motor_off_callback},
+      {.data = 1, .function = motor_off_callback},
 #endif
 #if N_FDC > 2
 # error "N_FDC > 2; please fix initializer for motor_off_timer[]"
@@ -2071,17 +2071,17 @@ static void do_wakeup(void)
 }
 
 static struct cont_t wakeup_cont = {
-	empty,
-	do_wakeup,
-	empty,
-	(done_f) empty
+	.interrupt	= empty,
+	.redo		= do_wakeup,
+	.error		= empty,
+	.done		= (done_f) empty
 };
 
 static struct cont_t intr_cont = {
-	empty,
-	process_fd_request,
-	empty,
-	(done_f) empty
+	.interrupt	= empty,
+	.redo		= process_fd_request,
+	.error		= empty,
+	.done		= (done_f) empty
 };
 
 static int wait_til_done(void (*handler) (void), int interruptible)
@@ -2303,10 +2303,10 @@ static void redo_format(void)
 }
 
 static struct cont_t format_cont = {
-	format_interrupt,
-	redo_format,
-	bad_flp_intr,
-	generic_done
+	.interrupt	= format_interrupt,
+	.redo		= redo_format,
+	.error		= bad_flp_intr,
+	.done		= generic_done
 };
 
 static int do_format(int drive, struct format_descr *tmp_format_req)
@@ -3026,10 +3026,10 @@ static void redo_fd_request(void)
 }
 
 static struct cont_t rw_cont = {
-	rw_interrupt,
-	redo_fd_request,
-	bad_flp_intr,
-	request_done
+	.interrupt	= rw_interrupt,
+	.redo		= redo_fd_request,
+	.error		= bad_flp_intr,
+	.done		= request_done
 };
 
 static void process_fd_request(void)
@@ -3064,10 +3064,10 @@ static void do_fd_request(request_queue_
 }
 
 static struct cont_t poll_cont = {
-	success_and_wakeup,
-	floppy_ready,
-	generic_failure,
-	generic_done
+	.interrupt	= success_and_wakeup,
+	.redo		= floppy_ready,
+	.error		= generic_failure,
+	.done		= generic_done
 };
 
 static int poll_drive(int interruptible, int flag)
@@ -3100,10 +3100,10 @@ static void reset_intr(void)
 }
 
 static struct cont_t reset_cont = {
-	reset_intr,
-	success_and_wakeup,
-	generic_failure,
-	generic_done
+	.interrupt	= reset_intr,
+	.redo		= success_and_wakeup,
+	.error		= generic_failure,
+	.done		= generic_done
 };
 
 static int user_reset_fdc(int drive, int arg, int interruptible)
@@ -3207,10 +3207,10 @@ static void raw_cmd_done(int flag)
 }
 
 static struct cont_t raw_cmd_cont = {
-	success_and_wakeup,
-	floppy_start,
-	generic_failure,
-	raw_cmd_done
+	.interrupt	= success_and_wakeup,
+	.redo		= floppy_start,
+	.error		= generic_failure,
+	.done		= raw_cmd_done
 };
 
 static inline int raw_cmd_copyout(int cmd, char *param,