All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Andrew Morton <akpm@osdl.org>
Cc: Linus Torvalds <torvalds@osdl.org>,
	Linux Kernel list <linux-kernel@vger.kernel.org>
Subject: [PATCH] Fix use of sector_t in swim3 driver
Date: Sat, 21 Feb 2004 19:01:08 +1100	[thread overview]
Message-ID: <1077350468.851.36.camel@gaston> (raw)

Hi !

This driver won't build with CONFIG_LBD due to a 64 bits division.

Use the "simple" fix of a cast down to 32 bits, this is only
a floppy driver, no need to do sector_div.

Please, apply.

Ben.

===== drivers/block/swim3.c 1.32 vs edited =====
--- 1.32/drivers/block/swim3.c	Sat Feb 14 19:29:14 2004
+++ edited/drivers/block/swim3.c	Sat Feb 21 18:57:10 2004
@@ -319,7 +319,7 @@
 #if 0
 		printk("do_fd_req: dev=%s cmd=%d sec=%ld nr_sec=%ld buf=%p\n",
 		       req->rq_disk->disk_name, req->cmd,
-		       req->sector, req->nr_sectors, req->buffer);
+		       (long)req->sector, req->nr_sectors, req->buffer);
 		printk("           rq_status=%d errors=%d current_nr_sectors=%ld\n",
 		       req->rq_status, req->errors, req->current_nr_sectors);
 #endif
@@ -346,8 +346,13 @@
 			}
 		}
 
-		fs->req_cyl = req->sector / fs->secpercyl;
-		x = req->sector % fs->secpercyl;
+		/* Do not remove the cast. req->sector is now a sector_t and
+		 * can be 64 bits, but it will never go past 32 bits for this
+		 * driver anyway, so we can safely cast it down and not have
+		 * to do a 64/32 division
+		 */
+		fs->req_cyl = ((long)req->sector) / fs->secpercyl;
+		x = ((long)req->sector) % fs->secpercyl;
 		fs->head = x / fs->secpertrack;
 		fs->req_sector = x % fs->secpertrack + 1;
 		fd_req = req;
@@ -614,7 +619,7 @@
 	fd_req->sector += s;
 	fd_req->current_nr_sectors -= s;
 	printk(KERN_ERR "swim3: timeout %sing sector %ld\n",
-	       (rq_data_dir(fd_req)==WRITE? "writ": "read"), fd_req->sector);
+	       (rq_data_dir(fd_req)==WRITE? "writ": "read"), (long)fd_req->sector);
 	end_request(fd_req, 0);
 	fs->state = idle;
 	start_request(fs);
@@ -730,7 +735,7 @@
 			} else {
 				printk("swim3: error %sing block %ld (err=%x)\n",
 				       rq_data_dir(fd_req) == WRITE? "writ": "read",
-				       fd_req->sector, err);
+				       (long)fd_req->sector, err);
 				end_request(fd_req, 0);
 				fs->state = idle;
 			}



                 reply	other threads:[~2004-02-21  8:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1077350468.851.36.camel@gaston \
    --to=benh@kernel.crashing.org \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.