Linux Kernel
1. `struct bus_type`
2. `struct device_driver`
3. `struct device`
usb_add_hcd
builtin_platform_driver(dw_plat_pcie_driver);
usb_register()
: register the driver structurestruct usb_driver
: hooking function device_driver
struct usb_device_id
: register supported devicesstruct usb_driver
structure of this driver.driver_register
: register driver with busdriver_find
: locate driver on a bus by its name.bus_add_driver
: Add a driver to the busdriver_add_groups
: Add sysfs file for driversudo apt-get install dtc
dtc -I dtb -o dts user-bbb.dtb>user-bbb.dts
static const struct i2c_device_id mma7660_i2c_id[] = {
{"mma7660", 0},
{}
};
MODULE_DEVICE_TABLE(i2c, mma7660_i2c_id);
static const struct of_device_id mma7660_of_match[] = {
{ .compatible = "fsl,mma7660" },
{ }
};
MODULE_DEVICE_TABLE(of, mma7660_of_match);
static const struct acpi_device_id mma7660_acpi_id[] = {
{"MMA7660", 0},
{}
};
mma7660_probe
: Register to bus framework.mma7660_remove
: Unregister from bus frameworkstatic struct i2c_driver mma7660_driver = {
.driver = {
.name = "mma7660",
.pm = MMA7660_PM_OPS,
.of_match_table = mma7660_of_match,
.acpi_match_table = ACPI_PTR(mma7660_acpi_id),
},
.probe = mma7660_probe,
.remove = mma7660_remove,
.id_table = mma7660_i2c_id,
};
module_i2c_driver(mma7660_driver);
Documentation/kbuild/modules.rst
Documentation/kbuild/makefiles.rst
.obj-m := <module_name>.o
Result in the kernel module <module_name>.ko
When the module is built from multiple sources, an additional line is
needed listing the files:
<module_name>-y := <src1>.o <src2>.o ...
or
<module_name>-objs := ./<src1>.o \
./<src1>.o
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Syncing