Compiling custom kmod package

Hi all,
I downloaded lede source , and managed to compile the source and generate an image for bcm63xx, the wifi hardware is pci bcm43xx , and I'm using brcmsmac driver , while b43 driver allows selection of ch 12,ch13, brcmsmac didn't , so I modified the source of brcmsmac and succeeded in making it select the channels, that worked by moving brcmsmac.ko to the target router, however when I build the Image from source it always replaces my modified version with the original one , so rootfs always contain the original version , how can I configure lede source to recompile kmod-brcmsmac from my modified source? It seems the build system is always downloading the original version from the internet.
Any help is appreciated.

What country are you in? Yes, it matters.

Simply editing the source files in build_dir will not be permanent. You need to commit your changes to patches which will be stored in the package make directory.

The process is described here. https://wiki.openwrt.org/doc/devel/patches

Jeff, I'm in Jordan , country code is JO , these channels are allowed in my country , this is an adsl router , and in the original firmware when I select jordan these channels become available, also on b43 driver , and on rt2800usb , selecting correct country makes these channels available.

Mk24, thank you I will try making a patch and see what happens.

Mk24,could you please give a more detailed approach? I want the package to be built-in in the image , not seperate , I tried make package/kernel/linux/ prepare (since the module is in kernel package) , but I don't know where to put the patch since there's no brcmsmac in package directory , any help is appreciated.

Thanks, that was the crux of the question. Patches are the way to go. https://openwrt.org/docs/guide-developer/build-system/use-patches-with-buildsystem should help you on your way.

Possibly:

target/linux/brcm63xx/patches-4.x

depending on your kernel choice.

Things are getting complicated , I tried many approaches with no success , I guess because the driver doesn't belong to the kernel natively but rather under compat-wireless , I managed to add my patch to package/kernel/mac80211 (there's another patch there that modifies the same file), patch applies and compiles successfully , but still the output package contains the original kernel module !

Final conclusion , when I searched for brcmsmac.mod (which indicates the module build dir) , it was exactly in modified source dir, so the original brcmsmac.ko is not being built at all, it's extracted from some package and placed in the final kmod package, no matter what patches I add , does anyone know where's the file that does this process? I.e. putting the brcmsmac.ko file into :

build_dir/target-mips_mips32_musl-1.1.16/linux-brcm63xx_generic/compat-wireless-2017-01-31/ipkg-mips_mips32/kmod-brcmsmac/lib/modules/4.4.92/brcmsmac.ko