Unload Routine of a Battery Miniclass Driver
The Unload routine for a battery miniclass driver ensures that all the driver's devices have been removed and frees any resources the miniclass driver has allocated.
The Unload routine should first check to ensure that all its devices have been removed and, if not, do the following for each remaining device:
Call BatteryClassUnload to inform the class driver that the miniclass driver is unloading the device.
Disable any device notifications from lower drivers, such as the ACPI driver, using that driver's interface.
Delete the device object for the device by calling IoDeleteDevice, as follows:
IoDeleteDevice (NewBatt->DeviceObject);
After all the miniclass driver's devices are unloaded, the Unload routine should free any resources allocated by the miniclass driver.
The miniclass driver's Unload routine can be called at any time after all the driver's devices have been removed. The PnP Manager calls the Unload routine in the context of a system thread at IRQL = PASSIVE_LEVEL.