Hello,
On Tue, Jan 26, 2021 at 5:06 PM Alexander Antonov
<alexander.antonov@xxxxxxxxxxxxxxx> wrote:
Introduce helper functions to control PCIe root ports list.[SNIP]
These helpers will be used in the follow-up patch.
Signed-off-by: Alexander Antonov <alexander.antonov@xxxxxxxxxxxxxxx>
---
+static int iio_root_ports_list_insert(struct iio_root_ports_list *list,Why is this +1 needed since you already have the number of
+ struct iio_root_port * const rp)
+{
+ struct iio_root_port **tmp_buf;
+
+ if (list && rp) {
+ rp->idx = list->nr_entries++;
+ /* One more for NULL.*/
+ tmp_buf = realloc(list->rps,
+ (list->nr_entries + 1) * sizeof(*list->rps));
entries in the list?
Thanks,
Namhyung
+ if (!tmp_buf) {
+ pr_err("Failed to realloc memory\n");
+ return -ENOMEM;
+ }
+ tmp_buf[rp->idx] = rp;
+ tmp_buf[list->nr_entries] = NULL;
+ list->rps = tmp_buf;
+ }
+ return 0;
+}
--
2.19.1