coresight: Rearrange platform data probing
We are about to introduce methods to clean up the platform data as we switch to tracking the device reference from "name" to "fwnode handles" for device connections. This requires us to drop the fwnode handle references when the data is no longer required - i.e, when the device probe fails or the device gets unregistered. In order to consolidate the invocation of the cleanup, we delay the platform probing to the very last minute, possibly before invoking the coresight_register. Then, we leave the coresight core code to do the clean up. i.e, if the coresight_register fails, it takes care of freeing the data. Otherwise, coresight_unregister will do the necessary operations. Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
b77e3ed038
commit
af7cfd0f80
|
@ -505,13 +505,6 @@ static int catu_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
struct device *dev = &adev->dev;
|
struct device *dev = &adev->dev;
|
||||||
void __iomem *base;
|
void __iomem *base;
|
||||||
|
|
||||||
pdata = coresight_get_platform_data(dev);
|
|
||||||
if (IS_ERR(pdata)) {
|
|
||||||
ret = PTR_ERR(pdata);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
dev->platform_data = pdata;
|
|
||||||
|
|
||||||
drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
|
drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
|
||||||
if (!drvdata) {
|
if (!drvdata) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
|
@ -544,6 +537,13 @@ static int catu_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
pdata = coresight_get_platform_data(dev);
|
||||||
|
if (IS_ERR(pdata)) {
|
||||||
|
ret = PTR_ERR(pdata);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
dev->platform_data = pdata;
|
||||||
|
|
||||||
drvdata->base = base;
|
drvdata->base = base;
|
||||||
catu_desc.pdata = pdata;
|
catu_desc.pdata = pdata;
|
||||||
catu_desc.dev = dev;
|
catu_desc.dev = dev;
|
||||||
|
|
|
@ -733,11 +733,6 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
struct resource *res = &adev->res;
|
struct resource *res = &adev->res;
|
||||||
struct coresight_desc desc = { 0 };
|
struct coresight_desc desc = { 0 };
|
||||||
|
|
||||||
pdata = coresight_get_platform_data(dev);
|
|
||||||
if (IS_ERR(pdata))
|
|
||||||
return PTR_ERR(pdata);
|
|
||||||
adev->dev.platform_data = pdata;
|
|
||||||
|
|
||||||
drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
|
drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
|
||||||
if (!drvdata)
|
if (!drvdata)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -772,6 +767,11 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
/* This device is not associated with a session */
|
/* This device is not associated with a session */
|
||||||
drvdata->pid = -1;
|
drvdata->pid = -1;
|
||||||
|
|
||||||
|
pdata = coresight_get_platform_data(dev);
|
||||||
|
if (IS_ERR(pdata))
|
||||||
|
return PTR_ERR(pdata);
|
||||||
|
adev->dev.platform_data = pdata;
|
||||||
|
|
||||||
desc.type = CORESIGHT_DEV_TYPE_SINK;
|
desc.type = CORESIGHT_DEV_TYPE_SINK;
|
||||||
desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_BUFFER;
|
desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_BUFFER;
|
||||||
desc.ops = &etb_cs_ops;
|
desc.ops = &etb_cs_ops;
|
||||||
|
|
|
@ -795,11 +795,6 @@ static int etm_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
if (!drvdata)
|
if (!drvdata)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
pdata = coresight_get_platform_data(dev);
|
|
||||||
if (IS_ERR(pdata))
|
|
||||||
return PTR_ERR(pdata);
|
|
||||||
|
|
||||||
adev->dev.platform_data = pdata;
|
|
||||||
drvdata->use_cp14 = fwnode_property_read_bool(dev->fwnode, "arm,cp14");
|
drvdata->use_cp14 = fwnode_property_read_bool(dev->fwnode, "arm,cp14");
|
||||||
dev_set_drvdata(dev, drvdata);
|
dev_set_drvdata(dev, drvdata);
|
||||||
|
|
||||||
|
@ -849,6 +844,13 @@ static int etm_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
etm_init_trace_id(drvdata);
|
etm_init_trace_id(drvdata);
|
||||||
etm_set_default(&drvdata->config);
|
etm_set_default(&drvdata->config);
|
||||||
|
|
||||||
|
pdata = coresight_get_platform_data(dev);
|
||||||
|
if (IS_ERR(pdata)) {
|
||||||
|
ret = PTR_ERR(pdata);
|
||||||
|
goto err_arch_supported;
|
||||||
|
}
|
||||||
|
adev->dev.platform_data = pdata;
|
||||||
|
|
||||||
desc.type = CORESIGHT_DEV_TYPE_SOURCE;
|
desc.type = CORESIGHT_DEV_TYPE_SOURCE;
|
||||||
desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_PROC;
|
desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_PROC;
|
||||||
desc.ops = &etm_cs_ops;
|
desc.ops = &etm_cs_ops;
|
||||||
|
|
|
@ -1089,11 +1089,6 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
if (!drvdata)
|
if (!drvdata)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
pdata = coresight_get_platform_data(dev);
|
|
||||||
if (IS_ERR(pdata))
|
|
||||||
return PTR_ERR(pdata);
|
|
||||||
adev->dev.platform_data = pdata;
|
|
||||||
|
|
||||||
dev_set_drvdata(dev, drvdata);
|
dev_set_drvdata(dev, drvdata);
|
||||||
|
|
||||||
/* Validity for the resource is already checked by the AMBA core */
|
/* Validity for the resource is already checked by the AMBA core */
|
||||||
|
@ -1136,6 +1131,13 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
etm4_init_trace_id(drvdata);
|
etm4_init_trace_id(drvdata);
|
||||||
etm4_set_default(&drvdata->config);
|
etm4_set_default(&drvdata->config);
|
||||||
|
|
||||||
|
pdata = coresight_get_platform_data(dev);
|
||||||
|
if (IS_ERR(pdata)) {
|
||||||
|
ret = PTR_ERR(pdata);
|
||||||
|
goto err_arch_supported;
|
||||||
|
}
|
||||||
|
adev->dev.platform_data = pdata;
|
||||||
|
|
||||||
desc.type = CORESIGHT_DEV_TYPE_SOURCE;
|
desc.type = CORESIGHT_DEV_TYPE_SOURCE;
|
||||||
desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_PROC;
|
desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_PROC;
|
||||||
desc.ops = &etm4_cs_ops;
|
desc.ops = &etm4_cs_ops;
|
||||||
|
|
|
@ -188,11 +188,6 @@ static int funnel_probe(struct device *dev, struct resource *res)
|
||||||
struct funnel_drvdata *drvdata;
|
struct funnel_drvdata *drvdata;
|
||||||
struct coresight_desc desc = { 0 };
|
struct coresight_desc desc = { 0 };
|
||||||
|
|
||||||
pdata = coresight_get_platform_data(dev);
|
|
||||||
if (IS_ERR(pdata))
|
|
||||||
return PTR_ERR(pdata);
|
|
||||||
dev->platform_data = pdata;
|
|
||||||
|
|
||||||
if (is_of_node(dev_fwnode(dev)) &&
|
if (is_of_node(dev_fwnode(dev)) &&
|
||||||
of_device_is_compatible(dev->of_node, "arm,coresight-funnel"))
|
of_device_is_compatible(dev->of_node, "arm,coresight-funnel"))
|
||||||
pr_warn_once("Uses OBSOLETE CoreSight funnel binding\n");
|
pr_warn_once("Uses OBSOLETE CoreSight funnel binding\n");
|
||||||
|
@ -224,6 +219,13 @@ static int funnel_probe(struct device *dev, struct resource *res)
|
||||||
|
|
||||||
dev_set_drvdata(dev, drvdata);
|
dev_set_drvdata(dev, drvdata);
|
||||||
|
|
||||||
|
pdata = coresight_get_platform_data(dev);
|
||||||
|
if (IS_ERR(pdata)) {
|
||||||
|
ret = PTR_ERR(pdata);
|
||||||
|
goto out_disable_clk;
|
||||||
|
}
|
||||||
|
dev->platform_data = pdata;
|
||||||
|
|
||||||
desc.type = CORESIGHT_DEV_TYPE_LINK;
|
desc.type = CORESIGHT_DEV_TYPE_LINK;
|
||||||
desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_MERG;
|
desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_MERG;
|
||||||
desc.ops = &funnel_cs_ops;
|
desc.ops = &funnel_cs_ops;
|
||||||
|
|
|
@ -179,11 +179,6 @@ static int replicator_probe(struct device *dev, struct resource *res)
|
||||||
struct coresight_desc desc = { 0 };
|
struct coresight_desc desc = { 0 };
|
||||||
void __iomem *base;
|
void __iomem *base;
|
||||||
|
|
||||||
pdata = coresight_get_platform_data(dev);
|
|
||||||
if (IS_ERR(pdata))
|
|
||||||
return PTR_ERR(pdata);
|
|
||||||
dev->platform_data = pdata;
|
|
||||||
|
|
||||||
if (is_of_node(dev_fwnode(dev)) &&
|
if (is_of_node(dev_fwnode(dev)) &&
|
||||||
of_device_is_compatible(dev->of_node, "arm,coresight-replicator"))
|
of_device_is_compatible(dev->of_node, "arm,coresight-replicator"))
|
||||||
pr_warn_once("Uses OBSOLETE CoreSight replicator binding\n");
|
pr_warn_once("Uses OBSOLETE CoreSight replicator binding\n");
|
||||||
|
@ -215,6 +210,13 @@ static int replicator_probe(struct device *dev, struct resource *res)
|
||||||
|
|
||||||
dev_set_drvdata(dev, drvdata);
|
dev_set_drvdata(dev, drvdata);
|
||||||
|
|
||||||
|
pdata = coresight_get_platform_data(dev);
|
||||||
|
if (IS_ERR(pdata)) {
|
||||||
|
ret = PTR_ERR(pdata);
|
||||||
|
goto out_disable_clk;
|
||||||
|
}
|
||||||
|
dev->platform_data = pdata;
|
||||||
|
|
||||||
desc.type = CORESIGHT_DEV_TYPE_LINK;
|
desc.type = CORESIGHT_DEV_TYPE_LINK;
|
||||||
desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_SPLIT;
|
desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_SPLIT;
|
||||||
desc.ops = &replicator_cs_ops;
|
desc.ops = &replicator_cs_ops;
|
||||||
|
|
|
@ -810,10 +810,6 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
size_t bitmap_size;
|
size_t bitmap_size;
|
||||||
struct coresight_desc desc = { 0 };
|
struct coresight_desc desc = { 0 };
|
||||||
|
|
||||||
pdata = coresight_get_platform_data(dev);
|
|
||||||
if (IS_ERR(pdata))
|
|
||||||
return PTR_ERR(pdata);
|
|
||||||
adev->dev.platform_data = pdata;
|
|
||||||
drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
|
drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
|
||||||
if (!drvdata)
|
if (!drvdata)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -866,6 +862,13 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
return -EPROBE_DEFER;
|
return -EPROBE_DEFER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pdata = coresight_get_platform_data(dev);
|
||||||
|
if (IS_ERR(pdata)) {
|
||||||
|
ret = PTR_ERR(pdata);
|
||||||
|
goto stm_unregister;
|
||||||
|
}
|
||||||
|
adev->dev.platform_data = pdata;
|
||||||
|
|
||||||
desc.type = CORESIGHT_DEV_TYPE_SOURCE;
|
desc.type = CORESIGHT_DEV_TYPE_SOURCE;
|
||||||
desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE;
|
desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE;
|
||||||
desc.ops = &stm_cs_ops;
|
desc.ops = &stm_cs_ops;
|
||||||
|
|
|
@ -398,13 +398,6 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
struct resource *res = &adev->res;
|
struct resource *res = &adev->res;
|
||||||
struct coresight_desc desc = { 0 };
|
struct coresight_desc desc = { 0 };
|
||||||
|
|
||||||
pdata = coresight_get_platform_data(dev);
|
|
||||||
if (IS_ERR(pdata)) {
|
|
||||||
ret = PTR_ERR(pdata);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
adev->dev.platform_data = pdata;
|
|
||||||
|
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
|
drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
|
||||||
if (!drvdata)
|
if (!drvdata)
|
||||||
|
@ -434,7 +427,6 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
else
|
else
|
||||||
drvdata->size = readl_relaxed(drvdata->base + TMC_RSZ) * 4;
|
drvdata->size = readl_relaxed(drvdata->base + TMC_RSZ) * 4;
|
||||||
|
|
||||||
desc.pdata = pdata;
|
|
||||||
desc.dev = dev;
|
desc.dev = dev;
|
||||||
desc.groups = coresight_tmc_groups;
|
desc.groups = coresight_tmc_groups;
|
||||||
desc.name = dev_name(dev);
|
desc.name = dev_name(dev);
|
||||||
|
@ -467,6 +459,14 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pdata = coresight_get_platform_data(dev);
|
||||||
|
if (IS_ERR(pdata)) {
|
||||||
|
ret = PTR_ERR(pdata);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
adev->dev.platform_data = pdata;
|
||||||
|
desc.pdata = pdata;
|
||||||
|
|
||||||
drvdata->csdev = coresight_register(&desc);
|
drvdata->csdev = coresight_register(&desc);
|
||||||
if (IS_ERR(drvdata->csdev)) {
|
if (IS_ERR(drvdata->csdev)) {
|
||||||
ret = PTR_ERR(drvdata->csdev);
|
ret = PTR_ERR(drvdata->csdev);
|
||||||
|
|
|
@ -125,11 +125,6 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
struct resource *res = &adev->res;
|
struct resource *res = &adev->res;
|
||||||
struct coresight_desc desc = { 0 };
|
struct coresight_desc desc = { 0 };
|
||||||
|
|
||||||
pdata = coresight_get_platform_data(dev);
|
|
||||||
if (IS_ERR(pdata))
|
|
||||||
return PTR_ERR(pdata);
|
|
||||||
dev->platform_data = pdata;
|
|
||||||
|
|
||||||
drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
|
drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
|
||||||
if (!drvdata)
|
if (!drvdata)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -152,6 +147,11 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
/* Disable tpiu to support older devices */
|
/* Disable tpiu to support older devices */
|
||||||
tpiu_disable_hw(drvdata);
|
tpiu_disable_hw(drvdata);
|
||||||
|
|
||||||
|
pdata = coresight_get_platform_data(dev);
|
||||||
|
if (IS_ERR(pdata))
|
||||||
|
return PTR_ERR(pdata);
|
||||||
|
dev->platform_data = pdata;
|
||||||
|
|
||||||
desc.type = CORESIGHT_DEV_TYPE_SINK;
|
desc.type = CORESIGHT_DEV_TYPE_SINK;
|
||||||
desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_PORT;
|
desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_PORT;
|
||||||
desc.ops = &tpiu_cs_ops;
|
desc.ops = &tpiu_cs_ops;
|
||||||
|
|
Loading…
Reference in New Issue