linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Linus Walleij <linus.walleij@linaro.org>,
	 Kent Gibson <warthog618@gmail.com>,
	 Erik Schilling <erik.schilling@linaro.org>,
	 Phil Howard <phil@gadgetoid.com>,
	 Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	 Viresh Kumar <viresh.kumar@linaro.org>,
	 Dan Carpenter <dan.carpenter@linaro.org>
Cc: "As advised by Dan Carpenter - I'm CC'ing
	dbus"@lists.freedesktop.orgto,  linux-gpio@vger.kernel.org,
	dbus@lists.freedesktop.org,
	 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: [PATCH RESEND libgpiod v2 00/18] dbus: add GLib-based DBus daemon and command-line client
Date: Fri, 28 Jun 2024 20:58:19 +0200	[thread overview]
Message-ID: <20240628-dbus-v2-0-c1331ac17cb8@linaro.org> (raw)

Resending as the emails bounced off dbus@lists.freedesktop.org due to me not
being subscribed before.

Note: As advised by Dan Carpenter - I'm CC'ing dbus@lists.freedesktop.org to
get some comments on the DBus API which can be found in dbus/lib/io.gpiod1.xml.

This has been in the works for a long time but I'm finally ready to share it
with the world. This introduces the DBus API definition and its implementation
in the form of a GPIO manager daemon and a companion command-line client as
well as GLib bindings to libgpiod which form the base on which the former are
built.

While I split the GLib and DBus code into several commits for easier review,
I intend to apply all changes to bindings/glib/ and dbus/ as two big commits
in the end as otherwise the split commits are not buildable until all of them
are applied.

The main point of interest is the DBus interface definition XML at
dbus/lib/io.gpiod1.xml as it is what defines the actual DBus API. Everything
else can be considered as implementation details as it's easier to change
later than the API that's supposed to be stable once released.

The first two patches expose the test infrastructure we use for the core
library and tools to the GLib bindings and dbus code. Next we add the GLib
bindings themselves. Not much to discuss here, they cover the entire libgpiod
API but wrap it in GObject abstractions and plug into the GLib event loop.

Finally we add the DBus code that's split into the daemon and command-line
client. I added some examples to the README and documented the behavior in
the help text of the programs as well as documented the interface file with
XML comments that gdbus-codegen can parse and use to generate docbook output.

For DBus, most of the testing happens in the command-line client bash tests.
It has a very good coverage of the daemon's code and also allows to run the
daemon through valgrind and verify there are no memory leaks and invalid
accesses. I still intend to extend the C test-suite for DBus with some corner
cases but didn't not have enough time for it.

Changes in v2:
- fixed most segfaults I noticed (or was made aware of by others) in RFC
- improve the code in GLib examples
- make command-line tests pass shellckeck
- fix build issue resulting in implicit pointer-to-int casting on some
  platforms
- many small tweaks, fixes and improvements all over the place but without
  changing the API
- fix a bunch of memory leaks reported by valgrind
- Link to v1: https://lore.kernel.org/linux-gpio/20240412122804.109323-1-brgl@bgdev.pl/

---
Bartosz Golaszewski (18):
      tests: split out reusable test code into a local static library
      tests: split out the common test code for bash scripts
      bindings: glib: add build files
      bindings: glib: add public headers
      bindings: glib: add core code
      bindings: glib: add examples
      bindings: glib: add tests
      README: document GLib bindings
      dbus: add build files
      dbus: add the API definitions
      dbus: add a wrapper around the gdbus-codegen generated header
      dbus: add data files
      dbus: add gpio-manager code
      dbus: add tests
      dbus: add a command-line client
      dbus: client: add tests
      README: document the DBus API
      TODO: drop the DBus daemon from the list

 .gitignore                                         |    2 +
 Doxyfile.in                                        |    4 +-
 Makefile.am                                        |    7 +
 README                                             |   73 +-
 TODO                                               |   17 -
 bindings/Makefile.am                               |    7 +
 bindings/glib/Makefile.am                          |   78 ++
 bindings/glib/chip-info.c                          |  118 ++
 bindings/glib/chip.c                               |  396 ++++++
 bindings/glib/edge-event.c                         |  158 +++
 bindings/glib/error.c                              |   67 +
 bindings/glib/examples/.gitignore                  |   14 +
 bindings/glib/examples/Makefile.am                 |   22 +
 bindings/glib/examples/find_line_by_name_glib.c    |   68 +
 bindings/glib/examples/get_chip_info_glib.c        |   39 +
 bindings/glib/examples/get_line_info_glib.c        |   79 ++
 bindings/glib/examples/get_line_value_glib.c       |   67 +
 .../glib/examples/get_multiple_line_values_glib.c  |   72 +
 .../examples/reconfigure_input_to_output_glib.c    |  103 ++
 bindings/glib/examples/toggle_line_value_glib.c    |   99 ++
 .../examples/toggle_multiple_line_values_glib.c    |  132 ++
 bindings/glib/examples/watch_line_info_glib.c      |   63 +
 bindings/glib/examples/watch_line_value_glib.c     |   91 ++
 .../examples/watch_multiple_edge_rising_glib.c     |   95 ++
 bindings/glib/generated-enums.c.template           |   43 +
 bindings/glib/generated-enums.h.template           |   30 +
 bindings/glib/gpiod-glib.h                         |   33 +
 bindings/glib/gpiod-glib.pc.in                     |   14 +
 bindings/glib/gpiod-glib/Makefile.am               |   18 +
 bindings/glib/gpiod-glib/chip-info.h               |   84 ++
 bindings/glib/gpiod-glib/chip.h                    |  164 +++
 bindings/glib/gpiod-glib/edge-event.h              |  114 ++
 bindings/glib/gpiod-glib/error.h                   |   67 +
 bindings/glib/gpiod-glib/info-event.h              |   97 ++
 bindings/glib/gpiod-glib/line-config.h             |  116 ++
 bindings/glib/gpiod-glib/line-info.h               |  171 +++
 bindings/glib/gpiod-glib/line-request.h            |  182 +++
 bindings/glib/gpiod-glib/line-settings.h           |  202 +++
 bindings/glib/gpiod-glib/line.h                    |  114 ++
 bindings/glib/gpiod-glib/misc.h                    |   51 +
 bindings/glib/gpiod-glib/request-config.h          |  107 ++
 bindings/glib/info-event.c                         |  150 ++
 bindings/glib/internal.c                           |  334 +++++
 bindings/glib/internal.h                           |   54 +
 bindings/glib/line-config.c                        |  186 +++
 bindings/glib/line-info.c                          |  274 ++++
 bindings/glib/line-request.c                       |  434 ++++++
 bindings/glib/line-settings.c                      |  359 +++++
 bindings/glib/misc.c                               |   17 +
 bindings/glib/request-config.c                     |  155 +++
 bindings/glib/tests/.gitignore                     |    4 +
 bindings/glib/tests/Makefile.am                    |   29 +
 bindings/glib/tests/helpers.c                      |   12 +
 bindings/glib/tests/helpers.h                      |  139 ++
 bindings/glib/tests/tests-chip-info.c              |   55 +
 bindings/glib/tests/tests-chip.c                   |  183 +++
 bindings/glib/tests/tests-edge-event.c             |  226 +++
 bindings/glib/tests/tests-info-event.c             |  321 +++++
 bindings/glib/tests/tests-line-config.c            |  186 +++
 bindings/glib/tests/tests-line-info.c              |   98 ++
 bindings/glib/tests/tests-line-request.c           |  704 ++++++++++
 bindings/glib/tests/tests-line-settings.c          |  252 ++++
 bindings/glib/tests/tests-misc.c                   |   88 ++
 bindings/glib/tests/tests-request-config.c         |   58 +
 configure.ac                                       |   72 +
 dbus/Makefile.am                                   |   10 +
 dbus/client/.gitignore                             |    4 +
 dbus/client/Makefile.am                            |   31 +
 dbus/client/common.c                               |  646 +++++++++
 dbus/client/common.h                               |  203 +++
 dbus/client/detect.c                               |   53 +
 dbus/client/find.c                                 |   66 +
 dbus/client/get.c                                  |  210 +++
 dbus/client/gpiocli-test.bash                      | 1443 ++++++++++++++++++++
 dbus/client/gpiocli.c                              |  174 +++
 dbus/client/info.c                                 |  184 +++
 dbus/client/monitor.c                              |  191 +++
 dbus/client/notify.c                               |  295 ++++
 dbus/client/reconfigure.c                          |   74 +
 dbus/client/release.c                              |   62 +
 dbus/client/request.c                              |  249 ++++
 dbus/client/requests.c                             |   71 +
 dbus/client/set.c                                  |  170 +++
 dbus/client/wait.c                                 |  188 +++
 dbus/data/Makefile.am                              |   13 +
 dbus/data/gpio-manager.service                     |   14 +
 dbus/data/io.gpiod1.conf                           |   29 +
 dbus/lib/Makefile.am                               |   28 +
 dbus/lib/gpiodbus.h                                |    9 +
 dbus/lib/io.gpiod1.xml                             |  318 +++++
 dbus/manager/.gitignore                            |    4 +
 dbus/manager/Makefile.am                           |   21 +
 dbus/manager/daemon.c                              |  821 +++++++++++
 dbus/manager/daemon.h                              |   22 +
 dbus/manager/gpio-manager.c                        |  167 +++
 dbus/manager/helpers.c                             |  420 ++++++
 dbus/manager/helpers.h                             |   24 +
 dbus/tests/.gitignore                              |    4 +
 dbus/tests/Makefile.am                             |   25 +
 dbus/tests/daemon-process.c                        |  129 ++
 dbus/tests/daemon-process.h                        |   20 +
 dbus/tests/helpers.c                               |  107 ++
 dbus/tests/helpers.h                               |  112 ++
 dbus/tests/tests-chip.c                            |  133 ++
 dbus/tests/tests-line.c                            |  231 ++++
 dbus/tests/tests-request.c                         |  116 ++
 tests/Makefile.am                                  |   14 +-
 tests/gpiod-test-helpers.c                         |   41 -
 tests/gpiosim-glib/Makefile.am                     |   13 +
 .../gpiosim-glib.c}                                |   30 +-
 .../gpiosim-glib.h}                                |   14 +
 tests/harness/Makefile.am                          |   12 +
 tests/harness/gpiod-test-common.h                  |   23 +
 tests/{ => harness}/gpiod-test.c                   |    0
 tests/{ => harness}/gpiod-test.h                   |    0
 tests/{gpiod-test-helpers.h => helpers.h}          |   36 +-
 tests/scripts/Makefile.am                          |    4 +
 tests/scripts/gpiod-bash-test-helper.inc           |  330 +++++
 tests/tests-chip-info.c                            |    7 +-
 tests/tests-chip.c                                 |   15 +-
 tests/tests-edge-event.c                           |    7 +-
 tests/tests-info-event.c                           |    7 +-
 tests/tests-kernel-uapi.c                          |    7 +-
 tests/tests-line-config.c                          |    7 +-
 tests/tests-line-info.c                            |   11 +-
 tests/tests-line-request.c                         |    7 +-
 tests/tests-line-settings.c                        |    5 +-
 tests/tests-misc.c                                 |    7 +-
 tests/tests-request-config.c                       |    5 +-
 tools/gpio-tools-test.bash                         |  566 ++------
 130 files changed, 15542 insertions(+), 585 deletions(-)
---
base-commit: db68634b738b8ba6078f879889d29e4795e585e3
change-id: 20240527-dbus-820e9f7463d0

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


             reply	other threads:[~2024-06-28 18:58 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-28 18:58 Bartosz Golaszewski [this message]
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 01/18] tests: split out reusable test code into a local static library Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 02/18] tests: split out the common test code for bash scripts Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 03/18] bindings: glib: add build files Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 04/18] bindings: glib: add public headers Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 05/18] bindings: glib: add core code Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 06/18] bindings: glib: add examples Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 07/18] bindings: glib: add tests Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 08/18] README: document GLib bindings Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 09/18] dbus: add build files Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 10/18] dbus: add the API definitions Bartosz Golaszewski
2024-06-30 16:49   ` Thiago Macieira
2024-07-01  8:40     ` Bartosz Golaszewski
2024-07-02  6:48     ` Sverdlin, Alexander
2024-07-02  9:06       ` Thiago Macieira
2024-07-02  9:15         ` Bartosz Golaszewski
2024-07-02 10:35           ` Sverdlin, Alexander
2024-07-03 10:53           ` Thiago Macieira
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 11/18] dbus: add a wrapper around the gdbus-codegen generated header Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 12/18] dbus: add data files Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 13/18] dbus: add gpio-manager code Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 14/18] dbus: add tests Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 15/18] dbus: add a command-line client Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 16/18] dbus: client: add tests Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 17/18] README: document the DBus API Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 18/18] TODO: drop the DBus daemon from the list Bartosz Golaszewski
2024-07-02  6:59 ` [PATCH RESEND libgpiod v2 00/18] dbus: add GLib-based DBus daemon and command-line client Sverdlin, Alexander

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240628-dbus-v2-0-c1331ac17cb8@linaro.org \
    --to=brgl@bgdev.pl \
    --cc="As advised by Dan Carpenter - I'm CC'ing dbus"@lists.freedesktop.orgto \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=dan.carpenter@linaro.org \
    --cc=dbus@lists.freedesktop.org \
    --cc=erik.schilling@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=phil@gadgetoid.com \
    --cc=viresh.kumar@linaro.org \
    --cc=warthog618@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).