diff options
author | Winkler, Tomas <tomas.winkler@intel.com> | 2016-09-12 09:04:20 -0400 |
---|---|---|
committer | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> | 2016-09-16 08:47:52 -0400 |
commit | 0c22db435bf79d3cf3089df7ff198d4867df3c27 (patch) | |
tree | b167e0063ded6f45dbf853969c27f3ba2d3d6cd0 | |
parent | 9514ff1961c6f0f5983ba72d94f384bc13e0d4a1 (diff) |
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>
-rw-r--r-- | drivers/char/tpm/tpm_crb.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c index 2d1669c0f6c0..d385e63008a6 100644 --- a/drivers/char/tpm/tpm_crb.c +++ b/drivers/char/tpm/tpm_crb.c | |||
@@ -265,21 +265,6 @@ static const struct tpm_class_ops tpm_crb = { | |||
265 | .req_complete_val = CRB_DRV_STS_COMPLETE, | 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 | static int crb_check_resource(struct acpi_resource *ares, void *data) | 268 | static int crb_check_resource(struct acpi_resource *ares, void *data) |
284 | { | 269 | { |
285 | struct resource *io_res = data; | 270 | struct resource *io_res = data; |
@@ -401,6 +386,7 @@ static int crb_acpi_add(struct acpi_device *device) | |||
401 | { | 386 | { |
402 | struct acpi_table_tpm2 *buf; | 387 | struct acpi_table_tpm2 *buf; |
403 | struct crb_priv *priv; | 388 | struct crb_priv *priv; |
389 | struct tpm_chip *chip; | ||
404 | struct device *dev = &device->dev; | 390 | struct device *dev = &device->dev; |
405 | acpi_status status; | 391 | acpi_status status; |
406 | u32 sm; | 392 | u32 sm; |
@@ -438,11 +424,19 @@ static int crb_acpi_add(struct acpi_device *device) | |||
438 | if (rc) | 424 | if (rc) |
439 | return rc; | 425 | return rc; |
440 | 426 | ||
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 | |||
441 | rc = crb_cmd_ready(dev, priv); | 435 | rc = crb_cmd_ready(dev, priv); |
442 | if (rc) | 436 | if (rc) |
443 | return rc; | 437 | return rc; |
444 | 438 | ||
445 | rc = crb_init(device, priv); | 439 | rc = tpm_chip_register(chip); |
446 | if (rc) | 440 | if (rc) |
447 | crb_go_idle(dev, priv); | 441 | crb_go_idle(dev, priv); |
448 | 442 | ||