aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/tpm/tpm-chip.c2
-rw-r--r--drivers/char/tpm/tpm_acpi.c8
-rw-r--r--drivers/char/tpm/tpm_eventlog.c26
-rw-r--r--drivers/char/tpm/tpm_of.c11
4 files changed, 26 insertions, 21 deletions
diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index 3f27753d96aa..7a4869151d3b 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -346,7 +346,7 @@ int tpm_chip_register(struct tpm_chip *chip)
346 tpm_sysfs_add_device(chip); 346 tpm_sysfs_add_device(chip);
347 347
348 rc = tpm_bios_log_setup(chip); 348 rc = tpm_bios_log_setup(chip);
349 if (rc == -ENODEV) 349 if (rc != 0 && rc != -ENODEV)
350 return rc; 350 return rc;
351 351
352 tpm_add_ppi(chip); 352 tpm_add_ppi(chip);
diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
index 0cb43ef5f79a..b7718c95fd0b 100644
--- a/drivers/char/tpm/tpm_acpi.c
+++ b/drivers/char/tpm/tpm_acpi.c
@@ -56,12 +56,18 @@ int tpm_read_log_acpi(struct tpm_chip *chip)
56 56
57 log = &chip->log; 57 log = &chip->log;
58 58
59 /* Unfortuntely ACPI does not associate the event log with a specific
60 * TPM, like PPI. Thus all ACPI TPMs will read the same log.
61 */
62 if (!chip->acpi_dev_handle)
63 return -ENODEV;
64
59 /* Find TCPA entry in RSDT (ACPI_LOGICAL_ADDRESSING) */ 65 /* Find TCPA entry in RSDT (ACPI_LOGICAL_ADDRESSING) */
60 status = acpi_get_table(ACPI_SIG_TCPA, 1, 66 status = acpi_get_table(ACPI_SIG_TCPA, 1,
61 (struct acpi_table_header **)&buff); 67 (struct acpi_table_header **)&buff);
62 68
63 if (ACPI_FAILURE(status)) 69 if (ACPI_FAILURE(status))
64 return -EIO; 70 return -ENODEV;
65 71
66 switch(buff->platform_class) { 72 switch(buff->platform_class) {
67 case BIOS_SERVER: 73 case BIOS_SERVER:
diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
index 34f0921f0203..c73f88cdeadf 100644
--- a/drivers/char/tpm/tpm_eventlog.c
+++ b/drivers/char/tpm/tpm_eventlog.c
@@ -368,14 +368,21 @@ static int tpm_read_log(struct tpm_chip *chip)
368 } 368 }
369 369
370 rc = tpm_read_log_acpi(chip); 370 rc = tpm_read_log_acpi(chip);
371 if ((rc == 0) || (rc == -ENOMEM)) 371 if (rc != -ENODEV)
372 return rc; 372 return rc;
373 373
374 rc = tpm_read_log_of(chip); 374 return tpm_read_log_of(chip);
375
376 return rc;
377} 375}
378 376
377/*
378 * tpm_bios_log_setup() - Read the event log from the firmware
379 * @chip: TPM chip to use.
380 *
381 * If an event log is found then the securityfs files are setup to
382 * export it to userspace, otherwise nothing is done.
383 *
384 * Returns -ENODEV if the firmware has no event log.
385 */
379int tpm_bios_log_setup(struct tpm_chip *chip) 386int tpm_bios_log_setup(struct tpm_chip *chip)
380{ 387{
381 const char *name = dev_name(&chip->dev); 388 const char *name = dev_name(&chip->dev);
@@ -386,15 +393,8 @@ int tpm_bios_log_setup(struct tpm_chip *chip)
386 return 0; 393 return 0;
387 394
388 rc = tpm_read_log(chip); 395 rc = tpm_read_log(chip);
389 /* 396 if (rc)
390 * read_log failure means event log is not supported except for ENOMEM. 397 return rc;
391 */
392 if (rc < 0) {
393 if (rc == -ENOMEM)
394 return -ENODEV;
395 else
396 return rc;
397 }
398 398
399 cnt = 0; 399 cnt = 0;
400 chip->bios_dir[cnt] = securityfs_create_dir(name, NULL); 400 chip->bios_dir[cnt] = securityfs_create_dir(name, NULL);
diff --git a/drivers/char/tpm/tpm_of.c b/drivers/char/tpm/tpm_of.c
index 36df9df4c472..7dee42d7b5e0 100644
--- a/drivers/char/tpm/tpm_of.c
+++ b/drivers/char/tpm/tpm_of.c
@@ -29,13 +29,16 @@ int tpm_read_log_of(struct tpm_chip *chip)
29 struct tpm_bios_log *log; 29 struct tpm_bios_log *log;
30 30
31 log = &chip->log; 31 log = &chip->log;
32 if (chip->dev.parent->of_node) 32 if (chip->dev.parent && chip->dev.parent->of_node)
33 np = chip->dev.parent->of_node; 33 np = chip->dev.parent->of_node;
34 else 34 else
35 return -ENODEV; 35 return -ENODEV;
36 36
37 sizep = of_get_property(np, "linux,sml-size", NULL); 37 sizep = of_get_property(np, "linux,sml-size", NULL);
38 if (sizep == NULL) 38 basep = of_get_property(np, "linux,sml-base", NULL);
39 if (sizep == NULL && basep == NULL)
40 return -ENODEV;
41 if (sizep == NULL || basep == NULL)
39 return -EIO; 42 return -EIO;
40 43
41 if (*sizep == 0) { 44 if (*sizep == 0) {
@@ -43,10 +46,6 @@ int tpm_read_log_of(struct tpm_chip *chip)
43 return -EIO; 46 return -EIO;
44 } 47 }
45 48
46 basep = of_get_property(np, "linux,sml-base", NULL);
47 if (basep == NULL)
48 return -EIO;
49
50 log->bios_event_log = kmalloc(*sizep, GFP_KERNEL); 49 log->bios_event_log = kmalloc(*sizep, GFP_KERNEL);
51 if (!log->bios_event_log) 50 if (!log->bios_event_log)
52 return -ENOMEM; 51 return -ENOMEM;