Linux kernel coding style
Link: https://www.kernel.org/doc/html/latest/process/coding-style.html#
Use proper multi-line comments as per the Coding Style.
Link: https://lkml.org/lkml/2018/7/4/318
I2C ID tables are non-mandatory for DT'ed devices
See da10c06a044b ("i2c: Make I2C ID tables non-mandatory for DT'ed devices")
The following code shouldn't be needed anymore for DT-only devices.
+static const struct i2c_device_id bd71837_i2c_id[] = {
+ { .name = "bd71837", },
+ { }
+};
+MODULE_DEVICE_TABLE(i2c, bd71837_i2c_id);
Trailing comma is preferred on structures/arrays arrays with simple items and without sentinels
If one needs to add a new entry/new member, then in the diff there will have only one new line added, instead of one line being changed (adding now necessary comma) and one added.
Link: https://lkml.org/lkml/2018/7/4/685
Examples:
+static struct cros_ec_sensor_platform sensor_platforms[] = {
+ { .sensor_num = 0 },
+ { .sensor_num = 1 },
+};
+static struct mfd_cell bd71837_mfd_cells[] = {
+ {
+ .name = "bd718xx-pwrkey",
+ .resources = &irqs[0],
+ .num_resources = ARRAY_SIZE(irqs),
+ },
+ { .name = "bd71837-pmic" },
+ { .name = "bd71837-clk" },
+};
No trailing comma for sentinel on structure/arrays
The sentinel indicates the last item on structure/arrays so no need to add a comma at the end.
Link: https://lkml.org/lkml/2018/7/4/685
Examples:
+static const struct i2c_device_id tps65217_id_table[] = {
+ {"tps65217", TPS65217},
+ { }
+};
Clarify SPDX license with GPL-2.0-only
Remove the ambiguity with GPL-2.0 and use an explicit GPL-2.0-only tag
Remove printk's for [kv][mz]alloc failures
When a memory allocation fails, the kernel will print out a backtrace automatically. Print statements are unnecessary.
Remove redundant func in dev_dbg()
Dynamic debug has a run time knob to enable function name printing. Remove this from dev_dbg() calls.
Remove duplicate messaging in probe and remove
The ->probe() and ->remove() stages can be easily debugged with initcall_debug or function tracer. There is no need to repeat the same explicitly in the driver.
Remove debug messages for function calls
Equivalent information can be nowadays obtained using function tracer.
Be quiet and do not spit out messages unnecessarily
When drivers are working, they should not spit out any messages, make dev_info() calls, dev_dbg() at the most.
No need to be so many lines.
+static struct cros_ec_sensor_platform sensor_platforms[] = {
+ {
+ .sensor_num = 0,
+ },
+ {
+ .sensor_num = 1,
+ }
+};
Each one of these entries can be placed on a single line.
+ { .sensor_num = 0 },
+ { .sensor_num = 1 }
Please don't use multiple blank lines
Nitpick: "something == NULL" is better written as "!something".
Link: https://lkml.org/lkml/2018/7/4/318
Note: That's not the preferred way on other subsystems, also checkpatch --strict will complain about it.
Before submitting bindings please run
make dt_binding_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/x.yaml
make dtbs_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/x.yaml
Node names are supposed to match the class of the device instead of the name of the device
+ battery: sbs-battery@b {
>
>This should be "battery@b {", since node names are supposed to
>match the class of the device instead of the name of the device.
Remove the unit address from the DT node
- usbc_extcon1: extcon@1 {
+ usbc_extcon1: extcon1 {
compatible = "google,extcon-usbc-cros-ec";
google,usb-port-id = <1>;
Make sure your dt-scheam is up to date
Before run 'make dt_binding_check' make sure dt-schema is up to date:
pip3 install git+https://github.com/devicetree-org/dt-schema.git@master --upgrade
Select VS depens on
Select is very strongly discouraged and should only be used for Kconfig symbols not visible to users.