Skip to contentSkip to conversation

ASoC: dt-bindings: wm8741: Convert to DT schema

PATCH In review Lorena Tanase 4 participants 5 messages Nov 9 – Nov 10

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ASoC: dt-bindings: wm8741: Convert to DT schema

Convert the WM8741 audio CODEC bindings to DT schema.

---
 .../devicetree/bindings/sound/wlf,wm8741.yaml | 40 +++++++++++++++++++
 .../devicetree/bindings/sound/wm8741.txt      | 29 --------------
 2 files changed, 40 insertions(+), 29 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/wlf,wm8741.yaml
 delete mode 100644 Documentation/devicetree/bindings/sound/wm8741.txt
Documentation/devicetree/bindings/sound/wlf,wm8741.yaml new file +40 -0
new file mode 100644
index 000000000000..a9a7fc2414bb
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/wlf,wm8741.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: WM8741 audio codec
+
+description: |
+  Wolfson Microelectronics WM8741 audio CODEC
+
+maintainers:
+  - [email protected]
+
+properties:
+  compatible:
+    const: wlf,wm8741
+
+  reg:
+    maxItems: 1
+
+diff-mode:
+  description: diferential output mode
+  $ref: /schemas/types.yaml#/definitions/uint32
+  enum: [0, 1, 2, 3]
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    wm8903: codec@1a {
+      compatible = "wlf,wm8741";
+      reg = <0x1a>;
+
+      diff-mode = <3>;    
+    };
Documentation/devicetree/bindings/sound/wm8741.txt deleted +0 -29
deleted file mode 100644
index b69e196c741c..000000000000
@@ -1,29 +0,0 @@
-WM8741 audio CODEC
-
-This device supports both I2C and SPI (configured with pin strapping
-on the board).
-
-Required properties:
-
-  - compatible : "wlf,wm8741"
-
-  - reg : the I2C address of the device for I2C, the chip select
-          number for SPI.
-
-Optional properties:
-
-  - diff-mode: Differential output mode configuration. Default value for field
-    DIFF in register R8 (MODE_CONTROL_2). If absent, the default is 0, shall be:
-    0 = stereo
-    1 = mono left
-    2 = stereo reversed
-    3 = mono right
-
-Example:
-
-wm8741: codec@1a {
-	compatible = "wlf,wm8741";
-	reg = <0x1a>;
-
-	diff-mode = <3>;
-};
Signature · 1 line
2.43.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 4 potential issues to consider: - [Medium] ASoC: dt-bindings: wm8741: diff-mode placed at root level of YAML schema - [Medium] ASoC…

Thank you for your contribution! Sashiko AI review found 4 potential issues to consider:
- [Medium] ASoC: dt-bindings: wm8741: diff-mode placed at root level of YAML schema
- [Medium] ASoC: dt-bindings: wm8741: invalid example bus addressing and trailing spaces
- [Low] ASoC: dt-bindings: wm8741: missing supplies, DAI, and SPI properties in schema
- [Low] ASoC: dt-bindings: wm8741: dangling sound/wm* file entry in MAINTAINERS
--

commit 9c3870a4814d3bc22a021bf5687bbcb6d6e76c1c
Author: Lorena Tanase <[email protected]>

ASoC: dt-bindings: wm8741: Convert to DT schema

This commit converts the Wolfson Microelectronics wm8741 audio codec device tree binding from plain text to yaml schema format.

Quoted 6 lines
Documentation/devicetree/bindings/sound/wlf,wm8741.yaml new file +0 -0
new file mode 100644
index 0000000000000..a9a7fc2414bb6
@@ -0,0 +1,40 @@

[ ... ]

Documentation/devicetree/bindings/sound/wlf,wm8741.yaml line 20

Quoted 6 lines
Documentation/devicetree/bindings/sound/wlf,wm8741.yaml new file +6 -0
+properties:
+  compatible:
+    const: wlf,wm8741
+
+  reg:
+    maxItems: 1

[Severity: Low]
Should this schema also document the regulator supplies, #sound-dai-cells, and spi peripheral properties?

Both wm8741_i2c_probe() and wm8741_spi_probe() in sound/soc/codecs/wm8741.c request the avdd and dvdd supplies via devm_regulator_bulk_get(), and the device supports both i2c and spi buses:

sound/soc/codecs/wm8741.c:

static const char *wm8741_supply_names[WM8741_NUM_SUPPLIES] = {
	"AVDD",
	"DVDD",
};

Because the schema sets additionalProperties: false, device tree nodes for wlf,wm8741 that specify avdd-supply, dvdd-supply, #sound-dai-cells, or spi properties such as spi-max-frequency will fail dtbs_check unless those properties and refs to dai-common.yaml# and /schemas/spi/spi-peripheral-props.yaml# (with unevaluatedProperties: false) are included.

Documentation/devicetree/bindings/sound/wlf,wm8741.yaml line 31

Quoted 11 lines
Documentation/devicetree/bindings/sound/wlf,wm8741.yaml new file +11 -0
+
+diff-mode:
+  description: diferential output mode
+  $ref: /schemas/types.yaml#/definitions/uint32
+  enum: [0, 1, 2, 3]
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false

[Severity: Medium]
Is diff-mode placed at the root of the document instead of indented under properties?

At column 0, diff-mode is rejected by dt-doc-validate as an unknown top-level keyword during make dt_binding_check, and any node using diff-mode (including the example below) fails validation against
additionalProperties: false.

Compared to wm8741.txt, this entry also drops default: 0 and the descriptions of the four mode values (0 = stereo, 1 = mono left, 2 = stereo reversed, 3 = mono right), and misspells differential as diferential.

Documentation/devicetree/bindings/sound/wlf,wm8741.yaml line 40

Quoted 9 lines
Documentation/devicetree/bindings/sound/wlf,wm8741.yaml new file +9 -0
+
+examples:
+  - |
+    wm8903: codec@1a {
+      compatible = "wlf,wm8741";
+      reg = <0x1a>;
+
+      diff-mode = <3>;    
+    };

[Severity: Medium]
Should codec@1a in the example be wrapped in an i2c or spi bus node?

Without a parent bus node setting #address-cells = <1> and #size-cells = <0>, dt-extract-example uses the default root cell sizes of 1 and 1, causing dtc to fail on reg = <0x1a> with a reg_format error during make dt_binding_check.

The diff-mode = <3>; line also has four trailing spaces that cause yamllint to fail, and the node uses an unused wm8903 label with 2-space indentation instead of standard 4-space example indentation.

Documentation/devicetree/bindings/sound/wm8741.txt

Quoted 5 lines
Documentation/devicetree/bindings/sound/wm8741.txt deleted +0 -0
deleted file mode 100644
index b69e196c741c4..0000000000000

[Severity: Low]
Does removing Documentation/devicetree/bindings/sound/wm8741.txt leave a dangling file pattern in the maintainers file?

wm8741.txt was the last file matching Documentation/devicetree/bindings/sound/wm*, while the new yaml file is already covered by Documentation/devicetree/bindings/sound/wlf,*.yaml, so get_maintainer.pl --self-test=patterns will warn unless the sound/wm* entry is removed.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to Lorena Tanase
Quoted 31 lines · Lorena Tanase

Convert the WM8741 audio CODEC bindings to DT schema.

---
 .../devicetree/bindings/sound/wlf,wm8741.yaml | 40 +++++++++++++++++++
 .../devicetree/bindings/sound/wm8741.txt      | 29 --------------
 2 files changed, 40 insertions(+), 29 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/wlf,wm8741.yaml
 delete mode 100644 Documentation/devicetree/bindings/sound/wm8741.txt
Documentation/devicetree/bindings/sound/wlf,wm8741.yaml new file +15 -0
new file mode 100644
index 000000000000..a9a7fc2414bb
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/wlf,wm8741.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: WM8741 audio codec
+
+description: |
+  Wolfson Microelectronics WM8741 audio CODEC
+
+maintainers:
+  - [email protected]
+
+properties:

Documentation/devicetree/bindings/sound/wlf,wm8741.yaml line 25

Quoted 10 lines
Documentation/devicetree/bindings/sound/wlf,wm8741.yaml new file +10 -0
+  compatible:
+    const: wlf,wm8741
+
+  reg:
+    maxItems: 1
+
+diff-mode:
+  description: diferential output mode
+  $ref: /schemas/types.yaml#/definitions/uint32
+  enum: [0, 1, 2, 3]

You never tested your code.

The main point of this commit is to convert to DT schema, right? So if you do not test if resulting DT schema is correct, this makes absolutely no sense. Please read ALL existing docs in DT/bindings directory.

Quoted 4 lines
Documentation/devicetree/bindings/sound/wlf,wm8741.yaml new file +4 -0
+
+required:
+  - compatible
+  - reg

Documentation/devicetree/bindings/sound/wlf,wm8741.yaml line 39

Quoted 10 lines
Documentation/devicetree/bindings/sound/wlf,wm8741.yaml new file +10 -0
+
+additionalProperties: false
+
+examples:
+  - |
+    wm8903: codec@1a {
+      compatible = "wlf,wm8741";
+      reg = <0x1a>;
+
+      diff-mode = <3>;    

Please run scripts/checkpatch.pl on the patches and fix reported warnings. After that, run also 'scripts/checkpatch.pl --strict' on the patches and (probably) fix more warnings. Some warnings can be ignored, especially from --strict run, but the code here looks like it needs a fix. Feel free to get in touch if the warning is not clear.

Best regards,
Krzysztof

maintainer
#4 lore raw
In reply to Lorena Tanase
Quoted 1 line

Convert the WM8741 audio CODEC bindings to DT schema.

Please remember to copy the Cirrus maintainers on new versions...

Documentation/devicetree/bindings/sound/wlf,wm8741.yaml line 13

Quoted 3 lines
Documentation/devicetree/bindings/sound/wlf,wm8741.yaml new file +3 -0
+
+maintainers:
+  - [email protected]

...especially given that you're voulunteering them to be maintainers.

Signature · 1 line
Mark Brown <[email protected]>