Isn't sd_major() broken ?

Badari Pulavarty (pbadari@us.ibm.com)
Thu, 10 Apr 2003 10:01:44 -0800


--------------Boundary-00=_WE35UDLQRP2F7W0TSKLT
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

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 =3D 8, It returns 143.=20
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
=2E..
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

--------------Boundary-00=_WE35UDLQRP2F7W0TSKLT
Content-Type: text/x-diff;
charset="us-ascii";
name="major"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="major"

--- 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 */

--------------Boundary-00=_WE35UDLQRP2F7W0TSKLT--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/