tpm-interface.c (fdc915f7f71939ad5a3dda3389b8d2d7a7c5ee66) tpm-interface.c (877c57d0d0cac2c8fc661f708d8ee3fa7aa8d28b)
1/*
2 * Copyright (C) 2004 IBM Corporation
3 * Copyright (C) 2014 Intel Corporation
4 *
5 * Authors:
6 * Leendert van Doorn <leendert@watson.ibm.com>
7 * Dave Safford <safford@watson.ibm.com>
8 * Reiner Sailer <sailer@watson.ibm.com>

--- 375 unchanged lines hidden (view full) ---

384ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space,
385 u8 *buf, size_t bufsiz, unsigned int flags)
386{
387 struct tpm_output_header *header = (void *)buf;
388 int rc;
389 ssize_t len = 0;
390 u32 count, ordinal;
391 unsigned long stop;
1/*
2 * Copyright (C) 2004 IBM Corporation
3 * Copyright (C) 2014 Intel Corporation
4 *
5 * Authors:
6 * Leendert van Doorn <leendert@watson.ibm.com>
7 * Dave Safford <safford@watson.ibm.com>
8 * Reiner Sailer <sailer@watson.ibm.com>

--- 375 unchanged lines hidden (view full) ---

384ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space,
385 u8 *buf, size_t bufsiz, unsigned int flags)
386{
387 struct tpm_output_header *header = (void *)buf;
388 int rc;
389 ssize_t len = 0;
390 u32 count, ordinal;
391 unsigned long stop;
392 bool need_locality;
392
393 if (!tpm_validate_command(chip, space, buf, bufsiz))
394 return -EINVAL;
395
396 if (bufsiz > TPM_BUFSIZE)
397 bufsiz = TPM_BUFSIZE;
398
399 count = be32_to_cpu(*((__be32 *) (buf + 2)));

--- 7 unchanged lines hidden (view full) ---

407 }
408
409 if (!(flags & TPM_TRANSMIT_UNLOCKED))
410 mutex_lock(&chip->tpm_mutex);
411
412 if (chip->dev.parent)
413 pm_runtime_get_sync(chip->dev.parent);
414
393
394 if (!tpm_validate_command(chip, space, buf, bufsiz))
395 return -EINVAL;
396
397 if (bufsiz > TPM_BUFSIZE)
398 bufsiz = TPM_BUFSIZE;
399
400 count = be32_to_cpu(*((__be32 *) (buf + 2)));

--- 7 unchanged lines hidden (view full) ---

408 }
409
410 if (!(flags & TPM_TRANSMIT_UNLOCKED))
411 mutex_lock(&chip->tpm_mutex);
412
413 if (chip->dev.parent)
414 pm_runtime_get_sync(chip->dev.parent);
415
416 /* Store the decision as chip->locality will be changed. */
417 need_locality = chip->locality == -1;
418
419 if (need_locality && chip->ops->request_locality) {
420 rc = chip->ops->request_locality(chip, 0);
421 if (rc < 0)
422 goto out_no_locality;
423 chip->locality = rc;
424 }
425
415 rc = tpm2_prepare_space(chip, space, ordinal, buf);
416 if (rc)
417 goto out;
418
419 rc = chip->ops->send(chip, (u8 *) buf, count);
420 if (rc < 0) {
421 dev_err(&chip->dev,
422 "tpm_transmit: tpm_send: error %d\n", rc);

--- 43 unchanged lines hidden (view full) ---

466 if (len != be32_to_cpu(header->length)) {
467 rc = -EFAULT;
468 goto out;
469 }
470
471 rc = tpm2_commit_space(chip, space, ordinal, buf, &len);
472
473out:
426 rc = tpm2_prepare_space(chip, space, ordinal, buf);
427 if (rc)
428 goto out;
429
430 rc = chip->ops->send(chip, (u8 *) buf, count);
431 if (rc < 0) {
432 dev_err(&chip->dev,
433 "tpm_transmit: tpm_send: error %d\n", rc);

--- 43 unchanged lines hidden (view full) ---

477 if (len != be32_to_cpu(header->length)) {
478 rc = -EFAULT;
479 goto out;
480 }
481
482 rc = tpm2_commit_space(chip, space, ordinal, buf, &len);
483
484out:
485 if (need_locality && chip->ops->relinquish_locality) {
486 chip->ops->relinquish_locality(chip, chip->locality);
487 chip->locality = -1;
488 }
489out_no_locality:
474 if (chip->dev.parent)
475 pm_runtime_put_sync(chip->dev.parent);
476
477 if (!(flags & TPM_TRANSMIT_UNLOCKED))
478 mutex_unlock(&chip->tpm_mutex);
479 return rc ? rc : len;
480}
481

--- 816 unchanged lines hidden ---
490 if (chip->dev.parent)
491 pm_runtime_put_sync(chip->dev.parent);
492
493 if (!(flags & TPM_TRANSMIT_UNLOCKED))
494 mutex_unlock(&chip->tpm_mutex);
495 return rc ? rc : len;
496}
497

--- 816 unchanged lines hidden ---