Commit 7518a21a authored by Jarkko Sakkinen's avatar Jarkko Sakkinen

tpm: drop tpm1_chip_register(/unregister)

Check for TPM2 chip in tpm_sysfs_add_device, tpm_bios_log_setup and
tpm_bios_log_teardown in order to make code flow cleaner and to enable
to implement TPM 2.0 support later on. This is partially derived from
the commit by Nayna Jain with the extension that also tpm1_chip_register
is dropped.
Signed-off-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reviewed-by: default avatarJason Gunthorpe <jgunthorpe@obsidianresearch.com>
Reviewed-by: default avatarNayna Jain <nayna@linux.vnet.ibm.com>
Tested-by: default avatarJason Gunthorpe <jgunthorpe@obsidianresearch.com>
Tested-by: default avatarNayna Jain <nayna@linux.vnet.ibm.com>
parent cd9b7631
...@@ -276,28 +276,6 @@ static void tpm_del_char_device(struct tpm_chip *chip) ...@@ -276,28 +276,6 @@ static void tpm_del_char_device(struct tpm_chip *chip)
up_write(&chip->ops_sem); up_write(&chip->ops_sem);
} }
static int tpm1_chip_register(struct tpm_chip *chip)
{
int rc;
if (chip->flags & TPM_CHIP_FLAG_TPM2)
return 0;
tpm_sysfs_add_device(chip);
rc = tpm_bios_log_setup(chip);
return rc;
}
static void tpm1_chip_unregister(struct tpm_chip *chip)
{
if (chip->flags & TPM_CHIP_FLAG_TPM2)
return;
tpm_bios_log_teardown(chip);
}
static void tpm_del_legacy_sysfs(struct tpm_chip *chip) static void tpm_del_legacy_sysfs(struct tpm_chip *chip)
{ {
struct attribute **i; struct attribute **i;
...@@ -364,7 +342,9 @@ int tpm_chip_register(struct tpm_chip *chip) ...@@ -364,7 +342,9 @@ int tpm_chip_register(struct tpm_chip *chip)
return rc; return rc;
} }
rc = tpm1_chip_register(chip); tpm_sysfs_add_device(chip);
rc = tpm_bios_log_setup(chip);
if (rc) if (rc)
return rc; return rc;
...@@ -372,7 +352,7 @@ int tpm_chip_register(struct tpm_chip *chip) ...@@ -372,7 +352,7 @@ int tpm_chip_register(struct tpm_chip *chip)
rc = tpm_add_char_device(chip); rc = tpm_add_char_device(chip);
if (rc) { if (rc) {
tpm1_chip_unregister(chip); tpm_bios_log_teardown(chip);
return rc; return rc;
} }
...@@ -402,8 +382,7 @@ EXPORT_SYMBOL_GPL(tpm_chip_register); ...@@ -402,8 +382,7 @@ EXPORT_SYMBOL_GPL(tpm_chip_register);
void tpm_chip_unregister(struct tpm_chip *chip) void tpm_chip_unregister(struct tpm_chip *chip)
{ {
tpm_del_legacy_sysfs(chip); tpm_del_legacy_sysfs(chip);
tpm_bios_log_teardown(chip);
tpm1_chip_unregister(chip);
tpm_del_char_device(chip); tpm_del_char_device(chip);
} }
EXPORT_SYMBOL_GPL(tpm_chip_unregister); EXPORT_SYMBOL_GPL(tpm_chip_unregister);
...@@ -284,6 +284,9 @@ static const struct attribute_group tpm_dev_group = { ...@@ -284,6 +284,9 @@ static const struct attribute_group tpm_dev_group = {
void tpm_sysfs_add_device(struct tpm_chip *chip) void tpm_sysfs_add_device(struct tpm_chip *chip)
{ {
if (chip->flags & TPM_CHIP_FLAG_TPM2)
return;
/* The sysfs routines rely on an implicit tpm_try_get_ops, device_del /* The sysfs routines rely on an implicit tpm_try_get_ops, device_del
* is called before ops is null'd and the sysfs core synchronizes this * is called before ops is null'd and the sysfs core synchronizes this
* removal so that no callbacks are running or can run again * removal so that no callbacks are running or can run again
......
...@@ -364,6 +364,9 @@ int tpm_bios_log_setup(struct tpm_chip *chip) ...@@ -364,6 +364,9 @@ int tpm_bios_log_setup(struct tpm_chip *chip)
const char *name = dev_name(&chip->dev); const char *name = dev_name(&chip->dev);
unsigned int cnt; unsigned int cnt;
if (chip->flags & TPM_CHIP_FLAG_TPM2)
return 0;
cnt = 0; cnt = 0;
chip->bios_dir[cnt] = securityfs_create_dir(name, NULL); chip->bios_dir[cnt] = securityfs_create_dir(name, NULL);
/* NOTE: securityfs_create_dir can return ENODEV if securityfs is /* NOTE: securityfs_create_dir can return ENODEV if securityfs is
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment