Repository navigation
channel parent attribute support - #1635
Draft
rodrigo455 wants to merge 9 commits into
Draft
rodrigo455 wants to merge 9 commits into
rodrigo455 wants to merge 9 commits into
Conversation
The IIO subsystem gained a <dir>_<type>[Y]_parent channel attribute, containing the sysfs name prefix of the parent channel (e.g. "out_altvoltage0"). It allows userspace to organize channels in a tree-like structure, reflecting virtual or logical relationships between them, e.g. profile-based subchannels configuring a primary output. - Add iio_channel_get_parent(), returning the parent channel, which belongs to the same device, or NULL if there is none - Add iio_channel_set_parent() to the backend API. It refuses a parent belonging to another device, or the channel itself. Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
Add the optional "parent" and "parent-type" attributes to the <channel> element, identifying the parent channel the same way channels are identified within a <device>: by their ID and direction. When "parent-type" is not set, the parent has the direction of the channel; it is only generated when the directions differ. As parents can be described after their subchannels, the XML backend sets them once all the channels of a device have been created. Unknown parents are ignored, with a warning. Older clients ignore the unknown attributes. Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
Read the <dir>_<type>[Y]_parent attribute of the channels, like it is done for the channel label. The attribute is not listed among the channel attributes. Its value, the sysfs name prefix of the parent channel, may contain a modifier and an extended name (e.g. "in_accel_x" or "in_voltage0_supply"). It is parsed with get_channel_id(), like the attribute names are when creating the channels: the channel ID is made of the type, index and modifier, while the extended name is not part of it. get_channel_id() now also accepts a prefix without attribute name, like it does for the hwmon attributes without underscore. The parent is then looked up by ID and direction, once all the channels of the device are known. Unknown parents are ignored, with a warning. Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
Parse the "parent" and "parent-type" attributes of the <channel> elements, so that emulated devices can describe hierarchical channel relationships. Like in the XML backend, the parents are set once all the channels of a device have been created. Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
Print the ID of the parent channel, e.g. "(parent: altvoltage0)", with its direction when it differs from the one of the channel. Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
Add test_parent, using a new fixture describing channels with parents. Test, with the XML and EMU backends: - channels without parent, siblings and nested subchannels - a parent described after its subchannel - a parent with a different direction, including one with the same ID - the default direction of the parent, when "parent-type" is not set - unknown parents and self-references, which are ignored - generation and parsing of the context XML, "parent-type" being only generated when the directions differ Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
Add the Channel.parent property, returning the parent channel or None. Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
Add parent() to Channel, returning an optional parent channel. Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
Add the Channel.parent property, returning the parent channel or null. The instance listed in Device.channels is returned when available. Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Description
Linux 7.4 adds a new IIO sysfs attribute,
<dir>_<type>Y_parent(e.g. out_altvoltage1_parent). It holds the sysfs name prefix of the channel's parent, such as out_altvoltage0. It lets userspace arrange channels in a tree that reflects virtual or logical relationships. A typical case is a set of profile- or mode-based subchannels that configure a single physical output channel.This PR exposes that relationship in libiio, across all backends and bindings.
PR Type
PR Checklist