Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
c276ff4d
Commit
c276ff4d
authored
Sep 07, 2002
by
Alexander Viro
Committed by
Linus Torvalds
Sep 07, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] (22/25) gendisks for SCSI cdroms
SCSI cdroms got gendisks.
parent
5c5302d4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
23 deletions
+35
-23
drivers/cdrom/cdrom.c
drivers/cdrom/cdrom.c
+1
-0
drivers/scsi/sr.c
drivers/scsi/sr.c
+32
-23
drivers/scsi/sr.h
drivers/scsi/sr.h
+2
-0
No files found.
drivers/cdrom/cdrom.c
View file @
c276ff4d
...
@@ -254,6 +254,7 @@
...
@@ -254,6 +254,7 @@
#include <linux/config.h>
#include <linux/config.h>
#include <linux/module.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/fs.h>
#include <linux/buffer_head.h>
#include <linux/major.h>
#include <linux/major.h>
#include <linux/types.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/errno.h>
...
...
drivers/scsi/sr.c
View file @
c276ff4d
...
@@ -88,7 +88,6 @@ static struct Scsi_Device_Template sr_template =
...
@@ -88,7 +88,6 @@ static struct Scsi_Device_Template sr_template =
};
};
static
Scsi_CD
*
scsi_CDs
;
static
Scsi_CD
*
scsi_CDs
;
static
int
*
sr_sizes
;
static
int
sr_open
(
struct
cdrom_device_info
*
,
int
);
static
int
sr_open
(
struct
cdrom_device_info
*
,
int
);
static
void
get_sectorsize
(
Scsi_CD
*
);
static
void
get_sectorsize
(
Scsi_CD
*
);
...
@@ -235,9 +234,9 @@ static void rw_intr(Scsi_Cmnd * SCpnt)
...
@@ -235,9 +234,9 @@ static void rw_intr(Scsi_Cmnd * SCpnt)
* block. Therefore, if we hit a medium error within the last
* block. Therefore, if we hit a medium error within the last
* 75 2K sectors, we decrease the saved size value.
* 75 2K sectors, we decrease the saved size value.
*/
*/
if
(
(
error_sector
>>
1
)
<
sr_sizes
[
device_nr
]
&&
if
(
error_sector
<
cd
->
disk
->
part
[
0
].
nr_sects
&&
cd
->
capacity
-
error_sector
<
4
*
75
)
cd
->
capacity
-
error_sector
<
4
*
75
)
sr_sizes
[
device_nr
]
=
error_sector
>>
1
;
cd
->
disk
->
part
[
0
].
nr_sects
=
error_sector
;
}
}
/*
/*
...
@@ -477,8 +476,6 @@ static void get_sectorsize(Scsi_CD *cd)
...
@@ -477,8 +476,6 @@ static void get_sectorsize(Scsi_CD *cd)
int
sector_size
;
int
sector_size
;
Scsi_Request
*
SRpnt
=
NULL
;
Scsi_Request
*
SRpnt
=
NULL
;
request_queue_t
*
queue
;
request_queue_t
*
queue
;
int
unit
=
cd
-
scsi_CDs
;
/* gack... we still need it for corresponding
sr_sizes[] element access */
buffer
=
kmalloc
(
512
,
GFP_DMA
);
buffer
=
kmalloc
(
512
,
GFP_DMA
);
if
(
!
buffer
)
if
(
!
buffer
)
...
@@ -558,7 +555,7 @@ static void get_sectorsize(Scsi_CD *cd)
...
@@ -558,7 +555,7 @@ static void get_sectorsize(Scsi_CD *cd)
* what the device is capable of.
* what the device is capable of.
*/
*/
cd
->
needs_sector_size
=
0
;
cd
->
needs_sector_size
=
0
;
sr_sizes
[
unit
]
=
cd
->
capacity
>>
(
BLOCK_SIZE_BITS
-
9
)
;
cd
->
disk
->
part
[
0
].
nr_sects
=
cd
->
capacity
;
}
}
queue
=
&
cd
->
device
->
request_queue
;
queue
=
&
cd
->
device
->
request_queue
;
...
@@ -713,15 +710,8 @@ static int sr_init()
...
@@ -713,15 +710,8 @@ static int sr_init()
memset
(
scsi_CDs
,
0
,
sr_template
.
dev_max
*
sizeof
(
Scsi_CD
));
memset
(
scsi_CDs
,
0
,
sr_template
.
dev_max
*
sizeof
(
Scsi_CD
));
for
(
i
=
0
;
i
<
sr_template
.
dev_max
;
i
++
)
for
(
i
=
0
;
i
<
sr_template
.
dev_max
;
i
++
)
sprintf
(
scsi_CDs
[
i
].
cdi
.
name
,
"sr%d"
,
i
);
sprintf
(
scsi_CDs
[
i
].
cdi
.
name
,
"sr%d"
,
i
);
sr_sizes
=
kmalloc
(
sr_template
.
dev_max
*
sizeof
(
int
),
GFP_ATOMIC
);
if
(
!
sr_sizes
)
goto
cleanup_cds
;
memset
(
sr_sizes
,
0
,
sr_template
.
dev_max
*
sizeof
(
int
));
return
0
;
return
0
;
cleanup_cds:
kfree
(
scsi_CDs
);
cleanup_dev:
cleanup_dev:
unregister_blkdev
(
MAJOR_NR
,
"sr"
);
unregister_blkdev
(
MAJOR_NR
,
"sr"
);
sr_registered
--
;
sr_registered
--
;
...
@@ -751,14 +741,34 @@ void sr_finish()
...
@@ -751,14 +741,34 @@ void sr_finish()
int
i
;
int
i
;
blk_dev
[
MAJOR_NR
].
queue
=
sr_find_queue
;
blk_dev
[
MAJOR_NR
].
queue
=
sr_find_queue
;
blk_size
[
MAJOR_NR
]
=
sr_sizes
;
for
(
i
=
0
;
i
<
sr_template
.
nr_dev
;
++
i
)
{
for
(
i
=
0
;
i
<
sr_template
.
nr_dev
;
++
i
)
{
struct
gendisk
*
disk
;
/* KLUDGE - will go away */
struct
{
struct
gendisk
disk
;
struct
hd_struct
part
;
}
*
p
;
Scsi_CD
*
cd
=
&
scsi_CDs
[
i
];
Scsi_CD
*
cd
=
&
scsi_CDs
[
i
];
/* If we have already seen this, then skip it. Comes up
/* If we have already seen this, then skip it. Comes up
* with loadable modules. */
* with loadable modules. */
if
(
cd
->
capacity
)
if
(
cd
->
disk
)
continue
;
p
=
kmalloc
(
sizeof
(
*
p
),
GFP_KERNEL
);
if
(
!
p
)
continue
;
if
(
cd
->
disk
)
{
kfree
(
p
);
continue
;
continue
;
}
memset
(
p
,
0
,
sizeof
(
*
p
));
p
->
disk
.
part
=
&
p
->
part
;
p
->
disk
.
major
=
MAJOR_NR
;
p
->
disk
.
first_minor
=
i
;
p
->
disk
.
major_name
=
cd
->
cdi
.
name
;
p
->
disk
.
minor_shift
=
0
;
p
->
disk
.
fops
=
&
sr_bdops
;
cd
->
disk
=
disk
=
&
p
->
disk
;
cd
->
capacity
=
0x1fffff
;
cd
->
capacity
=
0x1fffff
;
cd
->
device
->
sector_size
=
2048
;
/* A guess, just in case */
cd
->
device
->
sector_size
=
2048
;
/* A guess, just in case */
cd
->
needs_sector_size
=
1
;
cd
->
needs_sector_size
=
1
;
...
@@ -774,7 +784,6 @@ void sr_finish()
...
@@ -774,7 +784,6 @@ void sr_finish()
cd
->
device
->
remap
=
1
;
cd
->
device
->
remap
=
1
;
cd
->
readcd_known
=
0
;
cd
->
readcd_known
=
0
;
cd
->
readcd_cdda
=
0
;
cd
->
readcd_cdda
=
0
;
sr_sizes
[
i
]
=
cd
->
capacity
>>
(
BLOCK_SIZE_BITS
-
9
);
cd
->
cdi
.
ops
=
&
sr_dops
;
cd
->
cdi
.
ops
=
&
sr_dops
;
cd
->
cdi
.
handle
=
cd
;
cd
->
cdi
.
handle
=
cd
;
...
@@ -807,6 +816,9 @@ void sr_finish()
...
@@ -807,6 +816,9 @@ void sr_finish()
S_IFBLK
|
S_IRUGO
|
S_IWUGO
,
S_IFBLK
|
S_IRUGO
|
S_IWUGO
,
&
sr_bdops
,
NULL
);
&
sr_bdops
,
NULL
);
register_cdrom
(
&
cd
->
cdi
);
register_cdrom
(
&
cd
->
cdi
);
add_gendisk
(
disk
);
register_disk
(
disk
,
mk_kdev
(
disk
->
major
,
disk
->
first_minor
),
1
<<
disk
->
minor_shift
,
disk
->
fops
,
cd
->
capacity
);
}
}
}
}
...
@@ -822,7 +834,9 @@ static void sr_detach(Scsi_Device * SDp)
...
@@ -822,7 +834,9 @@ static void sr_detach(Scsi_Device * SDp)
* the device.
* the device.
* We should be kind to our buffer cache, however.
* We should be kind to our buffer cache, however.
*/
*/
invalidate_device
(
mk_kdev
(
MAJOR_NR
,
i
),
0
);
del_gendisk
(
cpnt
->
disk
);
kfree
(
cpnt
->
disk
);
cpnt
->
disk
=
NULL
;
/*
/*
* Reset things back to a sane state so that one can
* Reset things back to a sane state so that one can
...
@@ -834,7 +848,6 @@ static void sr_detach(Scsi_Device * SDp)
...
@@ -834,7 +848,6 @@ static void sr_detach(Scsi_Device * SDp)
SDp
->
attached
--
;
SDp
->
attached
--
;
sr_template
.
nr_dev
--
;
sr_template
.
nr_dev
--
;
sr_template
.
dev_noticed
--
;
sr_template
.
dev_noticed
--
;
sr_sizes
[
i
]
=
0
;
return
;
return
;
}
}
}
}
...
@@ -857,12 +870,8 @@ static void __exit exit_sr(void)
...
@@ -857,12 +870,8 @@ static void __exit exit_sr(void)
scsi_unregister_device
(
&
sr_template
);
scsi_unregister_device
(
&
sr_template
);
unregister_blkdev
(
MAJOR_NR
,
"sr"
);
unregister_blkdev
(
MAJOR_NR
,
"sr"
);
sr_registered
--
;
sr_registered
--
;
if
(
scsi_CDs
!=
NULL
)
{
if
(
scsi_CDs
!=
NULL
)
kfree
(
scsi_CDs
);
kfree
(
scsi_CDs
);
kfree
(
sr_sizes
);
sr_sizes
=
NULL
;
}
blk_clear
(
MAJOR_NR
);
blk_clear
(
MAJOR_NR
);
sr_template
.
dev_max
=
0
;
sr_template
.
dev_max
=
0
;
...
...
drivers/scsi/sr.h
View file @
c276ff4d
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#define _SR_H
#define _SR_H
#include "scsi.h"
#include "scsi.h"
#include <linux/genhd.h>
typedef
struct
{
typedef
struct
{
unsigned
capacity
;
/* size in blocks */
unsigned
capacity
;
/* size in blocks */
...
@@ -30,6 +31,7 @@ typedef struct {
...
@@ -30,6 +31,7 @@ typedef struct {
unsigned
readcd_known
:
1
;
/* drive supports READ_CD (0xbe) */
unsigned
readcd_known
:
1
;
/* drive supports READ_CD (0xbe) */
unsigned
readcd_cdda
:
1
;
/* reading audio data using READ_CD */
unsigned
readcd_cdda
:
1
;
/* reading audio data using READ_CD */
struct
cdrom_device_info
cdi
;
struct
cdrom_device_info
cdi
;
struct
gendisk
*
disk
;
}
Scsi_CD
;
}
Scsi_CD
;
int
sr_do_ioctl
(
Scsi_CD
*
,
unsigned
char
*
,
void
*
,
unsigned
,
int
,
int
,
struct
request_sense
*
);
int
sr_do_ioctl
(
Scsi_CD
*
,
unsigned
char
*
,
void
*
,
unsigned
,
int
,
int
,
struct
request_sense
*
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment