linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] staging: fsl-mc: multiple root DPRCs
@ 2015-10-04  7:09 itai.katz
  2015-10-04  7:09 ` [PATCH 1/5] staging: fsl-mc: abstract test for existence of fsl-mc bus itai.katz
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: itai.katz @ 2015-10-04  7:09 UTC (permalink / raw)
  To: gregkh, arnd, devel, linux-kernel
  Cc: stuart.yoder, german.rivera, lijun.pan, scottwood, agraf,
	bhamciu1, R89243, bhupesh.sharma, nir.erez, richard.schmitt,
	dan.carpenter, Itai Katz

From: Itai Katz <itai.katz@freescale.com>

This patch series adds support for supporting multiple root 
DPRCs, which is an item on the TODO list. (This situation can
is possible when assigning multiple DPRCs to KVM virtual machines.)

Patch 1 abstracts the test for existence of an fsl-mc bus instance
into a function.

Patch 2 abstracts the test for whether a dprc is a root dprc 
into a function.

Patch 3 replaces use of the dev_root field in the bus type
struct to identify the root dprc with a more flexible
pointer traversal mechanism.

Patch 4 adds a counter to track the number of root dprcs.

Patch 5 removes all references to the now unused dev_root

Itai Katz (5):
  staging: fsl-mc: abstract test for existence of fsl-mc bus
  staging: fsl-mc: abstract test for whether a dprc is a root dprc
  staging: fsl-mc: add function to return pointer to root dprc
  staging: fsl-mc: add counter to track number of root DPRCs
  staging: fsl-mc: remove references to dev_root

 drivers/staging/fsl-mc/bus/mc-bus.c |   74 ++++++++++++++++++++++++++++++-----
 drivers/staging/fsl-mc/include/mc.h |    2 +
 2 files changed, 66 insertions(+), 10 deletions(-)

-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/5] staging: fsl-mc: abstract test for existence of fsl-mc bus
  2015-10-04  7:09 [PATCH 0/5] staging: fsl-mc: multiple root DPRCs itai.katz
@ 2015-10-04  7:09 ` itai.katz
  2015-10-04  7:09 ` [PATCH 2/5] staging: fsl-mc: abstract test for whether a dprc is a root dprc itai.katz
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: itai.katz @ 2015-10-04  7:09 UTC (permalink / raw)
  To: gregkh, arnd, devel, linux-kernel
  Cc: stuart.yoder, german.rivera, lijun.pan, scottwood, agraf,
	bhamciu1, R89243, bhupesh.sharma, nir.erez, richard.schmitt,
	dan.carpenter, Itai Katz

From: Itai Katz <itai.katz@freescale.com>

Add function to test for existence of an fsl-mc bus instance
instead of doing this by looking directly at a field in the
bus type struct.

Signed-off-by: Itai Katz <itai.katz@freescale.com>
---
 drivers/staging/fsl-mc/bus/mc-bus.c |   13 +++++++++++--
 drivers/staging/fsl-mc/include/mc.h |    2 ++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c b/drivers/staging/fsl-mc/bus/mc-bus.c
index 92e0702..2aaeb3a 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -39,7 +39,7 @@ static int fsl_mc_bus_match(struct device *dev, struct device_driver *drv)
 	bool major_version_mismatch = false;
 	bool minor_version_mismatch = false;
 
-	if (WARN_ON(!fsl_mc_bus_type.dev_root))
+	if (WARN_ON(!fsl_mc_bus_exists()))
 		goto out;
 
 	if (!mc_drv->match_id_table)
@@ -206,6 +206,15 @@ void fsl_mc_driver_unregister(struct fsl_mc_driver *mc_driver)
 }
 EXPORT_SYMBOL_GPL(fsl_mc_driver_unregister);
 
+/**
+ * fsl_mc_bus_exists - check if a root dprc exists
+ */
+bool fsl_mc_bus_exists(void)
+{
+	return fsl_mc_bus_type.dev_root;
+}
+EXPORT_SYMBOL_GPL(fsl_mc_bus_exists);
+
 static int get_dprc_icid(struct fsl_mc_io *mc_io,
 			 int container_id, u16 *icid)
 {
@@ -407,7 +416,7 @@ int fsl_mc_device_add(struct dprc_obj_desc *obj_desc,
 
 			mc_io2 = mc_io;
 
-			if (!fsl_mc_bus_type.dev_root)
+			if (!fsl_mc_bus_exists())
 				fsl_mc_bus_type.dev_root = &mc_dev->dev;
 		}
 
diff --git a/drivers/staging/fsl-mc/include/mc.h b/drivers/staging/fsl-mc/include/mc.h
index 860bf26..a933291 100644
--- a/drivers/staging/fsl-mc/include/mc.h
+++ b/drivers/staging/fsl-mc/include/mc.h
@@ -182,6 +182,8 @@ int __must_check __fsl_mc_driver_register(struct fsl_mc_driver *fsl_mc_driver,
 
 void fsl_mc_driver_unregister(struct fsl_mc_driver *driver);
 
+bool fsl_mc_bus_exists(void);
+
 int __must_check fsl_mc_portal_allocate(struct fsl_mc_device *mc_dev,
 					u16 mc_io_flags,
 					struct fsl_mc_io **new_mc_io);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/5] staging: fsl-mc: abstract test for whether a dprc is a root dprc
  2015-10-04  7:09 [PATCH 0/5] staging: fsl-mc: multiple root DPRCs itai.katz
  2015-10-04  7:09 ` [PATCH 1/5] staging: fsl-mc: abstract test for existence of fsl-mc bus itai.katz
@ 2015-10-04  7:09 ` itai.katz
  2015-10-06  8:47   ` Mike Rapoport
  2015-10-04  7:09 ` [PATCH 3/5] staging: fsl-mc: add function to return pointer to " itai.katz
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: itai.katz @ 2015-10-04  7:09 UTC (permalink / raw)
  To: gregkh, arnd, devel, linux-kernel
  Cc: stuart.yoder, german.rivera, lijun.pan, scottwood, agraf,
	bhamciu1, R89243, bhupesh.sharma, nir.erez, richard.schmitt,
	dan.carpenter, Itai Katz

From: Itai Katz <itai.katz@freescale.com>

Instead of relying on assumptions about fields in data
structures, abstract the test for whether a dprc is a root
dprc into a function.

Signed-off-by: Itai Katz <itai.katz@freescale.com>
---
 drivers/staging/fsl-mc/bus/mc-bus.c |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c b/drivers/staging/fsl-mc/bus/mc-bus.c
index 2aaeb3a..6a6c5a6 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -22,6 +22,8 @@
 
 static struct kmem_cache *mc_dev_cache;
 
+static bool fsl_mc_is_root_dprc(struct device *dev);
+
 /**
  * fsl_mc_bus_match - device to driver matching callback
  * @dev: the MC object device structure to match against
@@ -50,7 +52,7 @@ static int fsl_mc_bus_match(struct device *dev, struct device_driver *drv)
 	 * Only exception is the root DPRC, which is a special case.
 	 */
 	if ((mc_dev->obj_desc.state & DPRC_OBJ_STATE_PLUGGED) == 0 &&
-	    &mc_dev->dev != fsl_mc_bus_type.dev_root)
+	    !fsl_mc_is_root_dprc(&mc_dev->dev))
 		goto out;
 
 	/*
@@ -215,6 +217,14 @@ bool fsl_mc_bus_exists(void)
 }
 EXPORT_SYMBOL_GPL(fsl_mc_bus_exists);
 
+/**
+ * fsl_mc_is_root_dprc - function to check if a given device is a root dprc
+ */
+static bool fsl_mc_is_root_dprc(struct device *dev)
+{
+	return dev == fsl_mc_bus_type.dev_root;
+}
+
 static int get_dprc_icid(struct fsl_mc_io *mc_io,
 			 int container_id, u16 *icid)
 {
@@ -500,7 +510,7 @@ void fsl_mc_device_remove(struct fsl_mc_device *mc_dev)
 			mc_dev->mc_io = NULL;
 		}
 
-		if (&mc_dev->dev == fsl_mc_bus_type.dev_root)
+		if (fsl_mc_is_root_dprc(&mc_dev->dev))
 			fsl_mc_bus_type.dev_root = NULL;
 	}
 
@@ -726,7 +736,7 @@ static int fsl_mc_bus_remove(struct platform_device *pdev)
 {
 	struct fsl_mc *mc = platform_get_drvdata(pdev);
 
-	if (WARN_ON(&mc->root_mc_bus_dev->dev != fsl_mc_bus_type.dev_root))
+	if (WARN_ON(!fsl_mc_is_root_dprc(&mc->root_mc_bus_dev->dev)))
 		return -EINVAL;
 
 	fsl_mc_device_remove(mc->root_mc_bus_dev);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/5] staging: fsl-mc: add function to return pointer to root dprc
  2015-10-04  7:09 [PATCH 0/5] staging: fsl-mc: multiple root DPRCs itai.katz
  2015-10-04  7:09 ` [PATCH 1/5] staging: fsl-mc: abstract test for existence of fsl-mc bus itai.katz
  2015-10-04  7:09 ` [PATCH 2/5] staging: fsl-mc: abstract test for whether a dprc is a root dprc itai.katz
@ 2015-10-04  7:09 ` itai.katz
  2015-10-04  7:09 ` [PATCH 4/5] staging: fsl-mc: add counter to track number of root DPRCs itai.katz
  2015-10-04  7:09 ` [PATCH 5/5] staging: fsl-mc: remove references to dev_root itai.katz
  4 siblings, 0 replies; 8+ messages in thread
From: itai.katz @ 2015-10-04  7:09 UTC (permalink / raw)
  To: gregkh, arnd, devel, linux-kernel
  Cc: stuart.yoder, german.rivera, lijun.pan, scottwood, agraf,
	bhamciu1, R89243, bhupesh.sharma, nir.erez, richard.schmitt,
	dan.carpenter, Itai Katz

From: Itai Katz <itai.katz@freescale.com>

To support multiple root dprcs, instead of relying on the
dev_root field of the bus type struct, instead create a
function to traverse to the root dprc and return a pointer
to the device struct

Signed-off-by: Itai Katz <itai.katz@freescale.com>
---
 drivers/staging/fsl-mc/bus/mc-bus.c |   38 +++++++++++++++++++++++++++++++----
 1 file changed, 34 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c b/drivers/staging/fsl-mc/bus/mc-bus.c
index 6a6c5a6..37f51f3 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -218,11 +218,34 @@ bool fsl_mc_bus_exists(void)
 EXPORT_SYMBOL_GPL(fsl_mc_bus_exists);
 
 /**
+* fsl_mc_get_root_dprc - function to traverse to the root dprc
+*/
+static void fsl_mc_get_root_dprc(struct device *dev,
+				 struct device **root_dprc_dev)
+{
+	if (WARN_ON(!dev)) {
+		*root_dprc_dev = NULL;
+	} else if (WARN_ON(dev->bus != &fsl_mc_bus_type)) {
+		*root_dprc_dev = NULL;
+	} else {
+		*root_dprc_dev = dev;
+		while ((*root_dprc_dev)->parent->bus == &fsl_mc_bus_type)
+			*root_dprc_dev = (*root_dprc_dev)->parent;
+	}
+}
+
+/**
  * fsl_mc_is_root_dprc - function to check if a given device is a root dprc
  */
 static bool fsl_mc_is_root_dprc(struct device *dev)
 {
-	return dev == fsl_mc_bus_type.dev_root;
+	struct device *root_dprc_dev;
+
+	fsl_mc_get_root_dprc(dev, &root_dprc_dev);
+	if (!root_dprc_dev)
+		return false;
+	else
+		return dev == root_dprc_dev;
 }
 
 static int get_dprc_icid(struct fsl_mc_io *mc_io,
@@ -253,11 +276,18 @@ common_cleanup:
 	return error;
 }
 
-static int translate_mc_addr(enum dprc_region_type mc_region_type,
+static int translate_mc_addr(struct fsl_mc_device *mc_dev,
+			     enum dprc_region_type mc_region_type,
 			     u64 mc_offset, phys_addr_t *phys_addr)
 {
 	int i;
-	struct fsl_mc *mc = dev_get_drvdata(fsl_mc_bus_type.dev_root->parent);
+	struct device *root_dprc_dev;
+	struct fsl_mc *mc;
+
+	fsl_mc_get_root_dprc(&mc_dev->dev, &root_dprc_dev);
+	if (WARN_ON(!root_dprc_dev))
+		return -EINVAL;
+	mc = dev_get_drvdata(root_dprc_dev->parent);
 
 	if (mc->num_translation_ranges == 0) {
 		/*
@@ -328,7 +358,7 @@ static int fsl_mc_device_get_mmio_regions(struct fsl_mc_device *mc_dev,
 		}
 
 		WARN_ON(region_desc.size == 0);
-		error = translate_mc_addr(mc_region_type,
+		error = translate_mc_addr(mc_dev, mc_region_type,
 					  region_desc.base_offset,
 					  &regions[i].start);
 		if (error < 0) {
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/5] staging: fsl-mc: add counter to track number of root DPRCs
  2015-10-04  7:09 [PATCH 0/5] staging: fsl-mc: multiple root DPRCs itai.katz
                   ` (2 preceding siblings ...)
  2015-10-04  7:09 ` [PATCH 3/5] staging: fsl-mc: add function to return pointer to " itai.katz
@ 2015-10-04  7:09 ` itai.katz
  2015-10-04  7:09 ` [PATCH 5/5] staging: fsl-mc: remove references to dev_root itai.katz
  4 siblings, 0 replies; 8+ messages in thread
From: itai.katz @ 2015-10-04  7:09 UTC (permalink / raw)
  To: gregkh, arnd, devel, linux-kernel
  Cc: stuart.yoder, german.rivera, lijun.pan, scottwood, agraf,
	bhamciu1, R89243, bhupesh.sharma, nir.erez, richard.schmitt,
	dan.carpenter, Itai Katz

From: Itai Katz <itai.katz@freescale.com>

Add a counter to track the number of root DPRCs.
When this counter is greater then 0 it means that at least
one root DPRC device exists.

Signed-off-by: Itai Katz <itai.katz@freescale.com>
---
 drivers/staging/fsl-mc/bus/mc-bus.c |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c b/drivers/staging/fsl-mc/bus/mc-bus.c
index 37f51f3..8a2b99c 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -109,6 +109,8 @@ struct bus_type fsl_mc_bus_type = {
 };
 EXPORT_SYMBOL_GPL(fsl_mc_bus_type);
 
+static atomic_t root_dprc_count = ATOMIC_INIT(0);
+
 static int fsl_mc_driver_probe(struct device *dev)
 {
 	struct fsl_mc_driver *mc_drv;
@@ -213,7 +215,7 @@ EXPORT_SYMBOL_GPL(fsl_mc_driver_unregister);
  */
 bool fsl_mc_bus_exists(void)
 {
-	return fsl_mc_bus_type.dev_root;
+	return atomic_read(&root_dprc_count) > 0;
 }
 EXPORT_SYMBOL_GPL(fsl_mc_bus_exists);
 
@@ -458,6 +460,8 @@ int fsl_mc_device_add(struct dprc_obj_desc *obj_desc,
 
 			if (!fsl_mc_bus_exists())
 				fsl_mc_bus_type.dev_root = &mc_dev->dev;
+
+			atomic_inc(&root_dprc_count);
 		}
 
 		error = get_dprc_icid(mc_io2, obj_desc->id, &mc_dev->icid);
@@ -540,8 +544,13 @@ void fsl_mc_device_remove(struct fsl_mc_device *mc_dev)
 			mc_dev->mc_io = NULL;
 		}
 
-		if (fsl_mc_is_root_dprc(&mc_dev->dev))
+		if (fsl_mc_is_root_dprc(&mc_dev->dev)) {
 			fsl_mc_bus_type.dev_root = NULL;
+			if (atomic_read(&root_dprc_count) > 0)
+				atomic_dec(&root_dprc_count);
+			else
+				WARN_ON(1);
+		}
 	}
 
 	if (mc_bus)
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 5/5] staging: fsl-mc: remove references to dev_root
  2015-10-04  7:09 [PATCH 0/5] staging: fsl-mc: multiple root DPRCs itai.katz
                   ` (3 preceding siblings ...)
  2015-10-04  7:09 ` [PATCH 4/5] staging: fsl-mc: add counter to track number of root DPRCs itai.katz
@ 2015-10-04  7:09 ` itai.katz
  4 siblings, 0 replies; 8+ messages in thread
From: itai.katz @ 2015-10-04  7:09 UTC (permalink / raw)
  To: gregkh, arnd, devel, linux-kernel
  Cc: stuart.yoder, german.rivera, lijun.pan, scottwood, agraf,
	bhamciu1, R89243, bhupesh.sharma, nir.erez, richard.schmitt,
	dan.carpenter, Itai Katz

From: Itai Katz <itai.katz@freescale.com>

The dev_root field in the bus type struct has been replaced by a
new mechanism to identify the root dprc.  Remove all references
to dev_root.

Signed-off-by: Itai Katz <itai.katz@freescale.com>
---
 drivers/staging/fsl-mc/bus/mc-bus.c |    4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c b/drivers/staging/fsl-mc/bus/mc-bus.c
index 8a2b99c..fd13053 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -458,9 +458,6 @@ int fsl_mc_device_add(struct dprc_obj_desc *obj_desc,
 
 			mc_io2 = mc_io;
 
-			if (!fsl_mc_bus_exists())
-				fsl_mc_bus_type.dev_root = &mc_dev->dev;
-
 			atomic_inc(&root_dprc_count);
 		}
 
@@ -545,7 +542,6 @@ void fsl_mc_device_remove(struct fsl_mc_device *mc_dev)
 		}
 
 		if (fsl_mc_is_root_dprc(&mc_dev->dev)) {
-			fsl_mc_bus_type.dev_root = NULL;
 			if (atomic_read(&root_dprc_count) > 0)
 				atomic_dec(&root_dprc_count);
 			else
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/5] staging: fsl-mc: abstract test for whether a dprc is a root dprc
  2015-10-04  7:09 ` [PATCH 2/5] staging: fsl-mc: abstract test for whether a dprc is a root dprc itai.katz
@ 2015-10-06  8:47   ` Mike Rapoport
  2015-10-06 13:39     ` Katz Itai
  0 siblings, 1 reply; 8+ messages in thread
From: Mike Rapoport @ 2015-10-06  8:47 UTC (permalink / raw)
  To: itai.katz
  Cc: gregkh, arnd, devel, linux-kernel, stuart.yoder, bhupesh.sharma,
	german.rivera, agraf, bhamciu1, nir.erez, scottwood, lijun.pan,
	R89243, dan.carpenter, richard.schmitt

On Sun, Oct 04, 2015 at 10:09:51AM +0300, itai.katz@freescale.com wrote:
> From: Itai Katz <itai.katz@freescale.com>
> 
> Instead of relying on assumptions about fields in data
> structures, abstract the test for whether a dprc is a root
> dprc into a function.
> 
> Signed-off-by: Itai Katz <itai.katz@freescale.com>
> ---
>  drivers/staging/fsl-mc/bus/mc-bus.c |   16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c b/drivers/staging/fsl-mc/bus/mc-bus.c
> index 2aaeb3a..6a6c5a6 100644
> --- a/drivers/staging/fsl-mc/bus/mc-bus.c
> +++ b/drivers/staging/fsl-mc/bus/mc-bus.c
> @@ -22,6 +22,8 @@
>  
>  static struct kmem_cache *mc_dev_cache;
>  
> +static bool fsl_mc_is_root_dprc(struct device *dev);

Prefer defining functions before they are used rather than using forward
declarations.

> +
>  /**
>   * fsl_mc_bus_match - device to driver matching callback
>   * @dev: the MC object device structure to match against
> @@ -50,7 +52,7 @@ static int fsl_mc_bus_match(struct device *dev, struct device_driver *drv)
>  	 * Only exception is the root DPRC, which is a special case.
>  	 */
>  	if ((mc_dev->obj_desc.state & DPRC_OBJ_STATE_PLUGGED) == 0 &&
> -	    &mc_dev->dev != fsl_mc_bus_type.dev_root)
> +	    !fsl_mc_is_root_dprc(&mc_dev->dev))
>  		goto out;
>  
>  	/*
> @@ -215,6 +217,14 @@ bool fsl_mc_bus_exists(void)
>  }
>  EXPORT_SYMBOL_GPL(fsl_mc_bus_exists);
>  
> +/**
> + * fsl_mc_is_root_dprc - function to check if a given device is a root dprc
> + */
> +static bool fsl_mc_is_root_dprc(struct device *dev)
> +{
> +	return dev == fsl_mc_bus_type.dev_root;
> +}
> +
>  static int get_dprc_icid(struct fsl_mc_io *mc_io,
>  			 int container_id, u16 *icid)
>  {
> @@ -500,7 +510,7 @@ void fsl_mc_device_remove(struct fsl_mc_device *mc_dev)
>  			mc_dev->mc_io = NULL;
>  		}
>  
> -		if (&mc_dev->dev == fsl_mc_bus_type.dev_root)
> +		if (fsl_mc_is_root_dprc(&mc_dev->dev))
>  			fsl_mc_bus_type.dev_root = NULL;
>  	}
>  
> @@ -726,7 +736,7 @@ static int fsl_mc_bus_remove(struct platform_device *pdev)
>  {
>  	struct fsl_mc *mc = platform_get_drvdata(pdev);
>  
> -	if (WARN_ON(&mc->root_mc_bus_dev->dev != fsl_mc_bus_type.dev_root))
> +	if (WARN_ON(!fsl_mc_is_root_dprc(&mc->root_mc_bus_dev->dev)))
>  		return -EINVAL;
>  
>  	fsl_mc_device_remove(mc->root_mc_bus_dev);
> -- 
> 1.7.9.5
> 
> _______________________________________________
> devel mailing list
> devel@linuxdriverproject.org
> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH 2/5] staging: fsl-mc: abstract test for whether a dprc is a root dprc
  2015-10-06  8:47   ` Mike Rapoport
@ 2015-10-06 13:39     ` Katz Itai
  0 siblings, 0 replies; 8+ messages in thread
From: Katz Itai @ 2015-10-06 13:39 UTC (permalink / raw)
  To: Mike Rapoport
  Cc: gregkh, arnd, devel, linux-kernel, Stuart Yoder, Sharma Bhupesh,
	Jose Rivera, agraf, Hamciuc Bogdan, Erez Nir, Scott Wood,
	Lijun Pan, Marginean Alexandru, dan.carpenter, Richard Schmitt


> -----Original Message-----
> From: Mike Rapoport [mailto:mike.rapoport@gmail.com]
> Sent: Tuesday, October 06, 2015 11:48 AM
> To: katz Itai-RM05202 <itai.katz@freescale.com>
> Cc: gregkh@linuxfoundation.org; arnd@arndb.de;
> devel@driverdev.osuosl.org; linux-kernel@vger.kernel.org; Yoder Stuart-
> B08248 <stuart.yoder@freescale.com>; Sharma Bhupesh-B45370
> <bhupesh.sharma@freescale.com>; Rivera Jose-B46482
> <German.Rivera@freescale.com>; agraf@suse.de; Hamciuc Bogdan-
> BHAMCIU1 <bhamciu1@freescale.com>; Erez Nir-RM30794
> <nir.erez@freescale.com>; Wood Scott-B07421
> <scottwood@freescale.com>; Pan Lijun-B44306 <Lijun.Pan@freescale.com>;
> Marginean Alexandru-R89243 <R89243@freescale.com>;
> dan.carpenter@oracle.com; Schmitt Richard-B43082
> <richard.schmitt@freescale.com>
> Subject: Re: [PATCH 2/5] staging: fsl-mc: abstract test for whether a dprc is a
> root dprc
> 
> On Sun, Oct 04, 2015 at 10:09:51AM +0300, itai.katz@freescale.com wrote:
> > From: Itai Katz <itai.katz@freescale.com>
> >
> > Instead of relying on assumptions about fields in data
> > structures, abstract the test for whether a dprc is a root
> > dprc into a function.
> >
> > Signed-off-by: Itai Katz <itai.katz@freescale.com>
> > ---
> >  drivers/staging/fsl-mc/bus/mc-bus.c |   16 +++++++++++++---
> >  1 file changed, 13 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c b/drivers/staging/fsl-
> mc/bus/mc-bus.c
> > index 2aaeb3a..6a6c5a6 100644
> > --- a/drivers/staging/fsl-mc/bus/mc-bus.c
> > +++ b/drivers/staging/fsl-mc/bus/mc-bus.c
> > @@ -22,6 +22,8 @@
> >
> >  static struct kmem_cache *mc_dev_cache;
> >
> > +static bool fsl_mc_is_root_dprc(struct device *dev);
> 
> Prefer defining functions before they are used rather than using forward
> declarations.

Thanks for the comment.
Since this patch was already added in Greg's staging git tree, I'll consider fixing this in a separate cleanup patch.

> 
> > +
> >  /**
> >   * fsl_mc_bus_match - device to driver matching callback
> >   * @dev: the MC object device structure to match against
> > @@ -50,7 +52,7 @@ static int fsl_mc_bus_match(struct device *dev, struct
> device_driver *drv)
> >  	 * Only exception is the root DPRC, which is a special case.
> >  	 */
> >  	if ((mc_dev->obj_desc.state & DPRC_OBJ_STATE_PLUGGED) == 0
> &&
> > -	    &mc_dev->dev != fsl_mc_bus_type.dev_root)
> > +	    !fsl_mc_is_root_dprc(&mc_dev->dev))
> >  		goto out;
> >
> >  	/*
> > @@ -215,6 +217,14 @@ bool fsl_mc_bus_exists(void)
> >  }
> >  EXPORT_SYMBOL_GPL(fsl_mc_bus_exists);
> >
> > +/**
> > + * fsl_mc_is_root_dprc - function to check if a given device is a root dprc
> > + */
> > +static bool fsl_mc_is_root_dprc(struct device *dev)
> > +{
> > +	return dev == fsl_mc_bus_type.dev_root;
> > +}
> > +
> >  static int get_dprc_icid(struct fsl_mc_io *mc_io,
> >  			 int container_id, u16 *icid)
> >  {
> > @@ -500,7 +510,7 @@ void fsl_mc_device_remove(struct fsl_mc_device
> *mc_dev)
> >  			mc_dev->mc_io = NULL;
> >  		}
> >
> > -		if (&mc_dev->dev == fsl_mc_bus_type.dev_root)
> > +		if (fsl_mc_is_root_dprc(&mc_dev->dev))
> >  			fsl_mc_bus_type.dev_root = NULL;
> >  	}
> >
> > @@ -726,7 +736,7 @@ static int fsl_mc_bus_remove(struct
> platform_device *pdev)
> >  {
> >  	struct fsl_mc *mc = platform_get_drvdata(pdev);
> >
> > -	if (WARN_ON(&mc->root_mc_bus_dev->dev !=
> fsl_mc_bus_type.dev_root))
> > +	if (WARN_ON(!fsl_mc_is_root_dprc(&mc->root_mc_bus_dev-
> >dev)))
> >  		return -EINVAL;
> >
> >  	fsl_mc_device_remove(mc->root_mc_bus_dev);
> > --
> > 1.7.9.5
> >
> > _______________________________________________
> > devel mailing list
> > devel@linuxdriverproject.org
> > http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-10-06 13:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-04  7:09 [PATCH 0/5] staging: fsl-mc: multiple root DPRCs itai.katz
2015-10-04  7:09 ` [PATCH 1/5] staging: fsl-mc: abstract test for existence of fsl-mc bus itai.katz
2015-10-04  7:09 ` [PATCH 2/5] staging: fsl-mc: abstract test for whether a dprc is a root dprc itai.katz
2015-10-06  8:47   ` Mike Rapoport
2015-10-06 13:39     ` Katz Itai
2015-10-04  7:09 ` [PATCH 3/5] staging: fsl-mc: add function to return pointer to " itai.katz
2015-10-04  7:09 ` [PATCH 4/5] staging: fsl-mc: add counter to track number of root DPRCs itai.katz
2015-10-04  7:09 ` [PATCH 5/5] staging: fsl-mc: remove references to dev_root itai.katz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).