Linux Kernel Development Diary 6
In this diary, I will describe the selection of the file Kim Kakeya and I altered and modifications untill the LGTM.
There were 3 versions of the patch.
Task and File Selection
FLUSP has given us some suggestions on relevant tasks that we could do. We chose to implement chages on mutex handling, using mutex guard() instead of lock and unlock.
Using ripgrep, we searched for the
1
2
3
4
mutex_lock(&lock);
...
goto out;
...
block logic inside some directories.
At first, we had chosen a file under the sound subsystem, but changed to a file under the IIO right after to keep our contributions aligned to the knowledged gathered by FLUSP on this subsystem.
More specifically, we chose the drivers/iio/light/vcnl4000.c file.
First Version
On the patch, we simply changed the mutex_lock and mutex_unlock by guard and kept the whole ret attribution consistent with the precious code.
At first, it seemed reasonable matching what we observed on the patch submition guidelines, but we got a feedback from Andy. He asked us to do direct returns on non-error logic.
All the changed were made on 4 functions inside the file.
Second Version
As asked by Andy, we turned
1
2
ret = func(...);
return ret;
into
1
return func(...);
and removed some unncessary breaks in the swtich-case logic.
I have ran into some difficulties in understanding how to submit the second version using KW, but it worked well adding -v 2 to the command and inserting commentaries on the message.
While trying to understand how to send the v2, I sent a unfinished patch to the CI and ran into a error I was already assessing (an unitialized variable). Fortunately, the final version of v2 compiled without errors.
Third Version
This one got the LGTM from Andy.
There was a problem on the second version on the indentation of function arguments after changing ret = func(...) for return func(...). After squeezing all arguments in a single line, Andy gave me the LGTM and suggested a little change on bitfield manipulation.