mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
Remove runqemu from build... document platform_device.c a bit further, add a modprobe.conf test
This commit is contained in:
@@ -19,6 +19,14 @@ Those parameters can also be read and modified at runtime from /sys.
|
|||||||
modinfo
|
modinfo
|
||||||
/params.ko
|
/params.ko
|
||||||
# Output contains MODULE_PARAM_DESC descriptions.
|
# Output contains MODULE_PARAM_DESC descriptions.
|
||||||
|
|
||||||
|
modprobe insertion can also set default parameters via the /etc/modprobe.conf file. So:
|
||||||
|
|
||||||
|
modprobe params
|
||||||
|
|
||||||
|
Outputs:
|
||||||
|
|
||||||
|
12 34
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/delay.h> /* usleep_range */
|
#include <linux/delay.h> /* usleep_range */
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
Only works for ARM.
|
Only works for ARM.
|
||||||
|
|
||||||
Uses the hw/misc/lkmc_platform_device.c minimal device added in our QEMU fork.
|
Uses:
|
||||||
|
|
||||||
|
- hw/misc/lkmc_platform_device.c minimal device added in our QEMU fork
|
||||||
|
|
||||||
|
- the device tree entry we added to our Linux kernel fork:
|
||||||
|
https://github.com/cirosantilli/linux/blob/361bb623671a52a36a077a6dd45843389a687a33/arch/arm/boot/dts/versatile-pb.dts#L42
|
||||||
|
|
||||||
See: https://stackoverflow.com/questions/28315265/how-to-add-a-new-device-in-qemu-source-code/44612957#44612957
|
See: https://stackoverflow.com/questions/28315265/how-to-add-a-new-device-in-qemu-source-code/44612957#44612957
|
||||||
|
|
||||||
@@ -49,7 +54,7 @@ static int lkmc_platform_device_probe(struct platform_device *pdev)
|
|||||||
|
|
||||||
dev_info(dev, "probe\n");
|
dev_info(dev, "probe\n");
|
||||||
|
|
||||||
/* Play with our custom poperty. */
|
/* Play with our custom device tree poperty. */
|
||||||
if (of_property_read_u32(np, "lkmc-asdf", &asdf) ) {
|
if (of_property_read_u32(np, "lkmc-asdf", &asdf) ) {
|
||||||
dev_err(dev, "of_property_read_u32\n");
|
dev_err(dev, "of_property_read_u32\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@@ -100,6 +105,8 @@ static int lkmc_platform_device_remove(struct platform_device *pdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const struct of_device_id of_lkmc_platform_device_match[] = {
|
static const struct of_device_id of_lkmc_platform_device_match[] = {
|
||||||
|
/* This tells our driver which device tree node it will use.
|
||||||
|
* It matches the kmc_platform_device@XXXX entry that we added to the device tree. */
|
||||||
{ .compatible = "lkmc_platform_device", },
|
{ .compatible = "lkmc_platform_device", },
|
||||||
{},
|
{},
|
||||||
};
|
};
|
||||||
|
|||||||
4
rootfs_overlay/etc/modprobe.conf
Normal file
4
rootfs_overlay/etc/modprobe.conf
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# Default parameters when loading modules.
|
||||||
|
# Especially important due to loading module dependencies:
|
||||||
|
# how else would you specify their parameters?
|
||||||
|
options params i=12 j=34
|
||||||
Reference in New Issue
Block a user