SW Gain Table not applied into the HW

Hello, I posted a reply to https://ez.analog.com/linux-device-drivers/microcontroller-no-os-drivers/f/q-a/85862/modifying-gain-table/107988#107988 but because it is already closed, I probably won't get any answer there.

We are using AD9361 and want to play with the Rx Amplification in manual mode using the Full Gain Table.

The problem we have is that, when modifying the values in full_gain_table[][][] in ad9361.c, we see no change.

I have already root caused the problem:

We do:

1) ad9361_init() -> ad9361_reset() // Hard reset
2)                       -> ad9361_setup() // In here this calls ad9361_load_gt() which loads the table
3) ad9361_set_no_ch_mode() -> ad9361_reset() // Hard reset
4)                                              -> ad9361_setup() // Calls ad9361_load_gt() again but table loading is skipped because considered done at step 2):

      static int32_t ad9361_load_gt(struct ad9361_rf_phy *phy, uint64_t freq, uint32_t dest)

            /* check if table is present */
            if (phy->current_table == band)
                   return 0;

    phy->current_table = NO_GAIN_TABLE;

So, I think that we either one of the following three issues here:
 - calling ad9361_set_no_ch_mode() is maybe not allowed after ad9361_init().
 - ad9361_reset() somehow maybe should not do a hard reset but rather a soft reset so that the table remains in the chip
 - bug in the driver? perhaps it should reset phy->current_table in ad9361_reset() as done in the above workaround

What do you think AD support? Don't we have a wider issue here when calling ad9361_init(); and then ad9361_set_no_ch_mode(); with the latter performing a HW reset again? Or are we calling those functions in the wrong ordering? But then we still have the same issue with ad9361_reset() being called twice :-/ It seems to me the cleanest would be to blend ad9361_init() and ad9361_set_no_ch_mode() into just one function at the end of which ad9361_reset() and ad9361_setup() would be called just once.

Please comment. Thanks,
Xavier Boniface