Commit b55f00c6 authored by Itai Katz's avatar Itai Katz Committed by Greg Kroah-Hartman

staging: fsl-mc: abstract test for whether a dprc is a root dprc

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: default avatarItai Katz <itai.katz@freescale.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 14f92805
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
static struct kmem_cache *mc_dev_cache; 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 * fsl_mc_bus_match - device to driver matching callback
* @dev: the MC object device structure to match against * @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) ...@@ -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. * Only exception is the root DPRC, which is a special case.
*/ */
if ((mc_dev->obj_desc.state & DPRC_OBJ_STATE_PLUGGED) == 0 && 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; goto out;
/* /*
...@@ -215,6 +217,14 @@ bool fsl_mc_bus_exists(void) ...@@ -215,6 +217,14 @@ bool fsl_mc_bus_exists(void)
} }
EXPORT_SYMBOL_GPL(fsl_mc_bus_exists); 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, static int get_dprc_icid(struct fsl_mc_io *mc_io,
int container_id, u16 *icid) int container_id, u16 *icid)
{ {
...@@ -500,7 +510,7 @@ void fsl_mc_device_remove(struct fsl_mc_device *mc_dev) ...@@ -500,7 +510,7 @@ void fsl_mc_device_remove(struct fsl_mc_device *mc_dev)
mc_dev->mc_io = NULL; 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; fsl_mc_bus_type.dev_root = NULL;
} }
...@@ -726,7 +736,7 @@ static int fsl_mc_bus_remove(struct platform_device *pdev) ...@@ -726,7 +736,7 @@ static int fsl_mc_bus_remove(struct platform_device *pdev)
{ {
struct fsl_mc *mc = platform_get_drvdata(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; return -EINVAL;
fsl_mc_device_remove(mc->root_mc_bus_dev); fsl_mc_device_remove(mc->root_mc_bus_dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment