-
Notifications
You must be signed in to change notification settings - Fork 319
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
Channel label support #1229
base: main
Are you sure you want to change the base?
Channel label support #1229
Conversation
603820a
to
3fb2071
Compare
V2:
|
Hi @dNechita, I plan to give a better review on this one next week. For now, some points from me:
|
reversing the order of the patches will cause build failures (won't it?) - since you will be using label, before it's added/initialized. I can see swapping the order of: so that local is filled out when you start using them - but it shouldn't really matter too much... |
I think the patch set is incomplete/wrong somewhere: running it I get (on iio_info):
the issue I want to point out is that the lable still shows up as an attribute, when it should be eaten as a label... We see:
rather than:
It doesn't make sense to expose the I think this just means it's missing an early return somewhere in local.c for example, this is what the early return does here:
|
I didn't meant literally. Likely, as you pointed out, it needs some rework in order to change the order. But it should be doable to code all the foundation and the last patch to just be exposing the API to the "outside world". As it stands, I do not think it makes to much sense to expose an API without being implemented. |
Yes, I have missed adding the implementation that would consider the label not to be a simple attribute. I will include it. Thanks! |
Regarding the order of the commits, this time I just used the order presented in issue that was requesting the feature. But if it wasn't for that order I would have still started with the end in mind, meaning adding API, and even updating the clients of the API and then going for the implementation. This is more of an order of how I would develop, and I can keep it while changing the commits order when creating a PR if that is easier to review. |
It's not it is easier to review. It just does not make sense to me to have a public API without being implemented. Naturally you're thinking on just having the complete PR merged and then this does not matter... I'm more looking at the series on a patch by patch basis and what makes sense to me. Sometimes, one also should have in mind things like All the above said, this is a nitpick and a minor detail |
3fb2071
to
384d318
Compare
V3:
|
I think the iio_info issue is fixed...
and main branch:
turns into:
which I think is what we are looking for... :) |
When the "label" channel attribute is found, initialize the channel's label to its value. Signed-off-by: Dan Nechita <[email protected]>
This function can be used to retrieve the label for this IIO Channel, if it was specified in linux driver. Signed-off-by: Dan Nechita <[email protected]>
Make iio_device_find_channel() able to search not only by ID and name, but also by label. Signed-off-by: Dan Nechita <[email protected]>
Signed-off-by: Dan Nechita <[email protected]>
Signed-off-by: Dan Nechita <[email protected]>
Signed-off-by: Dan Nechita <[email protected]>
If a IIO channel has a label, display it after the name. Signed-off-by: Dan Nechita <[email protected]>
chn->label = iio_strdup(chn_label_ptr); | ||
} | ||
return 0; | ||
} |
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.
To add on Robin's comments I wonder if we could not do this simpler:
name = get_short_attr_name(chn, name);
if (!strcmp(name, "label") {
const char *dev_id = iio_device_get_id(iio_channel_get_device(chn));
ret = local_do_read_dev_attr(dev_id, 0, name,
label, sizeof(label), IIO_ATTR_TYPE_CHANNEL);
/* But I actually wonder if we should ignore errors in this case?!! */
if (ret > 0) {
...
return 0;
}
}
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.
By simpler, do you mean doing the entire if() after name = get_short_attr_name(chn, name);
? The thing is that name
will never be equal to "label" since at this point, the channel name isn't known yet, therefore name will still resemble to something like: "in_voltage0_label".
For the other thing, I could add an error message for situations where label reading fails but I am not sure what else can be done. We will end up with a channel with no label and no attribute called 'label' and that is it. Are you considering doing more in this scenario?
If a IIO channel has a label, display it and support matching against the label. Signed-off-by: Dan Nechita <[email protected]>
384d318
to
8abf207
Compare
PR Description
Add support for labels in IIO channels, similar to IIO devices.
These changes add
iio_channel_get_label(const struct iio_channel *chn)
to the existing API.PR Type
PR Checklist