Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Winkler, Tomas and committed by
Jarkko Sakkinen
0c22db43 9514ff19

+10 -16
+10 -16
drivers/char/tpm/tpm_crb.c
··· 265 265 .req_complete_val = CRB_DRV_STS_COMPLETE, 266 266 }; 267 267 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 - 283 268 static int crb_check_resource(struct acpi_resource *ares, void *data) 284 269 { 285 270 struct resource *io_res = data; ··· 386 401 { 387 402 struct acpi_table_tpm2 *buf; 388 403 struct crb_priv *priv; 404 + struct tpm_chip *chip; 389 405 struct device *dev = &device->dev; 390 406 acpi_status status; 391 407 u32 sm; ··· 424 438 if (rc) 425 439 return rc; 426 440 441 + chip = tpmm_chip_alloc(dev, &tpm_crb); 442 + if (IS_ERR(chip)) 443 + return PTR_ERR(chip); 444 + 445 + dev_set_drvdata(&chip->dev, priv); 446 + chip->acpi_dev_handle = device->handle; 447 + chip->flags = TPM_CHIP_FLAG_TPM2; 448 + 427 449 rc = crb_cmd_ready(dev, priv); 428 450 if (rc) 429 451 return rc; 430 452 431 - rc = crb_init(device, priv); 453 + rc = tpm_chip_register(chip); 432 454 if (rc) 433 455 crb_go_idle(dev, priv); 434 456