On 12/25/25 1:37 PM, andy pugh wrote:
Merry Christmas :-)
Right!
(just another day of the year :-)
It might be possible, but not only did the name of almost every data
structure and function change, but also the whole design philosophy,
so searching for GPIO lines starts at the "other end" so to speak.
I think it can be done, but it would make for a very hard-to-read source file.
> As an illustration, here is the diff:
>
https://github.com/LinuxCNC/linuxcnc/commit/f3c7d024949387392aa2451b4e48947f10ddd9ff
I guess you can do an abstraction of the line setting code like:
#if V3
typedef struct gpiod_line_request gpioline_t
#else
typedef struct gpiod_line_bulk gpioline_t
#endif
struct {
...
// line 109 (or so about) change V2::'struct gpiod_line_bulk *bulk'
// and V3::'struct gpiod_line_request *request' into:
gpioline_t *lineref;
} hal_gpio_bulk_t;
static inline void line_set(gpioline_t *ref, int *vals)
{
#if V3
gpiod_line_request_set_values(ref, vals);
#else
gpiod_line_set_value_bulk(ref, vals);
#endif
}
And then replace the calls in lines 412, 432 and 454 into:
line_set(gpio->out_chips[c].lineref, gpio->out_chips[c].vals);
The rtapi_kfree() calls can then also be simplified into:
rtapi_kfree(gpio->out_chips[c].lineref);
There is a reference to (line 388):
gpiod_line_request_release(gpio->in_chips[c].request);
You could wrap this in an inline too so the body of the code stays the
same, while the dependencies are in a small set of (inlined) functions
at the top of the file.
You can most likely merge #if blocks to reduce the number #if blocks and
thereby improving readability. But that may be best viewed when you have
a good understanding of how and where you need them.
This is not a very comprehensive review, but it may give you some more
inspiration.
--
Greetings Bertho
(disclaimers are disclaimed)
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers