ba717131952f892d88459a265915563796683347 — Bryan Brattlof 3 years ago cecd3fa
task 4: add task readme
3 files changed, 78 insertions(+), 0 deletions(-)

M readme.rst
A tasks/04/coding_style.c
A tasks/04/readme
M readme.rst => readme.rst +2 -0
@@ 18,3 18,5 @@ Here are the links to each task's readme:
2. Building a Custom Kernel: `task <https://git.bryanbrattlof.com/eudyptula-challenge/tree/tasks/02/readme>`__

3. Modify our Custom Kernel: `task <https://git.bryanbrattlof.com/eudyptula-challenge/tree/tasks/03/readme>`__

4. The Coding Style Rules: `task <https://git.bryanbrattlof.com/eudyptula-challenge/tree/tasks/04/readme>`__

A tasks/04/coding_style.c => tasks/04/coding_style.c +35 -0
@@ 0,0 1,35 @@
#include <linux/delay.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
int do_work(int *my_int, int retval)
	int x;
	int y = *my_int;
	int z;

	for(x = 0 ; x < *my_int ; ++x)
	if (y < 10)
		/* That was a long sleep, tell userspace about it. */
		pr_debug("We slept a long time!");
	z = x * y;

	return z;

int my_init(void)
	int x = 10;

	x = do_work(&x, x);

	return x;

void my_exit(void)


A tasks/04/readme => tasks/04/readme +41 -0
@@ 0,0 1,41 @@
Task 04

Wonderful job in making it this far, I hope you have been having fun.
Oh, you're getting bored, just booting and installing kernels?  Well,
time for some pedantic things to make you feel that those kernel builds
are actually fun!

Part of the job of being a kernel developer is recognizing the proper
Linux kernel coding style.  The full description of this coding style
can be found in the kernel itself, in the Documentation/CodingStyle
file.  I'd recommend going and reading that right now, it's pretty
simple stuff, and something that you are going to need to know and
understand.  There is also a tool in the kernel source tree in the
scripts/ directory called checkpatch.pl that can be used to test for
adhering to the coding style rules, as kernel programmers are lazy and
prefer to let scripts do their work for them...

And why a coding standard at all?  That's because of your brain (yes,
yours, not mine, remember, I'm just some dumb shell scripts).  Once your
brain learns the patterns, the information contained really starts to
sink in better.  So it's important that everyone follow the same
standard so that the patterns become consistent.  In other words, you
want to make it really easy for other people to find the bugs in your
code, and not be confused and distracted by the fact that you happen to
prefer 5 spaces instead of tabs for indentation.  Of course you would
never prefer such a thing, I'd never accuse you of that, it was just an
example, please forgive my impertinence!

Anyway, the tasks for this round all deal with the Linux kernel coding
style.  Attached to this message are two kernel modules that do not
follow the proper Linux kernel coding style rules.  Please fix both of
them up, and send it back to me in such a way that does follow the

What, you recognize one of these modules?  Imagine that, perhaps I was
right to accuse you of the using a "wrong" coding style :)

Yes, the logic in the second module is crazy, and probably wrong, but
don't focus on that, just look at the patterns here, and fix up the
coding style, do not remove lines of code.
\ No newline at end of file