1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
6 #include <linux/kernel.h>
7 #include <linux/init.h>
8 #include <linux/types.h>
9 #include <linux/device.h>
11 #include <linux/err.h>
12 #include <linux/export.h>
13 #include <linux/slab.h>
14 #include <linux/mutex.h>
15 #include <linux/clk.h>
16 #include <linux/coresight.h>
17 #include <linux/of_platform.h>
18 #include <linux/delay.h>
19 #include <linux/pm_runtime.h>
21 #include "coresight-priv.h"
23 static DEFINE_MUTEX(coresight_mutex);
26 * struct coresight_node - elements of a path, from source to sink
27 * @csdev: Address of an element.
28 * @link: hook to the list.
30 struct coresight_node {
31 struct coresight_device *csdev;
32 struct list_head link;
36 * When operating Coresight drivers from the sysFS interface, only a single
37 * path can exist from a tracer (associated to a CPU) to a sink.
39 static DEFINE_PER_CPU(struct list_head *, tracer_path);
42 * As of this writing only a single STM can be found in CS topologies. Since
43 * there is no way to know if we'll ever see more and what kind of
44 * configuration they will enact, for the time being only define a single path
47 static struct list_head *stm_path;
50 * When losing synchronisation a new barrier packet needs to be inserted at the
51 * beginning of the data collected in a buffer. That way the decoder knows that
52 * it needs to look for another sync sequence.
54 const u32 barrier_pkt[4] = {0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff};
56 static int coresight_id_match(struct device *dev, void *data)
58 int trace_id, i_trace_id;
59 struct coresight_device *csdev, *i_csdev;
62 i_csdev = to_coresight_device(dev);
65 * No need to care about oneself and components that are not
66 * sources or not enabled
68 if (i_csdev == csdev || !i_csdev->enable ||
69 i_csdev->type != CORESIGHT_DEV_TYPE_SOURCE)
72 /* Get the source ID for both compoment */
73 trace_id = source_ops(csdev)->trace_id(csdev);
74 i_trace_id = source_ops(i_csdev)->trace_id(i_csdev);
76 /* All you need is one */
77 if (trace_id == i_trace_id)
83 static int coresight_source_is_unique(struct coresight_device *csdev)
85 int trace_id = source_ops(csdev)->trace_id(csdev);
87 /* this shouldn't happen */
91 return !bus_for_each_dev(&coresight_bustype, NULL,
92 csdev, coresight_id_match);
95 static int coresight_find_link_inport(struct coresight_device *csdev,
96 struct coresight_device *parent)
99 struct coresight_connection *conn;
101 for (i = 0; i < parent->nr_outport; i++) {
102 conn = &parent->conns[i];
103 if (conn->child_dev == csdev)
104 return conn->child_port;
107 dev_err(&csdev->dev, "couldn't find inport, parent: %s, child: %s\n",
108 dev_name(&parent->dev), dev_name(&csdev->dev));
113 static int coresight_find_link_outport(struct coresight_device *csdev,
114 struct coresight_device *child)
117 struct coresight_connection *conn;
119 for (i = 0; i < csdev->nr_outport; i++) {
120 conn = &csdev->conns[i];
121 if (conn->child_dev == child)
122 return conn->outport;
125 dev_err(&csdev->dev, "couldn't find outport, parent: %s, child: %s\n",
126 dev_name(&csdev->dev), dev_name(&child->dev));
131 static int coresight_enable_sink(struct coresight_device *csdev, u32 mode)
136 * We need to make sure the "new" session is compatible with the
137 * existing "mode" of operation.
139 if (sink_ops(csdev)->enable) {
140 ret = sink_ops(csdev)->enable(csdev, mode);
143 csdev->enable = true;
146 atomic_inc(csdev->refcnt);
151 static void coresight_disable_sink(struct coresight_device *csdev)
153 if (atomic_dec_return(csdev->refcnt) == 0) {
154 if (sink_ops(csdev)->disable) {
155 sink_ops(csdev)->disable(csdev);
156 csdev->enable = false;
161 static int coresight_enable_link(struct coresight_device *csdev,
162 struct coresight_device *parent,
163 struct coresight_device *child)
167 int refport, inport, outport;
169 if (!parent || !child)
172 inport = coresight_find_link_inport(csdev, parent);
173 outport = coresight_find_link_outport(csdev, child);
174 link_subtype = csdev->subtype.link_subtype;
176 if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_MERG)
178 else if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_SPLIT)
186 if (atomic_inc_return(&csdev->refcnt[refport]) == 1) {
187 if (link_ops(csdev)->enable) {
188 ret = link_ops(csdev)->enable(csdev, inport, outport);
194 csdev->enable = true;
199 static void coresight_disable_link(struct coresight_device *csdev,
200 struct coresight_device *parent,
201 struct coresight_device *child)
205 int refport, inport, outport;
207 if (!parent || !child)
210 inport = coresight_find_link_inport(csdev, parent);
211 outport = coresight_find_link_outport(csdev, child);
212 link_subtype = csdev->subtype.link_subtype;
214 if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_MERG) {
216 nr_conns = csdev->nr_inport;
217 } else if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_SPLIT) {
219 nr_conns = csdev->nr_outport;
225 if (atomic_dec_return(&csdev->refcnt[refport]) == 0) {
226 if (link_ops(csdev)->disable)
227 link_ops(csdev)->disable(csdev, inport, outport);
230 for (i = 0; i < nr_conns; i++)
231 if (atomic_read(&csdev->refcnt[i]) != 0)
234 csdev->enable = false;
237 static int coresight_enable_source(struct coresight_device *csdev, u32 mode)
241 if (!coresight_source_is_unique(csdev)) {
242 dev_warn(&csdev->dev, "traceID %d not unique\n",
243 source_ops(csdev)->trace_id(csdev));
247 if (!csdev->enable) {
248 if (source_ops(csdev)->enable) {
249 ret = source_ops(csdev)->enable(csdev, NULL, mode);
253 csdev->enable = true;
256 atomic_inc(csdev->refcnt);
262 * coresight_disable_source - Drop the reference count by 1 and disable
263 * the device if there are no users left.
265 * @csdev - The coresight device to disable
267 * Returns true if the device has been disabled.
269 static bool coresight_disable_source(struct coresight_device *csdev)
271 if (atomic_dec_return(csdev->refcnt) == 0) {
272 if (source_ops(csdev)->disable)
273 source_ops(csdev)->disable(csdev, NULL);
274 csdev->enable = false;
276 return !csdev->enable;
279 void coresight_disable_path(struct list_head *path)
282 struct coresight_node *nd;
283 struct coresight_device *csdev, *parent, *child;
285 list_for_each_entry(nd, path, link) {
290 * ETF devices are tricky... They can be a link or a sink,
291 * depending on how they are configured. If an ETF has been
292 * "activated" it will be configured as a sink, otherwise
293 * go ahead with the link configuration.
295 if (type == CORESIGHT_DEV_TYPE_LINKSINK)
296 type = (csdev == coresight_get_sink(path)) ?
297 CORESIGHT_DEV_TYPE_SINK :
298 CORESIGHT_DEV_TYPE_LINK;
301 case CORESIGHT_DEV_TYPE_SINK:
302 coresight_disable_sink(csdev);
304 case CORESIGHT_DEV_TYPE_SOURCE:
305 /* sources are disabled from either sysFS or Perf */
307 case CORESIGHT_DEV_TYPE_LINK:
308 parent = list_prev_entry(nd, link)->csdev;
309 child = list_next_entry(nd, link)->csdev;
310 coresight_disable_link(csdev, parent, child);
318 int coresight_enable_path(struct list_head *path, u32 mode)
323 struct coresight_node *nd;
324 struct coresight_device *csdev, *parent, *child;
326 list_for_each_entry_reverse(nd, path, link) {
331 * ETF devices are tricky... They can be a link or a sink,
332 * depending on how they are configured. If an ETF has been
333 * "activated" it will be configured as a sink, otherwise
334 * go ahead with the link configuration.
336 if (type == CORESIGHT_DEV_TYPE_LINKSINK)
337 type = (csdev == coresight_get_sink(path)) ?
338 CORESIGHT_DEV_TYPE_SINK :
339 CORESIGHT_DEV_TYPE_LINK;
342 case CORESIGHT_DEV_TYPE_SINK:
343 ret = coresight_enable_sink(csdev, mode);
345 * Sink is the first component turned on. If we
346 * failed to enable the sink, there are no components
347 * that need disabling. Disabling the path here
348 * would mean we could disrupt an existing session.
353 case CORESIGHT_DEV_TYPE_SOURCE:
354 /* sources are enabled from either sysFS or Perf */
356 case CORESIGHT_DEV_TYPE_LINK:
357 parent = list_prev_entry(nd, link)->csdev;
358 child = list_next_entry(nd, link)->csdev;
359 ret = coresight_enable_link(csdev, parent, child);
371 coresight_disable_path(path);
375 struct coresight_device *coresight_get_sink(struct list_head *path)
377 struct coresight_device *csdev;
382 csdev = list_last_entry(path, struct coresight_node, link)->csdev;
383 if (csdev->type != CORESIGHT_DEV_TYPE_SINK &&
384 csdev->type != CORESIGHT_DEV_TYPE_LINKSINK)
390 static int coresight_enabled_sink(struct device *dev, void *data)
393 struct coresight_device *csdev = to_coresight_device(dev);
395 if ((csdev->type == CORESIGHT_DEV_TYPE_SINK ||
396 csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) &&
399 * Now that we have a handle on the sink for this session,
400 * disable the sysFS "enable_sink" flag so that possible
401 * concurrent perf session that wish to use another sink don't
402 * trip on it. Doing so has no ramification for the current
406 csdev->activated = false;
415 * coresight_get_enabled_sink - returns the first enabled sink found on the bus
416 * @deactivate: Whether the 'enable_sink' flag should be reset
418 * When operated from perf the deactivate parameter should be set to 'true'.
419 * That way the "enabled_sink" flag of the sink that was selected can be reset,
420 * allowing for other concurrent perf sessions to choose a different sink.
422 * When operated from sysFS users have full control and as such the deactivate
423 * parameter should be set to 'false', hence mandating users to explicitly
426 struct coresight_device *coresight_get_enabled_sink(bool deactivate)
428 struct device *dev = NULL;
430 dev = bus_find_device(&coresight_bustype, NULL, &deactivate,
431 coresight_enabled_sink);
433 return dev ? to_coresight_device(dev) : NULL;
437 * coresight_grab_device - Power up this device and any of the helper
438 * devices connected to it for trace operation. Since the helper devices
439 * don't appear on the trace path, they should be handled along with the
442 static void coresight_grab_device(struct coresight_device *csdev)
446 for (i = 0; i < csdev->nr_outport; i++) {
447 struct coresight_device *child = csdev->conns[i].child_dev;
449 if (child && child->type == CORESIGHT_DEV_TYPE_HELPER)
450 pm_runtime_get_sync(child->dev.parent);
452 pm_runtime_get_sync(csdev->dev.parent);
456 * coresight_drop_device - Release this device and any of the helper
457 * devices connected to it.
459 static void coresight_drop_device(struct coresight_device *csdev)
463 pm_runtime_put(csdev->dev.parent);
464 for (i = 0; i < csdev->nr_outport; i++) {
465 struct coresight_device *child = csdev->conns[i].child_dev;
467 if (child && child->type == CORESIGHT_DEV_TYPE_HELPER)
468 pm_runtime_put(child->dev.parent);
473 * _coresight_build_path - recursively build a path from a @csdev to a sink.
474 * @csdev: The device to start from.
475 * @path: The list to add devices to.
477 * The tree of Coresight device is traversed until an activated sink is
478 * found. From there the sink is added to the list along with all the
479 * devices that led to that point - the end result is a list from source
480 * to sink. In that list the source is the first device and the sink the
483 static int _coresight_build_path(struct coresight_device *csdev,
484 struct coresight_device *sink,
485 struct list_head *path)
489 struct coresight_node *node;
491 /* An activated sink has been found. Enqueue the element */
495 /* Not a sink - recursively explore each port found on this element */
496 for (i = 0; i < csdev->nr_outport; i++) {
497 struct coresight_device *child_dev = csdev->conns[i].child_dev;
500 _coresight_build_path(child_dev, sink, path) == 0) {
511 * A path from this element to a sink has been found. The elements
512 * leading to the sink are already enqueued, all that is left to do
513 * is tell the PM runtime core we need this element and add a node
516 node = kzalloc(sizeof(struct coresight_node), GFP_KERNEL);
520 coresight_grab_device(csdev);
522 list_add(&node->link, path);
527 struct list_head *coresight_build_path(struct coresight_device *source,
528 struct coresight_device *sink)
530 struct list_head *path;
534 return ERR_PTR(-EINVAL);
536 path = kzalloc(sizeof(struct list_head), GFP_KERNEL);
538 return ERR_PTR(-ENOMEM);
540 INIT_LIST_HEAD(path);
542 rc = _coresight_build_path(source, sink, path);
552 * coresight_release_path - release a previously built path.
553 * @path: the path to release.
555 * Go through all the elements of a path and 1) removed it from the list and
556 * 2) free the memory allocated for each node.
558 void coresight_release_path(struct list_head *path)
560 struct coresight_device *csdev;
561 struct coresight_node *nd, *next;
563 list_for_each_entry_safe(nd, next, path, link) {
566 coresight_drop_device(csdev);
575 /** coresight_validate_source - make sure a source has the right credentials
576 * @csdev: the device structure for a source.
577 * @function: the function this was called from.
579 * Assumes the coresight_mutex is held.
581 static int coresight_validate_source(struct coresight_device *csdev,
582 const char *function)
587 subtype = csdev->subtype.source_subtype;
589 if (type != CORESIGHT_DEV_TYPE_SOURCE) {
590 dev_err(&csdev->dev, "wrong device type in %s\n", function);
594 if (subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_PROC &&
595 subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE) {
596 dev_err(&csdev->dev, "wrong device subtype in %s\n", function);
603 int coresight_enable(struct coresight_device *csdev)
606 struct coresight_device *sink;
607 struct list_head *path;
608 enum coresight_dev_subtype_source subtype;
610 subtype = csdev->subtype.source_subtype;
612 mutex_lock(&coresight_mutex);
614 ret = coresight_validate_source(csdev, __func__);
620 * There could be multiple applications driving the software
621 * source. So keep the refcount for each such user when the
622 * source is already enabled.
624 if (subtype == CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE)
625 atomic_inc(csdev->refcnt);
630 * Search for a valid sink for this session but don't reset the
631 * "enable_sink" flag in sysFS. Users get to do that explicitly.
633 sink = coresight_get_enabled_sink(false);
639 path = coresight_build_path(csdev, sink);
641 pr_err("building path(s) failed\n");
646 ret = coresight_enable_path(path, CS_MODE_SYSFS);
650 ret = coresight_enable_source(csdev, CS_MODE_SYSFS);
655 case CORESIGHT_DEV_SUBTYPE_SOURCE_PROC:
657 * When working from sysFS it is important to keep track
658 * of the paths that were created so that they can be
659 * undone in 'coresight_disable()'. Since there can only
660 * be a single session per tracer (when working from sysFS)
661 * a per-cpu variable will do just fine.
663 cpu = source_ops(csdev)->cpu_id(csdev);
664 per_cpu(tracer_path, cpu) = path;
666 case CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE:
670 /* We can't be here */
675 mutex_unlock(&coresight_mutex);
679 coresight_disable_path(path);
682 coresight_release_path(path);
685 EXPORT_SYMBOL_GPL(coresight_enable);
687 void coresight_disable(struct coresight_device *csdev)
690 struct list_head *path = NULL;
692 mutex_lock(&coresight_mutex);
694 ret = coresight_validate_source(csdev, __func__);
698 if (!csdev->enable || !coresight_disable_source(csdev))
701 switch (csdev->subtype.source_subtype) {
702 case CORESIGHT_DEV_SUBTYPE_SOURCE_PROC:
703 cpu = source_ops(csdev)->cpu_id(csdev);
704 path = per_cpu(tracer_path, cpu);
705 per_cpu(tracer_path, cpu) = NULL;
707 case CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE:
712 /* We can't be here */
716 coresight_disable_path(path);
717 coresight_release_path(path);
720 mutex_unlock(&coresight_mutex);
722 EXPORT_SYMBOL_GPL(coresight_disable);
724 static ssize_t enable_sink_show(struct device *dev,
725 struct device_attribute *attr, char *buf)
727 struct coresight_device *csdev = to_coresight_device(dev);
729 return scnprintf(buf, PAGE_SIZE, "%u\n", csdev->activated);
732 static ssize_t enable_sink_store(struct device *dev,
733 struct device_attribute *attr,
734 const char *buf, size_t size)
738 struct coresight_device *csdev = to_coresight_device(dev);
740 ret = kstrtoul(buf, 10, &val);
745 csdev->activated = true;
747 csdev->activated = false;
752 static DEVICE_ATTR_RW(enable_sink);
754 static ssize_t enable_source_show(struct device *dev,
755 struct device_attribute *attr, char *buf)
757 struct coresight_device *csdev = to_coresight_device(dev);
759 return scnprintf(buf, PAGE_SIZE, "%u\n", csdev->enable);
762 static ssize_t enable_source_store(struct device *dev,
763 struct device_attribute *attr,
764 const char *buf, size_t size)
768 struct coresight_device *csdev = to_coresight_device(dev);
770 ret = kstrtoul(buf, 10, &val);
775 ret = coresight_enable(csdev);
779 coresight_disable(csdev);
784 static DEVICE_ATTR_RW(enable_source);
786 static struct attribute *coresight_sink_attrs[] = {
787 &dev_attr_enable_sink.attr,
790 ATTRIBUTE_GROUPS(coresight_sink);
792 static struct attribute *coresight_source_attrs[] = {
793 &dev_attr_enable_source.attr,
796 ATTRIBUTE_GROUPS(coresight_source);
798 static struct device_type coresight_dev_type[] = {
804 .groups = coresight_sink_groups,
811 .groups = coresight_sink_groups,
815 .groups = coresight_source_groups,
822 static void coresight_device_release(struct device *dev)
824 struct coresight_device *csdev = to_coresight_device(dev);
827 kfree(csdev->refcnt);
831 static int coresight_orphan_match(struct device *dev, void *data)
834 bool still_orphan = false;
835 struct coresight_device *csdev, *i_csdev;
836 struct coresight_connection *conn;
839 i_csdev = to_coresight_device(dev);
841 /* No need to check oneself */
842 if (csdev == i_csdev)
845 /* Move on to another component if no connection is orphan */
846 if (!i_csdev->orphan)
849 * Circle throuch all the connection of that component. If we find
850 * an orphan connection whose name matches @csdev, link it.
852 for (i = 0; i < i_csdev->nr_outport; i++) {
853 conn = &i_csdev->conns[i];
855 /* We have found at least one orphan connection */
856 if (conn->child_dev == NULL) {
857 /* Does it match this newly added device? */
858 if (conn->child_name &&
859 !strcmp(dev_name(&csdev->dev), conn->child_name)) {
860 conn->child_dev = csdev;
862 /* This component still has an orphan */
868 i_csdev->orphan = still_orphan;
871 * Returning '0' ensures that all known component on the
872 * bus will be checked.
877 static void coresight_fixup_orphan_conns(struct coresight_device *csdev)
880 * No need to check for a return value as orphan connection(s)
881 * are hooked-up with each newly added component.
883 bus_for_each_dev(&coresight_bustype, NULL,
884 csdev, coresight_orphan_match);
888 static void coresight_fixup_device_conns(struct coresight_device *csdev)
892 for (i = 0; i < csdev->nr_outport; i++) {
893 struct coresight_connection *conn = &csdev->conns[i];
894 struct device *dev = NULL;
896 if (conn->child_name)
897 dev = bus_find_device_by_name(&coresight_bustype, NULL,
900 conn->child_dev = to_coresight_device(dev);
901 /* and put reference from 'bus_find_device()' */
904 csdev->orphan = true;
905 conn->child_dev = NULL;
910 static int coresight_remove_match(struct device *dev, void *data)
913 struct coresight_device *csdev, *iterator;
914 struct coresight_connection *conn;
917 iterator = to_coresight_device(dev);
919 /* No need to check oneself */
920 if (csdev == iterator)
924 * Circle throuch all the connection of that component. If we find
925 * a connection whose name matches @csdev, remove it.
927 for (i = 0; i < iterator->nr_outport; i++) {
928 conn = &iterator->conns[i];
930 if (conn->child_dev == NULL)
933 if (!strcmp(dev_name(&csdev->dev), conn->child_name)) {
934 iterator->orphan = true;
935 conn->child_dev = NULL;
936 /* No need to continue */
942 * Returning '0' ensures that all known component on the
943 * bus will be checked.
948 static void coresight_remove_conns(struct coresight_device *csdev)
950 bus_for_each_dev(&coresight_bustype, NULL,
951 csdev, coresight_remove_match);
955 * coresight_timeout - loop until a bit has changed to a specific state.
956 * @addr: base address of the area of interest.
957 * @offset: address of a register, starting from @addr.
958 * @position: the position of the bit of interest.
959 * @value: the value the bit should have.
961 * Return: 0 as soon as the bit has taken the desired state or -EAGAIN if
962 * TIMEOUT_US has elapsed, which ever happens first.
965 int coresight_timeout(void __iomem *addr, u32 offset, int position, int value)
970 for (i = TIMEOUT_US; i > 0; i--) {
971 val = __raw_readl(addr + offset);
972 /* waiting on the bit to go from 0 to 1 */
974 if (val & BIT(position))
976 /* waiting on the bit to go from 1 to 0 */
978 if (!(val & BIT(position)))
983 * Delay is arbitrary - the specification doesn't say how long
984 * we are expected to wait. Extra check required to make sure
985 * we don't wait needlessly on the last iteration.
994 struct bus_type coresight_bustype = {
998 static int __init coresight_init(void)
1000 return bus_register(&coresight_bustype);
1002 postcore_initcall(coresight_init);
1004 struct coresight_device *coresight_register(struct coresight_desc *desc)
1010 atomic_t *refcnts = NULL;
1011 struct coresight_device *csdev;
1012 struct coresight_connection *conns = NULL;
1014 csdev = kzalloc(sizeof(*csdev), GFP_KERNEL);
1017 goto err_kzalloc_csdev;
1020 if (desc->type == CORESIGHT_DEV_TYPE_LINK ||
1021 desc->type == CORESIGHT_DEV_TYPE_LINKSINK) {
1022 link_subtype = desc->subtype.link_subtype;
1024 if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_MERG)
1025 nr_refcnts = desc->pdata->nr_inport;
1026 else if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_SPLIT)
1027 nr_refcnts = desc->pdata->nr_outport;
1030 refcnts = kcalloc(nr_refcnts, sizeof(*refcnts), GFP_KERNEL);
1033 goto err_kzalloc_refcnts;
1036 csdev->refcnt = refcnts;
1038 csdev->nr_inport = desc->pdata->nr_inport;
1039 csdev->nr_outport = desc->pdata->nr_outport;
1041 /* Initialise connections if there is at least one outport */
1042 if (csdev->nr_outport) {
1043 conns = kcalloc(csdev->nr_outport, sizeof(*conns), GFP_KERNEL);
1046 goto err_kzalloc_conns;
1049 for (i = 0; i < csdev->nr_outport; i++) {
1050 conns[i].outport = desc->pdata->outports[i];
1051 conns[i].child_name = desc->pdata->child_names[i];
1052 conns[i].child_port = desc->pdata->child_ports[i];
1056 csdev->conns = conns;
1058 csdev->type = desc->type;
1059 csdev->subtype = desc->subtype;
1060 csdev->ops = desc->ops;
1061 csdev->orphan = false;
1063 csdev->dev.type = &coresight_dev_type[desc->type];
1064 csdev->dev.groups = desc->groups;
1065 csdev->dev.parent = desc->dev;
1066 csdev->dev.release = coresight_device_release;
1067 csdev->dev.bus = &coresight_bustype;
1068 dev_set_name(&csdev->dev, "%s", desc->pdata->name);
1070 ret = device_register(&csdev->dev);
1072 put_device(&csdev->dev);
1073 goto err_kzalloc_csdev;
1076 mutex_lock(&coresight_mutex);
1078 coresight_fixup_device_conns(csdev);
1079 coresight_fixup_orphan_conns(csdev);
1081 mutex_unlock(&coresight_mutex);
1087 err_kzalloc_refcnts:
1090 return ERR_PTR(ret);
1092 EXPORT_SYMBOL_GPL(coresight_register);
1094 void coresight_unregister(struct coresight_device *csdev)
1096 /* Remove references of that device in the topology */
1097 coresight_remove_conns(csdev);
1098 device_unregister(&csdev->dev);
1100 EXPORT_SYMBOL_GPL(coresight_unregister);