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
95bf6a39
Commit
95bf6a39
authored
Sep 21, 2002
by
Alexander Viro
Committed by
Linus Torvalds
Sep 21, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] gendisk for jsflash
jsflash switched to use of gendisk
parent
4f5f78e6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
38 deletions
+27
-38
drivers/sbus/char/jsflash.c
drivers/sbus/char/jsflash.c
+27
-38
No files found.
drivers/sbus/char/jsflash.c
View file @
95bf6a39
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
#include <linux/init.h>
#include <linux/init.h>
#include <linux/string.h>
#include <linux/string.h>
#include <linux/smp_lock.h>
#include <linux/smp_lock.h>
#include <linux/genhd.h>
/*
/*
* <linux/blk.h> is controlled from the outside with these definitions.
* <linux/blk.h> is controlled from the outside with these definitions.
...
@@ -126,8 +127,8 @@ struct jsflash {
...
@@ -126,8 +127,8 @@ struct jsflash {
/*
/*
*/
*/
static
int
jsfd_sizes
[
JSF_MAX
];
static
struct
gendisk
jsfd_disk
[
JSF_MAX
];
static
u64
jsfd_bytesizes
[
JSF_MAX
];
static
char
names
[
JSF_MAX
][
6
];
/*
/*
* Let's pretend we may have several of these...
* Let's pretend we may have several of these...
...
@@ -439,28 +440,6 @@ static int jsf_ioctl(struct inode *inode, struct file *f, unsigned int cmd,
...
@@ -439,28 +440,6 @@ static int jsf_ioctl(struct inode *inode, struct file *f, unsigned int cmd,
return
error
;
return
error
;
}
}
static
int
jsfd_ioctl
(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
int
dev
;
if
(
!
capable
(
CAP_SYS_ADMIN
))
return
-
EPERM
;
if
(
!
inode
)
return
-
EINVAL
;
if
((
dev
=
MINOR
(
inode
->
i_rdev
))
>=
JSF_MAX
)
return
-
ENODEV
;
switch
(
cmd
)
{
case
BLKGETSIZE
:
return
put_user
(
jsfd_bytesizes
[
dev
]
>>
9
,
(
unsigned
long
*
)
arg
);
case
BLKGETSIZE64
:
return
put_user
(
jsfd_bytesizes
[
dev
],
(
u64
*
)
arg
);
default:
;
}
return
-
ENOTTY
;
}
static
int
jsf_mmap
(
struct
file
*
file
,
struct
vm_area_struct
*
vma
)
static
int
jsf_mmap
(
struct
file
*
file
,
struct
vm_area_struct
*
vma
)
{
{
return
-
ENXIO
;
return
-
ENXIO
;
...
@@ -541,10 +520,9 @@ static struct block_device_operations jsfd_fops = {
...
@@ -541,10 +520,9 @@ static struct block_device_operations jsfd_fops = {
.
owner
=
THIS_MODULE
,
.
owner
=
THIS_MODULE
,
.
open
=
jsfd_open
,
.
open
=
jsfd_open
,
.
release
=
jsfd_release
,
.
release
=
jsfd_release
,
.
ioctl
=
jsfd_ioctl
,
};
};
int
jsflash_init
(
void
)
static
int
jsflash_init
(
void
)
{
{
int
rc
;
int
rc
;
struct
jsflash
*
jsf
;
struct
jsflash
*
jsf
;
...
@@ -632,14 +610,15 @@ int jsflash_init(void)
...
@@ -632,14 +610,15 @@ int jsflash_init(void)
return
0
;
return
0
;
}
}
int
jsfd_init
(
void
)
{
static
int
jsfd_init
(
void
)
{
static
spinlock_t
lock
=
SPIN_LOCK_UNLOCKED
;
struct
jsflash
*
jsf
;
struct
jsflash
*
jsf
;
struct
jsfd_part
*
jdp
;
struct
jsfd_part
*
jdp
;
int
i
;
int
i
;
if
(
jsf0
.
base
==
0
)
{
if
(
jsf0
.
base
==
0
)
return
-
ENXIO
;
return
-
ENXIO
;
}
if
(
register_blkdev
(
JSFD_MAJOR
,
"jsfd"
,
&
jsfd_fops
))
{
if
(
register_blkdev
(
JSFD_MAJOR
,
"jsfd"
,
&
jsfd_fops
))
{
printk
(
"jsfd_init: unable to get major number %d
\n
"
,
printk
(
"jsfd_init: unable to get major number %d
\n
"
,
...
@@ -647,20 +626,25 @@ int jsfd_init(void) {
...
@@ -647,20 +626,25 @@ int jsfd_init(void) {
return
-
EIO
;
return
-
EIO
;
}
}
blk_size
[
JSFD_MAJOR
]
=
jsfd_sizes
;
blk_init_queue
(
BLK_DEFAULT_QUEUE
(
MAJOR_NR
),
jsfd_do_request
,
&
lock
);
blk_init_queue
(
BLK_DEFAULT_QUEUE
(
MAJOR_NR
),
jsf_do_request
);
for
(
i
=
0
;
i
<
JSF_MAX
;
i
++
)
{
for
(
i
=
0
;
i
<
JSF_MAX
;
i
++
)
{
struct
gendisk
*
disk
=
jsfd_disk
+
i
;
if
((
i
&
JSF_PART_MASK
)
>=
JSF_NPART
)
continue
;
if
((
i
&
JSF_PART_MASK
)
>=
JSF_NPART
)
continue
;
jsf
=
&
jsf0
;
/* actually, &jsfv[i >> JSF_PART_BITS] */
jsf
=
&
jsf0
;
/* actually, &jsfv[i >> JSF_PART_BITS] */
jdp
=
&
jsf
->
dv
[
i
&
JSF_PART_MASK
];
jdp
=
&
jsf
->
dv
[
i
&
JSF_PART_MASK
];
jdp
->
refcnt
=
0
;
jdp
->
refcnt
=
0
;
jsfd_bytesizes
[
i
]
=
jdp
->
dsize
;
disk
->
major
=
JSFD_MAJOR
;
jsfd_sizes
[
i
]
=
jsfd_bytesizes
[
i
]
>>
10
;
disk
->
first_minor
=
i
;
register_disk
(
NULL
,
MKDEV
(
JSFD_MAJOR
,
i
),
1
,
&
jsfd_fops
,
sprintf
(
names
[
i
],
"jsfd%d"
,
i
);
jsfd_bytesizes
[
i
]
>>
9
);
disk
->
major_name
=
names
[
i
];
disk
->
fops
=
&
jsfd_fops
;
disk
->
minor_shift
=
0
;
add_gendisk
(
disk
);
register_disk
(
disk
,
mk_kdev
(
disk
->
major
,
disk
->
first_minor
),
1
<<
disk
->
minor_shift
,
disk
->
fops
,
jdp
->
dsize
>>
9
);
set_device_ro
(
MKDEV
(
JSFD_MAJOR
,
i
),
1
);
set_device_ro
(
MKDEV
(
JSFD_MAJOR
,
i
),
1
);
}
}
return
0
;
return
0
;
...
@@ -678,9 +662,14 @@ static int __init jsflash_init_module(void) {
...
@@ -678,9 +662,14 @@ static int __init jsflash_init_module(void) {
return
rc
;
return
rc
;
}
}
static
void
__exit
jsflash_cleanup_module
(
void
)
{
static
void
__exit
jsflash_cleanup_module
(
void
)
{
int
i
;
/* for (all probed units) { } */
for
(
i
=
0
;
i
<
JSF_MAX
;
i
++
)
{
if
((
i
&
JSF_PART_MASK
)
>=
JSF_NPART
)
continue
;
del_gendisk
(
jsfd_disk
+
i
);
}
if
(
jsf0
.
busy
)
if
(
jsf0
.
busy
)
printk
(
"jsf0: cleaning busy unit
\n
"
);
printk
(
"jsf0: cleaning busy unit
\n
"
);
jsf0
.
base
=
0
;
jsf0
.
base
=
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