I have not seen this explicitly documented anywhere, but if you want to switch between access point mode (uap8xxx module) and wlan mode (sd8xxx module) then you need to soft reset the wireless hardware *before* unloading the module. Otherwise, the new module will load, but the hardware will not be recognized by the system (e.g., /sys/class/net/uap0 and /sys/class/net/mlan0, respectively, won't even show up meaning that there is no hardware recognition).
The way to reset the module is not obvious (and is buried in the source code) but is as follows:
For uap8xxx, before unloading, issue the command:
cat 2 >| /proc/uap/uap0/hwstatus
This triggers the case HWReset in uap_proc.c and calls the function uap_soft_reset(). The message 'reset hw' is sent to the syslog.
For sd8xxx, there is no corresponding /proc/mlan/mlan0/hwstatus created in /proc and there is no HWReset in the corresponding wlan_proc.c
Instead, you issue the command:
iwpriv mlan0 softreset
This has the effect of ultimately calling the analogous wlan_soft_reset() function (though it's name seems to differ depending on driver version). No syslog message is generated.
This still leaves me with a couple of questions:
1. Why is this not better documented given that the modules cannot be switched properly without it? i.e., it's pretty basic functionality
2. Why doesn't the module code itself *automatically* trigger a software reset upon being unloaded? This would make it all seemless
3. Why are soft resets of uap8xxx and sd8xxx treated asymmetrically? i.e. why does uap8xxx use 'echo 2>| /proc/uap/uap0/hwstatus' while sd8xxx uses 'iwpriv mlan0 softreset'