tpm.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. /*
  2. * Copyright (C) 2004 IBM Corporation
  3. *
  4. * Authors:
  5. * Leendert van Doorn <leendert@watson.ibm.com>
  6. * Dave Safford <safford@watson.ibm.com>
  7. * Reiner Sailer <sailer@watson.ibm.com>
  8. * Kylene Hall <kjhall@us.ibm.com>
  9. *
  10. * Maintained by: <tpmdd_devel@lists.sourceforge.net>
  11. *
  12. * Device driver for TCG/TCPA TPM (trusted platform module).
  13. * Specifications at www.trustedcomputinggroup.org
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License as
  17. * published by the Free Software Foundation, version 2 of the
  18. * License.
  19. *
  20. * Note, the TPM chip is not interrupt driven (only polling)
  21. * and can have very long timeouts (minutes!). Hence the unusual
  22. * calls to msleep.
  23. *
  24. */
  25. #include <linux/sched.h>
  26. #include <linux/poll.h>
  27. #include <linux/spinlock.h>
  28. #include "tpm.h"
  29. #define TPM_MINOR 224 /* officially assigned */
  30. #define TPM_BUFSIZE 2048
  31. /* PCI configuration addresses */
  32. #define PCI_GEN_PMCON_1 0xA0
  33. #define PCI_GEN1_DEC 0xE4
  34. #define PCI_LPC_EN 0xE6
  35. #define PCI_GEN2_DEC 0xEC
  36. static LIST_HEAD(tpm_chip_list);
  37. static DEFINE_SPINLOCK(driver_lock);
  38. static int dev_mask[32];
  39. static void user_reader_timeout(unsigned long ptr)
  40. {
  41. struct tpm_chip *chip = (struct tpm_chip *) ptr;
  42. down(&chip->buffer_mutex);
  43. atomic_set(&chip->data_pending, 0);
  44. memset(chip->data_buffer, 0, TPM_BUFSIZE);
  45. up(&chip->buffer_mutex);
  46. }
  47. /*
  48. * Initialize the LPC bus and enable the TPM ports
  49. */
  50. int tpm_lpc_bus_init(struct pci_dev *pci_dev, u16 base)
  51. {
  52. u32 lpcenable, tmp;
  53. int is_lpcm = 0;
  54. switch (pci_dev->vendor) {
  55. case PCI_VENDOR_ID_INTEL:
  56. switch (pci_dev->device) {
  57. case PCI_DEVICE_ID_INTEL_82801CA_12:
  58. case PCI_DEVICE_ID_INTEL_82801DB_12:
  59. is_lpcm = 1;
  60. break;
  61. }
  62. /* init ICH (enable LPC) */
  63. pci_read_config_dword(pci_dev, PCI_GEN1_DEC, &lpcenable);
  64. lpcenable |= 0x20000000;
  65. pci_write_config_dword(pci_dev, PCI_GEN1_DEC, lpcenable);
  66. if (is_lpcm) {
  67. pci_read_config_dword(pci_dev, PCI_GEN1_DEC,
  68. &lpcenable);
  69. if ((lpcenable & 0x20000000) == 0) {
  70. dev_err(&pci_dev->dev,
  71. "cannot enable LPC\n");
  72. return -ENODEV;
  73. }
  74. }
  75. /* initialize TPM registers */
  76. pci_read_config_dword(pci_dev, PCI_GEN2_DEC, &tmp);
  77. if (!is_lpcm)
  78. tmp = (tmp & 0xFFFF0000) | (base & 0xFFF0);
  79. else
  80. tmp =
  81. (tmp & 0xFFFF0000) | (base & 0xFFF0) |
  82. 0x00000001;
  83. pci_write_config_dword(pci_dev, PCI_GEN2_DEC, tmp);
  84. if (is_lpcm) {
  85. pci_read_config_dword(pci_dev, PCI_GEN_PMCON_1,
  86. &tmp);
  87. tmp |= 0x00000004; /* enable CLKRUN */
  88. pci_write_config_dword(pci_dev, PCI_GEN_PMCON_1,
  89. tmp);
  90. }
  91. tpm_write_index(0x0D, 0x55); /* unlock 4F */
  92. tpm_write_index(0x0A, 0x00); /* int disable */
  93. tpm_write_index(0x08, base); /* base addr lo */
  94. tpm_write_index(0x09, (base & 0xFF00) >> 8); /* base addr hi */
  95. tpm_write_index(0x0D, 0xAA); /* lock 4F */
  96. break;
  97. case PCI_VENDOR_ID_AMD:
  98. /* nothing yet */
  99. break;
  100. }
  101. return 0;
  102. }
  103. EXPORT_SYMBOL_GPL(tpm_lpc_bus_init);
  104. /*
  105. * Internal kernel interface to transmit TPM commands
  106. */
  107. static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
  108. size_t bufsiz)
  109. {
  110. ssize_t len;
  111. u32 count;
  112. __be32 *native_size;
  113. unsigned long stop;
  114. native_size = (__force __be32 *) (buf + 2);
  115. count = be32_to_cpu(*native_size);
  116. if (count == 0)
  117. return -ENODATA;
  118. if (count > bufsiz) {
  119. dev_err(&chip->pci_dev->dev,
  120. "invalid count value %x %zx \n", count, bufsiz);
  121. return -E2BIG;
  122. }
  123. down(&chip->tpm_mutex);
  124. if ((len = chip->vendor->send(chip, (u8 *) buf, count)) < 0) {
  125. dev_err(&chip->pci_dev->dev,
  126. "tpm_transmit: tpm_send: error %zd\n", len);
  127. return len;
  128. }
  129. stop = jiffies + 2 * 60 * HZ;
  130. do {
  131. u8 status = inb(chip->vendor->base + 1);
  132. if ((status & chip->vendor->req_complete_mask) ==
  133. chip->vendor->req_complete_val) {
  134. goto out_recv;
  135. }
  136. msleep(TPM_TIMEOUT); /* CHECK */
  137. rmb();
  138. } while (time_before(jiffies, stop));
  139. chip->vendor->cancel(chip);
  140. dev_err(&chip->pci_dev->dev, "Time expired\n");
  141. up(&chip->tpm_mutex);
  142. return -EIO;
  143. out_recv:
  144. len = chip->vendor->recv(chip, (u8 *) buf, bufsiz);
  145. if (len < 0)
  146. dev_err(&chip->pci_dev->dev,
  147. "tpm_transmit: tpm_recv: error %zd\n", len);
  148. up(&chip->tpm_mutex);
  149. return len;
  150. }
  151. #define TPM_DIGEST_SIZE 20
  152. #define CAP_PCR_RESULT_SIZE 18
  153. static u8 cap_pcr[] = {
  154. 0, 193, /* TPM_TAG_RQU_COMMAND */
  155. 0, 0, 0, 22, /* length */
  156. 0, 0, 0, 101, /* TPM_ORD_GetCapability */
  157. 0, 0, 0, 5,
  158. 0, 0, 0, 4,
  159. 0, 0, 1, 1
  160. };
  161. #define READ_PCR_RESULT_SIZE 30
  162. static u8 pcrread[] = {
  163. 0, 193, /* TPM_TAG_RQU_COMMAND */
  164. 0, 0, 0, 14, /* length */
  165. 0, 0, 0, 21, /* TPM_ORD_PcrRead */
  166. 0, 0, 0, 0 /* PCR index */
  167. };
  168. static ssize_t show_pcrs(struct device *dev, struct device_attribute *attr, char *buf)
  169. {
  170. u8 data[READ_PCR_RESULT_SIZE];
  171. ssize_t len;
  172. int i, j, index, num_pcrs;
  173. char *str = buf;
  174. struct tpm_chip *chip =
  175. pci_get_drvdata(container_of(dev, struct pci_dev, dev));
  176. if (chip == NULL)
  177. return -ENODEV;
  178. memcpy(data, cap_pcr, sizeof(cap_pcr));
  179. if ((len = tpm_transmit(chip, data, sizeof(data)))
  180. < CAP_PCR_RESULT_SIZE)
  181. return len;
  182. num_pcrs = be32_to_cpu(*((__force __be32 *) (data + 14)));
  183. for (i = 0; i < num_pcrs; i++) {
  184. memcpy(data, pcrread, sizeof(pcrread));
  185. index = cpu_to_be32(i);
  186. memcpy(data + 10, &index, 4);
  187. if ((len = tpm_transmit(chip, data, sizeof(data)))
  188. < READ_PCR_RESULT_SIZE)
  189. return len;
  190. str += sprintf(str, "PCR-%02d: ", i);
  191. for (j = 0; j < TPM_DIGEST_SIZE; j++)
  192. str += sprintf(str, "%02X ", *(data + 10 + j));
  193. str += sprintf(str, "\n");
  194. }
  195. return str - buf;
  196. }
  197. static DEVICE_ATTR(pcrs, S_IRUGO, show_pcrs, NULL);
  198. #define READ_PUBEK_RESULT_SIZE 314
  199. static u8 readpubek[] = {
  200. 0, 193, /* TPM_TAG_RQU_COMMAND */
  201. 0, 0, 0, 30, /* length */
  202. 0, 0, 0, 124, /* TPM_ORD_ReadPubek */
  203. };
  204. static ssize_t show_pubek(struct device *dev, struct device_attribute *attr, char *buf)
  205. {
  206. u8 data[READ_PUBEK_RESULT_SIZE];
  207. ssize_t len;
  208. __be32 *native_val;
  209. int i;
  210. char *str = buf;
  211. struct tpm_chip *chip =
  212. pci_get_drvdata(container_of(dev, struct pci_dev, dev));
  213. if (chip == NULL)
  214. return -ENODEV;
  215. memcpy(data, readpubek, sizeof(readpubek));
  216. memset(data + sizeof(readpubek), 0, 20); /* zero nonce */
  217. if ((len = tpm_transmit(chip, data, sizeof(data))) <
  218. READ_PUBEK_RESULT_SIZE)
  219. return len;
  220. /*
  221. ignore header 10 bytes
  222. algorithm 32 bits (1 == RSA )
  223. encscheme 16 bits
  224. sigscheme 16 bits
  225. parameters (RSA 12->bytes: keybit, #primes, expbit)
  226. keylenbytes 32 bits
  227. 256 byte modulus
  228. ignore checksum 20 bytes
  229. */
  230. native_val = (__force __be32 *) (data + 34);
  231. str +=
  232. sprintf(str,
  233. "Algorithm: %02X %02X %02X %02X\nEncscheme: %02X %02X\n"
  234. "Sigscheme: %02X %02X\nParameters: %02X %02X %02X %02X"
  235. " %02X %02X %02X %02X %02X %02X %02X %02X\n"
  236. "Modulus length: %d\nModulus: \n",
  237. data[10], data[11], data[12], data[13], data[14],
  238. data[15], data[16], data[17], data[22], data[23],
  239. data[24], data[25], data[26], data[27], data[28],
  240. data[29], data[30], data[31], data[32], data[33],
  241. be32_to_cpu(*native_val)
  242. );
  243. for (i = 0; i < 256; i++) {
  244. str += sprintf(str, "%02X ", data[i + 39]);
  245. if ((i + 1) % 16 == 0)
  246. str += sprintf(str, "\n");
  247. }
  248. return str - buf;
  249. }
  250. static DEVICE_ATTR(pubek, S_IRUGO, show_pubek, NULL);
  251. #define CAP_VER_RESULT_SIZE 18
  252. static u8 cap_version[] = {
  253. 0, 193, /* TPM_TAG_RQU_COMMAND */
  254. 0, 0, 0, 18, /* length */
  255. 0, 0, 0, 101, /* TPM_ORD_GetCapability */
  256. 0, 0, 0, 6,
  257. 0, 0, 0, 0
  258. };
  259. #define CAP_MANUFACTURER_RESULT_SIZE 18
  260. static u8 cap_manufacturer[] = {
  261. 0, 193, /* TPM_TAG_RQU_COMMAND */
  262. 0, 0, 0, 22, /* length */
  263. 0, 0, 0, 101, /* TPM_ORD_GetCapability */
  264. 0, 0, 0, 5,
  265. 0, 0, 0, 4,
  266. 0, 0, 1, 3
  267. };
  268. static ssize_t show_caps(struct device *dev, struct device_attribute *attr, char *buf)
  269. {
  270. u8 data[READ_PUBEK_RESULT_SIZE];
  271. ssize_t len;
  272. char *str = buf;
  273. struct tpm_chip *chip =
  274. pci_get_drvdata(container_of(dev, struct pci_dev, dev));
  275. if (chip == NULL)
  276. return -ENODEV;
  277. memcpy(data, cap_manufacturer, sizeof(cap_manufacturer));
  278. if ((len = tpm_transmit(chip, data, sizeof(data))) <
  279. CAP_MANUFACTURER_RESULT_SIZE)
  280. return len;
  281. str += sprintf(str, "Manufacturer: 0x%x\n",
  282. be32_to_cpu(*(data + 14)));
  283. memcpy(data, cap_version, sizeof(cap_version));
  284. if ((len = tpm_transmit(chip, data, sizeof(data))) <
  285. CAP_VER_RESULT_SIZE)
  286. return len;
  287. str +=
  288. sprintf(str, "TCG version: %d.%d\nFirmware version: %d.%d\n",
  289. (int) data[14], (int) data[15], (int) data[16],
  290. (int) data[17]);
  291. return str - buf;
  292. }
  293. static DEVICE_ATTR(caps, S_IRUGO, show_caps, NULL);
  294. /*
  295. * Device file system interface to the TPM
  296. */
  297. int tpm_open(struct inode *inode, struct file *file)
  298. {
  299. int rc = 0, minor = iminor(inode);
  300. struct tpm_chip *chip = NULL, *pos;
  301. spin_lock(&driver_lock);
  302. list_for_each_entry(pos, &tpm_chip_list, list) {
  303. if (pos->vendor->miscdev.minor == minor) {
  304. chip = pos;
  305. break;
  306. }
  307. }
  308. if (chip == NULL) {
  309. rc = -ENODEV;
  310. goto err_out;
  311. }
  312. if (chip->num_opens) {
  313. dev_dbg(&chip->pci_dev->dev,
  314. "Another process owns this TPM\n");
  315. rc = -EBUSY;
  316. goto err_out;
  317. }
  318. chip->num_opens++;
  319. pci_dev_get(chip->pci_dev);
  320. spin_unlock(&driver_lock);
  321. chip->data_buffer = kmalloc(TPM_BUFSIZE * sizeof(u8), GFP_KERNEL);
  322. if (chip->data_buffer == NULL) {
  323. chip->num_opens--;
  324. pci_dev_put(chip->pci_dev);
  325. return -ENOMEM;
  326. }
  327. atomic_set(&chip->data_pending, 0);
  328. file->private_data = chip;
  329. return 0;
  330. err_out:
  331. spin_unlock(&driver_lock);
  332. return rc;
  333. }
  334. EXPORT_SYMBOL_GPL(tpm_open);
  335. int tpm_release(struct inode *inode, struct file *file)
  336. {
  337. struct tpm_chip *chip = file->private_data;
  338. file->private_data = NULL;
  339. spin_lock(&driver_lock);
  340. chip->num_opens--;
  341. spin_unlock(&driver_lock);
  342. down(&chip->timer_manipulation_mutex);
  343. if (timer_pending(&chip->user_read_timer))
  344. del_singleshot_timer_sync(&chip->user_read_timer);
  345. else if (timer_pending(&chip->device_timer))
  346. del_singleshot_timer_sync(&chip->device_timer);
  347. up(&chip->timer_manipulation_mutex);
  348. kfree(chip->data_buffer);
  349. atomic_set(&chip->data_pending, 0);
  350. pci_dev_put(chip->pci_dev);
  351. return 0;
  352. }
  353. EXPORT_SYMBOL_GPL(tpm_release);
  354. ssize_t tpm_write(struct file * file, const char __user * buf,
  355. size_t size, loff_t * off)
  356. {
  357. struct tpm_chip *chip = file->private_data;
  358. int in_size = size, out_size;
  359. /* cannot perform a write until the read has cleared
  360. either via tpm_read or a user_read_timer timeout */
  361. while (atomic_read(&chip->data_pending) != 0)
  362. msleep(TPM_TIMEOUT);
  363. down(&chip->buffer_mutex);
  364. if (in_size > TPM_BUFSIZE)
  365. in_size = TPM_BUFSIZE;
  366. if (copy_from_user
  367. (chip->data_buffer, (void __user *) buf, in_size)) {
  368. up(&chip->buffer_mutex);
  369. return -EFAULT;
  370. }
  371. /* atomic tpm command send and result receive */
  372. out_size = tpm_transmit(chip, chip->data_buffer, TPM_BUFSIZE);
  373. atomic_set(&chip->data_pending, out_size);
  374. up(&chip->buffer_mutex);
  375. /* Set a timeout by which the reader must come claim the result */
  376. down(&chip->timer_manipulation_mutex);
  377. init_timer(&chip->user_read_timer);
  378. chip->user_read_timer.function = user_reader_timeout;
  379. chip->user_read_timer.data = (unsigned long) chip;
  380. chip->user_read_timer.expires = jiffies + (60 * HZ);
  381. add_timer(&chip->user_read_timer);
  382. up(&chip->timer_manipulation_mutex);
  383. return in_size;
  384. }
  385. EXPORT_SYMBOL_GPL(tpm_write);
  386. ssize_t tpm_read(struct file * file, char __user * buf,
  387. size_t size, loff_t * off)
  388. {
  389. struct tpm_chip *chip = file->private_data;
  390. int ret_size = -ENODATA;
  391. if (atomic_read(&chip->data_pending) != 0) { /* Result available */
  392. down(&chip->timer_manipulation_mutex);
  393. del_singleshot_timer_sync(&chip->user_read_timer);
  394. up(&chip->timer_manipulation_mutex);
  395. down(&chip->buffer_mutex);
  396. ret_size = atomic_read(&chip->data_pending);
  397. atomic_set(&chip->data_pending, 0);
  398. if (ret_size == 0) /* timeout just occurred */
  399. ret_size = -ETIME;
  400. else if (ret_size > 0) { /* relay data */
  401. if (size < ret_size)
  402. ret_size = size;
  403. if (copy_to_user((void __user *) buf,
  404. chip->data_buffer, ret_size)) {
  405. ret_size = -EFAULT;
  406. }
  407. }
  408. up(&chip->buffer_mutex);
  409. }
  410. return ret_size;
  411. }
  412. EXPORT_SYMBOL_GPL(tpm_read);
  413. void __devexit tpm_remove(struct pci_dev *pci_dev)
  414. {
  415. struct tpm_chip *chip = pci_get_drvdata(pci_dev);
  416. if (chip == NULL) {
  417. dev_err(&pci_dev->dev, "No device data found\n");
  418. return;
  419. }
  420. spin_lock(&driver_lock);
  421. list_del(&chip->list);
  422. spin_unlock(&driver_lock);
  423. pci_set_drvdata(pci_dev, NULL);
  424. misc_deregister(&chip->vendor->miscdev);
  425. device_remove_file(&pci_dev->dev, &dev_attr_pubek);
  426. device_remove_file(&pci_dev->dev, &dev_attr_pcrs);
  427. device_remove_file(&pci_dev->dev, &dev_attr_caps);
  428. pci_disable_device(pci_dev);
  429. dev_mask[chip->dev_num / 32] &= !(1 << (chip->dev_num % 32));
  430. kfree(chip);
  431. pci_dev_put(pci_dev);
  432. }
  433. EXPORT_SYMBOL_GPL(tpm_remove);
  434. static u8 savestate[] = {
  435. 0, 193, /* TPM_TAG_RQU_COMMAND */
  436. 0, 0, 0, 10, /* blob length (in bytes) */
  437. 0, 0, 0, 152 /* TPM_ORD_SaveState */
  438. };
  439. /*
  440. * We are about to suspend. Save the TPM state
  441. * so that it can be restored.
  442. */
  443. int tpm_pm_suspend(struct pci_dev *pci_dev, pm_message_t pm_state)
  444. {
  445. struct tpm_chip *chip = pci_get_drvdata(pci_dev);
  446. if (chip == NULL)
  447. return -ENODEV;
  448. tpm_transmit(chip, savestate, sizeof(savestate));
  449. return 0;
  450. }
  451. EXPORT_SYMBOL_GPL(tpm_pm_suspend);
  452. /*
  453. * Resume from a power safe. The BIOS already restored
  454. * the TPM state.
  455. */
  456. int tpm_pm_resume(struct pci_dev *pci_dev)
  457. {
  458. struct tpm_chip *chip = pci_get_drvdata(pci_dev);
  459. if (chip == NULL)
  460. return -ENODEV;
  461. spin_lock(&driver_lock);
  462. tpm_lpc_bus_init(pci_dev, chip->vendor->base);
  463. spin_unlock(&driver_lock);
  464. return 0;
  465. }
  466. EXPORT_SYMBOL_GPL(tpm_pm_resume);
  467. /*
  468. * Called from tpm_<specific>.c probe function only for devices
  469. * the driver has determined it should claim. Prior to calling
  470. * this function the specific probe function has called pci_enable_device
  471. * upon errant exit from this function specific probe function should call
  472. * pci_disable_device
  473. */
  474. int tpm_register_hardware(struct pci_dev *pci_dev,
  475. struct tpm_vendor_specific *entry)
  476. {
  477. char devname[7];
  478. struct tpm_chip *chip;
  479. int i, j;
  480. /* Driver specific per-device data */
  481. chip = kmalloc(sizeof(*chip), GFP_KERNEL);
  482. if (chip == NULL)
  483. return -ENOMEM;
  484. memset(chip, 0, sizeof(struct tpm_chip));
  485. init_MUTEX(&chip->buffer_mutex);
  486. init_MUTEX(&chip->tpm_mutex);
  487. init_MUTEX(&chip->timer_manipulation_mutex);
  488. INIT_LIST_HEAD(&chip->list);
  489. chip->vendor = entry;
  490. chip->dev_num = -1;
  491. for (i = 0; i < 32; i++)
  492. for (j = 0; j < 8; j++)
  493. if ((dev_mask[i] & (1 << j)) == 0) {
  494. chip->dev_num = i * 32 + j;
  495. dev_mask[i] |= 1 << j;
  496. goto dev_num_search_complete;
  497. }
  498. dev_num_search_complete:
  499. if (chip->dev_num < 0) {
  500. dev_err(&pci_dev->dev,
  501. "No available tpm device numbers\n");
  502. kfree(chip);
  503. return -ENODEV;
  504. } else if (chip->dev_num == 0)
  505. chip->vendor->miscdev.minor = TPM_MINOR;
  506. else
  507. chip->vendor->miscdev.minor = MISC_DYNAMIC_MINOR;
  508. snprintf(devname, sizeof(devname), "%s%d", "tpm", chip->dev_num);
  509. chip->vendor->miscdev.name = devname;
  510. chip->vendor->miscdev.dev = &(pci_dev->dev);
  511. chip->pci_dev = pci_dev_get(pci_dev);
  512. if (misc_register(&chip->vendor->miscdev)) {
  513. dev_err(&chip->pci_dev->dev,
  514. "unable to misc_register %s, minor %d\n",
  515. chip->vendor->miscdev.name,
  516. chip->vendor->miscdev.minor);
  517. pci_dev_put(pci_dev);
  518. kfree(chip);
  519. dev_mask[i] &= !(1 << j);
  520. return -ENODEV;
  521. }
  522. pci_set_drvdata(pci_dev, chip);
  523. list_add(&chip->list, &tpm_chip_list);
  524. device_create_file(&pci_dev->dev, &dev_attr_pubek);
  525. device_create_file(&pci_dev->dev, &dev_attr_pcrs);
  526. device_create_file(&pci_dev->dev, &dev_attr_caps);
  527. return 0;
  528. }
  529. EXPORT_SYMBOL_GPL(tpm_register_hardware);
  530. static int __init init_tpm(void)
  531. {
  532. return 0;
  533. }
  534. static void __exit cleanup_tpm(void)
  535. {
  536. }
  537. module_init(init_tpm);
  538. module_exit(cleanup_tpm);
  539. MODULE_AUTHOR("Leendert van Doorn (leendert@watson.ibm.com)");
  540. MODULE_DESCRIPTION("TPM Driver");
  541. MODULE_VERSION("2.0");
  542. MODULE_LICENSE("GPL");