@@ -618,7 +618,6 @@ int dprc_setup(struct fsl_mc_device *mc_dev)
struct irq_domain *mc_msi_domain;
bool mc_io_created = false;
bool msi_domain_set = false;
- bool uapi_created = false;
u16 major_ver, minor_ver;
size_t region_size;
int error;
@@ -651,11 +650,6 @@ int dprc_setup(struct fsl_mc_device *mc_dev)
return error;
mc_io_created = true;
- } else {
- error = fsl_mc_uapi_create_device_file(mc_bus);
- if (error < 0)
- return -EPROBE_DEFER;
- uapi_created = true;
}
mc_msi_domain = fsl_mc_find_msi_domain(&mc_dev->dev);
@@ -713,9 +707,6 @@ int dprc_setup(struct fsl_mc_device *mc_dev)
mc_dev->mc_io = NULL;
}
- if (uapi_created)
- fsl_mc_uapi_remove_device_file(mc_bus);
-
return error;
}
EXPORT_SYMBOL_GPL(dprc_setup);
@@ -734,9 +725,15 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
{
int error;
+ if (fsl_mc_is_root_dprc(&mc_dev->dev)) {
+ error = fsl_mc_uapi_create_device_file(to_fsl_mc_bus(mc_dev));
+ if (error < 0)
+ return -EPROBE_DEFER;
+ }
+
error = dprc_setup(mc_dev);
if (error < 0)
- return error;
+ goto uapi_cleanup;
/*
* Discover MC objects in DPRC object:
@@ -759,6 +756,10 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
device_for_each_child(&mc_dev->dev, NULL, __fsl_mc_device_remove);
dprc_cleanup:
dprc_cleanup(mc_dev);
+uapi_cleanup:
+ if (fsl_mc_is_root_dprc(&mc_dev->dev))
+ fsl_mc_uapi_remove_device_file(to_fsl_mc_bus(mc_dev));
+
return error;
}
@@ -792,7 +793,6 @@ static void dprc_teardown_irq(struct fsl_mc_device *mc_dev)
int dprc_cleanup(struct fsl_mc_device *mc_dev)
{
- struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
int error;
/* this function should be called only for DPRCs, it
@@ -821,8 +821,6 @@ int dprc_cleanup(struct fsl_mc_device *mc_dev)
if (!fsl_mc_is_root_dprc(&mc_dev->dev)) {
fsl_destroy_mc_io(mc_dev->mc_io);
mc_dev->mc_io = NULL;
- } else {
- fsl_mc_uapi_remove_device_file(mc_bus);
}
return 0;
@@ -854,6 +852,9 @@ static int dprc_remove(struct fsl_mc_device *mc_dev)
device_for_each_child(&mc_dev->dev, NULL, __fsl_mc_device_remove);
+ if (fsl_mc_is_root_dprc(&mc_dev->dev))
+ fsl_mc_uapi_remove_device_file(to_fsl_mc_bus(mc_dev));
+
dprc_cleanup(mc_dev);
dev_info(&mc_dev->dev, "DPRC device unbound from driver");