Hi Martin,

it might make sense to add GPIO helper in a common object, and use libgpiod in there?

We will not be adding any further dependencies on GLib based libraries for oFono as GLib use is going to be deprecated over time (in favor of ell).  This is especially true for a small library like libgpiod.

I don't think libgpiod i GLib based:


Ah, good to know. Not sure why I assumed that. But in general we'd be very careful about introducing any new dependencies. In fact once we migrate to ell we can start dropping some (like libdbus-1)

So this has to be done either inside oFono itself or preferably as a set of class(es) inside ell.

As long as it is only a matter of setting a single GPIO on/off, then I think a helper in common/gpio.{c,h} should be enough - something like this from my little test program:

static bool gpio_set(uint32_t chip, uint32_t line, uint8_t value)
{
         struct gpiohandle_request req = {0};
         char path[] = "/dev/gpiochipXX";
         int ret, fd;

         snprintf(path, sizeof(path), "/dev/gpiochip%u", chip);
         fd = open(path, O_RDWR | O_CLOEXEC);
         if (fd < 0) {
                 error(0, errno, "open: %s", path);
                 return false;
         }

         req.lineoffsets[0] = line;
         req.lines = 1;
         req.flags = GPIOHANDLE_REQUEST_OUTPUT;
         req.default_values[0] = !!value;
         strncpy(req.consumer_label, "ofono", sizeof(req.consumer_label));

         ret = ioctl(fd, GPIO_GET_LINEHANDLE_IOCTL, &req);
         if (ret < 0) {
                 error(0, errno, "ioctl");
                 return false;
         }

         return true;
}


Looks simple enough. Since ell is now a required dependency, then you might as well start introducing it into ell. This can start small / primitive and grow as needed.

But if you want to keep it inside ofono.git/src, that is also fine.

Regards,
-Denis
_______________________________________________
ofono mailing list
[email protected]
https://lists.ofono.org/mailman/listinfo/ofono

Reply via email to