1 // SPDX-License-Identifier: GPL-2.0
3 * Intel(R) Trace Hub driver core
5 * Copyright (C) 2014-2015 Intel Corporation.
8 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
10 #include <linux/types.h>
11 #include <linux/module.h>
12 #include <linux/device.h>
13 #include <linux/sysfs.h>
14 #include <linux/kdev_t.h>
15 #include <linux/debugfs.h>
16 #include <linux/idr.h>
17 #include <linux/pci.h>
18 #include <linux/pm_runtime.h>
19 #include <linux/dma-mapping.h>
24 static bool host_mode __read_mostly;
25 module_param(host_mode, bool, 0444);
27 static DEFINE_IDA(intel_th_ida);
29 static int intel_th_match(struct device *dev, struct device_driver *driver)
31 struct intel_th_driver *thdrv = to_intel_th_driver(driver);
32 struct intel_th_device *thdev = to_intel_th_device(dev);
34 if (thdev->type == INTEL_TH_SWITCH &&
35 (!thdrv->enable || !thdrv->disable))
38 return !strcmp(thdev->name, driver->name);
41 static int intel_th_child_remove(struct device *dev, void *data)
43 device_release_driver(dev);
48 static int intel_th_probe(struct device *dev)
50 struct intel_th_driver *thdrv = to_intel_th_driver(dev->driver);
51 struct intel_th_device *thdev = to_intel_th_device(dev);
52 struct intel_th_driver *hubdrv;
53 struct intel_th_device *hub = NULL;
56 if (thdev->type == INTEL_TH_SWITCH)
59 hub = to_intel_th_device(dev->parent);
61 if (!hub || !hub->dev.driver)
64 hubdrv = to_intel_th_driver(hub->dev.driver);
66 pm_runtime_set_active(dev);
67 pm_runtime_no_callbacks(dev);
68 pm_runtime_enable(dev);
70 ret = thdrv->probe(to_intel_th_device(dev));
74 if (thdrv->attr_group) {
75 ret = sysfs_create_group(&thdev->dev.kobj, thdrv->attr_group);
80 if (thdev->type == INTEL_TH_OUTPUT &&
81 !intel_th_output_assigned(thdev))
82 /* does not talk to hardware */
83 ret = hubdrv->assign(hub, thdev);
91 pm_runtime_disable(dev);
96 static void intel_th_device_remove(struct intel_th_device *thdev);
98 static int intel_th_remove(struct device *dev)
100 struct intel_th_driver *thdrv = to_intel_th_driver(dev->driver);
101 struct intel_th_device *thdev = to_intel_th_device(dev);
102 struct intel_th_device *hub = to_intel_th_hub(thdev);
104 if (thdev->type == INTEL_TH_SWITCH) {
105 struct intel_th *th = to_intel_th(hub);
111 * intel_th_child_remove returns 0 unconditionally, so there is
112 * no need to check the return value of device_for_each_child.
114 device_for_each_child(dev, thdev, intel_th_child_remove);
117 * Remove outputs, that is, hub's children: they are created
118 * at hub's probe time by having the hub call
119 * intel_th_output_enable() for each of them.
121 for (i = 0, lowest = -1; i < th->num_thdevs; i++) {
123 * Move the non-output devices from higher up the
124 * th->thdev[] array to lower positions to maintain
125 * a contiguous array.
127 if (th->thdev[i]->type != INTEL_TH_OUTPUT) {
129 th->thdev[lowest] = th->thdev[i];
140 intel_th_device_remove(th->thdev[i]);
145 th->num_thdevs = lowest;
148 if (thdrv->attr_group)
149 sysfs_remove_group(&thdev->dev.kobj, thdrv->attr_group);
151 pm_runtime_get_sync(dev);
153 thdrv->remove(thdev);
155 if (intel_th_output_assigned(thdev)) {
156 struct intel_th_driver *hubdrv =
157 to_intel_th_driver(dev->parent->driver);
160 /* does not talk to hardware */
161 hubdrv->unassign(hub, thdev);
164 pm_runtime_disable(dev);
165 pm_runtime_set_active(dev);
166 pm_runtime_enable(dev);
171 static struct bus_type intel_th_bus = {
173 .match = intel_th_match,
174 .probe = intel_th_probe,
175 .remove = intel_th_remove,
178 static void intel_th_device_free(struct intel_th_device *thdev);
180 static void intel_th_device_release(struct device *dev)
182 intel_th_device_free(to_intel_th_device(dev));
185 static struct device_type intel_th_source_device_type = {
186 .name = "intel_th_source_device",
187 .release = intel_th_device_release,
190 static char *intel_th_output_devnode(struct device *dev, umode_t *mode,
191 kuid_t *uid, kgid_t *gid)
193 struct intel_th_device *thdev = to_intel_th_device(dev);
194 struct intel_th *th = to_intel_th(thdev);
198 node = kasprintf(GFP_KERNEL, "intel_th%d/%s%d", th->id,
199 thdev->name, thdev->id);
201 node = kasprintf(GFP_KERNEL, "intel_th%d/%s", th->id,
207 static ssize_t port_show(struct device *dev, struct device_attribute *attr,
210 struct intel_th_device *thdev = to_intel_th_device(dev);
212 if (thdev->output.port >= 0)
213 return scnprintf(buf, PAGE_SIZE, "%u\n", thdev->output.port);
215 return scnprintf(buf, PAGE_SIZE, "unassigned\n");
218 static DEVICE_ATTR_RO(port);
220 static void intel_th_trace_prepare(struct intel_th_device *thdev)
222 struct intel_th_device *hub = to_intel_th_hub(thdev);
223 struct intel_th_driver *hubdrv = to_intel_th_driver(hub->dev.driver);
225 if (hub->type != INTEL_TH_SWITCH)
228 if (thdev->type != INTEL_TH_OUTPUT)
231 pm_runtime_get_sync(&thdev->dev);
232 hubdrv->prepare(hub, &thdev->output);
233 pm_runtime_put(&thdev->dev);
236 static int intel_th_output_activate(struct intel_th_device *thdev)
238 struct intel_th_driver *thdrv =
239 to_intel_th_driver_or_null(thdev->dev.driver);
240 struct intel_th *th = to_intel_th(thdev);
246 if (!try_module_get(thdrv->driver.owner))
249 pm_runtime_get_sync(&thdev->dev);
252 ret = th->activate(th);
256 intel_th_trace_prepare(thdev);
258 ret = thdrv->activate(thdev);
260 intel_th_trace_enable(thdev);
263 goto fail_deactivate;
272 pm_runtime_put(&thdev->dev);
273 module_put(thdrv->driver.owner);
278 static void intel_th_output_deactivate(struct intel_th_device *thdev)
280 struct intel_th_driver *thdrv =
281 to_intel_th_driver_or_null(thdev->dev.driver);
282 struct intel_th *th = to_intel_th(thdev);
287 if (thdrv->deactivate)
288 thdrv->deactivate(thdev);
290 intel_th_trace_disable(thdev);
295 pm_runtime_put(&thdev->dev);
296 module_put(thdrv->driver.owner);
299 static ssize_t active_show(struct device *dev, struct device_attribute *attr,
302 struct intel_th_device *thdev = to_intel_th_device(dev);
304 return scnprintf(buf, PAGE_SIZE, "%d\n", thdev->output.active);
307 static ssize_t active_store(struct device *dev, struct device_attribute *attr,
308 const char *buf, size_t size)
310 struct intel_th_device *thdev = to_intel_th_device(dev);
314 ret = kstrtoul(buf, 10, &val);
318 if (!!val != thdev->output.active) {
320 ret = intel_th_output_activate(thdev);
322 intel_th_output_deactivate(thdev);
325 return ret ? ret : size;
328 static DEVICE_ATTR_RW(active);
330 static struct attribute *intel_th_output_attrs[] = {
332 &dev_attr_active.attr,
336 ATTRIBUTE_GROUPS(intel_th_output);
338 static struct device_type intel_th_output_device_type = {
339 .name = "intel_th_output_device",
340 .groups = intel_th_output_groups,
341 .release = intel_th_device_release,
342 .devnode = intel_th_output_devnode,
345 static struct device_type intel_th_switch_device_type = {
346 .name = "intel_th_switch_device",
347 .release = intel_th_device_release,
350 static struct device_type *intel_th_device_type[] = {
351 [INTEL_TH_SOURCE] = &intel_th_source_device_type,
352 [INTEL_TH_OUTPUT] = &intel_th_output_device_type,
353 [INTEL_TH_SWITCH] = &intel_th_switch_device_type,
356 int intel_th_driver_register(struct intel_th_driver *thdrv)
358 if (!thdrv->probe || !thdrv->remove)
361 thdrv->driver.bus = &intel_th_bus;
363 return driver_register(&thdrv->driver);
365 EXPORT_SYMBOL_GPL(intel_th_driver_register);
367 void intel_th_driver_unregister(struct intel_th_driver *thdrv)
369 driver_unregister(&thdrv->driver);
371 EXPORT_SYMBOL_GPL(intel_th_driver_unregister);
373 static struct intel_th_device *
374 intel_th_device_alloc(struct intel_th *th, unsigned int type, const char *name,
377 struct device *parent;
378 struct intel_th_device *thdev;
380 if (type == INTEL_TH_OUTPUT)
381 parent = &th->hub->dev;
385 thdev = kzalloc(sizeof(*thdev) + strlen(name) + 1, GFP_KERNEL);
392 strcpy(thdev->name, name);
393 device_initialize(&thdev->dev);
394 thdev->dev.bus = &intel_th_bus;
395 thdev->dev.type = intel_th_device_type[type];
396 thdev->dev.parent = parent;
397 thdev->dev.dma_mask = parent->dma_mask;
398 thdev->dev.dma_parms = parent->dma_parms;
399 dma_set_coherent_mask(&thdev->dev, parent->coherent_dma_mask);
401 dev_set_name(&thdev->dev, "%d-%s%d", th->id, name, id);
403 dev_set_name(&thdev->dev, "%d-%s", th->id, name);
408 static int intel_th_device_add_resources(struct intel_th_device *thdev,
409 struct resource *res, int nres)
413 r = kmemdup(res, sizeof(*res) * nres, GFP_KERNEL);
418 thdev->num_resources = nres;
423 static void intel_th_device_remove(struct intel_th_device *thdev)
425 device_del(&thdev->dev);
426 put_device(&thdev->dev);
429 static void intel_th_device_free(struct intel_th_device *thdev)
431 kfree(thdev->resource);
436 * Intel(R) Trace Hub subdevices
438 static const struct intel_th_subdevice {
440 struct resource res[3];
447 } intel_th_subdevices[] = {
452 /* Handle TSCU and CTS from GTH driver */
453 .start = REG_GTH_OFFSET,
454 .end = REG_CTS_OFFSET + REG_CTS_LENGTH - 1,
455 .flags = IORESOURCE_MEM,
459 .type = INTEL_TH_SWITCH,
466 .start = REG_MSU_OFFSET,
467 .end = REG_MSU_OFFSET + REG_MSU_LENGTH - 1,
468 .flags = IORESOURCE_MEM,
471 .start = BUF_MSU_OFFSET,
472 .end = BUF_MSU_OFFSET + BUF_MSU_LENGTH - 1,
473 .flags = IORESOURCE_MEM,
478 .type = INTEL_TH_OUTPUT,
481 .scrpd = SCRPD_MEM_IS_PRIM_DEST | SCRPD_MSC0_IS_ENABLED,
487 .start = REG_MSU_OFFSET,
488 .end = REG_MSU_OFFSET + REG_MSU_LENGTH - 1,
489 .flags = IORESOURCE_MEM,
492 .start = BUF_MSU_OFFSET,
493 .end = BUF_MSU_OFFSET + BUF_MSU_LENGTH - 1,
494 .flags = IORESOURCE_MEM,
499 .type = INTEL_TH_OUTPUT,
502 .scrpd = SCRPD_MEM_IS_PRIM_DEST | SCRPD_MSC1_IS_ENABLED,
508 .start = REG_STH_OFFSET,
509 .end = REG_STH_OFFSET + REG_STH_LENGTH - 1,
510 .flags = IORESOURCE_MEM,
515 .flags = IORESOURCE_MEM,
520 .type = INTEL_TH_SOURCE,
526 .start = REG_STH_OFFSET,
527 .end = REG_STH_OFFSET + REG_STH_LENGTH - 1,
528 .flags = IORESOURCE_MEM,
531 .start = TH_MMIO_RTIT,
533 .flags = IORESOURCE_MEM,
538 .type = INTEL_TH_SOURCE,
544 .start = REG_PTI_OFFSET,
545 .end = REG_PTI_OFFSET + REG_PTI_LENGTH - 1,
546 .flags = IORESOURCE_MEM,
551 .type = INTEL_TH_OUTPUT,
553 .scrpd = SCRPD_PTI_IS_PRIM_DEST,
559 .start = REG_PTI_OFFSET,
560 .end = REG_PTI_OFFSET + REG_PTI_LENGTH - 1,
561 .flags = IORESOURCE_MEM,
566 .type = INTEL_TH_OUTPUT,
568 .scrpd = SCRPD_PTI_IS_PRIM_DEST,
574 .start = REG_DCIH_OFFSET,
575 .end = REG_DCIH_OFFSET + REG_DCIH_LENGTH - 1,
576 .flags = IORESOURCE_MEM,
581 .type = INTEL_TH_OUTPUT,
585 #ifdef CONFIG_MODULES
586 static void __intel_th_request_hub_module(struct work_struct *work)
588 struct intel_th *th = container_of(work, struct intel_th,
589 request_module_work);
591 request_module("intel_th_%s", th->hub->name);
594 static int intel_th_request_hub_module(struct intel_th *th)
596 INIT_WORK(&th->request_module_work, __intel_th_request_hub_module);
597 schedule_work(&th->request_module_work);
602 static void intel_th_request_hub_module_flush(struct intel_th *th)
604 flush_work(&th->request_module_work);
607 static inline int intel_th_request_hub_module(struct intel_th *th)
612 static inline void intel_th_request_hub_module_flush(struct intel_th *th)
615 #endif /* CONFIG_MODULES */
617 static struct intel_th_device *
618 intel_th_subdevice_alloc(struct intel_th *th,
619 const struct intel_th_subdevice *subdev)
621 struct intel_th_device *thdev;
622 struct resource res[3];
623 unsigned int req = 0;
626 thdev = intel_th_device_alloc(th, subdev->type, subdev->name,
629 return ERR_PTR(-ENOMEM);
631 thdev->drvdata = th->drvdata;
633 memcpy(res, subdev->res,
634 sizeof(struct resource) * subdev->nres);
636 for (r = 0; r < subdev->nres; r++) {
637 struct resource *devres = th->resource;
638 int bar = TH_MMIO_CONFIG;
641 * Take .end == 0 to mean 'take the whole bar',
642 * .start then tells us which bar it is. Default to
645 if (!res[r].end && res[r].flags == IORESOURCE_MEM) {
648 if (bar >= th->num_resources)
649 goto fail_put_device;
651 res[r].end = resource_size(&devres[bar]) - 1;
654 if (res[r].flags & IORESOURCE_MEM) {
655 res[r].start += devres[bar].start;
656 res[r].end += devres[bar].start;
658 dev_dbg(th->dev, "%s:%d @ %pR\n",
659 subdev->name, r, &res[r]);
660 } else if (res[r].flags & IORESOURCE_IRQ) {
662 * Only pass on the IRQ if we have useful interrupts:
663 * the ones that can be configured via MINTCTL.
665 if (INTEL_TH_CAP(th, has_mintctl) && th->irq != -1)
666 res[r].start = th->irq;
670 err = intel_th_device_add_resources(thdev, res, subdev->nres);
672 goto fail_put_device;
674 if (subdev->type == INTEL_TH_OUTPUT) {
676 thdev->dev.devt = MKDEV(th->major, th->num_thdevs);
677 thdev->output.type = subdev->otype;
678 thdev->output.port = -1;
679 thdev->output.scratchpad = subdev->scrpd;
680 } else if (subdev->type == INTEL_TH_SWITCH) {
682 INTEL_TH_CAP(th, host_mode_only) ? true : host_mode;
686 err = device_add(&thdev->dev);
690 /* need switch driver to be loaded to enumerate the rest */
691 if (subdev->type == INTEL_TH_SWITCH && !req) {
692 err = intel_th_request_hub_module(th);
700 kfree(thdev->resource);
703 put_device(&thdev->dev);
709 * intel_th_output_enable() - find and enable a device for a given output type
710 * @th: Intel TH instance
711 * @otype: output type
713 * Go through the unallocated output devices, find the first one whos type
714 * matches @otype and instantiate it. These devices are removed when the hub
715 * device is removed, see intel_th_remove().
717 int intel_th_output_enable(struct intel_th *th, unsigned int otype)
719 struct intel_th_device *thdev;
720 int src = 0, dst = 0;
722 for (src = 0, dst = 0; dst <= th->num_thdevs; src++, dst++) {
723 for (; src < ARRAY_SIZE(intel_th_subdevices); src++) {
724 if (intel_th_subdevices[src].type != INTEL_TH_OUTPUT)
727 if (intel_th_subdevices[src].otype != otype)
733 /* no unallocated matching subdevices */
734 if (src == ARRAY_SIZE(intel_th_subdevices))
737 for (; dst < th->num_thdevs; dst++) {
738 if (th->thdev[dst]->type != INTEL_TH_OUTPUT)
741 if (th->thdev[dst]->output.type != otype)
748 * intel_th_subdevices[src] matches our requirements and is
749 * not matched in th::thdev[]
751 if (dst == th->num_thdevs)
758 thdev = intel_th_subdevice_alloc(th, &intel_th_subdevices[src]);
760 return PTR_ERR(thdev);
762 th->thdev[th->num_thdevs++] = thdev;
766 EXPORT_SYMBOL_GPL(intel_th_output_enable);
768 static int intel_th_populate(struct intel_th *th)
772 /* create devices for each intel_th_subdevice */
773 for (src = 0; src < ARRAY_SIZE(intel_th_subdevices); src++) {
774 const struct intel_th_subdevice *subdev =
775 &intel_th_subdevices[src];
776 struct intel_th_device *thdev;
778 /* only allow SOURCE and SWITCH devices in host mode */
779 if ((INTEL_TH_CAP(th, host_mode_only) || host_mode) &&
780 subdev->type == INTEL_TH_OUTPUT)
784 * don't enable port OUTPUTs in this path; SWITCH enables them
785 * via intel_th_output_enable()
787 if (subdev->type == INTEL_TH_OUTPUT &&
788 subdev->otype != GTH_NONE)
791 thdev = intel_th_subdevice_alloc(th, subdev);
792 /* note: caller should free subdevices from th::thdev[] */
794 /* ENODEV for individual subdevices is allowed */
795 if (PTR_ERR(thdev) == -ENODEV)
798 return PTR_ERR(thdev);
801 th->thdev[th->num_thdevs++] = thdev;
807 static int intel_th_output_open(struct inode *inode, struct file *file)
809 const struct file_operations *fops;
810 struct intel_th_driver *thdrv;
814 dev = bus_find_device_by_devt(&intel_th_bus, inode->i_rdev);
815 if (!dev || !dev->driver)
818 thdrv = to_intel_th_driver(dev->driver);
819 fops = fops_get(thdrv->fops);
823 replace_fops(file, fops);
825 file->private_data = to_intel_th_device(dev);
827 if (file->f_op->open) {
828 err = file->f_op->open(inode, file);
835 static const struct file_operations intel_th_output_fops = {
836 .open = intel_th_output_open,
837 .llseek = noop_llseek,
840 static irqreturn_t intel_th_irq(int irq, void *data)
842 struct intel_th *th = data;
843 irqreturn_t ret = IRQ_NONE;
844 struct intel_th_driver *d;
847 for (i = 0; i < th->num_thdevs; i++) {
848 if (th->thdev[i]->type != INTEL_TH_OUTPUT)
851 d = to_intel_th_driver(th->thdev[i]->dev.driver);
853 ret |= d->irq(th->thdev[i]);
860 * intel_th_alloc() - allocate a new Intel TH device and its subdevices
861 * @dev: parent device
862 * @devres: resources indexed by th_mmio_idx
866 intel_th_alloc(struct device *dev, const struct intel_th_drvdata *drvdata,
867 struct resource *devres, unsigned int ndevres)
869 int err, r, nr_mmios = 0;
872 th = kzalloc(sizeof(*th), GFP_KERNEL);
874 return ERR_PTR(-ENOMEM);
876 th->id = ida_simple_get(&intel_th_ida, 0, 0, GFP_KERNEL);
882 th->major = __register_chrdev(0, 0, TH_POSSIBLE_OUTPUTS,
883 "intel_th/output", &intel_th_output_fops);
890 th->drvdata = drvdata;
892 for (r = 0; r < ndevres; r++)
893 switch (devres[r].flags & IORESOURCE_TYPE_BITS) {
895 th->resource[nr_mmios++] = devres[r];
898 err = devm_request_irq(dev, devres[r].start,
899 intel_th_irq, IRQF_SHARED,
905 th->irq = devres[r].start;
909 dev_warn(dev, "Unknown resource type %lx\n",
914 th->num_resources = nr_mmios;
916 dev_set_drvdata(dev, th);
918 pm_runtime_no_callbacks(dev);
920 pm_runtime_allow(dev);
922 err = intel_th_populate(th);
924 /* free the subdevices and undo everything */
932 __unregister_chrdev(th->major, 0, TH_POSSIBLE_OUTPUTS,
936 ida_simple_remove(&intel_th_ida, th->id);
943 EXPORT_SYMBOL_GPL(intel_th_alloc);
945 void intel_th_free(struct intel_th *th)
949 intel_th_request_hub_module_flush(th);
951 intel_th_device_remove(th->hub);
952 for (i = 0; i < th->num_thdevs; i++) {
953 if (th->thdev[i] != th->hub)
954 intel_th_device_remove(th->thdev[i]);
960 for (i = 0; i < th->num_irqs; i++)
961 devm_free_irq(th->dev, th->irq + i, th);
963 pm_runtime_get_sync(th->dev);
964 pm_runtime_forbid(th->dev);
966 __unregister_chrdev(th->major, 0, TH_POSSIBLE_OUTPUTS,
969 ida_simple_remove(&intel_th_ida, th->id);
973 EXPORT_SYMBOL_GPL(intel_th_free);
976 * intel_th_trace_enable() - enable tracing for an output device
977 * @thdev: output device that requests tracing be enabled
979 int intel_th_trace_enable(struct intel_th_device *thdev)
981 struct intel_th_device *hub = to_intel_th_device(thdev->dev.parent);
982 struct intel_th_driver *hubdrv = to_intel_th_driver(hub->dev.driver);
984 if (WARN_ON_ONCE(hub->type != INTEL_TH_SWITCH))
987 if (WARN_ON_ONCE(thdev->type != INTEL_TH_OUTPUT))
990 pm_runtime_get_sync(&thdev->dev);
991 hubdrv->enable(hub, &thdev->output);
995 EXPORT_SYMBOL_GPL(intel_th_trace_enable);
998 * intel_th_trace_switch() - execute a switch sequence
999 * @thdev: output device that requests tracing switch
1001 int intel_th_trace_switch(struct intel_th_device *thdev)
1003 struct intel_th_device *hub = to_intel_th_device(thdev->dev.parent);
1004 struct intel_th_driver *hubdrv = to_intel_th_driver(hub->dev.driver);
1006 if (WARN_ON_ONCE(hub->type != INTEL_TH_SWITCH))
1009 if (WARN_ON_ONCE(thdev->type != INTEL_TH_OUTPUT))
1012 hubdrv->trig_switch(hub, &thdev->output);
1016 EXPORT_SYMBOL_GPL(intel_th_trace_switch);
1019 * intel_th_trace_disable() - disable tracing for an output device
1020 * @thdev: output device that requests tracing be disabled
1022 int intel_th_trace_disable(struct intel_th_device *thdev)
1024 struct intel_th_device *hub = to_intel_th_device(thdev->dev.parent);
1025 struct intel_th_driver *hubdrv = to_intel_th_driver(hub->dev.driver);
1027 WARN_ON_ONCE(hub->type != INTEL_TH_SWITCH);
1028 if (WARN_ON_ONCE(thdev->type != INTEL_TH_OUTPUT))
1031 hubdrv->disable(hub, &thdev->output);
1032 pm_runtime_put(&thdev->dev);
1036 EXPORT_SYMBOL_GPL(intel_th_trace_disable);
1038 int intel_th_set_output(struct intel_th_device *thdev,
1039 unsigned int master)
1041 struct intel_th_device *hub = to_intel_th_hub(thdev);
1042 struct intel_th_driver *hubdrv = to_intel_th_driver(hub->dev.driver);
1045 /* In host mode, this is up to the external debugger, do nothing. */
1050 * hub is instantiated together with the source device that
1051 * calls here, so guaranteed to be present.
1053 hubdrv = to_intel_th_driver(hub->dev.driver);
1054 if (!hubdrv || !try_module_get(hubdrv->driver.owner))
1057 if (!hubdrv->set_output) {
1062 ret = hubdrv->set_output(hub, master);
1065 module_put(hubdrv->driver.owner);
1068 EXPORT_SYMBOL_GPL(intel_th_set_output);
1070 static int __init intel_th_init(void)
1072 intel_th_debug_init();
1074 return bus_register(&intel_th_bus);
1076 subsys_initcall(intel_th_init);
1078 static void __exit intel_th_exit(void)
1080 intel_th_debug_done();
1082 bus_unregister(&intel_th_bus);
1084 module_exit(intel_th_exit);
1086 MODULE_LICENSE("GPL v2");
1087 MODULE_DESCRIPTION("Intel(R) Trace Hub controller driver");