aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/tpm
diff options
context:
space:
mode:
authorJason Gunthorpe <jgunthorpe@obsidianresearch.com>2013-11-26 15:30:42 -0500
committerPeter Huewe <peterhuewe@gmx.de>2014-01-06 08:37:25 -0500
commit1e3b73a95793555860512008035f6822406a2a79 (patch)
treedea6555c5b9f7e3267621bfde641e26b6e9d08d6 /drivers/char/tpm
parent000a07b0aac1bc69bcf602b468d975c3e37a155c (diff)
tpm: Pull all driver sysfs code into tpm-sysfs.c
The tpm core now sets up and controls all sysfs attributes, instead of having each driver have a unique take on it. All drivers now now have a uniform set of attributes, and no sysfs related entry points are exported from the tpm core module. This also uses the new method used to declare sysfs attributes with DEVICE_ATTR_RO and 'struct attribute *' Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com> [phuewe: had to apply the tpm_i2c_atmel part manually due to commit 191ffc6bde3fc tpm/tpm_i2c_atmel: fix coccinelle warnings] Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
Diffstat (limited to 'drivers/char/tpm')
-rw-r--r--drivers/char/tpm/tpm-interface.c4
-rw-r--r--drivers/char/tpm/tpm-sysfs.c99
-rw-r--r--drivers/char/tpm/tpm.h24
-rw-r--r--drivers/char/tpm/tpm_atmel.c16
-rw-r--r--drivers/char/tpm/tpm_i2c_atmel.c30
-rw-r--r--drivers/char/tpm/tpm_i2c_infineon.c30
-rw-r--r--drivers/char/tpm/tpm_i2c_nuvoton.c30
-rw-r--r--drivers/char/tpm/tpm_i2c_stm_st33.c25
-rw-r--r--drivers/char/tpm/tpm_ibmvtpm.c28
-rw-r--r--drivers/char/tpm/tpm_infineon.c16
-rw-r--r--drivers/char/tpm/tpm_nsc.c16
-rw-r--r--drivers/char/tpm/tpm_tis.c30
-rw-r--r--drivers/char/tpm/xen-tpmfront.c31
13 files changed, 72 insertions, 307 deletions
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index 3f8bddf8f7ed..389d483a887c 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -879,7 +879,7 @@ void tpm_remove_hardware(struct device *dev)
879 synchronize_rcu(); 879 synchronize_rcu();
880 880
881 tpm_dev_del_device(chip); 881 tpm_dev_del_device(chip);
882 sysfs_remove_group(&dev->kobj, chip->vendor.attr_group); 882 tpm_sysfs_del_device(chip);
883 tpm_remove_ppi(&dev->kobj); 883 tpm_remove_ppi(&dev->kobj);
884 tpm_bios_log_teardown(chip->bios_dir); 884 tpm_bios_log_teardown(chip->bios_dir);
885 885
@@ -1095,7 +1095,7 @@ struct tpm_chip *tpm_register_hardware(struct device *dev,
1095 if (tpm_dev_add_device(chip)) 1095 if (tpm_dev_add_device(chip))
1096 goto put_device; 1096 goto put_device;
1097 1097
1098 if (sysfs_create_group(&dev->kobj, chip->vendor.attr_group)) 1098 if (tpm_sysfs_add_device(chip))
1099 goto del_misc; 1099 goto del_misc;
1100 1100
1101 if (tpm_add_ppi(&dev->kobj)) 1101 if (tpm_add_ppi(&dev->kobj))
diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c
index 310d9609566f..506a07be5c3f 100644
--- a/drivers/char/tpm/tpm-sysfs.c
+++ b/drivers/char/tpm/tpm-sysfs.c
@@ -6,6 +6,9 @@
6 * Reiner Sailer <sailer@watson.ibm.com> 6 * Reiner Sailer <sailer@watson.ibm.com>
7 * Kylene Hall <kjhall@us.ibm.com> 7 * Kylene Hall <kjhall@us.ibm.com>
8 * 8 *
9 * Copyright (C) 2013 Obsidian Research Corp
10 * Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
11 *
9 * sysfs filesystem inspection interface to the TPM 12 * sysfs filesystem inspection interface to the TPM
10 * 13 *
11 * This program is free software; you can redistribute it and/or 14 * This program is free software; you can redistribute it and/or
@@ -43,9 +46,8 @@ static struct tpm_input_header tpm_readpubek_header = {
43 .length = cpu_to_be32(30), 46 .length = cpu_to_be32(30),
44 .ordinal = TPM_ORD_READPUBEK 47 .ordinal = TPM_ORD_READPUBEK
45}; 48};
46 49static ssize_t pubek_show(struct device *dev, struct device_attribute *attr,
47ssize_t tpm_show_pubek(struct device *dev, struct device_attribute *attr, 50 char *buf)
48 char *buf)
49{ 51{
50 u8 *data; 52 u8 *data;
51 struct tpm_cmd_t tpm_cmd; 53 struct tpm_cmd_t tpm_cmd;
@@ -99,10 +101,10 @@ out:
99 rc = str - buf; 101 rc = str - buf;
100 return rc; 102 return rc;
101} 103}
102EXPORT_SYMBOL_GPL(tpm_show_pubek); 104static DEVICE_ATTR_RO(pubek);
103 105
104ssize_t tpm_show_pcrs(struct device *dev, struct device_attribute *attr, 106static ssize_t pcrs_show(struct device *dev, struct device_attribute *attr,
105 char *buf) 107 char *buf)
106{ 108{
107 cap_t cap; 109 cap_t cap;
108 u8 digest[TPM_DIGEST_SIZE]; 110 u8 digest[TPM_DIGEST_SIZE];
@@ -128,10 +130,10 @@ ssize_t tpm_show_pcrs(struct device *dev, struct device_attribute *attr,
128 } 130 }
129 return str - buf; 131 return str - buf;
130} 132}
131EXPORT_SYMBOL_GPL(tpm_show_pcrs); 133static DEVICE_ATTR_RO(pcrs);
132 134
133ssize_t tpm_show_enabled(struct device *dev, struct device_attribute *attr, 135static ssize_t enabled_show(struct device *dev, struct device_attribute *attr,
134 char *buf) 136 char *buf)
135{ 137{
136 cap_t cap; 138 cap_t cap;
137 ssize_t rc; 139 ssize_t rc;
@@ -144,10 +146,10 @@ ssize_t tpm_show_enabled(struct device *dev, struct device_attribute *attr,
144 rc = sprintf(buf, "%d\n", !cap.perm_flags.disable); 146 rc = sprintf(buf, "%d\n", !cap.perm_flags.disable);
145 return rc; 147 return rc;
146} 148}
147EXPORT_SYMBOL_GPL(tpm_show_enabled); 149static DEVICE_ATTR_RO(enabled);
148 150
149ssize_t tpm_show_active(struct device *dev, struct device_attribute *attr, 151ssize_t active_show(struct device *dev, struct device_attribute *attr,
150 char *buf) 152 char *buf)
151{ 153{
152 cap_t cap; 154 cap_t cap;
153 ssize_t rc; 155 ssize_t rc;
@@ -160,10 +162,10 @@ ssize_t tpm_show_active(struct device *dev, struct device_attribute *attr,
160 rc = sprintf(buf, "%d\n", !cap.perm_flags.deactivated); 162 rc = sprintf(buf, "%d\n", !cap.perm_flags.deactivated);
161 return rc; 163 return rc;
162} 164}
163EXPORT_SYMBOL_GPL(tpm_show_active); 165static DEVICE_ATTR_RO(active);
164 166
165ssize_t tpm_show_owned(struct device *dev, struct device_attribute *attr, 167static ssize_t owned_show(struct device *dev, struct device_attribute *attr,
166 char *buf) 168 char *buf)
167{ 169{
168 cap_t cap; 170 cap_t cap;
169 ssize_t rc; 171 ssize_t rc;
@@ -176,10 +178,10 @@ ssize_t tpm_show_owned(struct device *dev, struct device_attribute *attr,
176 rc = sprintf(buf, "%d\n", cap.owned); 178 rc = sprintf(buf, "%d\n", cap.owned);
177 return rc; 179 return rc;
178} 180}
179EXPORT_SYMBOL_GPL(tpm_show_owned); 181static DEVICE_ATTR_RO(owned);
180 182
181ssize_t tpm_show_temp_deactivated(struct device *dev, 183static ssize_t temp_deactivated_show(struct device *dev,
182 struct device_attribute *attr, char *buf) 184 struct device_attribute *attr, char *buf)
183{ 185{
184 cap_t cap; 186 cap_t cap;
185 ssize_t rc; 187 ssize_t rc;
@@ -192,10 +194,10 @@ ssize_t tpm_show_temp_deactivated(struct device *dev,
192 rc = sprintf(buf, "%d\n", cap.stclear_flags.deactivated); 194 rc = sprintf(buf, "%d\n", cap.stclear_flags.deactivated);
193 return rc; 195 return rc;
194} 196}
195EXPORT_SYMBOL_GPL(tpm_show_temp_deactivated); 197static DEVICE_ATTR_RO(temp_deactivated);
196 198
197ssize_t tpm_show_caps(struct device *dev, struct device_attribute *attr, 199static ssize_t caps_show(struct device *dev, struct device_attribute *attr,
198 char *buf) 200 char *buf)
199{ 201{
200 cap_t cap; 202 cap_t cap;
201 ssize_t rc; 203 ssize_t rc;
@@ -234,10 +236,10 @@ ssize_t tpm_show_caps(struct device *dev, struct device_attribute *attr,
234 236
235 return str - buf; 237 return str - buf;
236} 238}
237EXPORT_SYMBOL_GPL(tpm_show_caps); 239static DEVICE_ATTR_RO(caps);
238 240
239ssize_t tpm_store_cancel(struct device *dev, struct device_attribute *attr, 241static ssize_t cancel_store(struct device *dev, struct device_attribute *attr,
240 const char *buf, size_t count) 242 const char *buf, size_t count)
241{ 243{
242 struct tpm_chip *chip = dev_get_drvdata(dev); 244 struct tpm_chip *chip = dev_get_drvdata(dev);
243 if (chip == NULL) 245 if (chip == NULL)
@@ -246,10 +248,10 @@ ssize_t tpm_store_cancel(struct device *dev, struct device_attribute *attr,
246 chip->vendor.cancel(chip); 248 chip->vendor.cancel(chip);
247 return count; 249 return count;
248} 250}
249EXPORT_SYMBOL_GPL(tpm_store_cancel); 251static DEVICE_ATTR_WO(cancel);
250 252
251ssize_t tpm_show_durations(struct device *dev, struct device_attribute *attr, 253static ssize_t durations_show(struct device *dev, struct device_attribute *attr,
252 char *buf) 254 char *buf)
253{ 255{
254 struct tpm_chip *chip = dev_get_drvdata(dev); 256 struct tpm_chip *chip = dev_get_drvdata(dev);
255 257
@@ -263,10 +265,10 @@ ssize_t tpm_show_durations(struct device *dev, struct device_attribute *attr,
263 chip->vendor.duration_adjusted 265 chip->vendor.duration_adjusted
264 ? "adjusted" : "original"); 266 ? "adjusted" : "original");
265} 267}
266EXPORT_SYMBOL_GPL(tpm_show_durations); 268static DEVICE_ATTR_RO(durations);
267 269
268ssize_t tpm_show_timeouts(struct device *dev, struct device_attribute *attr, 270static ssize_t timeouts_show(struct device *dev, struct device_attribute *attr,
269 char *buf) 271 char *buf)
270{ 272{
271 struct tpm_chip *chip = dev_get_drvdata(dev); 273 struct tpm_chip *chip = dev_get_drvdata(dev);
272 274
@@ -278,4 +280,39 @@ ssize_t tpm_show_timeouts(struct device *dev, struct device_attribute *attr,
278 chip->vendor.timeout_adjusted 280 chip->vendor.timeout_adjusted
279 ? "adjusted" : "original"); 281 ? "adjusted" : "original");
280} 282}
281EXPORT_SYMBOL_GPL(tpm_show_timeouts); 283static DEVICE_ATTR_RO(timeouts);
284
285static struct attribute *tpm_dev_attrs[] = {
286 &dev_attr_pubek.attr,
287 &dev_attr_pcrs.attr,
288 &dev_attr_enabled.attr,
289 &dev_attr_active.attr,
290 &dev_attr_owned.attr,
291 &dev_attr_temp_deactivated.attr,
292 &dev_attr_caps.attr,
293 &dev_attr_cancel.attr,
294 &dev_attr_durations.attr,
295 &dev_attr_timeouts.attr,
296 NULL,
297};
298
299static const struct attribute_group tpm_dev_group = {
300 .attrs = tpm_dev_attrs,
301};
302
303int tpm_sysfs_add_device(struct tpm_chip *chip)
304{
305 int err;
306 err = sysfs_create_group(&chip->dev->kobj,
307 &tpm_dev_group);
308
309 if (err)
310 dev_err(chip->dev,
311 "failed to create sysfs attributes, %d\n", err);
312 return err;
313}
314
315void tpm_sysfs_del_device(struct tpm_chip *chip)
316{
317 sysfs_remove_group(&chip->dev->kobj, &tpm_dev_group);
318}
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 41b1480e6e17..14ba1627d78e 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -61,27 +61,6 @@ enum tpm_duration {
61#define TPM_ERR_INVALID_POSTINIT 38 61#define TPM_ERR_INVALID_POSTINIT 38
62 62
63#define TPM_HEADER_SIZE 10 63#define TPM_HEADER_SIZE 10
64extern ssize_t tpm_show_pubek(struct device *, struct device_attribute *attr,
65 char *);
66extern ssize_t tpm_show_pcrs(struct device *, struct device_attribute *attr,
67 char *);
68extern ssize_t tpm_show_caps(struct device *, struct device_attribute *attr,
69 char *);
70extern ssize_t tpm_store_cancel(struct device *, struct device_attribute *attr,
71 const char *, size_t);
72extern ssize_t tpm_show_enabled(struct device *, struct device_attribute *attr,
73 char *);
74extern ssize_t tpm_show_active(struct device *, struct device_attribute *attr,
75 char *);
76extern ssize_t tpm_show_owned(struct device *, struct device_attribute *attr,
77 char *);
78extern ssize_t tpm_show_temp_deactivated(struct device *,
79 struct device_attribute *attr, char *);
80extern ssize_t tpm_show_durations(struct device *,
81 struct device_attribute *attr, char *);
82extern ssize_t tpm_show_timeouts(struct device *,
83 struct device_attribute *attr, char *);
84
85struct tpm_chip; 64struct tpm_chip;
86 65
87struct tpm_vendor_specific { 66struct tpm_vendor_specific {
@@ -103,7 +82,6 @@ struct tpm_vendor_specific {
103 u8 (*status) (struct tpm_chip *); 82 u8 (*status) (struct tpm_chip *);
104 void (*release) (struct device *); 83 void (*release) (struct device *);
105 struct miscdevice miscdev; 84 struct miscdevice miscdev;
106 struct attribute_group *attr_group;
107 struct list_head list; 85 struct list_head list;
108 int locality; 86 int locality;
109 unsigned long timeout_a, timeout_b, timeout_c, timeout_d; /* jiffies */ 87 unsigned long timeout_a, timeout_b, timeout_c, timeout_d; /* jiffies */
@@ -368,6 +346,8 @@ extern int wait_for_tpm_stat(struct tpm_chip *, u8, unsigned long,
368 346
369int tpm_dev_add_device(struct tpm_chip *chip); 347int tpm_dev_add_device(struct tpm_chip *chip);
370void tpm_dev_del_device(struct tpm_chip *chip); 348void tpm_dev_del_device(struct tpm_chip *chip);
349int tpm_sysfs_add_device(struct tpm_chip *chip);
350void tpm_sysfs_del_device(struct tpm_chip *chip);
371 351
372int tpm_pcr_read_dev(struct tpm_chip *chip, int pcr_idx, u8 *res_buf); 352int tpm_pcr_read_dev(struct tpm_chip *chip, int pcr_idx, u8 *res_buf);
373 353
diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c
index 9692e2f252e0..7e665d047c93 100644
--- a/drivers/char/tpm/tpm_atmel.c
+++ b/drivers/char/tpm/tpm_atmel.c
@@ -121,21 +121,6 @@ static bool tpm_atml_req_canceled(struct tpm_chip *chip, u8 status)
121 return (status == ATML_STATUS_READY); 121 return (status == ATML_STATUS_READY);
122} 122}
123 123
124static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL);
125static DEVICE_ATTR(pcrs, S_IRUGO, tpm_show_pcrs, NULL);
126static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps, NULL);
127static DEVICE_ATTR(cancel, S_IWUSR |S_IWGRP, NULL, tpm_store_cancel);
128
129static struct attribute* atmel_attrs[] = {
130 &dev_attr_pubek.attr,
131 &dev_attr_pcrs.attr,
132 &dev_attr_caps.attr,
133 &dev_attr_cancel.attr,
134 NULL,
135};
136
137static struct attribute_group atmel_attr_grp = { .attrs = atmel_attrs };
138
139static const struct tpm_vendor_specific tpm_atmel = { 124static const struct tpm_vendor_specific tpm_atmel = {
140 .recv = tpm_atml_recv, 125 .recv = tpm_atml_recv,
141 .send = tpm_atml_send, 126 .send = tpm_atml_send,
@@ -144,7 +129,6 @@ static const struct tpm_vendor_specific tpm_atmel = {
144 .req_complete_mask = ATML_STATUS_BUSY | ATML_STATUS_DATA_AVAIL, 129 .req_complete_mask = ATML_STATUS_BUSY | ATML_STATUS_DATA_AVAIL,
145 .req_complete_val = ATML_STATUS_DATA_AVAIL, 130 .req_complete_val = ATML_STATUS_DATA_AVAIL,
146 .req_canceled = tpm_atml_req_canceled, 131 .req_canceled = tpm_atml_req_canceled,
147 .attr_group = &atmel_attr_grp,
148}; 132};
149 133
150static struct platform_device *pdev; 134static struct platform_device *pdev;
diff --git a/drivers/char/tpm/tpm_i2c_atmel.c b/drivers/char/tpm/tpm_i2c_atmel.c
index 079c19d31187..fe8bdce7d24f 100644
--- a/drivers/char/tpm/tpm_i2c_atmel.c
+++ b/drivers/char/tpm/tpm_i2c_atmel.c
@@ -135,35 +135,6 @@ static u8 i2c_atmel_read_status(struct tpm_chip *chip)
135 return ATMEL_STS_OK; 135 return ATMEL_STS_OK;
136} 136}
137 137
138static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL);
139static DEVICE_ATTR(pcrs, S_IRUGO, tpm_show_pcrs, NULL);
140static DEVICE_ATTR(enabled, S_IRUGO, tpm_show_enabled, NULL);
141static DEVICE_ATTR(active, S_IRUGO, tpm_show_active, NULL);
142static DEVICE_ATTR(owned, S_IRUGO, tpm_show_owned, NULL);
143static DEVICE_ATTR(temp_deactivated, S_IRUGO, tpm_show_temp_deactivated, NULL);
144static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps, NULL);
145static DEVICE_ATTR(cancel, S_IWUSR | S_IWGRP, NULL, tpm_store_cancel);
146static DEVICE_ATTR(durations, S_IRUGO, tpm_show_durations, NULL);
147static DEVICE_ATTR(timeouts, S_IRUGO, tpm_show_timeouts, NULL);
148
149static struct attribute *i2c_atmel_attrs[] = {
150 &dev_attr_pubek.attr,
151 &dev_attr_pcrs.attr,
152 &dev_attr_enabled.attr,
153 &dev_attr_active.attr,
154 &dev_attr_owned.attr,
155 &dev_attr_temp_deactivated.attr,
156 &dev_attr_caps.attr,
157 &dev_attr_cancel.attr,
158 &dev_attr_durations.attr,
159 &dev_attr_timeouts.attr,
160 NULL,
161};
162
163static struct attribute_group i2c_atmel_attr_grp = {
164 .attrs = i2c_atmel_attrs
165};
166
167static bool i2c_atmel_req_canceled(struct tpm_chip *chip, u8 status) 138static bool i2c_atmel_req_canceled(struct tpm_chip *chip, u8 status)
168{ 139{
169 return false; 140 return false;
@@ -177,7 +148,6 @@ static const struct tpm_vendor_specific i2c_atmel = {
177 .req_complete_mask = ATMEL_STS_OK, 148 .req_complete_mask = ATMEL_STS_OK,
178 .req_complete_val = ATMEL_STS_OK, 149 .req_complete_val = ATMEL_STS_OK,
179 .req_canceled = i2c_atmel_req_canceled, 150 .req_canceled = i2c_atmel_req_canceled,
180 .attr_group = &i2c_atmel_attr_grp,
181}; 151};
182 152
183static int i2c_atmel_probe(struct i2c_client *client, 153static int i2c_atmel_probe(struct i2c_client *client,
diff --git a/drivers/char/tpm/tpm_i2c_infineon.c b/drivers/char/tpm/tpm_i2c_infineon.c
index c1ba7fa6830c..ac1218f41afe 100644
--- a/drivers/char/tpm/tpm_i2c_infineon.c
+++ b/drivers/char/tpm/tpm_i2c_infineon.c
@@ -566,35 +566,6 @@ static bool tpm_tis_i2c_req_canceled(struct tpm_chip *chip, u8 status)
566 return (status == TPM_STS_COMMAND_READY); 566 return (status == TPM_STS_COMMAND_READY);
567} 567}
568 568
569static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL);
570static DEVICE_ATTR(pcrs, S_IRUGO, tpm_show_pcrs, NULL);
571static DEVICE_ATTR(enabled, S_IRUGO, tpm_show_enabled, NULL);
572static DEVICE_ATTR(active, S_IRUGO, tpm_show_active, NULL);
573static DEVICE_ATTR(owned, S_IRUGO, tpm_show_owned, NULL);
574static DEVICE_ATTR(temp_deactivated, S_IRUGO, tpm_show_temp_deactivated, NULL);
575static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps, NULL);
576static DEVICE_ATTR(cancel, S_IWUSR | S_IWGRP, NULL, tpm_store_cancel);
577static DEVICE_ATTR(durations, S_IRUGO, tpm_show_durations, NULL);
578static DEVICE_ATTR(timeouts, S_IRUGO, tpm_show_timeouts, NULL);
579
580static struct attribute *tis_attrs[] = {
581 &dev_attr_pubek.attr,
582 &dev_attr_pcrs.attr,
583 &dev_attr_enabled.attr,
584 &dev_attr_active.attr,
585 &dev_attr_owned.attr,
586 &dev_attr_temp_deactivated.attr,
587 &dev_attr_caps.attr,
588 &dev_attr_cancel.attr,
589 &dev_attr_durations.attr,
590 &dev_attr_timeouts.attr,
591 NULL,
592};
593
594static struct attribute_group tis_attr_grp = {
595 .attrs = tis_attrs
596};
597
598static struct tpm_vendor_specific tpm_tis_i2c = { 569static struct tpm_vendor_specific tpm_tis_i2c = {
599 .status = tpm_tis_i2c_status, 570 .status = tpm_tis_i2c_status,
600 .recv = tpm_tis_i2c_recv, 571 .recv = tpm_tis_i2c_recv,
@@ -603,7 +574,6 @@ static struct tpm_vendor_specific tpm_tis_i2c = {
603 .req_complete_mask = TPM_STS_DATA_AVAIL | TPM_STS_VALID, 574 .req_complete_mask = TPM_STS_DATA_AVAIL | TPM_STS_VALID,
604 .req_complete_val = TPM_STS_DATA_AVAIL | TPM_STS_VALID, 575 .req_complete_val = TPM_STS_DATA_AVAIL | TPM_STS_VALID,
605 .req_canceled = tpm_tis_i2c_req_canceled, 576 .req_canceled = tpm_tis_i2c_req_canceled,
606 .attr_group = &tis_attr_grp,
607}; 577};
608 578
609static int tpm_tis_i2c_init(struct device *dev) 579static int tpm_tis_i2c_init(struct device *dev)
diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c
index c9bb60e45cb0..1e6905ba0dea 100644
--- a/drivers/char/tpm/tpm_i2c_nuvoton.c
+++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
@@ -455,35 +455,6 @@ static bool i2c_nuvoton_req_canceled(struct tpm_chip *chip, u8 status)
455 return (status == TPM_STS_COMMAND_READY); 455 return (status == TPM_STS_COMMAND_READY);
456} 456}
457 457
458static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL);
459static DEVICE_ATTR(pcrs, S_IRUGO, tpm_show_pcrs, NULL);
460static DEVICE_ATTR(enabled, S_IRUGO, tpm_show_enabled, NULL);
461static DEVICE_ATTR(active, S_IRUGO, tpm_show_active, NULL);
462static DEVICE_ATTR(owned, S_IRUGO, tpm_show_owned, NULL);
463static DEVICE_ATTR(temp_deactivated, S_IRUGO, tpm_show_temp_deactivated, NULL);
464static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps, NULL);
465static DEVICE_ATTR(cancel, S_IWUSR | S_IWGRP, NULL, tpm_store_cancel);
466static DEVICE_ATTR(durations, S_IRUGO, tpm_show_durations, NULL);
467static DEVICE_ATTR(timeouts, S_IRUGO, tpm_show_timeouts, NULL);
468
469static struct attribute *i2c_nuvoton_attrs[] = {
470 &dev_attr_pubek.attr,
471 &dev_attr_pcrs.attr,
472 &dev_attr_enabled.attr,
473 &dev_attr_active.attr,
474 &dev_attr_owned.attr,
475 &dev_attr_temp_deactivated.attr,
476 &dev_attr_caps.attr,
477 &dev_attr_cancel.attr,
478 &dev_attr_durations.attr,
479 &dev_attr_timeouts.attr,
480 NULL,
481};
482
483static struct attribute_group i2c_nuvoton_attr_grp = {
484 .attrs = i2c_nuvoton_attrs
485};
486
487static const struct tpm_vendor_specific tpm_i2c = { 458static const struct tpm_vendor_specific tpm_i2c = {
488 .status = i2c_nuvoton_read_status, 459 .status = i2c_nuvoton_read_status,
489 .recv = i2c_nuvoton_recv, 460 .recv = i2c_nuvoton_recv,
@@ -492,7 +463,6 @@ static const struct tpm_vendor_specific tpm_i2c = {
492 .req_complete_mask = TPM_STS_DATA_AVAIL | TPM_STS_VALID, 463 .req_complete_mask = TPM_STS_DATA_AVAIL | TPM_STS_VALID,
493 .req_complete_val = TPM_STS_DATA_AVAIL | TPM_STS_VALID, 464 .req_complete_val = TPM_STS_DATA_AVAIL | TPM_STS_VALID,
494 .req_canceled = i2c_nuvoton_req_canceled, 465 .req_canceled = i2c_nuvoton_req_canceled,
495 .attr_group = &i2c_nuvoton_attr_grp,
496}; 466};
497 467
498/* The only purpose for the handler is to signal to any waiting threads that 468/* The only purpose for the handler is to signal to any waiting threads that
diff --git a/drivers/char/tpm/tpm_i2c_stm_st33.c b/drivers/char/tpm/tpm_i2c_stm_st33.c
index e519e6815780..6902f7b11e48 100644
--- a/drivers/char/tpm/tpm_i2c_stm_st33.c
+++ b/drivers/char/tpm/tpm_i2c_stm_st33.c
@@ -574,30 +574,6 @@ static bool tpm_st33_i2c_req_canceled(struct tpm_chip *chip, u8 status)
574 return (status == TPM_STS_COMMAND_READY); 574 return (status == TPM_STS_COMMAND_READY);
575} 575}
576 576
577static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL);
578static DEVICE_ATTR(pcrs, S_IRUGO, tpm_show_pcrs, NULL);
579static DEVICE_ATTR(enabled, S_IRUGO, tpm_show_enabled, NULL);
580static DEVICE_ATTR(active, S_IRUGO, tpm_show_active, NULL);
581static DEVICE_ATTR(owned, S_IRUGO, tpm_show_owned, NULL);
582static DEVICE_ATTR(temp_deactivated, S_IRUGO, tpm_show_temp_deactivated, NULL);
583static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps, NULL);
584static DEVICE_ATTR(cancel, S_IWUSR | S_IWGRP, NULL, tpm_store_cancel);
585
586static struct attribute *stm_tpm_attrs[] = {
587 &dev_attr_pubek.attr,
588 &dev_attr_pcrs.attr,
589 &dev_attr_enabled.attr,
590 &dev_attr_active.attr,
591 &dev_attr_owned.attr,
592 &dev_attr_temp_deactivated.attr,
593 &dev_attr_caps.attr,
594 &dev_attr_cancel.attr, NULL,
595};
596
597static struct attribute_group stm_tpm_attr_grp = {
598 .attrs = stm_tpm_attrs
599};
600
601static struct tpm_vendor_specific st_i2c_tpm = { 577static struct tpm_vendor_specific st_i2c_tpm = {
602 .send = tpm_stm_i2c_send, 578 .send = tpm_stm_i2c_send,
603 .recv = tpm_stm_i2c_recv, 579 .recv = tpm_stm_i2c_recv,
@@ -606,7 +582,6 @@ static struct tpm_vendor_specific st_i2c_tpm = {
606 .req_complete_mask = TPM_STS_DATA_AVAIL | TPM_STS_VALID, 582 .req_complete_mask = TPM_STS_DATA_AVAIL | TPM_STS_VALID,
607 .req_complete_val = TPM_STS_DATA_AVAIL | TPM_STS_VALID, 583 .req_complete_val = TPM_STS_DATA_AVAIL | TPM_STS_VALID,
608 .req_canceled = tpm_st33_i2c_req_canceled, 584 .req_canceled = tpm_st33_i2c_req_canceled,
609 .attr_group = &stm_tpm_attr_grp,
610}; 585};
611 586
612static int interrupts; 587static int interrupts;
diff --git a/drivers/char/tpm/tpm_ibmvtpm.c b/drivers/char/tpm/tpm_ibmvtpm.c
index 2ee43093066f..ff064f08b48e 100644
--- a/drivers/char/tpm/tpm_ibmvtpm.c
+++ b/drivers/char/tpm/tpm_ibmvtpm.c
@@ -403,33 +403,6 @@ static bool tpm_ibmvtpm_req_canceled(struct tpm_chip *chip, u8 status)
403 return (status == 0); 403 return (status == 0);
404} 404}
405 405
406static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL);
407static DEVICE_ATTR(pcrs, S_IRUGO, tpm_show_pcrs, NULL);
408static DEVICE_ATTR(enabled, S_IRUGO, tpm_show_enabled, NULL);
409static DEVICE_ATTR(active, S_IRUGO, tpm_show_active, NULL);
410static DEVICE_ATTR(owned, S_IRUGO, tpm_show_owned, NULL);
411static DEVICE_ATTR(temp_deactivated, S_IRUGO, tpm_show_temp_deactivated,
412 NULL);
413static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps, NULL);
414static DEVICE_ATTR(cancel, S_IWUSR | S_IWGRP, NULL, tpm_store_cancel);
415static DEVICE_ATTR(durations, S_IRUGO, tpm_show_durations, NULL);
416static DEVICE_ATTR(timeouts, S_IRUGO, tpm_show_timeouts, NULL);
417
418static struct attribute *ibmvtpm_attrs[] = {
419 &dev_attr_pubek.attr,
420 &dev_attr_pcrs.attr,
421 &dev_attr_enabled.attr,
422 &dev_attr_active.attr,
423 &dev_attr_owned.attr,
424 &dev_attr_temp_deactivated.attr,
425 &dev_attr_caps.attr,
426 &dev_attr_cancel.attr,
427 &dev_attr_durations.attr,
428 &dev_attr_timeouts.attr, NULL,
429};
430
431static struct attribute_group ibmvtpm_attr_grp = { .attrs = ibmvtpm_attrs };
432
433static const struct tpm_vendor_specific tpm_ibmvtpm = { 406static const struct tpm_vendor_specific tpm_ibmvtpm = {
434 .recv = tpm_ibmvtpm_recv, 407 .recv = tpm_ibmvtpm_recv,
435 .send = tpm_ibmvtpm_send, 408 .send = tpm_ibmvtpm_send,
@@ -438,7 +411,6 @@ static const struct tpm_vendor_specific tpm_ibmvtpm = {
438 .req_complete_mask = 0, 411 .req_complete_mask = 0,
439 .req_complete_val = 0, 412 .req_complete_val = 0,
440 .req_canceled = tpm_ibmvtpm_req_canceled, 413 .req_canceled = tpm_ibmvtpm_req_canceled,
441 .attr_group = &ibmvtpm_attr_grp,
442}; 414};
443 415
444static const struct dev_pm_ops tpm_ibmvtpm_pm_ops = { 416static const struct dev_pm_ops tpm_ibmvtpm_pm_ops = {
diff --git a/drivers/char/tpm/tpm_infineon.c b/drivers/char/tpm/tpm_infineon.c
index c75c10ca2660..9525be5c136c 100644
--- a/drivers/char/tpm/tpm_infineon.c
+++ b/drivers/char/tpm/tpm_infineon.c
@@ -371,21 +371,6 @@ static u8 tpm_inf_status(struct tpm_chip *chip)
371 return tpm_data_in(STAT); 371 return tpm_data_in(STAT);
372} 372}
373 373
374static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL);
375static DEVICE_ATTR(pcrs, S_IRUGO, tpm_show_pcrs, NULL);
376static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps, NULL);
377static DEVICE_ATTR(cancel, S_IWUSR | S_IWGRP, NULL, tpm_store_cancel);
378
379static struct attribute *inf_attrs[] = {
380 &dev_attr_pubek.attr,
381 &dev_attr_pcrs.attr,
382 &dev_attr_caps.attr,
383 &dev_attr_cancel.attr,
384 NULL,
385};
386
387static struct attribute_group inf_attr_grp = {.attrs = inf_attrs };
388
389static const struct tpm_vendor_specific tpm_inf = { 374static const struct tpm_vendor_specific tpm_inf = {
390 .recv = tpm_inf_recv, 375 .recv = tpm_inf_recv,
391 .send = tpm_inf_send, 376 .send = tpm_inf_send,
@@ -393,7 +378,6 @@ static const struct tpm_vendor_specific tpm_inf = {
393 .status = tpm_inf_status, 378 .status = tpm_inf_status,
394 .req_complete_mask = 0, 379 .req_complete_mask = 0,
395 .req_complete_val = 0, 380 .req_complete_val = 0,
396 .attr_group = &inf_attr_grp,
397}; 381};
398 382
399static const struct pnp_device_id tpm_inf_pnp_tbl[] = { 383static const struct pnp_device_id tpm_inf_pnp_tbl[] = {
diff --git a/drivers/char/tpm/tpm_nsc.c b/drivers/char/tpm/tpm_nsc.c
index a4acac9008f7..ad980be553dc 100644
--- a/drivers/char/tpm/tpm_nsc.c
+++ b/drivers/char/tpm/tpm_nsc.c
@@ -232,21 +232,6 @@ static bool tpm_nsc_req_canceled(struct tpm_chip *chip, u8 status)
232 return (status == NSC_STATUS_RDY); 232 return (status == NSC_STATUS_RDY);
233} 233}
234 234
235static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL);
236static DEVICE_ATTR(pcrs, S_IRUGO, tpm_show_pcrs, NULL);
237static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps, NULL);
238static DEVICE_ATTR(cancel, S_IWUSR|S_IWGRP, NULL, tpm_store_cancel);
239
240static struct attribute * nsc_attrs[] = {
241 &dev_attr_pubek.attr,
242 &dev_attr_pcrs.attr,
243 &dev_attr_caps.attr,
244 &dev_attr_cancel.attr,
245 NULL,
246};
247
248static struct attribute_group nsc_attr_grp = { .attrs = nsc_attrs };
249
250static const struct tpm_vendor_specific tpm_nsc = { 235static const struct tpm_vendor_specific tpm_nsc = {
251 .recv = tpm_nsc_recv, 236 .recv = tpm_nsc_recv,
252 .send = tpm_nsc_send, 237 .send = tpm_nsc_send,
@@ -255,7 +240,6 @@ static const struct tpm_vendor_specific tpm_nsc = {
255 .req_complete_mask = NSC_STATUS_OBF, 240 .req_complete_mask = NSC_STATUS_OBF,
256 .req_complete_val = NSC_STATUS_OBF, 241 .req_complete_val = NSC_STATUS_OBF,
257 .req_canceled = tpm_nsc_req_canceled, 242 .req_canceled = tpm_nsc_req_canceled,
258 .attr_group = &nsc_attr_grp,
259}; 243};
260 244
261static struct platform_device *pdev = NULL; 245static struct platform_device *pdev = NULL;
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 46f57f5dda7d..a362edec58d4 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -432,35 +432,6 @@ static bool tpm_tis_req_canceled(struct tpm_chip *chip, u8 status)
432 } 432 }
433} 433}
434 434
435static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL);
436static DEVICE_ATTR(pcrs, S_IRUGO, tpm_show_pcrs, NULL);
437static DEVICE_ATTR(enabled, S_IRUGO, tpm_show_enabled, NULL);
438static DEVICE_ATTR(active, S_IRUGO, tpm_show_active, NULL);
439static DEVICE_ATTR(owned, S_IRUGO, tpm_show_owned, NULL);
440static DEVICE_ATTR(temp_deactivated, S_IRUGO, tpm_show_temp_deactivated,
441 NULL);
442static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps, NULL);
443static DEVICE_ATTR(cancel, S_IWUSR | S_IWGRP, NULL, tpm_store_cancel);
444static DEVICE_ATTR(durations, S_IRUGO, tpm_show_durations, NULL);
445static DEVICE_ATTR(timeouts, S_IRUGO, tpm_show_timeouts, NULL);
446
447static struct attribute *tis_attrs[] = {
448 &dev_attr_pubek.attr,
449 &dev_attr_pcrs.attr,
450 &dev_attr_enabled.attr,
451 &dev_attr_active.attr,
452 &dev_attr_owned.attr,
453 &dev_attr_temp_deactivated.attr,
454 &dev_attr_caps.attr,
455 &dev_attr_cancel.attr,
456 &dev_attr_durations.attr,
457 &dev_attr_timeouts.attr, NULL,
458};
459
460static struct attribute_group tis_attr_grp = {
461 .attrs = tis_attrs
462};
463
464static struct tpm_vendor_specific tpm_tis = { 435static struct tpm_vendor_specific tpm_tis = {
465 .status = tpm_tis_status, 436 .status = tpm_tis_status,
466 .recv = tpm_tis_recv, 437 .recv = tpm_tis_recv,
@@ -469,7 +440,6 @@ static struct tpm_vendor_specific tpm_tis = {
469 .req_complete_mask = TPM_STS_DATA_AVAIL | TPM_STS_VALID, 440 .req_complete_mask = TPM_STS_DATA_AVAIL | TPM_STS_VALID,
470 .req_complete_val = TPM_STS_DATA_AVAIL | TPM_STS_VALID, 441 .req_complete_val = TPM_STS_DATA_AVAIL | TPM_STS_VALID,
471 .req_canceled = tpm_tis_req_canceled, 442 .req_canceled = tpm_tis_req_canceled,
472 .attr_group = &tis_attr_grp,
473}; 443};
474 444
475static irqreturn_t tis_int_probe(int irq, void *dev_id) 445static irqreturn_t tis_int_probe(int irq, void *dev_id)
diff --git a/drivers/char/tpm/xen-tpmfront.c b/drivers/char/tpm/xen-tpmfront.c
index e3c7c0154515..d4f6b5213443 100644
--- a/drivers/char/tpm/xen-tpmfront.c
+++ b/drivers/char/tpm/xen-tpmfront.c
@@ -143,36 +143,6 @@ static int vtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count)
143 return length; 143 return length;
144} 144}
145 145
146static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL);
147static DEVICE_ATTR(pcrs, S_IRUGO, tpm_show_pcrs, NULL);
148static DEVICE_ATTR(enabled, S_IRUGO, tpm_show_enabled, NULL);
149static DEVICE_ATTR(active, S_IRUGO, tpm_show_active, NULL);
150static DEVICE_ATTR(owned, S_IRUGO, tpm_show_owned, NULL);
151static DEVICE_ATTR(temp_deactivated, S_IRUGO, tpm_show_temp_deactivated,
152 NULL);
153static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps, NULL);
154static DEVICE_ATTR(cancel, S_IWUSR | S_IWGRP, NULL, tpm_store_cancel);
155static DEVICE_ATTR(durations, S_IRUGO, tpm_show_durations, NULL);
156static DEVICE_ATTR(timeouts, S_IRUGO, tpm_show_timeouts, NULL);
157
158static struct attribute *vtpm_attrs[] = {
159 &dev_attr_pubek.attr,
160 &dev_attr_pcrs.attr,
161 &dev_attr_enabled.attr,
162 &dev_attr_active.attr,
163 &dev_attr_owned.attr,
164 &dev_attr_temp_deactivated.attr,
165 &dev_attr_caps.attr,
166 &dev_attr_cancel.attr,
167 &dev_attr_durations.attr,
168 &dev_attr_timeouts.attr,
169 NULL,
170};
171
172static struct attribute_group vtpm_attr_grp = {
173 .attrs = vtpm_attrs,
174};
175
176static const struct tpm_vendor_specific tpm_vtpm = { 146static const struct tpm_vendor_specific tpm_vtpm = {
177 .status = vtpm_status, 147 .status = vtpm_status,
178 .recv = vtpm_recv, 148 .recv = vtpm_recv,
@@ -181,7 +151,6 @@ static const struct tpm_vendor_specific tpm_vtpm = {
181 .req_complete_mask = VTPM_STATUS_IDLE | VTPM_STATUS_RESULT, 151 .req_complete_mask = VTPM_STATUS_IDLE | VTPM_STATUS_RESULT,
182 .req_complete_val = VTPM_STATUS_IDLE | VTPM_STATUS_RESULT, 152 .req_complete_val = VTPM_STATUS_IDLE | VTPM_STATUS_RESULT,
183 .req_canceled = vtpm_req_canceled, 153 .req_canceled = vtpm_req_canceled,
184 .attr_group = &vtpm_attr_grp,
185}; 154};
186 155
187static irqreturn_t tpmif_interrupt(int dummy, void *dev_id) 156static irqreturn_t tpmif_interrupt(int dummy, void *dev_id)