Skip to content

Feature request: Go to Definition on compatible string values #148

@yijiyang

Description

@yijiyang

Summary

Ctrl+click / F12 on a compatible string value (e.g. compatible = "qcom,sm8450-pinctrl") should navigate to the matching of_device_id entry in the kernel driver C source. If no driver match is found, fall back to the corresponding DT binding YAML file.

Current behavior

  • Go to Definition works on &label phandle references and property names.
  • Hovering a compatible string already shows the binding documentation (since v0.9.0).
  • Autocompletion suggests compatible strings from the binding index.
  • But F12 / Ctrl+click on the compatible string value itself does nothing.

Expected behavior

When the cursor is on a string literal inside a compatible property, the LSP textDocument/definition handler should:

  1. Primary target — driver source: Search for the compatible string in of_device_id tables (.compatible = "qcom,sm8450-pinctrl") across the kernel tree and navigate to the matching line in the driver C file.
  2. Fallback — binding YAML: If no driver match is found, resolve it to the YAML binding file that declares that compatible (using the already-loaded binding index).

This mirrors how developers actually work: the first thing you want to see when clicking a compatible string is the driver that handles it — the binding schema is secondary.

Use case

Kernel developers frequently need to jump from a DTS compatible string to the driver that probes it. Today this requires a manual grep -r across the tree. Direct F12 navigation would make the workflow significantly faster — especially in large SoC trees with hundreds of drivers.

Implementation notes

  • The compatible string already exists in the binding index (used for hover/autocomplete).
  • For driver lookup, a workspace-wide index of of_device_id tables (grepping for .compatible = "..." patterns in *.c files) would cover the vast majority of cases.
  • Priority: driver C file > binding YAML > nothing.

Environment

  • Extension version: 0.9.3
  • Binding type: DevicetreeOrg
  • Binding path configured: Documentation/devicetree/bindings
  • OS: Linux (remote SSH via VS Code)

Notes

Happy to test pre-release builds if helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions