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
ba26d89f
Commit
ba26d89f
authored
Nov 17, 2002
by
Doug Ledford
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
aic7xxx_old: fix up the biosparam function to do 64bit math safely
parent
dceeb5a9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
8 deletions
+17
-8
drivers/scsi/aic7xxx_old.c
drivers/scsi/aic7xxx_old.c
+17
-8
No files found.
drivers/scsi/aic7xxx_old.c
View file @
ba26d89f
...
...
@@ -10974,7 +10974,8 @@ int
aic7xxx_biosparam
(
struct
scsi_device
*
sdev
,
struct
block_device
*
bdev
,
sector_t
capacity
,
int
geom
[])
{
int
heads
,
sectors
,
cylinders
,
ret
;
sector_t
heads
,
sectors
,
cylinders
;
int
ret
;
struct
aic7xxx_host
*
p
;
unsigned
char
*
buf
;
...
...
@@ -10991,18 +10992,26 @@ aic7xxx_biosparam(struct scsi_device *sdev, struct block_device *bdev,
heads
=
64
;
sectors
=
32
;
cylinders
=
(
unsigned
long
)
capacity
/
(
heads
*
sectors
)
;
cylinders
=
capacity
>>
11
;
if
((
p
->
flags
&
AHC_EXTEND_TRANS_A
)
&&
(
cylinders
>
1024
))
{
heads
=
255
;
sectors
=
63
;
cylinders
=
(
unsigned
long
)
capacity
/
(
heads
*
sectors
);
}
geom
[
0
]
=
heads
;
geom
[
1
]
=
sectors
;
geom
[
2
]
=
cylinders
;
/* pull this crap because 64bit math in the kernel is a no-no as far
* as division is concerned, but 64bit multiplication can be done */
/* This shift approximates capacity / (heads * sectors) */
cylinders
=
capacity
>>
14
;
/* Now we brute force upping cylinders until we go over by 1 */
while
(
capacity
>=
(
cylinders
*
sectors
*
heads
))
cylinders
++
;
/* Then back it back down by one */
cylinders
--
;
}
geom
[
0
]
=
(
int
)
heads
;
geom
[
1
]
=
(
int
)
sectors
;
geom
[
2
]
=
(
int
)
cylinders
;
return
(
0
);
}
...
...
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