All of lore.kernel.org
 help / color / mirror / Atom feed
* API between modules
@ 2023-05-18  7:16 Lucas Tanure
  2023-05-18 10:33 ` Greg KH
  2023-05-19  6:30 ` Prathu Baronia
  0 siblings, 2 replies; 4+ messages in thread
From: Lucas Tanure @ 2023-05-18  7:16 UTC (permalink / raw)
  To: kernelnewbies

Hi,

I have two kernel modules that need to talk over an API, and right
now, they are statically linked together, but I am looking for a
better way to separate them and share an API between them.

A few years ago, I did the HDA component:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/sound/pci/hda/hda_component.h

Using the component API:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/include/linux/component.h

Are there other ways for a module to wait for another module to load
and use its API?
Is there a default way to do that?

I know that with MFD devices, you can have children, but that's not
the case. My modules are not related in that way.

Thanks
Lucas

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: API between modules
  2023-05-18  7:16 API between modules Lucas Tanure
@ 2023-05-18 10:33 ` Greg KH
  2023-05-19  6:30 ` Prathu Baronia
  1 sibling, 0 replies; 4+ messages in thread
From: Greg KH @ 2023-05-18 10:33 UTC (permalink / raw)
  To: Lucas Tanure; +Cc: kernelnewbies

On Thu, May 18, 2023 at 08:16:18AM +0100, Lucas Tanure wrote:
> Hi,
> 
> I have two kernel modules that need to talk over an API, and right
> now, they are statically linked together, but I am looking for a
> better way to separate them and share an API between them.
> 
> A few years ago, I did the HDA component:
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/sound/pci/hda/hda_component.h
> 
> Using the component API:
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/include/linux/component.h
> 
> Are there other ways for a module to wait for another module to load
> and use its API?
> Is there a default way to do that?

Yes, just call a function in that other module and it will be loaded
properly before your module can call it.  That's how all in-kernel apis
work.

thanks,

greg k-h

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: API between modules
  2023-05-18  7:16 API between modules Lucas Tanure
  2023-05-18 10:33 ` Greg KH
@ 2023-05-19  6:30 ` Prathu Baronia
  2023-05-27  7:19   ` Release of my Kernel Development Tool Lucas Tanure
  1 sibling, 1 reply; 4+ messages in thread
From: Prathu Baronia @ 2023-05-19  6:30 UTC (permalink / raw)
  To: Lucas Tanure; +Cc: kernelnewbies

On Thu, May 18, 2023 at 08:16:18AM +0100, Lucas Tanure wrote:
> Are there other ways for a module to wait for another module to load
> and use its API?
> Is there a default way to do that?
Hi Lucas,
IIUC you can use MODULE_SOFTDEP macro to establish loading dependencies.
This stack overflow explains it:-
https://stackoverflow.com/questions/29717761/how-do-i-define-dependency-among-kernel-modules

Prathu

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Release of my Kernel Development Tool
  2023-05-19  6:30 ` Prathu Baronia
@ 2023-05-27  7:19   ` Lucas Tanure
  0 siblings, 0 replies; 4+ messages in thread
From: Lucas Tanure @ 2023-05-27  7:19 UTC (permalink / raw)
  To: kernelnewbies

Hi,

I have been working with Kernel development and single-board computers
for a few years now, and to help me with my development, I created
this tool:

https://github.com/lucastanure/kernel_dev_tools  (GPLv2)

It helps me to build and test the kernel in a faster and easy way. But
it also helps me to switch between boards (Rpi4, Vim4, Vim3, rk399) in
a reliable way.
The aim of this tool is to centralize the configuration of a
particular board (cross-compiler, kernel configuration, make targets,
etc.) in a config file and expose a simple workflow.
Example:

I have my VIM4 board configuration:
[vim4_arm64]
cc                      = aarch64-none-linux-gnu-
cc_path             =
~/.local/bin/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin
kernel_target     = Image
kernel_file          = Image-devel
dtb_path            = dtbs_devel
config_file          = $kdt_boards/vim4_arm64_defconfig
ramfs_file           = initramfs-linux-devel.img
update_ramfs    = mkinitcpio -k $version -g $ramfs_file
on                       = kasa --alias Strip_9BA6 --type strip on --name P2
off                       = kasa --alias Strip_9BA6 --type strip off --name P2

And my workflow to develop the kernel is as follows:
$ export board=vim4
# Do some kernel changes
$ kb config        # Configures the kernel
$ kb build          # Builds the kernel
$ kb scp vim4   # Copy the kernel, modules and device trees to my VIM4
board using rsync and scp
# Reboot the board using ssh or issue:
$ kb off ; sleep 2 ; kb on    # Power cycle the board if reboot by ssh
is not available

This tool has many more features, like updating kernels in image files
and removing Gerrit "Change-id" from patch files.
In the near future, I will add the following:
- Check a series of patches before upstreaming. Build the kernel with
every patch in a patch series and check for building warnings,
checkpatch, sparse, etc.
- Device tree tool to help to upstream new boards to the kernel
mainline. Like, find device nodes from a device tree that don't have a
driver for it and list Kernel configs needed by the device tree.

Happy coding

Thanks
Lucas

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-05-27  7:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-18  7:16 API between modules Lucas Tanure
2023-05-18 10:33 ` Greg KH
2023-05-19  6:30 ` Prathu Baronia
2023-05-27  7:19   ` Release of my Kernel Development Tool Lucas Tanure

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.