On 7/28/23 03:52, Simon Glass wrote:
[...]
@@ -1341,6 +1358,13 @@ static int gpio_post_probe(struct udevice *dev)
if (!uc_priv->name)
return -ENOMEM;
+ uc_priv->claimed = calloc(DIV_ROUND_UP(uc_priv->gpio_count, 32),
+ sizeof(*uc_priv->claimed));
+ if (!uc_priv->claimed) {
+ free(uc_priv->name);
+ return -ENOMEM;
+ }
We already have the name[] array which holds the name for each GPIO.
What do you think about a struct for each GPIO, with both the name and
the bool in it. It is messy to have two separate, mirrored arrays.
I think that would not be memory efficient, which is why I picked the
array. You would basically waste a few bytes for each "claimed" flag
instead of just one bit for each flag.
[...]