Merge "overlay: writeback: Do not create writeback instance on dumpsys" into klp-dev
diff --git a/msm8974/libhwcomposer/hwc.cpp b/msm8974/libhwcomposer/hwc.cpp
index eed6cff..b26c32a 100644
--- a/msm8974/libhwcomposer/hwc.cpp
+++ b/msm8974/libhwcomposer/hwc.cpp
@@ -677,8 +677,10 @@
     ctx->mRotMgr->getDump(ovDump, 1024);
     dumpsys_log(aBuf, ovDump);
     ovDump[0] = '\0';
-    Writeback::getInstance()->getDump(ovDump, 1024);
-    dumpsys_log(aBuf, ovDump);
+    if(Writeback::getDump(ovDump, 1024)) {
+        dumpsys_log(aBuf, ovDump);
+        ovDump[0] = '\0';
+    }
     strlcpy(buff, aBuf.string(), buff_len);
 }
 
diff --git a/msm8974/liboverlay/overlayWriteback.cpp b/msm8974/liboverlay/overlayWriteback.cpp
index 7d2ede8..d1d3223 100644
--- a/msm8974/liboverlay/overlayWriteback.cpp
+++ b/msm8974/liboverlay/overlayWriteback.cpp
@@ -213,13 +213,6 @@
     return mOpFmt;
 }
 
-void Writeback::getDump(char *buf, size_t len) const {
-    utils::getDump(buf, len, "WBData", mFbData);
-    char str[4] = {'\0'};
-    snprintf(str, 4, "\n");
-    strncat(buf, str, strlen(str));
-}
-
 //static
 
 Writeback *Writeback::getInstance() {
@@ -245,6 +238,17 @@
     }
 }
 
+bool Writeback::getDump(char *buf, size_t len) {
+    if(sWb) {
+        utils::getDump(buf, len, "WBData", sWb->mFbData);
+        char str[4] = {'\0'};
+        snprintf(str, 4, "\n");
+        strncat(buf, str, strlen(str));
+        return true;
+    }
+    return false;
+}
+
 Writeback *Writeback::sWb = 0;
 bool Writeback::sUsed = false;
 
diff --git a/msm8974/liboverlay/overlayWriteback.h b/msm8974/liboverlay/overlayWriteback.h
index 33eb059..9785b64 100644
--- a/msm8974/liboverlay/overlayWriteback.h
+++ b/msm8974/liboverlay/overlayWriteback.h
@@ -87,12 +87,14 @@
     int getFbFd() const { return mFd.getFD(); }
     int getOutputFormat();
     bool setOutputFormat(int mdpFormat);
-    void getDump(char *buf, size_t len) const;
 
     static Writeback* getInstance();
     static void configBegin() { sUsed = false; }
     static void configDone();
     static void clear();
+    //Will take a dump of data structure only if there is an instance existing
+    //Returns true if dump is added to the input buffer, false otherwise
+    static bool getDump(char *buf, size_t len);
 
 private:
     explicit Writeback();