aboutsummaryrefslogtreecommitdiff
path: root/sem3/osc/mm1
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2020-10-12 16:26:42 +0200
committerJulian T <julian@jtle.dk>2020-10-12 16:54:48 +0200
commit4e05a55e373bd315e721d534a1711fec4c0054c5 (patch)
tree4fc0141760c2730ed79aaa4c7aa60ea45cc66cc0 /sem3/osc/mm1
parentb7f9cf43c8a9ab3400cbb30d5e1cadb0c6c2cf23 (diff)
Moved to linux kernel inspired clang-format
Diffstat (limited to 'sem3/osc/mm1')
-rw-r--r--sem3/osc/mm1/mm1/jmod.c77
-rw-r--r--sem3/osc/mm1/mm2/tprog.c28
2 files changed, 50 insertions, 55 deletions
diff --git a/sem3/osc/mm1/mm1/jmod.c b/sem3/osc/mm1/mm1/jmod.c
index 472ad46..05eb7c1 100644
--- a/sem3/osc/mm1/mm1/jmod.c
+++ b/sem3/osc/mm1/mm1/jmod.c
@@ -7,67 +7,62 @@
static int major_num;
static int busy;
-
static int cool_open(struct inode *inode, struct file *file)
{
- /* Check if we are already serving someone */
- if (busy) {
- return -EBUSY;
- }
+ /* Check if we are already serving someone */
+ if (busy) {
+ return -EBUSY;
+ }
- busy = 1;
- return 0;
+ busy = 1;
+ return 0;
}
-static int cool_release (struct inode *inode, struct file *file)
+static int cool_release(struct inode *inode, struct file *file)
{
- busy = 0;
+ busy = 0;
- return 0;
+ return 0;
}
-static ssize_t cool_read (struct file *filp, char *buffer, size_t len, loff_t *offset)
+static ssize_t cool_read(struct file *filp, char *buffer, size_t len,
+ loff_t *offset)
{
+ char str[12] = "hej med dig";
+ int i;
- char str[12] = "hej med dig";
- int i;
-
- for (i = 0; i < len; i++) {
- put_user(str[i % 12], buffer++);
- }
+ for (i = 0; i < len; i++) {
+ put_user(str[i % 12], buffer++);
+ }
- return i;
+ return i;
}
-static struct file_operations file_ops = {
- .owner = THIS_MODULE,
- .read = cool_read,
- .open = cool_open,
- .release = cool_release
-};
+static struct file_operations file_ops = { .owner = THIS_MODULE,
+ .read = cool_read,
+ .open = cool_open,
+ .release = cool_release };
-static int __init jmod_init(void)
+static int __init jmod_init(void)
{
- printk(KERN_INFO "COOL_MODULE: Registering cooldev\n");
-
- major_num = register_chrdev(0, "cooldev", &file_ops);
- if (major_num < 0) {
- printk(KERN_ERR "COOL_MODULE: Could not register major\n");
- return 1;
- }
+ printk(KERN_INFO "COOL_MODULE: Registering cooldev\n");
- printk(KERN_INFO "COOL_MODULE: Got major %d\n", major_num);
+ major_num = register_chrdev(0, "cooldev", &file_ops);
+ if (major_num < 0) {
+ printk(KERN_ERR "COOL_MODULE: Could not register major\n");
+ return 1;
+ }
- return 0;
-}
+ printk(KERN_INFO "COOL_MODULE: Got major %d\n", major_num);
+ return 0;
+}
-static void __exit jmod_exit(void)
+static void __exit jmod_exit(void)
{
- printk(KERN_INFO "COOL_MODULE: Nou moe\n");
- unregister_chrdev(major_num, "cooldev");
+ printk(KERN_INFO "COOL_MODULE: Nou moe\n");
+ unregister_chrdev(major_num, "cooldev");
}
-module_init( jmod_init );
-module_exit( jmod_exit );
-
+module_init(jmod_init);
+module_exit(jmod_exit);
diff --git a/sem3/osc/mm1/mm2/tprog.c b/sem3/osc/mm1/mm2/tprog.c
index bb04778..82c9fb2 100644
--- a/sem3/osc/mm1/mm2/tprog.c
+++ b/sem3/osc/mm1/mm2/tprog.c
@@ -19,26 +19,26 @@ void timer_handler(int signum)
/* Calculate new alarm */
tv->tv_sec *= SPEED;
if (tv->tv_sec == 0) {
- /* If tv_usec is 0 set i to 1 sec otherwise half it */
- if (tv->tv_usec == 0) {
- tv->tv_usec = 999999;
- } else if (tv->tv_usec > ENDUSEC) {
- tv->tv_usec *= SPEED;
- if (tv->tv_usec < ENDUSEC) {
- tv->tv_usec = ENDUSEC;
- }
- } else {
- /* Return letting the timer be set to ENDUSEC */
- return;
- }
+ /* If tv_usec is 0 set i to 1 sec otherwise half it */
+ if (tv->tv_usec == 0) {
+ tv->tv_usec = 999999;
+ } else if (tv->tv_usec > ENDUSEC) {
+ tv->tv_usec *= SPEED;
+ if (tv->tv_usec < ENDUSEC) {
+ tv->tv_usec = ENDUSEC;
+ }
+ } else {
+ /* Return letting the timer be set to ENDUSEC */
+ return;
+ }
}
printf("Set to %d and %d\n", timer.it_value.tv_sec, timer.it_value.tv_usec);
/* Set alarm */
int err = setitimer(ITIMER_REAL, &timer, NULL);
if (err) {
- printf("Hey we got an error guys\n");
- exit(1);
+ printf("Hey we got an error guys\n");
+ exit(1);
}
}