diff options
Diffstat (limited to 'drivers/char/tpm/tpm_i2c_stm_st33.c')
-rw-r--r-- | drivers/char/tpm/tpm_i2c_stm_st33.c | 48 |
1 files changed, 9 insertions, 39 deletions
diff --git a/drivers/char/tpm/tpm_i2c_stm_st33.c b/drivers/char/tpm/tpm_i2c_stm_st33.c index a0d6ceb5d005..5b0dd8ef74c0 100644 --- a/drivers/char/tpm/tpm_i2c_stm_st33.c +++ b/drivers/char/tpm/tpm_i2c_stm_st33.c | |||
@@ -410,6 +410,8 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count) | |||
410 | &chip->vendor.read_queue) | 410 | &chip->vendor.read_queue) |
411 | == 0) { | 411 | == 0) { |
412 | burstcnt = get_burstcount(chip); | 412 | burstcnt = get_burstcount(chip); |
413 | if (burstcnt < 0) | ||
414 | return burstcnt; | ||
413 | len = min_t(int, burstcnt, count - size); | 415 | len = min_t(int, burstcnt, count - size); |
414 | I2C_READ_DATA(client, TPM_DATA_FIFO, buf + size, len); | 416 | I2C_READ_DATA(client, TPM_DATA_FIFO, buf + size, len); |
415 | size += len; | 417 | size += len; |
@@ -451,7 +453,8 @@ static irqreturn_t tpm_ioserirq_handler(int irq, void *dev_id) | |||
451 | static int tpm_stm_i2c_send(struct tpm_chip *chip, unsigned char *buf, | 453 | static int tpm_stm_i2c_send(struct tpm_chip *chip, unsigned char *buf, |
452 | size_t len) | 454 | size_t len) |
453 | { | 455 | { |
454 | u32 status, burstcnt = 0, i, size; | 456 | u32 status, i, size; |
457 | int burstcnt = 0; | ||
455 | int ret; | 458 | int ret; |
456 | u8 data; | 459 | u8 data; |
457 | struct i2c_client *client; | 460 | struct i2c_client *client; |
@@ -482,6 +485,8 @@ static int tpm_stm_i2c_send(struct tpm_chip *chip, unsigned char *buf, | |||
482 | 485 | ||
483 | for (i = 0; i < len - 1;) { | 486 | for (i = 0; i < len - 1;) { |
484 | burstcnt = get_burstcount(chip); | 487 | burstcnt = get_burstcount(chip); |
488 | if (burstcnt < 0) | ||
489 | return burstcnt; | ||
485 | size = min_t(int, len - i - 1, burstcnt); | 490 | size = min_t(int, len - i - 1, burstcnt); |
486 | ret = I2C_WRITE_DATA(client, TPM_DATA_FIFO, buf, size); | 491 | ret = I2C_WRITE_DATA(client, TPM_DATA_FIFO, buf, size); |
487 | if (ret < 0) | 492 | if (ret < 0) |
@@ -559,7 +564,7 @@ static int tpm_stm_i2c_recv(struct tpm_chip *chip, unsigned char *buf, | |||
559 | } | 564 | } |
560 | 565 | ||
561 | out: | 566 | out: |
562 | chip->vendor.cancel(chip); | 567 | chip->ops->cancel(chip); |
563 | release_locality(chip); | 568 | release_locality(chip); |
564 | return size; | 569 | return size; |
565 | } | 570 | } |
@@ -569,40 +574,7 @@ static bool tpm_st33_i2c_req_canceled(struct tpm_chip *chip, u8 status) | |||
569 | return (status == TPM_STS_COMMAND_READY); | 574 | return (status == TPM_STS_COMMAND_READY); |
570 | } | 575 | } |
571 | 576 | ||
572 | static const struct file_operations tpm_st33_i2c_fops = { | 577 | static const struct tpm_class_ops st_i2c_tpm = { |
573 | .owner = THIS_MODULE, | ||
574 | .llseek = no_llseek, | ||
575 | .read = tpm_read, | ||
576 | .write = tpm_write, | ||
577 | .open = tpm_open, | ||
578 | .release = tpm_release, | ||
579 | }; | ||
580 | |||
581 | static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL); | ||
582 | static DEVICE_ATTR(pcrs, S_IRUGO, tpm_show_pcrs, NULL); | ||
583 | static DEVICE_ATTR(enabled, S_IRUGO, tpm_show_enabled, NULL); | ||
584 | static DEVICE_ATTR(active, S_IRUGO, tpm_show_active, NULL); | ||
585 | static DEVICE_ATTR(owned, S_IRUGO, tpm_show_owned, NULL); | ||
586 | static DEVICE_ATTR(temp_deactivated, S_IRUGO, tpm_show_temp_deactivated, NULL); | ||
587 | static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps, NULL); | ||
588 | static DEVICE_ATTR(cancel, S_IWUSR | S_IWGRP, NULL, tpm_store_cancel); | ||
589 | |||
590 | static struct attribute *stm_tpm_attrs[] = { | ||
591 | &dev_attr_pubek.attr, | ||
592 | &dev_attr_pcrs.attr, | ||
593 | &dev_attr_enabled.attr, | ||
594 | &dev_attr_active.attr, | ||
595 | &dev_attr_owned.attr, | ||
596 | &dev_attr_temp_deactivated.attr, | ||
597 | &dev_attr_caps.attr, | ||
598 | &dev_attr_cancel.attr, NULL, | ||
599 | }; | ||
600 | |||
601 | static struct attribute_group stm_tpm_attr_grp = { | ||
602 | .attrs = stm_tpm_attrs | ||
603 | }; | ||
604 | |||
605 | static struct tpm_vendor_specific st_i2c_tpm = { | ||
606 | .send = tpm_stm_i2c_send, | 578 | .send = tpm_stm_i2c_send, |
607 | .recv = tpm_stm_i2c_recv, | 579 | .recv = tpm_stm_i2c_recv, |
608 | .cancel = tpm_stm_i2c_cancel, | 580 | .cancel = tpm_stm_i2c_cancel, |
@@ -610,8 +582,6 @@ static struct tpm_vendor_specific st_i2c_tpm = { | |||
610 | .req_complete_mask = TPM_STS_DATA_AVAIL | TPM_STS_VALID, | 582 | .req_complete_mask = TPM_STS_DATA_AVAIL | TPM_STS_VALID, |
611 | .req_complete_val = TPM_STS_DATA_AVAIL | TPM_STS_VALID, | 583 | .req_complete_val = TPM_STS_DATA_AVAIL | TPM_STS_VALID, |
612 | .req_canceled = tpm_st33_i2c_req_canceled, | 584 | .req_canceled = tpm_st33_i2c_req_canceled, |
613 | .attr_group = &stm_tpm_attr_grp, | ||
614 | .miscdev = {.fops = &tpm_st33_i2c_fops,}, | ||
615 | }; | 585 | }; |
616 | 586 | ||
617 | static int interrupts; | 587 | static int interrupts; |
@@ -837,7 +807,7 @@ static int tpm_st33_i2c_pm_resume(struct device *dev) | |||
837 | if (power_mgt) { | 807 | if (power_mgt) { |
838 | gpio_set_value(pin_infos->io_lpcpd, 1); | 808 | gpio_set_value(pin_infos->io_lpcpd, 1); |
839 | ret = wait_for_serirq_timeout(chip, | 809 | ret = wait_for_serirq_timeout(chip, |
840 | (chip->vendor.status(chip) & | 810 | (chip->ops->status(chip) & |
841 | TPM_STS_VALID) == TPM_STS_VALID, | 811 | TPM_STS_VALID) == TPM_STS_VALID, |
842 | chip->vendor.timeout_b); | 812 | chip->vendor.timeout_b); |
843 | } else { | 813 | } else { |