Skip to content

Commit 36ce089

Browse files
snitsJarkko Sakkinen
authored andcommitted
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>
1 parent 08a8112 commit 36ce089

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

drivers/char/tpm/tpm1-cmd.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,7 @@ int tpm1_get_timeouts(struct tpm_chip *chip)
380380
* of misreporting.
381381
*/
382382
if (chip->ops->update_timeouts)
383-
chip->timeout_adjusted =
384-
chip->ops->update_timeouts(chip, timeout_eff);
383+
chip->ops->update_timeouts(chip, timeout_eff);
385384

386385
if (!chip->timeout_adjusted) {
387386
/* Restore default if chip reported 0 */

drivers/char/tpm/tpm_tis_core.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -521,35 +521,38 @@ static const struct tis_vendor_timeout_override vendor_timeout_overrides[] = {
521521
(TIS_SHORT_TIMEOUT*1000), (TIS_SHORT_TIMEOUT*1000) } },
522522
};
523523

524-
static bool tpm_tis_update_timeouts(struct tpm_chip *chip,
524+
static void tpm_tis_update_timeouts(struct tpm_chip *chip,
525525
unsigned long *timeout_cap)
526526
{
527527
struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev);
528528
int i, rc;
529529
u32 did_vid;
530530

531+
chip->timeout_adjusted = false;
532+
531533
if (chip->ops->clk_enable != NULL)
532534
chip->ops->clk_enable(chip, true);
533535

534536
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);
536540
goto out;
541+
}
537542

538543
for (i = 0; i != ARRAY_SIZE(vendor_timeout_overrides); i++) {
539544
if (vendor_timeout_overrides[i].did_vid != did_vid)
540545
continue;
541546
memcpy(timeout_cap, vendor_timeout_overrides[i].timeout_us,
542547
sizeof(vendor_timeout_overrides[i].timeout_us));
543-
rc = true;
548+
chip->timeout_adjusted = true;
544549
}
545550

546-
rc = false;
547-
548551
out:
549552
if (chip->ops->clk_enable != NULL)
550553
chip->ops->clk_enable(chip, false);
551554

552-
return rc;
555+
return;
553556
}
554557

555558
/*

include/linux/tpm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct tpm_class_ops {
4141
int (*send) (struct tpm_chip *chip, u8 *buf, size_t len);
4242
void (*cancel) (struct tpm_chip *chip);
4343
u8 (*status) (struct tpm_chip *chip);
44-
bool (*update_timeouts)(struct tpm_chip *chip,
44+
void (*update_timeouts)(struct tpm_chip *chip,
4545
unsigned long *timeout_cap);
4646
int (*go_idle)(struct tpm_chip *chip);
4747
int (*cmd_ready)(struct tpm_chip *chip);

0 commit comments

Comments
 (0)