I am trying to write a new linux net module where I am adding my own match extension. Although the code exists for implementing my idea, I am having difficulty in understanding the code in many places

1. In files such as xt_*.c, we have a call to
xt_register_matches(struct xt_match *match, unsigned int n) function in x_tables.c

for (i = 0; i < n; i++) {
err = xt_register_match(&match[i]);
if (err)
goto err;

method is defined where inside xt_register_match(struct xt_match * match) function is called. In this function there is something done with the semaphore. Can you please explain what is going on in this register_module? I am not able to understand the code as I am looping around a particular function and I forget from where I started.