Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
embedded-linux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
David Maul
embedded-linux
Commits
dbe6d44c
Commit
dbe6d44c
authored
4 months ago
by
Leon Bohnwagner
Browse files
Options
Downloads
Patches
Plain Diff
feat: update kernel module logging
parent
c4046057
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
common/src/userspace_comm.c
+0
-1
0 additions, 1 deletion
common/src/userspace_comm.c
daemon/src/receive.c
+0
-1
0 additions, 1 deletion
daemon/src/receive.c
daemon/src/send.c
+0
-1
0 additions, 1 deletion
daemon/src/send.c
kernel/kmod.c
+21
-15
21 additions, 15 deletions
kernel/kmod.c
with
21 additions
and
18 deletions
common/src/userspace_comm.c
+
0
−
1
View file @
dbe6d44c
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
*
*
* This file provides the implementation of the functions declared in
* This file provides the implementation of the functions declared in
* userspace_comm.h.
* userspace_comm.h.
*
*/
*/
#include
"../include/userspace_comm.h"
#include
"../include/userspace_comm.h"
...
...
This diff is collapsed.
Click to expand it.
daemon/src/receive.c
+
0
−
1
View file @
dbe6d44c
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
*
*
* This file provides the implementation of the functions declared in
* This file provides the implementation of the functions declared in
* receive.h.
* receive.h.
*
*/
*/
#include
"../include/receive.h"
#include
"../include/receive.h"
...
...
This diff is collapsed.
Click to expand it.
daemon/src/send.c
+
0
−
1
View file @
dbe6d44c
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
*
*
* This file provides the implementation of the functions declared in
* This file provides the implementation of the functions declared in
* send.h.
* send.h.
*
*/
*/
#include
"../include/send.h"
#include
"../include/send.h"
...
...
This diff is collapsed.
Click to expand it.
kernel/kmod.c
+
21
−
15
View file @
dbe6d44c
...
@@ -146,7 +146,7 @@ static ssize_t device_write(struct file *filp, const char *input, size_t length,
...
@@ -146,7 +146,7 @@ static ssize_t device_write(struct file *filp, const char *input, size_t length,
}
}
if
(
temp_data
.
count
>=
MAX_MEASUREMENTS
)
{
if
(
temp_data
.
count
>=
MAX_MEASUREMENTS
)
{
printk
(
KERN_ALERT
"
lkm
:
T
ried to write more measurements than allowed
\n
"
);
printk
(
KERN_ALERT
"
sibyl
:
t
ried to write more measurements than allowed
\n
"
);
return
-
EFAULT
;
return
-
EFAULT
;
}
}
...
@@ -197,8 +197,6 @@ static inline void send_byte(uint8_t byte) {
...
@@ -197,8 +197,6 @@ static inline void send_byte(uint8_t byte) {
}
}
static
void
send_buffer
(
void
)
{
static
void
send_buffer
(
void
)
{
printk
(
KERN_INFO
"Send %zu bytes
\n
"
,
primary_send_buffer_size
);
unsigned
long
flags
;
unsigned
long
flags
;
local_irq_save
(
flags
);
local_irq_save
(
flags
);
...
@@ -226,7 +224,7 @@ static int timed_thread_fn(void *args) {
...
@@ -226,7 +224,7 @@ static int timed_thread_fn(void *args) {
return
0
;
return
0
;
}
}
static
int
__init
l
km_init
(
void
)
{
static
int
__init
km
od
_init
(
void
)
{
dev_t
dev
;
dev_t
dev
;
mutex_init
(
&
send_buffer_mutex
);
mutex_init
(
&
send_buffer_mutex
);
...
@@ -275,7 +273,7 @@ static int __init lkm_init(void) {
...
@@ -275,7 +273,7 @@ static int __init lkm_init(void) {
vfree
(
secondary_send_buffer
);
vfree
(
secondary_send_buffer
);
vfree
(
packet
->
data
.
measurements
);
vfree
(
packet
->
data
.
measurements
);
vfree
(
packet
);
vfree
(
packet
);
printk
(
KERN_ALERT
"
F
ailed to allocate major number
\n
"
);
printk
(
KERN_ALERT
"
sibyl: f
ailed to allocate major number
\n
"
);
return
-
1
;
return
-
1
;
}
}
major_number
=
MAJOR
(
dev
);
major_number
=
MAJOR
(
dev
);
...
@@ -287,7 +285,7 @@ static int __init lkm_init(void) {
...
@@ -287,7 +285,7 @@ static int __init lkm_init(void) {
vfree
(
packet
->
data
.
measurements
);
vfree
(
packet
->
data
.
measurements
);
vfree
(
packet
);
vfree
(
packet
);
unregister_chrdev_region
(
MKDEV
(
major_number
,
0
),
1
);
unregister_chrdev_region
(
MKDEV
(
major_number
,
0
),
1
);
printk
(
KERN_ALERT
"
F
ailed to create device class
\n
"
);
printk
(
KERN_ALERT
"
sibyl: f
ailed to create device class
\n
"
);
return
PTR_ERR
(
class
);
return
PTR_ERR
(
class
);
}
}
...
@@ -299,7 +297,7 @@ static int __init lkm_init(void) {
...
@@ -299,7 +297,7 @@ static int __init lkm_init(void) {
vfree
(
packet
);
vfree
(
packet
);
class_destroy
(
class
);
class_destroy
(
class
);
unregister_chrdev_region
(
MKDEV
(
major_number
,
0
),
1
);
unregister_chrdev_region
(
MKDEV
(
major_number
,
0
),
1
);
printk
(
KERN_ALERT
"
F
ailed to create device
\n
"
);
printk
(
KERN_ALERT
"
sibyl: f
ailed to create device
\n
"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -312,11 +310,11 @@ static int __init lkm_init(void) {
...
@@ -312,11 +310,11 @@ static int __init lkm_init(void) {
device_destroy
(
class
,
MKDEV
(
major_number
,
0
));
device_destroy
(
class
,
MKDEV
(
major_number
,
0
));
class_destroy
(
class
);
class_destroy
(
class
);
unregister_chrdev_region
(
MKDEV
(
major_number
,
0
),
1
);
unregister_chrdev_region
(
MKDEV
(
major_number
,
0
),
1
);
printk
(
KERN_ALERT
"
F
ailed to add character device
\n
"
);
printk
(
KERN_ALERT
"
sibyl: f
ailed to add character device
\n
"
);
return
-
1
;
return
-
1
;
}
}
printk
(
KERN_INFO
"
lkm
: device created successfully
\n
"
);
printk
(
KERN_INFO
"
sibyl
: device created successfully
\n
"
);
if
(
gpio_request
(
GPIO_PIN
,
"GPIO_PIN"
)
<
0
)
{
if
(
gpio_request
(
GPIO_PIN
,
"GPIO_PIN"
)
<
0
)
{
vfree
(
primary_send_buffer
);
vfree
(
primary_send_buffer
);
...
@@ -327,7 +325,7 @@ static int __init lkm_init(void) {
...
@@ -327,7 +325,7 @@ static int __init lkm_init(void) {
device_destroy
(
class
,
MKDEV
(
major_number
,
0
));
device_destroy
(
class
,
MKDEV
(
major_number
,
0
));
class_destroy
(
class
);
class_destroy
(
class
);
unregister_chrdev_region
(
MKDEV
(
major_number
,
0
),
1
);
unregister_chrdev_region
(
MKDEV
(
major_number
,
0
),
1
);
printk
(
KERN_ALERT
"
F
ailed to request GPIO pin
\n
"
);
printk
(
KERN_ALERT
"
sibyl: f
ailed to request GPIO pin
\n
"
);
return
-
1
;
return
-
1
;
}
}
gpio_direction_output
(
GPIO_PIN
,
1
);
gpio_direction_output
(
GPIO_PIN
,
1
);
...
@@ -342,25 +340,33 @@ static int __init lkm_init(void) {
...
@@ -342,25 +340,33 @@ static int __init lkm_init(void) {
device_destroy
(
class
,
MKDEV
(
major_number
,
0
));
device_destroy
(
class
,
MKDEV
(
major_number
,
0
));
class_destroy
(
class
);
class_destroy
(
class
);
unregister_chrdev_region
(
MKDEV
(
major_number
,
0
),
1
);
unregister_chrdev_region
(
MKDEV
(
major_number
,
0
),
1
);
printk
(
KERN_ALERT
"
F
ailed to create timed thread
\n
"
);
printk
(
KERN_ALERT
"
sibyl: f
ailed to create timed thread
\n
"
);
return
-
1
;
return
-
1
;
}
}
printk
(
KERN_INFO
"sibyl: timed thread started successfully
\n
"
);
interval
=
ktime_set
(
0
,
SLOT_INTERVAL_NS
);
interval
=
ktime_set
(
0
,
SLOT_INTERVAL_NS
);
hrtimer_init
(
&
timer
,
CLOCK_MONOTONIC
,
HRTIMER_MODE_REL
);
hrtimer_init
(
&
timer
,
CLOCK_MONOTONIC
,
HRTIMER_MODE_REL
);
timer
.
function
=
timer_callback
;
timer
.
function
=
timer_callback
;
hrtimer_start
(
&
timer
,
interval
,
HRTIMER_MODE_REL
);
hrtimer_start
(
&
timer
,
interval
,
HRTIMER_MODE_REL
);
printk
(
KERN_INFO
"sibyl: hrtimer started successfully
\n
"
);
return
0
;
return
0
;
}
}
static
void
__exit
l
km_exit
(
void
)
{
static
void
__exit
km
od
_exit
(
void
)
{
if
(
timed_thread
)
{
if
(
timed_thread
)
{
kthread_stop
(
timed_thread
);
kthread_stop
(
timed_thread
);
}
}
printk
(
KERN_INFO
"sibyl: timed thread stopped successfully
\n
"
);
hrtimer_cancel
(
&
timer
);
hrtimer_cancel
(
&
timer
);
printk
(
KERN_INFO
"sibyl: hrtimer cancelled successfully
\n
"
);
mutex_destroy
(
&
send_buffer_mutex
);
mutex_destroy
(
&
send_buffer_mutex
);
vfree
(
primary_send_buffer
);
vfree
(
primary_send_buffer
);
...
@@ -371,13 +377,13 @@ static void __exit lkm_exit(void) {
...
@@ -371,13 +377,13 @@ static void __exit lkm_exit(void) {
device_destroy
(
class
,
MKDEV
(
major_number
,
0
));
device_destroy
(
class
,
MKDEV
(
major_number
,
0
));
class_destroy
(
class
);
class_destroy
(
class
);
unregister_chrdev_region
(
MKDEV
(
major_number
,
0
),
1
);
unregister_chrdev_region
(
MKDEV
(
major_number
,
0
),
1
);
printk
(
KERN_INFO
"
lkm
: device removed successfully
\n
"
);
printk
(
KERN_INFO
"
sibyl
: device removed successfully
\n
"
);
gpio_set_value
(
GPIO_PIN
,
0
);
gpio_set_value
(
GPIO_PIN
,
0
);
gpio_free
(
GPIO_PIN
);
gpio_free
(
GPIO_PIN
);
}
}
module_init
(
l
km_init
);
module_init
(
km
od
_init
);
module_exit
(
l
km_exit
);
module_exit
(
km
od
_exit
);
MODULE_LICENSE
(
"GPL"
);
MODULE_LICENSE
(
"GPL"
);
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