qcacld-3.0: Use ref count to sync unload and /dev/wlan access

As a part of driver load, a device file /dev/wlan is created to provide
control to the userspace to turn ON and OFF the wifi. This file also acts
as a holding-the-context entity for the userspace till the host driver
and firmware are properly up and ready as a part of driver probe.

In a scenario where driver probe fails, there can be an occurrence of a
race condition wherein the driver gets unloaded in the probe error path
before the userspace releases the control of the /dev/wlan file.
This leads to a NULL pointer access as the file memory gets deleted as
part of driver unload.

To achieve a serialization between the userspace context, where file is
being accessed, and the driver context, where unload is being done,
implement a simple reference counting through which the driver unload
waits till userspace cleanly releases access to the file.

Change-Id: I3dc214397c53b76111da33dc0ae6db296fc98cb4
CRs-Fixed: 2660321
1 file changed