/* Shut down omap_device @od by calling all .deactivate_func() entries in the omap_device's pm_lats table and then shutting down all of the underlying omap_hwmods. Used when a device is being "removed" or a device driver is being unloaded. Returns -EINVAL if the omap_device is not currently enabled or idle, or passes along the return value of _omap_device_deactivate().  */
int omap_device_shutdown(struct platform_device *pdev)
/* Shut down omap_device @od by calling all .deactivate_func() entries in the omap_device's pm_lats table and then shutting down all of the underlying omap_hwmods. Used when a device is being "removed" or a device driver is being unloaded. Returns -EINVAL if the omap_device is not currently enabled or idle, or passes along the return value of _omap_device_deactivate().  */
int omap_device_shutdown(struct platform_device *pdev)
{
	int ret, i;
	struct omap_device *od;
	struct omap_hwmod *oh;
	od = _find_by_pdev(pdev);
	if (od->_state != OMAP_DEVICE_STATE_ENABLED &&
	    od->_state != OMAP_DEVICE_STATE_IDLE) {
		WARN(1, "omap_device: %s.%d: omap_device_shutdown() called "
		     "from invalid state\n", od->pdev.name, od->pdev.id);
		return -EINVAL;
	}
	ret = _omap_device_deactivate(od, IGNORE_WAKEUP_LAT);
	for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++)
		omap_hwmod_shutdown(oh);
	od->_state = OMAP_DEVICE_STATE_SHUTDOWN;
	return ret;
}