}
/*
- * tpm_chip_startup() - performs auto startup and allocates the PCRs
+ * tpm_chip_bootstrap() - Boostrap TPM chip after power on
* @chip: TPM chip to use.
+ *
+ * Initialize TPM chip after power on. This a one-shot function: subsequent
+ * calls will have no effect.
*/
-int tpm_chip_startup(struct tpm_chip *chip)
+int tpm_chip_bootstrap(struct tpm_chip *chip)
{
int rc;
+ if (chip->flags & TPM_CHIP_FLAG_BOOTSTRAPPED)
+ return 0;
+
rc = tpm_chip_start(chip);
if (rc)
return rc;
stop:
tpm_chip_stop(chip);
+ /*
+ * Unconditionally set, as driver initialization should cease, when the
+ * boostrapping process fails.
+ */
+ chip->flags |= TPM_CHIP_FLAG_BOOTSTRAPPED;
+
return rc;
}
-EXPORT_SYMBOL_GPL(tpm_chip_startup);
+EXPORT_SYMBOL_GPL(tpm_chip_bootstrap);
/*
* tpm_chip_register() - create a character device for the TPM chip
{
int rc;
+ rc = tpm_chip_bootstrap(chip);
+ if (rc)
+ return rc;
+
tpm_sysfs_add_device(chip);
tpm_bios_log_setup(chip);