How to compile linux kernel with some patches?

Unfortunately, my nettop candidate (Beelink Mini S12 Pro) for CNC mill has a problem with Wi-Fi on Debian 12. This is common for intel PC and there is a wide range of solutions in the Internet. For my particular case there is a good kernel patch on AskUbuntu. Also, there are more details for those who want to understand the topic deeper.

If in short, here is the patch:

--- a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c       2023-04-04 10:22:33.957021791 +0800
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c       2023-04-04 11:51:37.377716152 +0800
@@ -1091,7 +1091,7 @@
        _IWL_DEV_INFO(IWL_CFG_ANY, IWL_CFG_ANY,
                      IWL_CFG_MAC_TYPE_SO, IWL_CFG_ANY,
                      IWL_CFG_RF_TYPE_HR1, IWL_CFG_ANY,
-                     IWL_CFG_160, IWL_CFG_ANY, IWL_CFG_NO_CDB, IWL_CFG_ANY,
+                     IWL_CFG_ANY, IWL_CFG_ANY, IWL_CFG_NO_CDB, IWL_CFG_ANY,
                      iwl_cfg_so_a0_hr_a0, iwl_ax101_name),
        _IWL_DEV_INFO(IWL_CFG_ANY, IWL_CFG_ANY,
                      IWL_CFG_MAC_TYPE_SO, IWL_CFG_ANY,
@@ -1108,7 +1108,7 @@
        _IWL_DEV_INFO(IWL_CFG_ANY, IWL_CFG_ANY,
                      IWL_CFG_MAC_TYPE_SOF, IWL_CFG_ANY,
                      IWL_CFG_RF_TYPE_HR1, IWL_CFG_ANY,
-                     IWL_CFG_160, IWL_CFG_ANY, IWL_CFG_NO_CDB, IWL_CFG_ANY,
+                     IWL_CFG_ANY, IWL_CFG_ANY, IWL_CFG_NO_CDB, IWL_CFG_ANY,
                      iwl_cfg_so_a0_hr_a0, iwl_ax101_name),
        _IWL_DEV_INFO(IWL_CFG_ANY, IWL_CFG_ANY,
                      IWL_CFG_MAC_TYPE_SOF, IWL_CFG_ANY,

Of course, this is not for Debian 12 and not for me current version of kernel which is 6.1.146. Therefore, need to apply al that changes manually. But where to find a kernel?

Debian has its own patches over a vanilla linux kernel. But I don’t want to understand all that nuances right now! Therefore, was found an excellent manual about compiling kernel for LinuxCNC.

This is easy:

In case of any errors - ask Google, AI or any other assistance on your choice.

Advanced tweaks

To speed up the compilation process you can disable debug info by CONFIG_DEBUG_INFO=n. Main problem - this leads to a compilation error in a very end of the process. Theoretically, BTF disabling should solve the problem. See corresponding thread for details.