coresight: Add support for releasing platform specific data
authorSuzuki K Poulose <suzuki.poulose@arm.com>
Wed, 19 Jun 2019 19:53:01 +0000 (13:53 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 20 Jun 2019 05:56:13 +0000 (07:56 +0200)
Add a helper to clean up the platform specific data provided
by the firmware. This will be later used for dropping the necessary
references when we switch to the fwnode handles for tracking
connections.

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>
drivers/hwtracing/coresight/coresight-platform.c
drivers/hwtracing/coresight/coresight-priv.h
drivers/hwtracing/coresight/coresight.c

index f500de61e7f907ff611684729baf7ca0e9e7cc42..53d6eed44a203d09f3d8ecce7dcbd7ca02ef5e50 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/cpumask.h>
 #include <asm/smp_plat.h>
 
+#include "coresight-priv.h"
 /*
  * coresight_alloc_conns: Allocate connections record for each output
  * port from the device.
@@ -311,7 +312,7 @@ struct coresight_platform_data *
 coresight_get_platform_data(struct device *dev)
 {
        int ret = -ENOENT;
-       struct coresight_platform_data *pdata;
+       struct coresight_platform_data *pdata = NULL;
        struct fwnode_handle *fwnode = dev_fwnode(dev);
 
        if (IS_ERR_OR_NULL(fwnode))
@@ -329,6 +330,9 @@ coresight_get_platform_data(struct device *dev)
        if (!ret)
                return pdata;
 error:
+       if (!IS_ERR_OR_NULL(pdata))
+               /* Cleanup the connection information */
+               coresight_release_platform_data(pdata);
        return ERR_PTR(ret);
 }
 EXPORT_SYMBOL_GPL(coresight_get_platform_data);
index e0684d06e9ee9b0cf1a139cd84742cc559358d2b..c21642114fc31f8590f0e9a15b14ad815f3129b0 100644 (file)
@@ -200,4 +200,8 @@ static inline void *coresight_get_uci_data(const struct amba_id *id)
        return 0;
 }
 
+static inline void
+coresight_release_platform_data(struct coresight_platform_data *pdata)
+{}
+
 #endif
index 96e15154a56635b92e52cc6fe2b966a44a10a99e..526141c2f876247c147303e06276885553e7595d 100644 (file)
@@ -1250,6 +1250,8 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
 err_free_csdev:
        kfree(csdev);
 err_out:
+       /* Cleanup the connection information */
+       coresight_release_platform_data(desc->pdata);
        return ERR_PTR(ret);
 }
 EXPORT_SYMBOL_GPL(coresight_register);
@@ -1259,6 +1261,7 @@ void coresight_unregister(struct coresight_device *csdev)
        etm_perf_del_symlink_sink(csdev);
        /* Remove references of that device in the topology */
        coresight_remove_conns(csdev);
+       coresight_release_platform_data(csdev->pdata);
        device_unregister(&csdev->dev);
 }
 EXPORT_SYMBOL_GPL(coresight_unregister);