Loading drivers/hwtracing/coresight/of_coresight.c +44 −2 Original line number Diff line number Diff line /* Copyright (c) 2012, 2016 The Linux Foundation. All rights reserved. /* Copyright (c) 2012, 2016-2017, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading @@ -23,7 +23,7 @@ #include <linux/coresight.h> #include <linux/cpumask.h> #include <asm/smp_plat.h> #include <linux/coresight-cti.h> static int of_dev_node_match(struct device *dev, void *data) { Loading Loading @@ -196,3 +196,45 @@ struct coresight_platform_data *of_get_coresight_platform_data( return pdata; } EXPORT_SYMBOL_GPL(of_get_coresight_platform_data); struct coresight_cti_data *of_get_coresight_cti_data( struct device *dev, struct device_node *node) { int i, ret; uint32_t ctis_len; struct device_node *child_node; struct coresight_cti_data *ctidata; ctidata = devm_kzalloc(dev, sizeof(*ctidata), GFP_KERNEL); if (!ctidata) return ERR_PTR(-ENOMEM); if (of_get_property(node, "coresight-ctis", &ctis_len)) ctidata->nr_ctis = ctis_len/sizeof(uint32_t); else return ERR_PTR(-EINVAL); if (ctidata->nr_ctis) { ctidata->names = devm_kzalloc(dev, ctidata->nr_ctis * sizeof(*ctidata->names), GFP_KERNEL); if (!ctidata->names) return ERR_PTR(-ENOMEM); for (i = 0; i < ctidata->nr_ctis; i++) { child_node = of_parse_phandle(node, "coresight-ctis", i); if (!child_node) return ERR_PTR(-EINVAL); ret = of_property_read_string(child_node, "coresight-name", &ctidata->names[i]); of_node_put(child_node); if (ret) return ERR_PTR(ret); } } return ctidata; } EXPORT_SYMBOL(of_get_coresight_cti_data); include/linux/coresight.h +4 −0 Original line number Diff line number Diff line Loading @@ -266,9 +266,13 @@ static inline int coresight_timeout(void __iomem *addr, u32 offset, #ifdef CONFIG_OF extern struct coresight_platform_data *of_get_coresight_platform_data( struct device *dev, struct device_node *node); extern struct coresight_cti_data *of_get_coresight_cti_data( struct device *dev, struct device_node *node); #else static inline struct coresight_platform_data *of_get_coresight_platform_data( struct device *dev, struct device_node *node) { return NULL; } static inlint struct coresight_cti_data *of_get_coresight_cti_data( struct device *dev, struct device_node *node) { return NULL; } #endif #ifdef CONFIG_PID_NS Loading Loading
drivers/hwtracing/coresight/of_coresight.c +44 −2 Original line number Diff line number Diff line /* Copyright (c) 2012, 2016 The Linux Foundation. All rights reserved. /* Copyright (c) 2012, 2016-2017, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading @@ -23,7 +23,7 @@ #include <linux/coresight.h> #include <linux/cpumask.h> #include <asm/smp_plat.h> #include <linux/coresight-cti.h> static int of_dev_node_match(struct device *dev, void *data) { Loading Loading @@ -196,3 +196,45 @@ struct coresight_platform_data *of_get_coresight_platform_data( return pdata; } EXPORT_SYMBOL_GPL(of_get_coresight_platform_data); struct coresight_cti_data *of_get_coresight_cti_data( struct device *dev, struct device_node *node) { int i, ret; uint32_t ctis_len; struct device_node *child_node; struct coresight_cti_data *ctidata; ctidata = devm_kzalloc(dev, sizeof(*ctidata), GFP_KERNEL); if (!ctidata) return ERR_PTR(-ENOMEM); if (of_get_property(node, "coresight-ctis", &ctis_len)) ctidata->nr_ctis = ctis_len/sizeof(uint32_t); else return ERR_PTR(-EINVAL); if (ctidata->nr_ctis) { ctidata->names = devm_kzalloc(dev, ctidata->nr_ctis * sizeof(*ctidata->names), GFP_KERNEL); if (!ctidata->names) return ERR_PTR(-ENOMEM); for (i = 0; i < ctidata->nr_ctis; i++) { child_node = of_parse_phandle(node, "coresight-ctis", i); if (!child_node) return ERR_PTR(-EINVAL); ret = of_property_read_string(child_node, "coresight-name", &ctidata->names[i]); of_node_put(child_node); if (ret) return ERR_PTR(ret); } } return ctidata; } EXPORT_SYMBOL(of_get_coresight_cti_data);
include/linux/coresight.h +4 −0 Original line number Diff line number Diff line Loading @@ -266,9 +266,13 @@ static inline int coresight_timeout(void __iomem *addr, u32 offset, #ifdef CONFIG_OF extern struct coresight_platform_data *of_get_coresight_platform_data( struct device *dev, struct device_node *node); extern struct coresight_cti_data *of_get_coresight_cti_data( struct device *dev, struct device_node *node); #else static inline struct coresight_platform_data *of_get_coresight_platform_data( struct device *dev, struct device_node *node) { return NULL; } static inlint struct coresight_cti_data *of_get_coresight_cti_data( struct device *dev, struct device_node *node) { return NULL; } #endif #ifdef CONFIG_PID_NS Loading