Part of making an upstream patch involves collapsing those ifdefs to match the current kernel version. That by itself should considerably simplify that function. - Jonathan Morton