Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AndroidKernelMSM
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Werner Sembach
AndroidKernelMSM
Commits
d9ea7207
Commit
d9ea7207
authored
Aug 31, 2018
by
Werner Sembach
Browse files
Options
Downloads
Patches
Plain Diff
Automatically create /dev/klist
parent
1e7e20c3
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
drivers/klist/klist.c
+25
-0
25 additions, 0 deletions
drivers/klist/klist.c
with
25 additions
and
0 deletions
drivers/klist/klist.c
+
25
−
0
View file @
d9ea7207
...
@@ -11,6 +11,9 @@
...
@@ -11,6 +11,9 @@
#include
<linux/uaccess.h>
#include
<linux/uaccess.h>
#include
<linux/tty.h>
#include
<linux/tty.h>
#include
<asm/errno.h>
#include
<asm/errno.h>
#include
<linux/device.h>
#include
<linux/kdev_t.h>
/* #define DEBUG */
/* #define DEBUG */
#ifdef DEBUG
#ifdef DEBUG
...
@@ -19,6 +22,8 @@
...
@@ -19,6 +22,8 @@
#define LOG(...)
#define LOG(...)
#endif
#endif
#define ERR(...) printk(KERN_ERR __VA_ARGS__)
/* klist functions */
/* klist functions */
#define LIST_CMD 0x1337
#define LIST_CMD 0x1337
#define LIST_ADD (LIST_CMD + 0)
#define LIST_ADD (LIST_CMD + 0)
...
@@ -30,6 +35,8 @@
...
@@ -30,6 +35,8 @@
/* consts */
/* consts */
#define MAX_SIZE 0x400
#define MAX_SIZE 0x400
static
struct
class
*
cl
;
static
long
k_list
[
MAX_SIZE
];
static
long
k_list
[
MAX_SIZE
];
static
unsigned
long
list_size
;
static
unsigned
long
list_size
;
...
@@ -172,12 +179,30 @@ static int __init init_list(void)
...
@@ -172,12 +179,30 @@ static int __init init_list(void)
ret
=
register_chrdev
(
1337
,
"klist"
,
&
list_fops
);
ret
=
register_chrdev
(
1337
,
"klist"
,
&
list_fops
);
LOG
(
"register device: %d
\n
"
,
ret
);
LOG
(
"register device: %d
\n
"
,
ret
);
list_size
=
0
;
list_size
=
0
;
if
(
ret
)
{
ERR
(
"register device failed."
);
return
ret
;
}
//automatically populate /sys/class/ and create /dev/klist on module startup
cl
=
class_create
(
THIS_MODULE
,
"klist"
);
if
(
IS_ERR
(
cl
))
{
ERR
(
"automatic /dev/klist creation failed on class_create."
);
return
ret
;
}
if
(
IS_ERR
(
device_create
(
cl
,
NULL
,
MKDEV
(
1337
,
0
),
NULL
,
"klist"
)))
{
ERR
(
"automatic /dev/klist creation failed on class_create."
);
class_destroy
(
cl
);
return
ret
;
}
return
ret
;
return
ret
;
}
}
static
void
__exit
exit_list
(
void
)
static
void
__exit
exit_list
(
void
)
{
{
device_destroy
(
cl
,
MKDEV
(
1337
,
0
));
class_destroy
(
cl
);
unregister_chrdev
(
1337
,
"klist"
);
unregister_chrdev
(
1337
,
"klist"
);
LOG
(
"exit.
\n
"
);
LOG
(
"exit.
\n
"
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment