Add use counters to omap_device to enable multiple potential users of an omap_device. This is needed if ever there are multiple users or multiple instances of a driver with a single omap_device. Without usecounting, with multiple users, the first one to call idle may forcibly idle the device while other users are still active. Signed-off-by: Kevin Hilman <khilman@xxxxxxxxxxxxxxxxxxx> --- arch/arm/plat-omap/include/plat/omap_device.h | 1 + arch/arm/plat-omap/omap_device.c | 9 +++++++++ 2 files changed, 10 insertions(+), 0 deletions(-) diff --git a/arch/arm/plat-omap/include/plat/omap_device.h b/arch/arm/plat-omap/include/plat/omap_device.h index d939246..c504780 100644 --- a/arch/arm/plat-omap/include/plat/omap_device.h +++ b/arch/arm/plat-omap/include/plat/omap_device.h @@ -71,6 +71,7 @@ struct omap_device { s8 pm_lat_level; u8 hwmods_cnt; u8 _state; + u32 _usecount; }; /* Device driver interface (call via platform_data fn ptrs) */ diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c index da649f2..6a8b0ce 100644 --- a/arch/arm/plat-omap/omap_device.c +++ b/arch/arm/plat-omap/omap_device.c @@ -388,6 +388,8 @@ struct omap_device *omap_device_build_ss(const char *pdev_name, int pdev_id, od->pm_lats = pm_lats; od->pm_lats_cnt = pm_lats_cnt; + od->_usecount = 0; + ret = omap_device_register(od); if (ret) goto odbs_exit4; @@ -446,6 +448,9 @@ int omap_device_enable(struct platform_device *pdev) od = _find_by_pdev(pdev); + if (od->_usecount++) + return 0; + if (od->_state == OMAP_DEVICE_STATE_ENABLED) { WARN(1, "omap_device: %s.%d: omap_device_enable() called from " "invalid state\n", od->pdev.name, od->pdev.id); @@ -485,6 +490,9 @@ int omap_device_idle(struct platform_device *pdev) od = _find_by_pdev(pdev); + if (--od->_usecount) + return 0; + if (od->_state != OMAP_DEVICE_STATE_ENABLED) { WARN(1, "omap_device: %s.%d: omap_device_idle() called from " "invalid state\n", od->pdev.name, od->pdev.id); @@ -530,6 +538,7 @@ int omap_device_shutdown(struct platform_device *pdev) omap_hwmod_shutdown(oh); od->_state = OMAP_DEVICE_STATE_SHUTDOWN; + od->_usecount = 0; return ret; } -- 1.6.5.1 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html