public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Badari Pulavarty <pbadari@us.ibm.com>
To: linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: Isn't sd_major() broken ?
Date: Thu, 10 Apr 2003 10:01:44 -0800	[thread overview]
Message-ID: <200304101101.44493.pbadari@us.ibm.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1207 bytes --]

Hi,

I am little confused about the correctness of sd_major() in drivers/scsi/sd.c.

static int sd_major(int major_idx)
{
        switch (major_idx) {
        case 0:
                return SCSI_DISK0_MAJOR;
        case 1 ... 7:
                return SCSI_DISK1_MAJOR + major_idx - 1;
        case 8 ... 15:
                return SCSI_DISK8_MAJOR + major_idx;
        default:
                BUG();
                return 0;       /* shut up gcc */
        }
}

So, if major_idx = 8, It returns 143. 
But according to major.h, scsi has 128-135 reserved
majors. But it is registering 136 - 143 as its majors.

#define SCSI_DISK8_MAJOR        128
#define SCSI_DISK9_MAJOR        129
#define SCSI_DISK10_MAJOR       130
#define SCSI_DISK11_MAJOR       131
#define SCSI_DISK12_MAJOR       132
#define SCSI_DISK13_MAJOR       133
#define SCSI_DISK14_MAJOR       134
#define SCSI_DISK15_MAJOR       135

Isn't sd_major() broken ? Here is the patch to fix it.

Thanks,
Badari

# cat /proc/devices
...
Block devices:
  2 fd
  3 ide0
  8 sd
 11 sr
 65 sd
 66 sd
 67 sd
 68 sd
 69 sd
 70 sd
 71 sd
136 sd
137 sd
138 sd
139 sd
140 sd
141 sd
142 sd
143 sd

[-- Attachment #2: major --]
[-- Type: text/x-diff, Size: 366 bytes --]

--- drivers/scsi/sd.c.org	Wed Apr  9 13:12:38 2003
+++ drivers/scsi/sd.c	Thu Apr 10 11:01:45 2003
@@ -123,7 +123,7 @@ static int sd_major(int major_idx)
 	case 1 ... 7:
 		return SCSI_DISK1_MAJOR + major_idx - 1;
 	case 8 ... 15:
-		return SCSI_DISK8_MAJOR + major_idx;
+		return SCSI_DISK8_MAJOR + major_idx - 8;
 	default:
 		BUG();
 		return 0;	/* shut up gcc */

             reply	other threads:[~2003-04-10 17:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-10 18:01 Badari Pulavarty [this message]
     [not found] <mailman.1049998202.18407.linux-kernel2news@redhat.com>
2003-04-10 20:39 ` Isn't sd_major() broken ? Pete Zaitcev
  -- strict thread matches above, loose matches on Subject: below --
2003-04-10 20:46 Andries.Brouwer

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=200304101101.44493.pbadari@us.ibm.com \
    --to=pbadari@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox