Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devicetree: add binding support for variant compatibles #20289

Closed
wants to merge 3 commits into from

Conversation

pabigot
Copy link
Collaborator

@pabigot pabigot commented Nov 2, 2019

This is a step towards #19904. The motivation is removing redundant bindings from dts/ that aren't associated with their own driver implementation, and eliminating the annoying checkpatch warnings when an unspecified compatible is added in a commit.

Knowledge of the variants may also assist in addressing #20287.

@pabigot pabigot requested review from ulfalizer and galak November 2, 2019 12:31
@pabigot pabigot force-pushed the dts/20191102b branch 2 times, most recently from adf43ef to 0340856 Compare November 2, 2019 12:33
@zephyrbot
Copy link
Collaborator

zephyrbot commented Nov 2, 2019

All checks are passing now.

Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages.

Copy link
Collaborator

@ulfalizer ulfalizer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should check the format of variant-compatible too. Search for all(isinstance in edtlib.py for examples of how it's done for other keys.

@@ -29,6 +29,11 @@ compatible: "manufacturer,device"
#
# If more than one binding for a compatible is found, an error is raised.

# Used to identify variants known to work with the driver for 'compatible'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we go with this, this ought to explain that variant-compatible isn't used by the code, and is just a "syntaxified comment" in a sense. Otherwise, I'd wonder how it's used.

Think I'm fine with it as long as that's clear. Might help bring some structure.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Could update the comment later if/when it gets used for other stuff. As long as it's unused, it's nice to document it, to avoid confusion.)

@@ -416,7 +416,8 @@ def _check_binding(self, binding, binding_path):
_err("missing, malformed, or empty '{}' in {}"
.format(prop, binding_path))

ok_top = {"title", "description", "compatible", "properties", "#cells",
ok_top = {"title", "description", "compatible", "variant-compatible",
"properties", "#cells",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could reflow all of ok_top, or put on separate lines if you're worried about history (though I wonder if the vertical spam is worthwhile).

@pabigot pabigot force-pushed the dts/20191102b branch 2 times, most recently from 5856bb5 to 4c5baad Compare November 2, 2019 21:13
@pabigot pabigot marked this pull request as ready for review November 2, 2019 22:31
if prop == "variant-compatible":
if not all(isinstance(elm, str) for elm in binding[prop]):
_err("all elements in '{}:' in {} should be strings"
.format(prop, binding_path))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should verify that it's a list as well, or it'll pass for variant-compatible: "foo" by iterating over "f", "o", "o".

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could maybe put it outside the loop. Think some other stuff was:

if "variant-compatible" in binding:
    var_comp = binding["variant_compatible"]
    if not (isinstance(var_comp, list) and
            all(isinstance(elm, str) for elm in var_comp)):
        _err("... should be a list of strings")

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could put it next to the

if "child-binding" in binding:
    ....

if "sub-node" in binding:
    ...

if "#cells" in binding:
    ...

stuff below.

@pabigot pabigot changed the title [RFC] add binding support for variant compatibles devicetree: add binding support for variant compatibles Nov 3, 2019
@@ -27,7 +27,7 @@
};

lsm303agr-magn@1e {
compatible = "st,lis2mdl","st,lsm303agr-magn";
compatible = "st,lsm303agr-magn", "st,lis2mdl";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason to invert the devices in the compatible list?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because standard practice is to order them from most-specific to least-specific, selecting the first one that is supported. There is no lsm303agr-magn driver right now, but there is a lis2mdl that works with that device.

Historically Zephyr only paid attention to the first entry, but that was fixed some months ago so we can now be consistent with other devicetree usage.

binding-template specifies the order, but does not explain why it's that way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@avisconti please revisit this; note @galak's non-verbal support for this change.

@@ -34,7 +34,7 @@
};

lsm303agr-accel@19 {
compatible = "st,lis2dh", "st,lsm303agr-accel";
compatible = "st,lsm303agr-accel", "st,lis2dh";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

@@ -94,7 +94,7 @@
};

lsm303dlhc-accel@19 {
compatible = "st,lis2dh", "st,lsm303dlhc-accel";
compatible = "st,lsm303dlhc-accel", "st,lis2dh";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also here

@galak galak requested a review from avisconti November 4, 2019 13:56
Copy link
Collaborator

@ulfalizer ulfalizer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with me.

if not (isinstance(var_comp, list) and
all(isinstance(elm, str) for elm in var_comp)):
_err("malformed 'variant-compatible:' in {}, expected "
" list of strings".format(binding_path))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Accidental two spaces between "expected" and "list".

Copy link
Collaborator

@ulfalizer ulfalizer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with me.

Copy link
Collaborator

@ulfalizer ulfalizer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with me.

Copy link
Collaborator

@ulfalizer ulfalizer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with me.

Copy link
Collaborator

@ulfalizer ulfalizer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with me.

@ulfalizer
Copy link
Collaborator

Heh... GitHub bugged out for a moment there.

2 similar comments
@ulfalizer
Copy link
Collaborator

Heh... GitHub bugged out for a moment there.

@ulfalizer
Copy link
Collaborator

Heh... GitHub bugged out for a moment there.

@galak galak added area: Devicetree Tooling PR modifies or adds a Device Tree tooling and removed area: Devicetree labels Jan 30, 2020
@github-actions github-actions bot added area: Devicetree has-conflicts Issue/PR has conflicts with another issue/PR area: Device Tree area: Devicetree Binding PR modifies or adds a Device Tree binding labels Jun 29, 2020
@github-actions github-actions bot added has-conflicts Issue/PR has conflicts with another issue/PR area: Shields Shields (add-on boards) platform: STM32 ST Micro STM32 and removed has-conflicts Issue/PR has conflicts with another issue/PR labels Jul 1, 2020
@pabigot
Copy link
Collaborator Author

pabigot commented Jul 20, 2020

This PR is too out of data and there seems to be little interest in the cleanup it provides.

@pabigot pabigot closed this Jul 20, 2020
@pabigot pabigot deleted the dts/20191102b branch July 20, 2020 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Boards area: Devicetree Binding PR modifies or adds a Device Tree binding area: Devicetree Tooling PR modifies or adds a Device Tree tooling area: Devicetree area: Shields Shields (add-on boards) DNM This PR should not be merged (Do Not Merge) has-conflicts Issue/PR has conflicts with another issue/PR platform: STM32 ST Micro STM32
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants