We are using the AD9361 with the no-OS driver on a Xilinx w/ MicroBlaze FPGA on our custom board. The reference clock is derived from a cable connection to the main box. So far, things are working fine. But, I need to support the situation where that cable is unplugged/re-plugged. The board is still powered, but the reference clock will be disrupted. For one thing, I noticed that the Multi-Chip Sync gets misaligned and can't recover. I believe the best thing to do when the system detects a link change on the cable, is to re-run the ad9361_init() function.
The problem is that the driver does not seem designed to handle repeated calls to the ad9361_init() function. The allocated memory blocks are never freed, and eventually you get a -ENOMEM return on one of the lower-level function calls. I created a function to free the zmalloc'd memory that were previously allocated in ad9361_init(), but I'm not sure about the malloc'd memory in ad9361_clk_register() and register_clocks(). Don't these need to be free'd? If so, how should I code that?