diff options
author | Jerry Snitselaar <jsnitsel@redhat.com> | 2019-01-30 17:06:58 -0500 |
---|---|---|
committer | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> | 2019-02-13 02:47:01 -0500 |
commit | 36ce089758b1b55df5854d6b6d74713f609e125d (patch) | |
tree | 45bd1df16ab47554076866dab97b88bf22a1ddca | |
parent | 08a8112ad9c17ec3d78363bf7123df6598f09bc2 (diff) |
tpm: don't return bool from update_timeouts
Set tpm_chip->timeouts_adjusted directly in the update_timeouts
code instead of returning bool. In case of tpm read failing
print warning that the read failed and continue on.
Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
-rw-r--r-- | drivers/char/tpm/tpm1-cmd.c | 3 | ||||
-rw-r--r-- | drivers/char/tpm/tpm_tis_core.c | 15 | ||||
-rw-r--r-- | include/linux/tpm.h | 2 |
3 files changed, 11 insertions, 9 deletions
diff --git a/drivers/char/tpm/tpm1-cmd.c b/drivers/char/tpm/tpm1-cmd.c index 6f306338953b..bda9a16b44f6 100644 --- a/drivers/char/tpm/tpm1-cmd.c +++ b/drivers/char/tpm/tpm1-cmd.c | |||
@@ -380,8 +380,7 @@ int tpm1_get_timeouts(struct tpm_chip *chip) | |||
380 | * of misreporting. | 380 | * of misreporting. |
381 | */ | 381 | */ |
382 | if (chip->ops->update_timeouts) | 382 | if (chip->ops->update_timeouts) |
383 | chip->timeout_adjusted = | 383 | chip->ops->update_timeouts(chip, timeout_eff); |
384 | chip->ops->update_timeouts(chip, timeout_eff); | ||
385 | 384 | ||
386 | if (!chip->timeout_adjusted) { | 385 | if (!chip->timeout_adjusted) { |
387 | /* Restore default if chip reported 0 */ | 386 | /* Restore default if chip reported 0 */ |
diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index bb0c2e160562..c6b0c6d541a5 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c | |||
@@ -521,35 +521,38 @@ static const struct tis_vendor_timeout_override vendor_timeout_overrides[] = { | |||
521 | (TIS_SHORT_TIMEOUT*1000), (TIS_SHORT_TIMEOUT*1000) } }, | 521 | (TIS_SHORT_TIMEOUT*1000), (TIS_SHORT_TIMEOUT*1000) } }, |
522 | }; | 522 | }; |
523 | 523 | ||
524 | static bool tpm_tis_update_timeouts(struct tpm_chip *chip, | 524 | static void tpm_tis_update_timeouts(struct tpm_chip *chip, |
525 | unsigned long *timeout_cap) | 525 | unsigned long *timeout_cap) |
526 | { | 526 | { |
527 | struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); | 527 | struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); |
528 | int i, rc; | 528 | int i, rc; |
529 | u32 did_vid; | 529 | u32 did_vid; |
530 | 530 | ||
531 | chip->timeout_adjusted = false; | ||
532 | |||
531 | if (chip->ops->clk_enable != NULL) | 533 | if (chip->ops->clk_enable != NULL) |
532 | chip->ops->clk_enable(chip, true); | 534 | chip->ops->clk_enable(chip, true); |
533 | 535 | ||
534 | rc = tpm_tis_read32(priv, TPM_DID_VID(0), &did_vid); | 536 | rc = tpm_tis_read32(priv, TPM_DID_VID(0), &did_vid); |
535 | if (rc < 0) | 537 | if (rc < 0) { |
538 | dev_warn(&chip->dev, "%s: failed to read did_vid: %d\n", | ||
539 | __func__, rc); | ||
536 | goto out; | 540 | goto out; |
541 | } | ||
537 | 542 | ||
538 | for (i = 0; i != ARRAY_SIZE(vendor_timeout_overrides); i++) { | 543 | for (i = 0; i != ARRAY_SIZE(vendor_timeout_overrides); i++) { |
539 | if (vendor_timeout_overrides[i].did_vid != did_vid) | 544 | if (vendor_timeout_overrides[i].did_vid != did_vid) |
540 | continue; | 545 | continue; |
541 | memcpy(timeout_cap, vendor_timeout_overrides[i].timeout_us, | 546 | memcpy(timeout_cap, vendor_timeout_overrides[i].timeout_us, |
542 | sizeof(vendor_timeout_overrides[i].timeout_us)); | 547 | sizeof(vendor_timeout_overrides[i].timeout_us)); |
543 | rc = true; | 548 | chip->timeout_adjusted = true; |
544 | } | 549 | } |
545 | 550 | ||
546 | rc = false; | ||
547 | |||
548 | out: | 551 | out: |
549 | if (chip->ops->clk_enable != NULL) | 552 | if (chip->ops->clk_enable != NULL) |
550 | chip->ops->clk_enable(chip, false); | 553 | chip->ops->clk_enable(chip, false); |
551 | 554 | ||
552 | return rc; | 555 | return; |
553 | } | 556 | } |
554 | 557 | ||
555 | /* | 558 | /* |
diff --git a/include/linux/tpm.h b/include/linux/tpm.h index b49a55cf775f..13563b8c0c3a 100644 --- a/include/linux/tpm.h +++ b/include/linux/tpm.h | |||
@@ -41,7 +41,7 @@ struct tpm_class_ops { | |||
41 | int (*send) (struct tpm_chip *chip, u8 *buf, size_t len); | 41 | int (*send) (struct tpm_chip *chip, u8 *buf, size_t len); |
42 | void (*cancel) (struct tpm_chip *chip); | 42 | void (*cancel) (struct tpm_chip *chip); |
43 | u8 (*status) (struct tpm_chip *chip); | 43 | u8 (*status) (struct tpm_chip *chip); |
44 | bool (*update_timeouts)(struct tpm_chip *chip, | 44 | void (*update_timeouts)(struct tpm_chip *chip, |
45 | unsigned long *timeout_cap); | 45 | unsigned long *timeout_cap); |
46 | int (*go_idle)(struct tpm_chip *chip); | 46 | int (*go_idle)(struct tpm_chip *chip); |
47 | int (*cmd_ready)(struct tpm_chip *chip); | 47 | int (*cmd_ready)(struct tpm_chip *chip); |