core.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  1. /*
  2. * Intel(R) Trace Hub driver core
  3. *
  4. * Copyright (C) 2014-2015 Intel Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. */
  15. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  16. #include <linux/types.h>
  17. #include <linux/module.h>
  18. #include <linux/device.h>
  19. #include <linux/sysfs.h>
  20. #include <linux/kdev_t.h>
  21. #include <linux/debugfs.h>
  22. #include <linux/idr.h>
  23. #include <linux/pci.h>
  24. #include <linux/dma-mapping.h>
  25. #include "intel_th.h"
  26. #include "debug.h"
  27. static DEFINE_IDA(intel_th_ida);
  28. static int intel_th_match(struct device *dev, struct device_driver *driver)
  29. {
  30. struct intel_th_driver *thdrv = to_intel_th_driver(driver);
  31. struct intel_th_device *thdev = to_intel_th_device(dev);
  32. if (thdev->type == INTEL_TH_SWITCH &&
  33. (!thdrv->enable || !thdrv->disable))
  34. return 0;
  35. return !strcmp(thdev->name, driver->name);
  36. }
  37. static int intel_th_child_remove(struct device *dev, void *data)
  38. {
  39. device_release_driver(dev);
  40. return 0;
  41. }
  42. static int intel_th_probe(struct device *dev)
  43. {
  44. struct intel_th_driver *thdrv = to_intel_th_driver(dev->driver);
  45. struct intel_th_device *thdev = to_intel_th_device(dev);
  46. struct intel_th_driver *hubdrv;
  47. struct intel_th_device *hub = NULL;
  48. int ret;
  49. if (thdev->type == INTEL_TH_SWITCH)
  50. hub = thdev;
  51. else if (dev->parent)
  52. hub = to_intel_th_device(dev->parent);
  53. if (!hub || !hub->dev.driver)
  54. return -EPROBE_DEFER;
  55. hubdrv = to_intel_th_driver(hub->dev.driver);
  56. ret = thdrv->probe(to_intel_th_device(dev));
  57. if (ret)
  58. return ret;
  59. if (thdrv->attr_group) {
  60. ret = sysfs_create_group(&thdev->dev.kobj, thdrv->attr_group);
  61. if (ret) {
  62. thdrv->remove(thdev);
  63. return ret;
  64. }
  65. }
  66. if (thdev->type == INTEL_TH_OUTPUT &&
  67. !intel_th_output_assigned(thdev))
  68. ret = hubdrv->assign(hub, thdev);
  69. return ret;
  70. }
  71. static int intel_th_remove(struct device *dev)
  72. {
  73. struct intel_th_driver *thdrv = to_intel_th_driver(dev->driver);
  74. struct intel_th_device *thdev = to_intel_th_device(dev);
  75. struct intel_th_device *hub = to_intel_th_device(dev->parent);
  76. int err;
  77. if (thdev->type == INTEL_TH_SWITCH) {
  78. err = device_for_each_child(dev, thdev, intel_th_child_remove);
  79. if (err)
  80. return err;
  81. }
  82. if (thdrv->attr_group)
  83. sysfs_remove_group(&thdev->dev.kobj, thdrv->attr_group);
  84. thdrv->remove(thdev);
  85. if (intel_th_output_assigned(thdev)) {
  86. struct intel_th_driver *hubdrv =
  87. to_intel_th_driver(dev->parent->driver);
  88. if (hub->dev.driver)
  89. hubdrv->unassign(hub, thdev);
  90. }
  91. return 0;
  92. }
  93. static struct bus_type intel_th_bus = {
  94. .name = "intel_th",
  95. .dev_attrs = NULL,
  96. .match = intel_th_match,
  97. .probe = intel_th_probe,
  98. .remove = intel_th_remove,
  99. };
  100. static void intel_th_device_free(struct intel_th_device *thdev);
  101. static void intel_th_device_release(struct device *dev)
  102. {
  103. intel_th_device_free(to_intel_th_device(dev));
  104. }
  105. static struct device_type intel_th_source_device_type = {
  106. .name = "intel_th_source_device",
  107. .release = intel_th_device_release,
  108. };
  109. static struct intel_th *to_intel_th(struct intel_th_device *thdev)
  110. {
  111. /*
  112. * subdevice tree is flat: if this one is not a switch, its
  113. * parent must be
  114. */
  115. if (thdev->type != INTEL_TH_SWITCH)
  116. thdev = to_intel_th_hub(thdev);
  117. if (WARN_ON_ONCE(!thdev || thdev->type != INTEL_TH_SWITCH))
  118. return NULL;
  119. return dev_get_drvdata(thdev->dev.parent);
  120. }
  121. static char *intel_th_output_devnode(struct device *dev, umode_t *mode,
  122. kuid_t *uid, kgid_t *gid)
  123. {
  124. struct intel_th_device *thdev = to_intel_th_device(dev);
  125. struct intel_th *th = to_intel_th(thdev);
  126. char *node;
  127. if (thdev->id >= 0)
  128. node = kasprintf(GFP_KERNEL, "intel_th%d/%s%d", th->id,
  129. thdev->name, thdev->id);
  130. else
  131. node = kasprintf(GFP_KERNEL, "intel_th%d/%s", th->id,
  132. thdev->name);
  133. return node;
  134. }
  135. static ssize_t port_show(struct device *dev, struct device_attribute *attr,
  136. char *buf)
  137. {
  138. struct intel_th_device *thdev = to_intel_th_device(dev);
  139. if (thdev->output.port >= 0)
  140. return scnprintf(buf, PAGE_SIZE, "%u\n", thdev->output.port);
  141. return scnprintf(buf, PAGE_SIZE, "unassigned\n");
  142. }
  143. static DEVICE_ATTR_RO(port);
  144. static int intel_th_output_activate(struct intel_th_device *thdev)
  145. {
  146. struct intel_th_driver *thdrv =
  147. to_intel_th_driver_or_null(thdev->dev.driver);
  148. if (!thdrv)
  149. return -ENODEV;
  150. if (thdrv->activate)
  151. return thdrv->activate(thdev);
  152. intel_th_trace_enable(thdev);
  153. return 0;
  154. }
  155. static void intel_th_output_deactivate(struct intel_th_device *thdev)
  156. {
  157. struct intel_th_driver *thdrv =
  158. to_intel_th_driver_or_null(thdev->dev.driver);
  159. if (!thdrv)
  160. return;
  161. if (thdrv->deactivate)
  162. thdrv->deactivate(thdev);
  163. else
  164. intel_th_trace_disable(thdev);
  165. }
  166. static ssize_t active_show(struct device *dev, struct device_attribute *attr,
  167. char *buf)
  168. {
  169. struct intel_th_device *thdev = to_intel_th_device(dev);
  170. return scnprintf(buf, PAGE_SIZE, "%d\n", thdev->output.active);
  171. }
  172. static ssize_t active_store(struct device *dev, struct device_attribute *attr,
  173. const char *buf, size_t size)
  174. {
  175. struct intel_th_device *thdev = to_intel_th_device(dev);
  176. unsigned long val;
  177. int ret;
  178. ret = kstrtoul(buf, 10, &val);
  179. if (ret)
  180. return ret;
  181. if (!!val != thdev->output.active) {
  182. if (val)
  183. ret = intel_th_output_activate(thdev);
  184. else
  185. intel_th_output_deactivate(thdev);
  186. }
  187. return ret ? ret : size;
  188. }
  189. static DEVICE_ATTR_RW(active);
  190. static struct attribute *intel_th_output_attrs[] = {
  191. &dev_attr_port.attr,
  192. &dev_attr_active.attr,
  193. NULL,
  194. };
  195. ATTRIBUTE_GROUPS(intel_th_output);
  196. static struct device_type intel_th_output_device_type = {
  197. .name = "intel_th_output_device",
  198. .groups = intel_th_output_groups,
  199. .release = intel_th_device_release,
  200. .devnode = intel_th_output_devnode,
  201. };
  202. static struct device_type intel_th_switch_device_type = {
  203. .name = "intel_th_switch_device",
  204. .release = intel_th_device_release,
  205. };
  206. static struct device_type *intel_th_device_type[] = {
  207. [INTEL_TH_SOURCE] = &intel_th_source_device_type,
  208. [INTEL_TH_OUTPUT] = &intel_th_output_device_type,
  209. [INTEL_TH_SWITCH] = &intel_th_switch_device_type,
  210. };
  211. int intel_th_driver_register(struct intel_th_driver *thdrv)
  212. {
  213. if (!thdrv->probe || !thdrv->remove)
  214. return -EINVAL;
  215. thdrv->driver.bus = &intel_th_bus;
  216. return driver_register(&thdrv->driver);
  217. }
  218. EXPORT_SYMBOL_GPL(intel_th_driver_register);
  219. void intel_th_driver_unregister(struct intel_th_driver *thdrv)
  220. {
  221. driver_unregister(&thdrv->driver);
  222. }
  223. EXPORT_SYMBOL_GPL(intel_th_driver_unregister);
  224. static struct intel_th_device *
  225. intel_th_device_alloc(struct intel_th *th, unsigned int type, const char *name,
  226. int id)
  227. {
  228. struct device *parent;
  229. struct intel_th_device *thdev;
  230. if (type == INTEL_TH_SWITCH)
  231. parent = th->dev;
  232. else
  233. parent = &th->hub->dev;
  234. thdev = kzalloc(sizeof(*thdev) + strlen(name) + 1, GFP_KERNEL);
  235. if (!thdev)
  236. return NULL;
  237. thdev->id = id;
  238. thdev->type = type;
  239. strcpy(thdev->name, name);
  240. device_initialize(&thdev->dev);
  241. thdev->dev.bus = &intel_th_bus;
  242. thdev->dev.type = intel_th_device_type[type];
  243. thdev->dev.parent = parent;
  244. thdev->dev.dma_mask = parent->dma_mask;
  245. thdev->dev.dma_parms = parent->dma_parms;
  246. dma_set_coherent_mask(&thdev->dev, parent->coherent_dma_mask);
  247. if (id >= 0)
  248. dev_set_name(&thdev->dev, "%d-%s%d", th->id, name, id);
  249. else
  250. dev_set_name(&thdev->dev, "%d-%s", th->id, name);
  251. return thdev;
  252. }
  253. static int intel_th_device_add_resources(struct intel_th_device *thdev,
  254. struct resource *res, int nres)
  255. {
  256. struct resource *r;
  257. r = kmemdup(res, sizeof(*res) * nres, GFP_KERNEL);
  258. if (!r)
  259. return -ENOMEM;
  260. thdev->resource = r;
  261. thdev->num_resources = nres;
  262. return 0;
  263. }
  264. static void intel_th_device_remove(struct intel_th_device *thdev)
  265. {
  266. device_del(&thdev->dev);
  267. put_device(&thdev->dev);
  268. }
  269. static void intel_th_device_free(struct intel_th_device *thdev)
  270. {
  271. kfree(thdev->resource);
  272. kfree(thdev);
  273. }
  274. /*
  275. * Intel(R) Trace Hub subdevices
  276. */
  277. static struct intel_th_subdevice {
  278. const char *name;
  279. struct resource res[3];
  280. unsigned nres;
  281. unsigned type;
  282. unsigned otype;
  283. unsigned scrpd;
  284. int id;
  285. } intel_th_subdevices[TH_SUBDEVICE_MAX] = {
  286. {
  287. .nres = 1,
  288. .res = {
  289. {
  290. .start = REG_GTH_OFFSET,
  291. .end = REG_GTH_OFFSET + REG_GTH_LENGTH - 1,
  292. .flags = IORESOURCE_MEM,
  293. },
  294. },
  295. .name = "gth",
  296. .type = INTEL_TH_SWITCH,
  297. .id = -1,
  298. },
  299. {
  300. .nres = 2,
  301. .res = {
  302. {
  303. .start = REG_MSU_OFFSET,
  304. .end = REG_MSU_OFFSET + REG_MSU_LENGTH - 1,
  305. .flags = IORESOURCE_MEM,
  306. },
  307. {
  308. .start = BUF_MSU_OFFSET,
  309. .end = BUF_MSU_OFFSET + BUF_MSU_LENGTH - 1,
  310. .flags = IORESOURCE_MEM,
  311. },
  312. },
  313. .name = "msc",
  314. .id = 0,
  315. .type = INTEL_TH_OUTPUT,
  316. .otype = GTH_MSU,
  317. .scrpd = SCRPD_MEM_IS_PRIM_DEST | SCRPD_MSC0_IS_ENABLED,
  318. },
  319. {
  320. .nres = 2,
  321. .res = {
  322. {
  323. .start = REG_MSU_OFFSET,
  324. .end = REG_MSU_OFFSET + REG_MSU_LENGTH - 1,
  325. .flags = IORESOURCE_MEM,
  326. },
  327. {
  328. .start = BUF_MSU_OFFSET,
  329. .end = BUF_MSU_OFFSET + BUF_MSU_LENGTH - 1,
  330. .flags = IORESOURCE_MEM,
  331. },
  332. },
  333. .name = "msc",
  334. .id = 1,
  335. .type = INTEL_TH_OUTPUT,
  336. .otype = GTH_MSU,
  337. .scrpd = SCRPD_MEM_IS_PRIM_DEST | SCRPD_MSC1_IS_ENABLED,
  338. },
  339. {
  340. .nres = 2,
  341. .res = {
  342. {
  343. .start = REG_STH_OFFSET,
  344. .end = REG_STH_OFFSET + REG_STH_LENGTH - 1,
  345. .flags = IORESOURCE_MEM,
  346. },
  347. {
  348. .start = TH_MMIO_SW,
  349. .end = 0,
  350. .flags = IORESOURCE_MEM,
  351. },
  352. },
  353. .id = -1,
  354. .name = "sth",
  355. .type = INTEL_TH_SOURCE,
  356. },
  357. {
  358. .nres = 1,
  359. .res = {
  360. {
  361. .start = REG_PTI_OFFSET,
  362. .end = REG_PTI_OFFSET + REG_PTI_LENGTH - 1,
  363. .flags = IORESOURCE_MEM,
  364. },
  365. },
  366. .id = -1,
  367. .name = "pti",
  368. .type = INTEL_TH_OUTPUT,
  369. .otype = GTH_PTI,
  370. .scrpd = SCRPD_PTI_IS_PRIM_DEST,
  371. },
  372. {
  373. .nres = 1,
  374. .res = {
  375. {
  376. .start = REG_DCIH_OFFSET,
  377. .end = REG_DCIH_OFFSET + REG_DCIH_LENGTH - 1,
  378. .flags = IORESOURCE_MEM,
  379. },
  380. },
  381. .id = -1,
  382. .name = "dcih",
  383. .type = INTEL_TH_OUTPUT,
  384. },
  385. };
  386. static int intel_th_populate(struct intel_th *th, struct resource *devres,
  387. unsigned int ndevres, int irq)
  388. {
  389. struct resource res[3];
  390. unsigned int req = 0;
  391. int i, err;
  392. /* create devices for each intel_th_subdevice */
  393. for (i = 0; i < ARRAY_SIZE(intel_th_subdevices); i++) {
  394. struct intel_th_subdevice *subdev = &intel_th_subdevices[i];
  395. struct intel_th_device *thdev;
  396. int r;
  397. thdev = intel_th_device_alloc(th, subdev->type, subdev->name,
  398. subdev->id);
  399. if (!thdev) {
  400. err = -ENOMEM;
  401. goto kill_subdevs;
  402. }
  403. memcpy(res, subdev->res,
  404. sizeof(struct resource) * subdev->nres);
  405. for (r = 0; r < subdev->nres; r++) {
  406. int bar = TH_MMIO_CONFIG;
  407. /*
  408. * Take .end == 0 to mean 'take the whole bar',
  409. * .start then tells us which bar it is. Default to
  410. * TH_MMIO_CONFIG.
  411. */
  412. if (!res[r].end && res[r].flags == IORESOURCE_MEM) {
  413. bar = res[r].start;
  414. res[r].start = 0;
  415. res[r].end = resource_size(&devres[bar]) - 1;
  416. }
  417. if (res[r].flags & IORESOURCE_MEM) {
  418. res[r].start += devres[bar].start;
  419. res[r].end += devres[bar].start;
  420. dev_dbg(th->dev, "%s:%d @ %pR\n",
  421. subdev->name, r, &res[r]);
  422. } else if (res[r].flags & IORESOURCE_IRQ) {
  423. res[r].start = irq;
  424. }
  425. }
  426. err = intel_th_device_add_resources(thdev, res, subdev->nres);
  427. if (err) {
  428. put_device(&thdev->dev);
  429. goto kill_subdevs;
  430. }
  431. if (subdev->type == INTEL_TH_OUTPUT) {
  432. thdev->dev.devt = MKDEV(th->major, i);
  433. thdev->output.type = subdev->otype;
  434. thdev->output.port = -1;
  435. thdev->output.scratchpad = subdev->scrpd;
  436. }
  437. err = device_add(&thdev->dev);
  438. if (err) {
  439. put_device(&thdev->dev);
  440. goto kill_subdevs;
  441. }
  442. /* need switch driver to be loaded to enumerate the rest */
  443. if (subdev->type == INTEL_TH_SWITCH && !req) {
  444. th->hub = thdev;
  445. err = request_module("intel_th_%s", subdev->name);
  446. if (!err)
  447. req++;
  448. }
  449. th->thdev[i] = thdev;
  450. }
  451. return 0;
  452. kill_subdevs:
  453. for (i-- ; i >= 0; i--)
  454. intel_th_device_remove(th->thdev[i]);
  455. return err;
  456. }
  457. static int match_devt(struct device *dev, void *data)
  458. {
  459. dev_t devt = (dev_t)(unsigned long)data;
  460. return dev->devt == devt;
  461. }
  462. static int intel_th_output_open(struct inode *inode, struct file *file)
  463. {
  464. const struct file_operations *fops;
  465. struct intel_th_driver *thdrv;
  466. struct device *dev;
  467. int err;
  468. dev = bus_find_device(&intel_th_bus, NULL,
  469. (void *)(unsigned long)inode->i_rdev,
  470. match_devt);
  471. if (!dev || !dev->driver)
  472. return -ENODEV;
  473. thdrv = to_intel_th_driver(dev->driver);
  474. fops = fops_get(thdrv->fops);
  475. if (!fops)
  476. return -ENODEV;
  477. replace_fops(file, fops);
  478. file->private_data = to_intel_th_device(dev);
  479. if (file->f_op->open) {
  480. err = file->f_op->open(inode, file);
  481. return err;
  482. }
  483. return 0;
  484. }
  485. static const struct file_operations intel_th_output_fops = {
  486. .open = intel_th_output_open,
  487. .llseek = noop_llseek,
  488. };
  489. /**
  490. * intel_th_alloc() - allocate a new Intel TH device and its subdevices
  491. * @dev: parent device
  492. * @devres: parent's resources
  493. * @ndevres: number of resources
  494. * @irq: irq number
  495. */
  496. struct intel_th *
  497. intel_th_alloc(struct device *dev, struct resource *devres,
  498. unsigned int ndevres, int irq)
  499. {
  500. struct intel_th *th;
  501. int err;
  502. th = kzalloc(sizeof(*th), GFP_KERNEL);
  503. if (!th)
  504. return ERR_PTR(-ENOMEM);
  505. th->id = ida_simple_get(&intel_th_ida, 0, 0, GFP_KERNEL);
  506. if (th->id < 0) {
  507. err = th->id;
  508. goto err_alloc;
  509. }
  510. th->major = __register_chrdev(0, 0, TH_POSSIBLE_OUTPUTS,
  511. "intel_th/output", &intel_th_output_fops);
  512. if (th->major < 0) {
  513. err = th->major;
  514. goto err_ida;
  515. }
  516. th->dev = dev;
  517. dev_set_drvdata(dev, th);
  518. err = intel_th_populate(th, devres, ndevres, irq);
  519. if (err)
  520. goto err_chrdev;
  521. return th;
  522. err_chrdev:
  523. __unregister_chrdev(th->major, 0, TH_POSSIBLE_OUTPUTS,
  524. "intel_th/output");
  525. err_ida:
  526. ida_simple_remove(&intel_th_ida, th->id);
  527. err_alloc:
  528. kfree(th);
  529. return ERR_PTR(err);
  530. }
  531. EXPORT_SYMBOL_GPL(intel_th_alloc);
  532. void intel_th_free(struct intel_th *th)
  533. {
  534. int i;
  535. for (i = 0; i < TH_SUBDEVICE_MAX; i++)
  536. if (th->thdev[i] != th->hub)
  537. intel_th_device_remove(th->thdev[i]);
  538. intel_th_device_remove(th->hub);
  539. __unregister_chrdev(th->major, 0, TH_POSSIBLE_OUTPUTS,
  540. "intel_th/output");
  541. ida_simple_remove(&intel_th_ida, th->id);
  542. kfree(th);
  543. }
  544. EXPORT_SYMBOL_GPL(intel_th_free);
  545. /**
  546. * intel_th_trace_enable() - enable tracing for an output device
  547. * @thdev: output device that requests tracing be enabled
  548. */
  549. int intel_th_trace_enable(struct intel_th_device *thdev)
  550. {
  551. struct intel_th_device *hub = to_intel_th_device(thdev->dev.parent);
  552. struct intel_th_driver *hubdrv = to_intel_th_driver(hub->dev.driver);
  553. if (WARN_ON_ONCE(hub->type != INTEL_TH_SWITCH))
  554. return -EINVAL;
  555. if (WARN_ON_ONCE(thdev->type != INTEL_TH_OUTPUT))
  556. return -EINVAL;
  557. hubdrv->enable(hub, &thdev->output);
  558. return 0;
  559. }
  560. EXPORT_SYMBOL_GPL(intel_th_trace_enable);
  561. /**
  562. * intel_th_trace_disable() - disable tracing for an output device
  563. * @thdev: output device that requests tracing be disabled
  564. */
  565. int intel_th_trace_disable(struct intel_th_device *thdev)
  566. {
  567. struct intel_th_device *hub = to_intel_th_device(thdev->dev.parent);
  568. struct intel_th_driver *hubdrv = to_intel_th_driver(hub->dev.driver);
  569. WARN_ON_ONCE(hub->type != INTEL_TH_SWITCH);
  570. if (WARN_ON_ONCE(thdev->type != INTEL_TH_OUTPUT))
  571. return -EINVAL;
  572. hubdrv->disable(hub, &thdev->output);
  573. return 0;
  574. }
  575. EXPORT_SYMBOL_GPL(intel_th_trace_disable);
  576. int intel_th_set_output(struct intel_th_device *thdev,
  577. unsigned int master)
  578. {
  579. struct intel_th_device *hub = to_intel_th_device(thdev->dev.parent);
  580. struct intel_th_driver *hubdrv = to_intel_th_driver(hub->dev.driver);
  581. if (!hubdrv->set_output)
  582. return -ENOTSUPP;
  583. return hubdrv->set_output(hub, master);
  584. }
  585. EXPORT_SYMBOL_GPL(intel_th_set_output);
  586. static int __init intel_th_init(void)
  587. {
  588. intel_th_debug_init();
  589. return bus_register(&intel_th_bus);
  590. }
  591. subsys_initcall(intel_th_init);
  592. static void __exit intel_th_exit(void)
  593. {
  594. intel_th_debug_done();
  595. bus_unregister(&intel_th_bus);
  596. }
  597. module_exit(intel_th_exit);
  598. MODULE_LICENSE("GPL v2");
  599. MODULE_DESCRIPTION("Intel(R) Trace Hub controller driver");
  600. MODULE_AUTHOR("Alexander Shishkin <alexander.shishkin@linux.intel.com>");