Files
u-boot/include
Rasmus Villemoes 008c4b3c31 cyclic: make clients embed a struct cyclic_info in their own data structure
There are of course not a whole lot of examples in-tree yet, but
before they appear, let's make this API change: Instead of separately
allocating a 'struct cyclic_info', make the users embed such an
instance in their own structure, and make the convention that the
callback simply receives the 'struct cyclic_info *', from which the
clients can get their own data using the container_of() macro.

This has a number of advantages.

First, it means cyclic_register() simply cannot fail, simplifying the
code. The necessary storage will simply be allocated automatically
when the client's own structure is allocated (often via
uclass_priv_auto or similar).

Second, code for which CONFIG_CYCLIC is just an option can more easily
be written without #ifdefs, if we just provide an empty struct
cyclic_info {}. For example, the nested CONFIG_IS_ENABLED()s in
https://lore.kernel.org/u-boot/20240316201416.211480-1-marek.vasut+renesas@mailbox.org/
are mostly due to the existence of the 'struct cyclic_info *' member
being guarded by #ifdef CONFIG_CYCLIC.

And we do probably want to avoid the extra memory overhead of that
member when !CONFIG_CYCLIC. But that is automatic if, instead of a
'struct cyclic_info *', one simply embeds a 'struct cyclic_info',
which will have size 0 when !CONFIG_CYCLIC. Also, the no-op
cyclic_register() function can just unconditionally be called, and the
compiler will see that (1) the callback is referenced, so not emit a
warning for a maybe-unused function and (2) see that it can actually
never be reached, so not emit any code for it.

Reviewed-by: Stefan Roese <sr@denx.de>
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
2024-06-16 12:13:44 +02:00
..
2024-01-03 09:22:47 -05:00
2022-10-30 20:07:16 +01:00
2022-09-29 16:07:57 -04:00
2024-05-22 08:55:28 -06:00
2022-09-24 10:47:01 -04:00
2023-08-25 13:54:33 -04:00
2022-07-26 02:30:56 -06:00
2023-08-08 10:22:03 -04:00
2023-12-21 08:54:37 -05:00
2024-02-13 15:38:49 -05:00
2024-01-29 22:35:02 -05:00
2024-04-21 09:07:00 +02:00
2023-02-06 13:04:52 -05:00
2024-05-03 12:22:58 -06:00
2023-05-02 14:23:34 -04:00
2022-10-18 09:32:53 +08:00
2023-01-20 12:27:06 -05:00
2022-07-26 11:29:00 +02:00
2023-11-07 14:50:51 -05:00
2023-12-21 08:54:37 -05:00
2023-10-31 09:08:51 +01:00
2023-04-27 13:51:06 -04:00
2024-06-07 16:20:33 -06:00
2022-07-26 11:29:02 +02:00
2023-12-21 11:59:49 -05:00
2023-08-19 04:12:53 +02:00
2023-12-13 11:35:13 -05:00
2022-10-30 20:07:17 +01:00
2023-12-21 08:54:37 -05:00
2023-10-11 15:43:55 -04:00
2023-12-21 08:54:37 -05:00
2023-11-18 10:08:09 +02:00
2024-03-26 19:58:26 -04:00
2023-01-16 18:01:10 +08:00
2023-12-21 08:54:37 -05:00
2024-03-27 09:23:30 +01:00
2023-11-16 13:49:14 -05:00
2023-10-09 15:24:31 -04:00
2024-05-22 08:55:29 -06:00
2023-02-10 07:41:40 -05:00
2022-12-07 16:04:17 -05:00
2022-12-22 10:31:49 -05:00
2023-11-14 20:04:00 -07:00
2024-05-22 08:55:29 -06:00
2022-09-18 10:26:49 +02:00