Skip to content

Commit

Permalink
sort: Move channel attribute sorting to context creation
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Getz <[email protected]>
  • Loading branch information
rgetz committed Oct 24, 2018
1 parent 8405704 commit b9008a7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 6 additions & 2 deletions context.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,12 @@ static void reorder_channels(struct iio_device *dev)
qsort(dev->channels, dev->nb_channels, sizeof(struct iio_channel *),
iio_channel_compare);

for (i = 0; i < dev->nb_channels; i++)
dev->channels[i]->number = i;
for (i = 0; i < dev->nb_channels; i++) {
struct iio_channel *chn = dev->channels[i];
chn->number = i;
qsort(chn->attrs, chn->nb_attrs, sizeof(struct iio_channel_attr),
iio_channel_attr_compare);
}
}

int iio_context_init(struct iio_context *ctx)
Expand Down
3 changes: 0 additions & 3 deletions local.c
Original file line number Diff line number Diff line change
Expand Up @@ -1767,9 +1767,6 @@ static int create_device(void *d, const char *path)
free_protected_attrs(chn);
if (ret < 0)
goto err_free_scan_elements;

qsort(chn->attrs, chn->nb_attrs, sizeof(struct iio_channel_attr),
iio_channel_attr_compare);
}

ret = detect_and_move_global_attrs(dev);
Expand Down

0 comments on commit b9008a7

Please sign in to comment.