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

Better backend API #1138

Merged
merged 10 commits into from
Mar 11, 2024
Merged

Better backend API #1138

merged 10 commits into from
Mar 11, 2024

Conversation

pcercuei
Copy link
Contributor

Modify/add functions:

  • iio_context_add_device, which will create a iio_device and add it to the context;
  • iio_device_add_channel, which will create a iio_channel and add it to the device;
  • The functions iio_{context,device,channel}_add_attr to add attributes to contexts/devices/channels are now backend API
  • iio_create_context_from_backend now takes a few extra parameters that will be used to create the iio_context.

With these changes, the XML backend was updated to be fully implemented on top of the public API (be it iio.h or iio-backend.h) and does not use iio-private.h anymore.

In theory, the local backend could do that too but it's a lot more work (due to how it currently creates the context).

The code should be considered very experimental, it was not thoroughly tested.

Sort attributes as soon as a new one has been added.

Signed-off-by: Paul Cercueil <[email protected]>
A backend API function iio_context_add_device() will be introduced;
rename the old function so that it won't get in the way.

Signed-off-by: Paul Cercueil <[email protected]>
This API function can be used to create and add a iio_device to the
iio_context.

Signed-off-by: Paul Cercueil <[email protected]>
Copy link

@buha buha left a comment

Choose a reason for hiding this comment

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

i've played with a few of these functions and they provide a good alternative to the iio_create_context_from_xml function which uses libxml2 which grows the .text area of the binary about 3 times in my tests (100k -> 300k)

what Paul did here is very good for embedding tinyiiod on small embedded devices

This API function can be used to create and add a iio_channel to the
iio_device.

Signed-off-by: Paul Cercueil <[email protected]>
These functions can be used to add an attribute to an iio_context,
iio_device and iio_channel respectively.

Signed-off-by: Paul Cercueil <[email protected]>
Change its prototype so that it takes a iio_context_params pointer, as
well as major/minor/git_tag version information.

Signed-off-by: Paul Cercueil <[email protected]>
Use the new backend functions to create the iio_context, iio_device and
iio_channel objects. By doing so, the XML backend is now fully decoupled
from the private API, and it only uses public headers.

Note that we don't need to print the channel or device names with the
debug macros, as they already do that for us.

Signed-off-by: Paul Cercueil <[email protected]>
Rework the code to use the new iio_context_add_device() from the backend
API, instead of using Libiio's internal functions directly.

Signed-off-by: Paul Cercueil <[email protected]>
This function is not used anywhere anymore.

Signed-off-by: Paul Cercueil <[email protected]>
@buha
Copy link

buha commented Feb 5, 2024

@pcercuei you may merge this

@pcercuei pcercuei marked this pull request as ready for review February 5, 2024 09:01
@pcercuei
Copy link
Contributor Author

pcercuei commented Feb 5, 2024

Only people from ADI can merge 🙃

@pcercuei
Copy link
Contributor Author

pcercuei commented Mar 8, 2024

Gentle ping.

@mhennerich mhennerich merged commit 8f019fd into main Mar 11, 2024
22 of 25 checks passed
@mhennerich mhennerich deleted the pcercuei/better-backend-api branch March 11, 2024 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants