-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Conversation
adf43ef
to
0340856
Compare
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. |
There was a problem hiding this 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.
dts/binding-template.yaml
Outdated
@@ -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' |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.)
scripts/dts/edtlib.py
Outdated
@@ -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", |
There was a problem hiding this comment.
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).
5856bb5
to
4c5baad
Compare
scripts/dts/edtlib.py
Outdated
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)) |
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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")
There was a problem hiding this comment.
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.
4c5baad
to
0323e15
Compare
0323e15
to
d65ebcb
Compare
@@ -27,7 +27,7 @@ | |||
}; | |||
|
|||
lsm303agr-magn@1e { | |||
compatible = "st,lis2mdl","st,lsm303agr-magn"; | |||
compatible = "st,lsm303agr-magn", "st,lis2mdl"; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine with me.
scripts/dts/edtlib.py
Outdated
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)) |
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine with me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine with me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine with me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine with me.
Heh... GitHub bugged out for a moment there. |
2 similar comments
Heh... GitHub bugged out for a moment there. |
Heh... GitHub bugged out for a moment there. |
This PR is too out of data and there seems to be little interest in the cleanup it provides. |
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.