From 213c59501bbd6da8c56e95f90f8a8c6af2682002 Mon Sep 17 00:00:00 2001
From: Razvan Stefanescu <razvan.stefanescu@freescale.com>
Date: Thu, 18 Feb 2016 10:54:40 +0200
Subject: [PATCH 217/226] dpaa2-evb: Add object version check

Abort probing if DPDMUX object version is smaller than required.

Signed-off-by: Razvan Stefanescu <razvan.stefanescu@freescale.com>
---
 drivers/staging/fsl-dpaa2/evb/evb.c |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

--- a/drivers/staging/fsl-dpaa2/evb/evb.c
+++ b/drivers/staging/fsl-dpaa2/evb/evb.c
@@ -44,6 +44,10 @@
 #include "dpdmux.h"
 #include "dpdmux-cmd.h"
 
+/* Minimal supported DPDMUX version */
+#define DPDMUX_MIN_VER_MAJOR			5
+#define DPDMUX_MIN_VER_MINOR			0
+
 /* IRQ index */
 #define DPDMUX_MAX_IRQ_NUM			2
 
@@ -1004,6 +1008,17 @@ static int evb_init(struct fsl_mc_device
 		goto err_close;
 	}
 
+	/* Minimum supported DPDMUX version check */
+	if (priv->attr.version.major < DPDMUX_MIN_VER_MAJOR ||
+	    (priv->attr.version.major == DPDMUX_MIN_VER_MAJOR &&
+	     priv->attr.version.minor < DPDMUX_MIN_VER_MINOR)) {
+		dev_err(dev, "DPDMUX version %d.%d not supported. Use %d.%d or greater.\n",
+			priv->attr.version.major, priv->attr.version.minor,
+			DPDMUX_MIN_VER_MAJOR, DPDMUX_MIN_VER_MAJOR);
+		err = -ENOTSUPP;
+		goto err_close;
+	}
+
 	err = dpdmux_reset(priv->mc_io, 0, priv->mux_handle);
 	if (unlikely(err)) {
 		dev_err(dev, "dpdmux_reset err %d\n", err);
