All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Andries Brouwer <aebr@win.tue.nl>
Cc: James Bottomley <James.Bottomley@steeleye.com>,
	Christoph Hellwig <hch@lst.de>,
	linux-scsi@vger.kernel.org
Subject: Re: [PATCH] fix sector_div use in scsicam.c
Date: Mon, 28 Oct 2002 02:45:19 +0100	[thread overview]
Message-ID: <20021028024519.A18865@lst.de> (raw)
In-Reply-To: <20021028005053.GA28587@win.tue.nl>; from aebr@win.tue.nl on Mon, Oct 28, 2002 at 01:50:53AM +0100

On Mon, Oct 28, 2002 at 01:50:53AM +0100, Andries Brouwer wrote:
> On Sun, Oct 27, 2002 at 06:05:07PM -0600, James Bottomley wrote:
> 
> > If the return type will be ignored by most applications, I don't see
> > what the problem is.
> 
> There is no problem. My longish reaction was mostly because you used
> "future proofing", that gave the impression that you did not know
> what this is about.
> 
> > (like an obviously wrong truncation)
> 
> No, the code I wrote was optimal.
> If you have 16 bits and the value is 70000, I prefer returning
> 65535 over 4464.

Why didn't you write is as patch?  James, this in Andries code
in patch from, it get's rid of the ugly sector_div so it should
be in if not just because of that.

--- 1.12/drivers/scsi/scsicam.c	Sun Oct 27 11:56:37 2002
+++ edited/drivers/scsi/scsicam.c	Mon Oct 28 01:12:24 2002
@@ -78,15 +78,18 @@
 	/* if something went wrong, then apparently we have to return
 	   a geometry with more than 1024 cylinders */
 	if (ret || ip[0] > 255 || ip[1] > 63) {
-		ip[0] = 64;
-		ip[1] = 32;
-		sector_div(capacity, ip[0] * ip[1]);
-		if (capacity > 65534) {
+		if ((capacity >> 11) > 65534) {
 			ip[0] = 255;
 			ip[1] = 63;
-			sector_div(capacity, ip[0] * ip[1]);
+		} else {
+			ip[0] = 64;
+			ip[1] = 32;
 		}
-		ip[2] = capacity;
+
+		if (capacity > 65535*63*255)
+			ip[2] = 65535;
+		else
+			ip[2] = (unsigned long)capacity / (ip[0] * ip[1]);
 	}
 
 	return 0;

      reply	other threads:[~2002-10-28  1:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-27 16:02 [PATCH] fix sector_div use in scsicam.c Christoph Hellwig
2002-10-27 16:21 ` James Bottomley
2002-10-27 16:23   ` Christoph Hellwig
2002-10-27 16:34     ` James Bottomley
2002-10-27 16:37       ` Christoph Hellwig
2002-10-27 19:22         ` Andries Brouwer
2002-10-27 20:53           ` James Bottomley
2002-10-27 22:10             ` Andries Brouwer
2002-10-28  0:05               ` James Bottomley
2002-10-28  0:50                 ` Andries Brouwer
2002-10-28  1:45                   ` Christoph Hellwig [this message]

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=20021028024519.A18865@lst.de \
    --to=hch@lst.de \
    --cc=James.Bottomley@steeleye.com \
    --cc=aebr@win.tue.nl \
    --cc=linux-scsi@vger.kernel.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.