How to revise an exsiting kernel package?

I want to make some revisions to the code of package/kernel/mac80211.
I am new to OpenWrt and after some research, I think I should change the PKG_SOURCE_URL to my own GitHub repository, which is my own copy of /linux/kernel/projects/backports/stable/v4.19.120.
So I change package/kernel/mac80211/Makefile like following:

PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/sheep94lion/openwrt.git
PKG_SOURCE_VERSION:=168bae33318ebd14d8c035b543a2583ea31f9f52
PKG_MIRROR_HASH:=skip

# PKG_SOURCE_URL:=@KERNEL/linux/kernel/projects/backports/stable/v4.19.120/
# PKG_HASH:=2bafd75da301a30a5f2b98f433b6545d7b58c1fc3af15e9e9aa085df7f9db1d4

My question is: am I in the right direction? What is the right/proper way to revise an existing kernel package?

You could add your own patches locally, using something like this:
https://openwrt.org/docs/guide-developer/build-system/use-patches-with-buildsystem

So, for this package:

make package/kernel/mac80211/update V=s QUILT=1
## See the verbose output from above, to find where this got unpacked
cd build_dir/target-<target>/linux-<foo>/backports-<ver>/
quilt push -a
## Start working on a new patch
quilt new build/my-modifications.patch
quilt add <file(s) you want to modify>
... perform edits ...
quilt refresh
## Move back to $(TOPDIR)
cd -
## Move your patch into the buildroot
make package/kernel/mac80211/update V=s
## New patch at: package/kernel/mac80211/patches/build/my-modifications.patch

I'm a bit new at this, so I might be missing some details. When in doubt, trust the documentation over me!

Thanks!
I think using patch is the right way when I finish the development and want to release the revised code. But it seems not very convenient during development since I will make revisions frequently.

At present, I copy the source files to package/kernel/mac80211/src directory (create the directory first), and then revise Makefile to use local source files instead of downloading and unpack from the official uri.

The revisions in Makefile is as following:

# comment out the configurations to download the tarbar.
# PKG_SOURCE_URL:=@KERNEL/linux/kernel/projects/backports/stable/v4.19.120/
# PKG_HASH:=2bafd75da301a30a5f2b98f433b6545d7b58c1fc3af15e9e9aa085df7f9db1d4

# PKG_SOURCE:=backports-$(PKG_VERSION).tar.xz

......

define Build/Prepare
	rm -rf $(PKG_BUILD_DIR)
	mkdir -p $(PKG_BUILD_DIR)
    # do not unpack the downloaded tarbar.
	# $(PKG_UNPACK)
    # instead, copy files under src to the build directory.
	$(CP) ./src/* $(PKG_BUILD_DIR)/
	$(Build/Patch)

When I want to release the code, I think I should use the patch method you posted.

1 Like