Commit bb9e1c7a authored by Badari Pulavarty's avatar Badari Pulavarty Committed by Linus Torvalds

Isn't sd_major() broken ?

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
parent f01d7733
......@@ -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 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment