On Wed, 17 Aug 2022 at 22:30, Jassi Brar <[email protected]> wrote: > > On Wed, 17 Aug 2022 at 07:44, Sughosh Ganu <[email protected]> wrote: > ..... > > diff --git a/lib/fwu_updates/fwu.c b/lib/fwu_updates/fwu.c > > new file mode 100644 > > index 0000000000..9808036eec > > --- /dev/null > > +++ b/lib/fwu_updates/fwu.c > > @@ -0,0 +1,22 @@ > > +// SPDX-License-Identifier: GPL-2.0-or-later > > +/* > > + * Copyright (c) 2022, Linaro Limited > > + */ > > + > > +#include <fwu.h> > > +#include <fwu_mdata.h> > > + > > +__weak int fwu_plat_get_update_index(u32 *update_idx) > > +{ > > + int ret; > > + u32 active_idx; > > + > > + ret = fwu_get_active_index(&active_idx); > > + > > + if (ret < 0) > > + return -1; > > + > > + *update_idx = active_idx ^= 0x1; > > + > It shoud be > *update_idx = (active_idx + 1) % CONFIG_FWU_NUM_BANKS;
As mentioned in the commit message, this is a weak function for the case where CONFIG_FWU_NUM_BANKS = 2, where the above logic works since the fwu_get_active_index() function checks that a sane value is being returned for the active_index. However, with the logic that you suggest, this function can be extended for platforms with the number of banks more than 2. I will incorporate this in the next version. Thanks. -sughosh > > cheers.

