Commit df5e9b5f authored by Nipun Gupta's avatar Nipun Gupta Committed by Greg Kroah-Hartman
Browse files

fsl-mc: add helper macro to determine if a device is of fsl_mc type



Add a helper macro to return if a device has a bus type of fsl_mc.
This makes the bus driver code more readable and provides a way for
drivers like the SMMU driver to easily check the bus type.

Signed-off-by: default avatarNipun Gupta <nipun.gupta@nxp.com>
Signed-off-by: default avatarBharat Bhushan <bharat.bhushan@nxp.com>
Acked-by: default avatarStuart Yoder <stuart.yoder@nxp.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 243d38aa
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -649,7 +649,7 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
		/*
		/*
		 * This is a child DPRC:
		 * This is a child DPRC:
		 */
		 */
		if (WARN_ON(parent_dev->bus != &fsl_mc_bus_type))
		if (WARN_ON(!dev_is_fsl_mc(parent_dev)))
			return -EINVAL;
			return -EINVAL;


		if (WARN_ON(mc_dev->obj_desc.region_count == 0))
		if (WARN_ON(mc_dev->obj_desc.region_count == 0))
@@ -681,7 +681,7 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
		 */
		 */
		struct irq_domain *mc_msi_domain;
		struct irq_domain *mc_msi_domain;


		if (WARN_ON(parent_dev->bus == &fsl_mc_bus_type))
		if (WARN_ON(dev_is_fsl_mc(parent_dev)))
			return -EINVAL;
			return -EINVAL;


		error = fsl_mc_find_msi_domain(parent_dev,
		error = fsl_mc_find_msi_domain(parent_dev,
+1 −1
Original line number Original line Diff line number Diff line
@@ -35,7 +35,7 @@ static int its_fsl_mc_msi_prepare(struct irq_domain *msi_domain,
	struct fsl_mc_device *mc_bus_dev;
	struct fsl_mc_device *mc_bus_dev;
	struct msi_domain_info *msi_info;
	struct msi_domain_info *msi_info;


	if (WARN_ON(dev->bus != &fsl_mc_bus_type))
	if (WARN_ON(!dev_is_fsl_mc(dev)))
		return -EINVAL;
		return -EINVAL;


	mc_bus_dev = to_fsl_mc_device(dev);
	mc_bus_dev = to_fsl_mc_device(dev);
+3 −3
Original line number Original line Diff line number Diff line
@@ -281,7 +281,7 @@ int __must_check fsl_mc_portal_allocate(struct fsl_mc_device *mc_dev,
	if (mc_dev->flags & FSL_MC_IS_DPRC) {
	if (mc_dev->flags & FSL_MC_IS_DPRC) {
		mc_bus_dev = mc_dev;
		mc_bus_dev = mc_dev;
	} else {
	} else {
		if (WARN_ON(mc_dev->dev.parent->bus != &fsl_mc_bus_type))
		if (WARN_ON(!dev_is_fsl_mc(mc_dev->dev.parent)))
			return error;
			return error;


		mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
		mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
@@ -420,7 +420,7 @@ int __must_check fsl_mc_object_allocate(struct fsl_mc_device *mc_dev,
	if (WARN_ON(mc_dev->flags & FSL_MC_IS_DPRC))
	if (WARN_ON(mc_dev->flags & FSL_MC_IS_DPRC))
		goto error;
		goto error;


	if (WARN_ON(mc_dev->dev.parent->bus != &fsl_mc_bus_type))
	if (WARN_ON(!dev_is_fsl_mc(mc_dev->dev.parent)))
		goto error;
		goto error;


	if (WARN_ON(pool_type == FSL_MC_POOL_DPMCP))
	if (WARN_ON(pool_type == FSL_MC_POOL_DPMCP))
@@ -678,7 +678,7 @@ static int fsl_mc_allocator_probe(struct fsl_mc_device *mc_dev)
		return -EINVAL;
		return -EINVAL;


	mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
	mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
	if (WARN_ON(mc_bus_dev->dev.bus != &fsl_mc_bus_type))
	if (WARN_ON(!dev_is_fsl_mc(&mc_bus_dev->dev)))
		return -EINVAL;
		return -EINVAL;


	mc_bus = to_fsl_mc_bus(mc_bus_dev);
	mc_bus = to_fsl_mc_bus(mc_bus_dev);
+3 −3
Original line number Original line Diff line number Diff line
@@ -236,11 +236,11 @@ static void fsl_mc_get_root_dprc(struct device *dev,
{
{
	if (WARN_ON(!dev)) {
	if (WARN_ON(!dev)) {
		*root_dprc_dev = NULL;
		*root_dprc_dev = NULL;
	} else if (WARN_ON(dev->bus != &fsl_mc_bus_type)) {
	} else if (WARN_ON(!dev_is_fsl_mc(dev))) {
		*root_dprc_dev = NULL;
		*root_dprc_dev = NULL;
	} else {
	} else {
		*root_dprc_dev = dev;
		*root_dprc_dev = dev;
		while ((*root_dprc_dev)->parent->bus == &fsl_mc_bus_type)
		while (dev_is_fsl_mc((*root_dprc_dev)->parent))
			*root_dprc_dev = (*root_dprc_dev)->parent;
			*root_dprc_dev = (*root_dprc_dev)->parent;
	}
	}
}
}
@@ -434,7 +434,7 @@ int fsl_mc_device_add(struct dprc_obj_desc *obj_desc,
	struct fsl_mc_bus *mc_bus = NULL;
	struct fsl_mc_bus *mc_bus = NULL;
	struct fsl_mc_device *parent_mc_dev;
	struct fsl_mc_device *parent_mc_dev;


	if (parent_dev->bus == &fsl_mc_bus_type)
	if (dev_is_fsl_mc(parent_dev))
		parent_mc_dev = to_fsl_mc_device(parent_dev);
		parent_mc_dev = to_fsl_mc_device(parent_dev);
	else
	else
		parent_mc_dev = NULL;
		parent_mc_dev = NULL;
+7 −0
Original line number Original line Diff line number Diff line
@@ -166,6 +166,13 @@ struct fsl_mc_device {
#define to_fsl_mc_device(_dev) \
#define to_fsl_mc_device(_dev) \
	container_of(_dev, struct fsl_mc_device, dev)
	container_of(_dev, struct fsl_mc_device, dev)


#ifdef CONFIG_FSL_MC_BUS
#define dev_is_fsl_mc(_dev) ((_dev)->bus == &fsl_mc_bus_type)
#else
/* If fsl-mc bus is not present device cannot belong to fsl-mc bus */
#define dev_is_fsl_mc(_dev) (0)
#endif

/*
/*
 * module_fsl_mc_driver() - Helper macro for drivers that don't do
 * module_fsl_mc_driver() - Helper macro for drivers that don't do
 * anything special in module init/exit.  This eliminates a lot of
 * anything special in module init/exit.  This eliminates a lot of