Skip to content

Commit 0c22db4

Browse files
Winkler, TomasJarkko Sakkinen
authored andcommitted
tpm/tpm_crb: open code the crb_init into acpi_add
This is preparation step for implementing tpm crb runtime pm. We need to have tpm chip allocated and populated before we access the runtime handlers. Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Tested-by: Jarkko Sakkinen <jarkko.sakkinn@linux.intel.com>
1 parent 9514ff1 commit 0c22db4

1 file changed

Lines changed: 10 additions & 16 deletions

File tree

‎drivers/char/tpm/tpm_crb.c‎

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -265,21 +265,6 @@ static const struct tpm_class_ops tpm_crb = {
265265
.req_complete_val = CRB_DRV_STS_COMPLETE,
266266
};
267267

268-
static int crb_init(struct acpi_device *device, struct crb_priv *priv)
269-
{
270-
struct tpm_chip *chip;
271-
272-
chip = tpmm_chip_alloc(&device->dev, &tpm_crb);
273-
if (IS_ERR(chip))
274-
return PTR_ERR(chip);
275-
276-
dev_set_drvdata(&chip->dev, priv);
277-
chip->acpi_dev_handle = device->handle;
278-
chip->flags = TPM_CHIP_FLAG_TPM2;
279-
280-
return tpm_chip_register(chip);
281-
}
282-
283268
static int crb_check_resource(struct acpi_resource *ares, void *data)
284269
{
285270
struct resource *io_res = data;
@@ -401,6 +386,7 @@ static int crb_acpi_add(struct acpi_device *device)
401386
{
402387
struct acpi_table_tpm2 *buf;
403388
struct crb_priv *priv;
389+
struct tpm_chip *chip;
404390
struct device *dev = &device->dev;
405391
acpi_status status;
406392
u32 sm;
@@ -438,11 +424,19 @@ static int crb_acpi_add(struct acpi_device *device)
438424
if (rc)
439425
return rc;
440426

427+
chip = tpmm_chip_alloc(dev, &tpm_crb);
428+
if (IS_ERR(chip))
429+
return PTR_ERR(chip);
430+
431+
dev_set_drvdata(&chip->dev, priv);
432+
chip->acpi_dev_handle = device->handle;
433+
chip->flags = TPM_CHIP_FLAG_TPM2;
434+
441435
rc = crb_cmd_ready(dev, priv);
442436
if (rc)
443437
return rc;
444438

445-
rc = crb_init(device, priv);
439+
rc = tpm_chip_register(chip);
446440
if (rc)
447441
crb_go_idle(dev, priv);
448442

0 commit comments

Comments
 (0)