aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/tpm
diff options
context:
space:
mode:
authorJason Gunthorpe <jgunthorpe@obsidianresearch.com>2013-11-26 15:30:43 -0500
committerPeter Huewe <peterhuewe@gmx.de>2014-01-06 08:37:25 -0500
commit01ad1fa75dd243909d62dba25a93254b20d5fe81 (patch)
treef7a09e61ead8f9e0a1002dde7e53d0376b8b3c19 /drivers/char/tpm
parent1e3b73a95793555860512008035f6822406a2a79 (diff)
tpm: Create a tpm_class_ops structure and use it in the drivers
This replaces the static initialization of a tpm_vendor_specific structure in the drivers with the standard Linux idiom of providing a const structure of function pointers. Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com> Reviewed-by: Joel Schopp <jschopp@linux.vnet.ibm.com> Reviewed-by: Ashley Lai <adlai@linux.vnet.ibm.com> [phuewe: did apply manually due to commit 191ffc6bde3 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.c10
-rw-r--r--drivers/char/tpm/tpm.h6
-rw-r--r--drivers/char/tpm/tpm_atmel.c2
-rw-r--r--drivers/char/tpm/tpm_i2c_atmel.c2
-rw-r--r--drivers/char/tpm/tpm_i2c_infineon.c2
-rw-r--r--drivers/char/tpm/tpm_i2c_nuvoton.c2
-rw-r--r--drivers/char/tpm/tpm_i2c_stm_st33.c2
-rw-r--r--drivers/char/tpm/tpm_ibmvtpm.c2
-rw-r--r--drivers/char/tpm/tpm_infineon.c2
-rw-r--r--drivers/char/tpm/tpm_nsc.c2
-rw-r--r--drivers/char/tpm/tpm_tis.c2
-rw-r--r--drivers/char/tpm/xen-tpmfront.c2
12 files changed, 21 insertions, 15 deletions
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index 389d483a887c..1b012463da7c 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -1060,7 +1060,7 @@ static void tpm_dev_release(struct device *dev)
1060 * pci_disable_device 1060 * pci_disable_device
1061 */ 1061 */
1062struct tpm_chip *tpm_register_hardware(struct device *dev, 1062struct tpm_chip *tpm_register_hardware(struct device *dev,
1063 const struct tpm_vendor_specific *entry) 1063 const struct tpm_class_ops *ops)
1064{ 1064{
1065 struct tpm_chip *chip; 1065 struct tpm_chip *chip;
1066 1066
@@ -1073,7 +1073,13 @@ struct tpm_chip *tpm_register_hardware(struct device *dev,
1073 mutex_init(&chip->tpm_mutex); 1073 mutex_init(&chip->tpm_mutex);
1074 INIT_LIST_HEAD(&chip->list); 1074 INIT_LIST_HEAD(&chip->list);
1075 1075
1076 memcpy(&chip->vendor, entry, sizeof(struct tpm_vendor_specific)); 1076 chip->vendor.req_complete_mask = ops->req_complete_mask;
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;
1077 1083
1078 chip->dev_num = find_first_zero_bit(dev_mask, TPM_NUM_DEVICES); 1084 chip->dev_num = find_first_zero_bit(dev_mask, TPM_NUM_DEVICES);
1079 1085
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 14ba1627d78e..a56af2c13518 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -64,8 +64,8 @@ enum tpm_duration {
64struct tpm_chip; 64struct tpm_chip;
65 65
66struct tpm_vendor_specific { 66struct tpm_vendor_specific {
67 const u8 req_complete_mask; 67 u8 req_complete_mask;
68 const u8 req_complete_val; 68 u8 req_complete_val;
69 bool (*req_canceled)(struct tpm_chip *chip, u8 status); 69 bool (*req_canceled)(struct tpm_chip *chip, u8 status);
70 void __iomem *iobase; /* ioremapped address */ 70 void __iomem *iobase; /* ioremapped address */
71 unsigned long base; /* TPM base address */ 71 unsigned long base; /* TPM base address */
@@ -336,7 +336,7 @@ extern void tpm_gen_interrupt(struct tpm_chip *);
336extern int tpm_do_selftest(struct tpm_chip *); 336extern int tpm_do_selftest(struct tpm_chip *);
337extern unsigned long tpm_calc_ordinal_duration(struct tpm_chip *, u32); 337extern unsigned long tpm_calc_ordinal_duration(struct tpm_chip *, u32);
338extern struct tpm_chip* tpm_register_hardware(struct device *, 338extern struct tpm_chip* tpm_register_hardware(struct device *,
339 const struct tpm_vendor_specific *); 339 const struct tpm_class_ops *ops);
340extern void tpm_dev_vendor_release(struct tpm_chip *); 340extern void tpm_dev_vendor_release(struct tpm_chip *);
341extern void tpm_remove_hardware(struct device *); 341extern void tpm_remove_hardware(struct device *);
342extern int tpm_pm_suspend(struct device *); 342extern int tpm_pm_suspend(struct device *);
diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c
index 7e665d047c93..6069d13ae4ac 100644
--- a/drivers/char/tpm/tpm_atmel.c
+++ b/drivers/char/tpm/tpm_atmel.c
@@ -121,7 +121,7 @@ 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 const struct tpm_vendor_specific tpm_atmel = { 124static const struct tpm_class_ops tpm_atmel = {
125 .recv = tpm_atml_recv, 125 .recv = tpm_atml_recv,
126 .send = tpm_atml_send, 126 .send = tpm_atml_send,
127 .cancel = tpm_atml_cancel, 127 .cancel = tpm_atml_cancel,
diff --git a/drivers/char/tpm/tpm_i2c_atmel.c b/drivers/char/tpm/tpm_i2c_atmel.c
index fe8bdce7d24f..77272925dee6 100644
--- a/drivers/char/tpm/tpm_i2c_atmel.c
+++ b/drivers/char/tpm/tpm_i2c_atmel.c
@@ -140,7 +140,7 @@ static bool i2c_atmel_req_canceled(struct tpm_chip *chip, u8 status)
140 return false; 140 return false;
141} 141}
142 142
143static const struct tpm_vendor_specific i2c_atmel = { 143static const struct tpm_class_ops i2c_atmel = {
144 .status = i2c_atmel_read_status, 144 .status = i2c_atmel_read_status,
145 .recv = i2c_atmel_recv, 145 .recv = i2c_atmel_recv,
146 .send = i2c_atmel_send, 146 .send = i2c_atmel_send,
diff --git a/drivers/char/tpm/tpm_i2c_infineon.c b/drivers/char/tpm/tpm_i2c_infineon.c
index ac1218f41afe..52b9b2b2f300 100644
--- a/drivers/char/tpm/tpm_i2c_infineon.c
+++ b/drivers/char/tpm/tpm_i2c_infineon.c
@@ -566,7 +566,7 @@ 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 struct tpm_vendor_specific tpm_tis_i2c = { 569static const struct tpm_class_ops tpm_tis_i2c = {
570 .status = tpm_tis_i2c_status, 570 .status = tpm_tis_i2c_status,
571 .recv = tpm_tis_i2c_recv, 571 .recv = tpm_tis_i2c_recv,
572 .send = tpm_tis_i2c_send, 572 .send = tpm_tis_i2c_send,
diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c
index 1e6905ba0dea..7b158efd49f7 100644
--- a/drivers/char/tpm/tpm_i2c_nuvoton.c
+++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
@@ -455,7 +455,7 @@ 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 const struct tpm_vendor_specific tpm_i2c = { 458static const struct tpm_class_ops tpm_i2c = {
459 .status = i2c_nuvoton_read_status, 459 .status = i2c_nuvoton_read_status,
460 .recv = i2c_nuvoton_recv, 460 .recv = i2c_nuvoton_recv,
461 .send = i2c_nuvoton_send, 461 .send = i2c_nuvoton_send,
diff --git a/drivers/char/tpm/tpm_i2c_stm_st33.c b/drivers/char/tpm/tpm_i2c_stm_st33.c
index 6902f7b11e48..874b3be330bc 100644
--- a/drivers/char/tpm/tpm_i2c_stm_st33.c
+++ b/drivers/char/tpm/tpm_i2c_stm_st33.c
@@ -574,7 +574,7 @@ 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 struct tpm_vendor_specific st_i2c_tpm = { 577static const struct tpm_class_ops st_i2c_tpm = {
578 .send = tpm_stm_i2c_send, 578 .send = tpm_stm_i2c_send,
579 .recv = tpm_stm_i2c_recv, 579 .recv = tpm_stm_i2c_recv,
580 .cancel = tpm_stm_i2c_cancel, 580 .cancel = tpm_stm_i2c_cancel,
diff --git a/drivers/char/tpm/tpm_ibmvtpm.c b/drivers/char/tpm/tpm_ibmvtpm.c
index ff064f08b48e..af74c57e5090 100644
--- a/drivers/char/tpm/tpm_ibmvtpm.c
+++ b/drivers/char/tpm/tpm_ibmvtpm.c
@@ -403,7 +403,7 @@ 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 const struct tpm_vendor_specific tpm_ibmvtpm = { 406static const struct tpm_class_ops tpm_ibmvtpm = {
407 .recv = tpm_ibmvtpm_recv, 407 .recv = tpm_ibmvtpm_recv,
408 .send = tpm_ibmvtpm_send, 408 .send = tpm_ibmvtpm_send,
409 .cancel = tpm_ibmvtpm_cancel, 409 .cancel = tpm_ibmvtpm_cancel,
diff --git a/drivers/char/tpm/tpm_infineon.c b/drivers/char/tpm/tpm_infineon.c
index 9525be5c136c..dc0a2554034e 100644
--- a/drivers/char/tpm/tpm_infineon.c
+++ b/drivers/char/tpm/tpm_infineon.c
@@ -371,7 +371,7 @@ 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 const struct tpm_vendor_specific tpm_inf = { 374static const struct tpm_class_ops tpm_inf = {
375 .recv = tpm_inf_recv, 375 .recv = tpm_inf_recv,
376 .send = tpm_inf_send, 376 .send = tpm_inf_send,
377 .cancel = tpm_inf_cancel, 377 .cancel = tpm_inf_cancel,
diff --git a/drivers/char/tpm/tpm_nsc.c b/drivers/char/tpm/tpm_nsc.c
index ad980be553dc..3179ec9cffdc 100644
--- a/drivers/char/tpm/tpm_nsc.c
+++ b/drivers/char/tpm/tpm_nsc.c
@@ -232,7 +232,7 @@ 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 const struct tpm_vendor_specific tpm_nsc = { 235static const struct tpm_class_ops tpm_nsc = {
236 .recv = tpm_nsc_recv, 236 .recv = tpm_nsc_recv,
237 .send = tpm_nsc_send, 237 .send = tpm_nsc_send,
238 .cancel = tpm_nsc_cancel, 238 .cancel = tpm_nsc_cancel,
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index a362edec58d4..8094b081a8be 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -432,7 +432,7 @@ static bool tpm_tis_req_canceled(struct tpm_chip *chip, u8 status)
432 } 432 }
433} 433}
434 434
435static struct tpm_vendor_specific tpm_tis = { 435static const struct tpm_class_ops tpm_tis = {
436 .status = tpm_tis_status, 436 .status = tpm_tis_status,
437 .recv = tpm_tis_recv, 437 .recv = tpm_tis_recv,
438 .send = tpm_tis_send, 438 .send = tpm_tis_send,
diff --git a/drivers/char/tpm/xen-tpmfront.c b/drivers/char/tpm/xen-tpmfront.c
index d4f6b5213443..92b097064df5 100644
--- a/drivers/char/tpm/xen-tpmfront.c
+++ b/drivers/char/tpm/xen-tpmfront.c
@@ -143,7 +143,7 @@ static int vtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count)
143 return length; 143 return length;
144} 144}
145 145
146static const struct tpm_vendor_specific tpm_vtpm = { 146static const struct tpm_class_ops tpm_vtpm = {
147 .status = vtpm_status, 147 .status = vtpm_status,
148 .recv = vtpm_recv, 148 .recv = vtpm_recv,
149 .send = vtpm_send, 149 .send = vtpm_send,