diff options
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/tpm/tpm-interface.c | 34 | ||||
-rw-r--r-- | drivers/char/tpm/tpm-sysfs.c | 2 | ||||
-rw-r--r-- | drivers/char/tpm/tpm.h | 9 | ||||
-rw-r--r-- | drivers/char/tpm/tpm_i2c_stm_st33.c | 4 |
4 files changed, 16 insertions, 33 deletions
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c index 1b012463da7c..62e10fd1e1cb 100644 --- a/drivers/char/tpm/tpm-interface.c +++ b/drivers/char/tpm/tpm-interface.c | |||
@@ -353,7 +353,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf, | |||
353 | 353 | ||
354 | mutex_lock(&chip->tpm_mutex); | 354 | mutex_lock(&chip->tpm_mutex); |
355 | 355 | ||
356 | rc = chip->vendor.send(chip, (u8 *) buf, count); | 356 | rc = chip->ops->send(chip, (u8 *) buf, count); |
357 | if (rc < 0) { | 357 | if (rc < 0) { |
358 | dev_err(chip->dev, | 358 | dev_err(chip->dev, |
359 | "tpm_transmit: tpm_send: error %zd\n", rc); | 359 | "tpm_transmit: tpm_send: error %zd\n", rc); |
@@ -365,12 +365,12 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf, | |||
365 | 365 | ||
366 | stop = jiffies + tpm_calc_ordinal_duration(chip, ordinal); | 366 | stop = jiffies + tpm_calc_ordinal_duration(chip, ordinal); |
367 | do { | 367 | do { |
368 | u8 status = chip->vendor.status(chip); | 368 | u8 status = chip->ops->status(chip); |
369 | if ((status & chip->vendor.req_complete_mask) == | 369 | if ((status & chip->ops->req_complete_mask) == |
370 | chip->vendor.req_complete_val) | 370 | chip->ops->req_complete_val) |
371 | goto out_recv; | 371 | goto out_recv; |
372 | 372 | ||
373 | if (chip->vendor.req_canceled(chip, status)) { | 373 | if (chip->ops->req_canceled(chip, status)) { |
374 | dev_err(chip->dev, "Operation Canceled\n"); | 374 | dev_err(chip->dev, "Operation Canceled\n"); |
375 | rc = -ECANCELED; | 375 | rc = -ECANCELED; |
376 | goto out; | 376 | goto out; |
@@ -380,13 +380,13 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf, | |||
380 | rmb(); | 380 | rmb(); |
381 | } while (time_before(jiffies, stop)); | 381 | } while (time_before(jiffies, stop)); |
382 | 382 | ||
383 | chip->vendor.cancel(chip); | 383 | chip->ops->cancel(chip); |
384 | dev_err(chip->dev, "Operation Timed out\n"); | 384 | dev_err(chip->dev, "Operation Timed out\n"); |
385 | rc = -ETIME; | 385 | rc = -ETIME; |
386 | goto out; | 386 | goto out; |
387 | 387 | ||
388 | out_recv: | 388 | out_recv: |
389 | rc = chip->vendor.recv(chip, (u8 *) buf, bufsiz); | 389 | rc = chip->ops->recv(chip, (u8 *) buf, bufsiz); |
390 | if (rc < 0) | 390 | if (rc < 0) |
391 | dev_err(chip->dev, | 391 | dev_err(chip->dev, |
392 | "tpm_transmit: tpm_recv: error %zd\n", rc); | 392 | "tpm_transmit: tpm_recv: error %zd\n", rc); |
@@ -807,12 +807,12 @@ EXPORT_SYMBOL_GPL(tpm_send); | |||
807 | static bool wait_for_tpm_stat_cond(struct tpm_chip *chip, u8 mask, | 807 | static bool wait_for_tpm_stat_cond(struct tpm_chip *chip, u8 mask, |
808 | bool check_cancel, bool *canceled) | 808 | bool check_cancel, bool *canceled) |
809 | { | 809 | { |
810 | u8 status = chip->vendor.status(chip); | 810 | u8 status = chip->ops->status(chip); |
811 | 811 | ||
812 | *canceled = false; | 812 | *canceled = false; |
813 | if ((status & mask) == mask) | 813 | if ((status & mask) == mask) |
814 | return true; | 814 | return true; |
815 | if (check_cancel && chip->vendor.req_canceled(chip, status)) { | 815 | if (check_cancel && chip->ops->req_canceled(chip, status)) { |
816 | *canceled = true; | 816 | *canceled = true; |
817 | return true; | 817 | return true; |
818 | } | 818 | } |
@@ -828,7 +828,7 @@ int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout, | |||
828 | bool canceled = false; | 828 | bool canceled = false; |
829 | 829 | ||
830 | /* check current status */ | 830 | /* check current status */ |
831 | status = chip->vendor.status(chip); | 831 | status = chip->ops->status(chip); |
832 | if ((status & mask) == mask) | 832 | if ((status & mask) == mask) |
833 | return 0; | 833 | return 0; |
834 | 834 | ||
@@ -855,7 +855,7 @@ again: | |||
855 | } else { | 855 | } else { |
856 | do { | 856 | do { |
857 | msleep(TPM_TIMEOUT); | 857 | msleep(TPM_TIMEOUT); |
858 | status = chip->vendor.status(chip); | 858 | status = chip->ops->status(chip); |
859 | if ((status & mask) == mask) | 859 | if ((status & mask) == mask) |
860 | return 0; | 860 | return 0; |
861 | } while (time_before(jiffies, stop)); | 861 | } while (time_before(jiffies, stop)); |
@@ -1027,9 +1027,6 @@ void tpm_dev_vendor_release(struct tpm_chip *chip) | |||
1027 | if (!chip) | 1027 | if (!chip) |
1028 | return; | 1028 | return; |
1029 | 1029 | ||
1030 | if (chip->vendor.release) | ||
1031 | chip->vendor.release(chip->dev); | ||
1032 | |||
1033 | clear_bit(chip->dev_num, dev_mask); | 1030 | clear_bit(chip->dev_num, dev_mask); |
1034 | } | 1031 | } |
1035 | EXPORT_SYMBOL_GPL(tpm_dev_vendor_release); | 1032 | EXPORT_SYMBOL_GPL(tpm_dev_vendor_release); |
@@ -1073,14 +1070,7 @@ struct tpm_chip *tpm_register_hardware(struct device *dev, | |||
1073 | mutex_init(&chip->tpm_mutex); | 1070 | mutex_init(&chip->tpm_mutex); |
1074 | INIT_LIST_HEAD(&chip->list); | 1071 | INIT_LIST_HEAD(&chip->list); |
1075 | 1072 | ||
1076 | chip->vendor.req_complete_mask = ops->req_complete_mask; | 1073 | chip->ops = ops; |
1077 | chip->vendor.req_complete_val = ops->req_complete_val; | ||
1078 | chip->vendor.req_canceled = ops->req_canceled; | ||
1079 | chip->vendor.recv = ops->recv; | ||
1080 | chip->vendor.send = ops->send; | ||
1081 | chip->vendor.cancel = ops->cancel; | ||
1082 | chip->vendor.status = ops->status; | ||
1083 | |||
1084 | chip->dev_num = find_first_zero_bit(dev_mask, TPM_NUM_DEVICES); | 1074 | chip->dev_num = find_first_zero_bit(dev_mask, TPM_NUM_DEVICES); |
1085 | 1075 | ||
1086 | if (chip->dev_num >= TPM_NUM_DEVICES) { | 1076 | if (chip->dev_num >= TPM_NUM_DEVICES) { |
diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c index 506a07be5c3f..c3503cb70a37 100644 --- a/drivers/char/tpm/tpm-sysfs.c +++ b/drivers/char/tpm/tpm-sysfs.c | |||
@@ -245,7 +245,7 @@ static ssize_t cancel_store(struct device *dev, struct device_attribute *attr, | |||
245 | if (chip == NULL) | 245 | if (chip == NULL) |
246 | return 0; | 246 | return 0; |
247 | 247 | ||
248 | chip->vendor.cancel(chip); | 248 | chip->ops->cancel(chip); |
249 | return count; | 249 | return count; |
250 | } | 250 | } |
251 | static DEVICE_ATTR_WO(cancel); | 251 | static DEVICE_ATTR_WO(cancel); |
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index a56af2c13518..7b0a46e214c5 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h | |||
@@ -64,9 +64,6 @@ enum tpm_duration { | |||
64 | struct tpm_chip; | 64 | struct tpm_chip; |
65 | 65 | ||
66 | struct tpm_vendor_specific { | 66 | struct tpm_vendor_specific { |
67 | u8 req_complete_mask; | ||
68 | u8 req_complete_val; | ||
69 | bool (*req_canceled)(struct tpm_chip *chip, u8 status); | ||
70 | void __iomem *iobase; /* ioremapped address */ | 67 | void __iomem *iobase; /* ioremapped address */ |
71 | unsigned long base; /* TPM base address */ | 68 | unsigned long base; /* TPM base address */ |
72 | 69 | ||
@@ -76,11 +73,6 @@ struct tpm_vendor_specific { | |||
76 | int region_size; | 73 | int region_size; |
77 | int have_region; | 74 | int have_region; |
78 | 75 | ||
79 | int (*recv) (struct tpm_chip *, u8 *, size_t); | ||
80 | int (*send) (struct tpm_chip *, u8 *, size_t); | ||
81 | void (*cancel) (struct tpm_chip *); | ||
82 | u8 (*status) (struct tpm_chip *); | ||
83 | void (*release) (struct device *); | ||
84 | struct miscdevice miscdev; | 76 | struct miscdevice miscdev; |
85 | struct list_head list; | 77 | struct list_head list; |
86 | int locality; | 78 | int locality; |
@@ -104,6 +96,7 @@ struct tpm_vendor_specific { | |||
104 | 96 | ||
105 | struct tpm_chip { | 97 | struct tpm_chip { |
106 | struct device *dev; /* Device stuff */ | 98 | struct device *dev; /* Device stuff */ |
99 | const struct tpm_class_ops *ops; | ||
107 | 100 | ||
108 | int dev_num; /* /dev/tpm# */ | 101 | int dev_num; /* /dev/tpm# */ |
109 | char devname[7]; | 102 | char devname[7]; |
diff --git a/drivers/char/tpm/tpm_i2c_stm_st33.c b/drivers/char/tpm/tpm_i2c_stm_st33.c index 874b3be330bc..5b0dd8ef74c0 100644 --- a/drivers/char/tpm/tpm_i2c_stm_st33.c +++ b/drivers/char/tpm/tpm_i2c_stm_st33.c | |||
@@ -564,7 +564,7 @@ static int tpm_stm_i2c_recv(struct tpm_chip *chip, unsigned char *buf, | |||
564 | } | 564 | } |
565 | 565 | ||
566 | out: | 566 | out: |
567 | chip->vendor.cancel(chip); | 567 | chip->ops->cancel(chip); |
568 | release_locality(chip); | 568 | release_locality(chip); |
569 | return size; | 569 | return size; |
570 | } | 570 | } |
@@ -807,7 +807,7 @@ static int tpm_st33_i2c_pm_resume(struct device *dev) | |||
807 | if (power_mgt) { | 807 | if (power_mgt) { |
808 | gpio_set_value(pin_infos->io_lpcpd, 1); | 808 | gpio_set_value(pin_infos->io_lpcpd, 1); |
809 | ret = wait_for_serirq_timeout(chip, | 809 | ret = wait_for_serirq_timeout(chip, |
810 | (chip->vendor.status(chip) & | 810 | (chip->ops->status(chip) & |
811 | TPM_STS_VALID) == TPM_STS_VALID, | 811 | TPM_STS_VALID) == TPM_STS_VALID, |
812 | chip->vendor.timeout_b); | 812 | chip->vendor.timeout_b); |
813 | } else { | 813 | } else { |