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
aebd88df
Commit
aebd88df
authored
Oct 02, 2002
by
Alexander Viro
Committed by
Linus Torvalds
Oct 02, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] floppy.c switched to dynamic allocation
parent
9a94d76a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
28 deletions
+43
-28
drivers/block/floppy.c
drivers/block/floppy.c
+43
-28
No files found.
drivers/block/floppy.c
View file @
aebd88df
...
@@ -415,8 +415,7 @@ static struct floppy_drive_params drive_params[N_DRIVE];
...
@@ -415,8 +415,7 @@ static struct floppy_drive_params drive_params[N_DRIVE];
static
struct
floppy_drive_struct
drive_state
[
N_DRIVE
];
static
struct
floppy_drive_struct
drive_state
[
N_DRIVE
];
static
struct
floppy_write_errors
write_errors
[
N_DRIVE
];
static
struct
floppy_write_errors
write_errors
[
N_DRIVE
];
static
struct
timer_list
motor_off_timer
[
N_DRIVE
];
static
struct
timer_list
motor_off_timer
[
N_DRIVE
];
static
struct
gendisk
disks
[
N_DRIVE
];
static
struct
gendisk
*
disks
[
N_DRIVE
];
static
char
names
[
N_DRIVE
][
4
];
static
struct
floppy_raw_cmd
*
raw_cmd
,
default_raw_cmd
;
static
struct
floppy_raw_cmd
*
raw_cmd
,
default_raw_cmd
;
/*
/*
...
@@ -3772,7 +3771,7 @@ static int floppy_open(struct inode * inode, struct file * filp)
...
@@ -3772,7 +3771,7 @@ static int floppy_open(struct inode * inode, struct file * filp)
}
}
UDRS
->
fd_device
=
minor
(
inode
->
i_rdev
);
UDRS
->
fd_device
=
minor
(
inode
->
i_rdev
);
set_capacity
(
&
disks
[
drive
],
floppy_sizes
[
minor
(
inode
->
i_rdev
)]);
set_capacity
(
disks
[
drive
],
floppy_sizes
[
minor
(
inode
->
i_rdev
)]);
if
(
old_dev
!=
-
1
&&
old_dev
!=
minor
(
inode
->
i_rdev
))
{
if
(
old_dev
!=
-
1
&&
old_dev
!=
minor
(
inode
->
i_rdev
))
{
if
(
buffer_drive
==
drive
)
if
(
buffer_drive
==
drive
)
buffer_track
=
-
1
;
buffer_track
=
-
1
;
...
@@ -3952,7 +3951,7 @@ static int floppy_revalidate(kdev_t dev)
...
@@ -3952,7 +3951,7 @@ static int floppy_revalidate(kdev_t dev)
process_fd_request
();
process_fd_request
();
}
}
}
}
set_capacity
(
&
disks
[
drive
],
floppy_sizes
[
minor
(
dev
)]);
set_capacity
(
disks
[
drive
],
floppy_sizes
[
minor
(
dev
)]);
return
res
;
return
res
;
}
}
...
@@ -4230,26 +4229,34 @@ static struct gendisk *floppy_find(int minor)
...
@@ -4230,26 +4229,34 @@ static struct gendisk *floppy_find(int minor)
!
(
allowed_drive_mask
&
(
1
<<
drive
))
||
!
(
allowed_drive_mask
&
(
1
<<
drive
))
||
fdc_state
[
FDC
(
drive
)].
version
==
FDC_NONE
)
fdc_state
[
FDC
(
drive
)].
version
==
FDC_NONE
)
return
NULL
;
return
NULL
;
return
&
disks
[
drive
];
return
disks
[
drive
];
}
}
int
__init
floppy_init
(
void
)
int
__init
floppy_init
(
void
)
{
{
int
i
,
unit
,
drive
;
int
i
,
unit
,
drive
;
int
err
;
raw_cmd
=
NULL
;
raw_cmd
=
NULL
;
for
(
i
=
0
;
i
<
N_DRIVE
;
i
++
)
{
disks
[
i
]
=
alloc_disk
();
if
(
!
disks
[
i
])
goto
Enomem
;
}
devfs_handle
=
devfs_mk_dir
(
NULL
,
"floppy"
,
NULL
);
devfs_handle
=
devfs_mk_dir
(
NULL
,
"floppy"
,
NULL
);
if
(
register_blkdev
(
MAJOR_NR
,
"fd"
,
&
floppy_fops
))
{
if
(
register_blkdev
(
MAJOR_NR
,
"fd"
,
&
floppy_fops
))
{
printk
(
"Unable to get major %d for floppy
\n
"
,
MAJOR_NR
);
printk
(
"Unable to get major %d for floppy
\n
"
,
MAJOR_NR
);
return
-
EBUSY
;
err
=
-
EBUSY
;
goto
out
;
}
}
for
(
i
=
0
;
i
<
N_DRIVE
;
i
++
)
{
for
(
i
=
0
;
i
<
N_DRIVE
;
i
++
)
{
disks
[
i
]
.
major
=
MAJOR_NR
;
disks
[
i
]
->
major
=
MAJOR_NR
;
disks
[
i
]
.
first_minor
=
TOMINOR
(
i
);
disks
[
i
]
->
first_minor
=
TOMINOR
(
i
);
disks
[
i
]
.
fops
=
&
floppy_fops
;
disks
[
i
]
->
fops
=
&
floppy_fops
;
sprintf
(
disks
[
i
]
.
disk_name
,
"fd%d"
,
i
);
sprintf
(
disks
[
i
]
->
disk_name
,
"fd%d"
,
i
);
}
}
blk_set_probe
(
MAJOR_NR
,
floppy_find
);
blk_set_probe
(
MAJOR_NR
,
floppy_find
);
...
@@ -4281,11 +4288,8 @@ int __init floppy_init(void)
...
@@ -4281,11 +4288,8 @@ int __init floppy_init(void)
use_virtual_dma
=
can_use_virtual_dma
&
1
;
use_virtual_dma
=
can_use_virtual_dma
&
1
;
fdc_state
[
0
].
address
=
FDC1
;
fdc_state
[
0
].
address
=
FDC1
;
if
(
fdc_state
[
0
].
address
==
-
1
)
{
if
(
fdc_state
[
0
].
address
==
-
1
)
{
unregister_blkdev
(
MAJOR_NR
,
"fd"
);
err
=
-
ENODEV
;
del_timer
(
&
fd_timeout
);
goto
out1
;
blk_cleanup_queue
(
BLK_DEFAULT_QUEUE
(
MAJOR_NR
));
blk_set_probe
(
MAJOR_NR
,
NULL
);
return
-
ENODEV
;
}
}
#if N_FDC > 1
#if N_FDC > 1
fdc_state
[
1
].
address
=
FDC2
;
fdc_state
[
1
].
address
=
FDC2
;
...
@@ -4293,11 +4297,8 @@ int __init floppy_init(void)
...
@@ -4293,11 +4297,8 @@ int __init floppy_init(void)
fdc
=
0
;
/* reset fdc in case of unexpected interrupt */
fdc
=
0
;
/* reset fdc in case of unexpected interrupt */
if
(
floppy_grab_irq_and_dma
()){
if
(
floppy_grab_irq_and_dma
()){
del_timer
(
&
fd_timeout
);
err
=
-
EBUSY
;
blk_cleanup_queue
(
BLK_DEFAULT_QUEUE
(
MAJOR_NR
));
goto
out1
;
unregister_blkdev
(
MAJOR_NR
,
"fd"
);
blk_set_probe
(
MAJOR_NR
,
NULL
);
return
-
EBUSY
;
}
}
/* initialise drive state */
/* initialise drive state */
...
@@ -4352,15 +4353,13 @@ int __init floppy_init(void)
...
@@ -4352,15 +4353,13 @@ int __init floppy_init(void)
current_drive
=
0
;
current_drive
=
0
;
floppy_release_irq_and_dma
();
floppy_release_irq_and_dma
();
initialising
=
0
;
initialising
=
0
;
if
(
have_no_fdc
)
if
(
have_no_fdc
)
{
{
DPRINT
(
"no floppy controllers found
\n
"
);
DPRINT
(
"no floppy controllers found
\n
"
);
flush_scheduled_tasks
();
flush_scheduled_tasks
();
if
(
usage_count
)
if
(
usage_count
)
floppy_release_irq_and_dma
();
floppy_release_irq_and_dma
();
blk_cleanup_queue
(
BLK_DEFAULT_QUEUE
(
MAJOR_NR
));
err
=
have_no_fdc
;
unregister_blkdev
(
MAJOR_NR
,
"fd"
);
goto
out2
;
blk_set_probe
(
MAJOR_NR
,
NULL
);
}
}
for
(
drive
=
0
;
drive
<
N_DRIVE
;
drive
++
)
{
for
(
drive
=
0
;
drive
<
N_DRIVE
;
drive
++
)
{
...
@@ -4370,12 +4369,27 @@ int __init floppy_init(void)
...
@@ -4370,12 +4369,27 @@ int __init floppy_init(void)
continue
;
continue
;
if
(
fdc_state
[
FDC
(
drive
)].
version
==
FDC_NONE
)
if
(
fdc_state
[
FDC
(
drive
)].
version
==
FDC_NONE
)
continue
;
continue
;
add_disk
(
disks
+
drive
);
add_disk
(
disks
[
drive
]
);
}
}
platform_device_register
(
&
floppy_device
);
platform_device_register
(
&
floppy_device
);
return
0
;
return
have_no_fdc
;
out1:
del_timer
(
&
fd_timeout
);
out2:
unregister_blkdev
(
MAJOR_NR
,
"fd"
);
blk_cleanup_queue
(
BLK_DEFAULT_QUEUE
(
MAJOR_NR
));
blk_set_probe
(
MAJOR_NR
,
NULL
);
out:
for
(
i
=
0
;
i
<
N_DRIVE
;
i
++
)
put_disk
(
disks
[
i
]);
return
err
;
Enomem:
while
(
i
--
)
put_disk
(
disks
[
i
]);
return
-
ENOMEM
;
}
}
static
spinlock_t
floppy_usage_lock
=
SPIN_LOCK_UNLOCKED
;
static
spinlock_t
floppy_usage_lock
=
SPIN_LOCK_UNLOCKED
;
...
@@ -4564,7 +4578,8 @@ void cleanup_module(void)
...
@@ -4564,7 +4578,8 @@ void cleanup_module(void)
for
(
drive
=
0
;
drive
<
N_DRIVE
;
drive
++
)
{
for
(
drive
=
0
;
drive
<
N_DRIVE
;
drive
++
)
{
if
((
allowed_drive_mask
&
(
1
<<
drive
))
&&
if
((
allowed_drive_mask
&
(
1
<<
drive
))
&&
fdc_state
[
FDC
(
drive
)].
version
!=
FDC_NONE
)
fdc_state
[
FDC
(
drive
)].
version
!=
FDC_NONE
)
del_gendisk
(
disks
+
drive
);
del_gendisk
(
disks
[
drive
]);
put_disk
(
disks
[
drive
]);
}
}
blk_cleanup_queue
(
BLK_DEFAULT_QUEUE
(
MAJOR_NR
));
blk_cleanup_queue
(
BLK_DEFAULT_QUEUE
(
MAJOR_NR
));
...
...
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