slim_msm: Make sure runtime PM reference count doesn't go -ve

Clients may vote for slimbus controller runtime using pm_runtime_get
and pm_runtime_put APIs. Make sure error is logged when client tries
to call pm_runtime_put more than/before pm_runtime_get and it's
not sent to the runtime PM framework to avoid reference count
going -ve.

Change-Id: I794d5df5e98477b3423c04537eb577383537b1c7
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
diff --git a/drivers/slimbus/slim-msm-ctrl.c b/drivers/slimbus/slim-msm-ctrl.c
index aa67c8c..6c5b380 100644
--- a/drivers/slimbus/slim-msm-ctrl.c
+++ b/drivers/slimbus/slim-msm-ctrl.c
@@ -354,8 +354,13 @@
 static void msm_slim_put_ctrl(struct msm_slim_ctrl *dev)
 {
 #ifdef CONFIG_PM_RUNTIME
+	int ref;
 	pm_runtime_mark_last_busy(dev->dev);
-	pm_runtime_put(dev->dev);
+	ref = atomic_read(&dev->dev->power.usage_count);
+	if (ref <= 0)
+		dev_err(dev->dev, "reference count mismatch:%d", ref);
+	else
+		pm_runtime_put(dev->dev);
 #endif
 }