aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Morton <akpm@osdl.org>2005-10-30 18:03:28 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-10-30 20:37:29 -0500
commitb888c87b7498557d1dbb9de3d4b8402b1bb89193 (patch)
tree31d43ab177ef00fbef3d15c9513ba737029b6d48
parent1b8333b02aa281a2849331ad62ee595c46a1c5ac (diff)
[PATCH] tpm-tidies
- Various whitespace fixes - Use kzalloc() Acked-by: Kylene Hall <kjhall@us.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--drivers/char/tpm/tpm.c35
-rw-r--r--drivers/char/tpm/tpm_atmel.c17
-rw-r--r--drivers/char/tpm/tpm_infineon.c8
3 files changed, 23 insertions, 37 deletions
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index e3919c353f3d..303f15880466 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -162,7 +162,8 @@ ssize_t tpm_show_pcrs(struct device *dev, struct device_attribute *attr,
162 < READ_PCR_RESULT_SIZE){ 162 < READ_PCR_RESULT_SIZE){
163 dev_dbg(chip->dev, "A TPM error (%d) occurred" 163 dev_dbg(chip->dev, "A TPM error (%d) occurred"
164 " attempting to read PCR %d of %d\n", 164 " attempting to read PCR %d of %d\n",
165 be32_to_cpu(*((__be32 *) (data + 6))), i, num_pcrs); 165 be32_to_cpu(*((__be32 *) (data + 6))),
166 i, num_pcrs);
166 goto out; 167 goto out;
167 } 168 }
168 str += sprintf(str, "PCR-%02d: ", i); 169 str += sprintf(str, "PCR-%02d: ", i);
@@ -194,12 +195,11 @@ ssize_t tpm_show_pubek(struct device *dev, struct device_attribute *attr,
194 if (chip == NULL) 195 if (chip == NULL)
195 return -ENODEV; 196 return -ENODEV;
196 197
197 data = kmalloc(READ_PUBEK_RESULT_SIZE, GFP_KERNEL); 198 data = kzalloc(READ_PUBEK_RESULT_SIZE, GFP_KERNEL);
198 if (!data) 199 if (!data)
199 return -ENOMEM; 200 return -ENOMEM;
200 201
201 memcpy(data, readpubek, sizeof(readpubek)); 202 memcpy(data, readpubek, sizeof(readpubek));
202 memset(data + sizeof(readpubek), 0, 20); /* zero nonce */
203 203
204 if ((len = tpm_transmit(chip, data, READ_PUBEK_RESULT_SIZE)) < 204 if ((len = tpm_transmit(chip, data, READ_PUBEK_RESULT_SIZE)) <
205 READ_PUBEK_RESULT_SIZE) { 205 READ_PUBEK_RESULT_SIZE) {
@@ -243,7 +243,6 @@ out:
243 kfree(data); 243 kfree(data);
244 return rc; 244 return rc;
245} 245}
246
247EXPORT_SYMBOL_GPL(tpm_show_pubek); 246EXPORT_SYMBOL_GPL(tpm_show_pubek);
248 247
249#define CAP_VER_RESULT_SIZE 18 248#define CAP_VER_RESULT_SIZE 18
@@ -312,7 +311,6 @@ ssize_t tpm_store_cancel(struct device *dev, struct device_attribute *attr,
312} 311}
313EXPORT_SYMBOL_GPL(tpm_store_cancel); 312EXPORT_SYMBOL_GPL(tpm_store_cancel);
314 313
315
316/* 314/*
317 * Device file system interface to the TPM 315 * Device file system interface to the TPM
318 */ 316 */
@@ -336,8 +334,7 @@ int tpm_open(struct inode *inode, struct file *file)
336 } 334 }
337 335
338 if (chip->num_opens) { 336 if (chip->num_opens) {
339 dev_dbg(chip->dev, 337 dev_dbg(chip->dev, "Another process owns this TPM\n");
340 "Another process owns this TPM\n");
341 rc = -EBUSY; 338 rc = -EBUSY;
342 goto err_out; 339 goto err_out;
343 } 340 }
@@ -363,7 +360,6 @@ err_out:
363 spin_unlock(&driver_lock); 360 spin_unlock(&driver_lock);
364 return rc; 361 return rc;
365} 362}
366
367EXPORT_SYMBOL_GPL(tpm_open); 363EXPORT_SYMBOL_GPL(tpm_open);
368 364
369int tpm_release(struct inode *inode, struct file *file) 365int tpm_release(struct inode *inode, struct file *file)
@@ -380,10 +376,9 @@ int tpm_release(struct inode *inode, struct file *file)
380 spin_unlock(&driver_lock); 376 spin_unlock(&driver_lock);
381 return 0; 377 return 0;
382} 378}
383
384EXPORT_SYMBOL_GPL(tpm_release); 379EXPORT_SYMBOL_GPL(tpm_release);
385 380
386ssize_t tpm_write(struct file * file, const char __user * buf, 381ssize_t tpm_write(struct file *file, const char __user *buf,
387 size_t size, loff_t * off) 382 size_t size, loff_t * off)
388{ 383{
389 struct tpm_chip *chip = file->private_data; 384 struct tpm_chip *chip = file->private_data;
@@ -419,7 +414,7 @@ ssize_t tpm_write(struct file * file, const char __user * buf,
419 414
420EXPORT_SYMBOL_GPL(tpm_write); 415EXPORT_SYMBOL_GPL(tpm_write);
421 416
422ssize_t tpm_read(struct file * file, char __user * buf, 417ssize_t tpm_read(struct file * file, char __user *buf,
423 size_t size, loff_t * off) 418 size_t size, loff_t * off)
424{ 419{
425 struct tpm_chip *chip = file->private_data; 420 struct tpm_chip *chip = file->private_data;
@@ -441,7 +436,6 @@ ssize_t tpm_read(struct file * file, char __user * buf,
441 436
442 return ret_size; 437 return ret_size;
443} 438}
444
445EXPORT_SYMBOL_GPL(tpm_read); 439EXPORT_SYMBOL_GPL(tpm_read);
446 440
447void tpm_remove_hardware(struct device *dev) 441void tpm_remove_hardware(struct device *dev)
@@ -465,13 +459,13 @@ void tpm_remove_hardware(struct device *dev)
465 459
466 sysfs_remove_group(&dev->kobj, chip->vendor->attr_group); 460 sysfs_remove_group(&dev->kobj, chip->vendor->attr_group);
467 461
468 dev_mask[chip->dev_num / TPM_NUM_MASK_ENTRIES ] &= !(1 << (chip->dev_num % TPM_NUM_MASK_ENTRIES)); 462 dev_mask[chip->dev_num / TPM_NUM_MASK_ENTRIES ] &=
463 !(1 << (chip->dev_num % TPM_NUM_MASK_ENTRIES));
469 464
470 kfree(chip); 465 kfree(chip);
471 466
472 put_device(dev); 467 put_device(dev);
473} 468}
474
475EXPORT_SYMBOL_GPL(tpm_remove_hardware); 469EXPORT_SYMBOL_GPL(tpm_remove_hardware);
476 470
477static u8 savestate[] = { 471static u8 savestate[] = {
@@ -493,7 +487,6 @@ int tpm_pm_suspend(struct device *dev, pm_message_t pm_state)
493 tpm_transmit(chip, savestate, sizeof(savestate)); 487 tpm_transmit(chip, savestate, sizeof(savestate));
494 return 0; 488 return 0;
495} 489}
496
497EXPORT_SYMBOL_GPL(tpm_pm_suspend); 490EXPORT_SYMBOL_GPL(tpm_pm_suspend);
498 491
499/* 492/*
@@ -509,7 +502,6 @@ int tpm_pm_resume(struct device *dev)
509 502
510 return 0; 503 return 0;
511} 504}
512
513EXPORT_SYMBOL_GPL(tpm_pm_resume); 505EXPORT_SYMBOL_GPL(tpm_pm_resume);
514 506
515/* 507/*
@@ -519,8 +511,7 @@ EXPORT_SYMBOL_GPL(tpm_pm_resume);
519 * upon errant exit from this function specific probe function should call 511 * upon errant exit from this function specific probe function should call
520 * pci_disable_device 512 * pci_disable_device
521 */ 513 */
522int tpm_register_hardware(struct device *dev, 514int tpm_register_hardware(struct device *dev, struct tpm_vendor_specific *entry)
523 struct tpm_vendor_specific *entry)
524{ 515{
525#define DEVNAME_SIZE 7 516#define DEVNAME_SIZE 7
526 517
@@ -529,12 +520,10 @@ int tpm_register_hardware(struct device *dev,
529 int i, j; 520 int i, j;
530 521
531 /* Driver specific per-device data */ 522 /* Driver specific per-device data */
532 chip = kmalloc(sizeof(*chip), GFP_KERNEL); 523 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
533 if (chip == NULL) 524 if (chip == NULL)
534 return -ENOMEM; 525 return -ENOMEM;
535 526
536 memset(chip, 0, sizeof(struct tpm_chip));
537
538 init_MUTEX(&chip->buffer_mutex); 527 init_MUTEX(&chip->buffer_mutex);
539 init_MUTEX(&chip->tpm_mutex); 528 init_MUTEX(&chip->tpm_mutex);
540 INIT_LIST_HEAD(&chip->list); 529 INIT_LIST_HEAD(&chip->list);
@@ -558,8 +547,7 @@ int tpm_register_hardware(struct device *dev,
558 547
559dev_num_search_complete: 548dev_num_search_complete:
560 if (chip->dev_num < 0) { 549 if (chip->dev_num < 0) {
561 dev_err(dev, 550 dev_err(dev, "No available tpm device numbers\n");
562 "No available tpm device numbers\n");
563 kfree(chip); 551 kfree(chip);
564 return -ENODEV; 552 return -ENODEV;
565 } else if (chip->dev_num == 0) 553 } else if (chip->dev_num == 0)
@@ -597,7 +585,6 @@ dev_num_search_complete:
597 585
598 return 0; 586 return 0;
599} 587}
600
601EXPORT_SYMBOL_GPL(tpm_register_hardware); 588EXPORT_SYMBOL_GPL(tpm_register_hardware);
602 589
603MODULE_AUTHOR("Leendert van Doorn (leendert@watson.ibm.com)"); 590MODULE_AUTHOR("Leendert van Doorn (leendert@watson.ibm.com)");
diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c
index a9100ad3d030..d12ac1a346b5 100644
--- a/drivers/char/tpm/tpm_atmel.c
+++ b/drivers/char/tpm/tpm_atmel.c
@@ -40,7 +40,7 @@ enum tpm_atmel_read_status {
40 ATML_STATUS_READY = 0x08 40 ATML_STATUS_READY = 0x08
41}; 41};
42 42
43static int tpm_atml_recv(struct tpm_chip *chip, u8 * buf, size_t count) 43static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
44{ 44{
45 u8 status, *hdr = buf; 45 u8 status, *hdr = buf;
46 u32 size; 46 u32 size;
@@ -100,7 +100,7 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 * buf, size_t count)
100 return size; 100 return size;
101} 101}
102 102
103static int tpm_atml_send(struct tpm_chip *chip, u8 * buf, size_t count) 103static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count)
104{ 104{
105 int i; 105 int i;
106 106
@@ -159,12 +159,12 @@ static struct tpm_vendor_specific tpm_atmel = {
159 .miscdev = { .fops = &atmel_ops, }, 159 .miscdev = { .fops = &atmel_ops, },
160}; 160};
161 161
162static struct platform_device *pdev = NULL; 162static struct platform_device *pdev;
163 163
164static void __devexit tpm_atml_remove(struct device *dev) 164static void __devexit tpm_atml_remove(struct device *dev)
165{ 165{
166 struct tpm_chip *chip = dev_get_drvdata(dev); 166 struct tpm_chip *chip = dev_get_drvdata(dev);
167 if ( chip ) { 167 if (chip) {
168 release_region(chip->vendor->base, 2); 168 release_region(chip->vendor->base, 2);
169 tpm_remove_hardware(chip->dev); 169 tpm_remove_hardware(chip->dev);
170 } 170 }
@@ -201,19 +201,17 @@ static int __init init_atmel(void)
201 (tpm_read_index(TPM_ADDR, 0x01) != 0x01 )) 201 (tpm_read_index(TPM_ADDR, 0x01) != 0x01 ))
202 return -ENODEV; 202 return -ENODEV;
203 203
204 pdev = kmalloc(sizeof(struct platform_device), GFP_KERNEL); 204 pdev = kzalloc(sizeof(struct platform_device), GFP_KERNEL);
205 if ( !pdev ) 205 if ( !pdev )
206 return -ENOMEM; 206 return -ENOMEM;
207 207
208 memset(pdev, 0, sizeof(struct platform_device));
209
210 pdev->name = "tpm_atmel0"; 208 pdev->name = "tpm_atmel0";
211 pdev->id = -1; 209 pdev->id = -1;
212 pdev->num_resources = 0; 210 pdev->num_resources = 0;
213 pdev->dev.release = tpm_atml_remove; 211 pdev->dev.release = tpm_atml_remove;
214 pdev->dev.driver = &atml_drv; 212 pdev->dev.driver = &atml_drv;
215 213
216 if ((rc=platform_device_register(pdev)) < 0) { 214 if ((rc = platform_device_register(pdev)) < 0) {
217 kfree(pdev); 215 kfree(pdev);
218 pdev = NULL; 216 pdev = NULL;
219 return rc; 217 return rc;
@@ -234,7 +232,8 @@ static int __init init_atmel(void)
234 return rc; 232 return rc;
235 } 233 }
236 234
237 dev_info(&pdev->dev, "Atmel TPM 1.1, Base Address: 0x%x\n", tpm_atmel.base); 235 dev_info(&pdev->dev, "Atmel TPM 1.1, Base Address: 0x%x\n",
236 tpm_atmel.base);
238 return 0; 237 return 0;
239} 238}
240 239
diff --git a/drivers/char/tpm/tpm_infineon.c b/drivers/char/tpm/tpm_infineon.c
index d356f53c49b4..8198dbb7370f 100644
--- a/drivers/char/tpm/tpm_infineon.c
+++ b/drivers/char/tpm/tpm_infineon.c
@@ -30,10 +30,10 @@
30#define TPM_INFINEON_DEV_VEN_VALUE 0x15D1 30#define TPM_INFINEON_DEV_VEN_VALUE 0x15D1
31 31
32/* These values will be filled after PnP-call */ 32/* These values will be filled after PnP-call */
33static int TPM_INF_DATA = 0; 33static int TPM_INF_DATA;
34static int TPM_INF_ADDR = 0; 34static int TPM_INF_ADDR;
35static int TPM_INF_BASE = 0; 35static int TPM_INF_BASE;
36static int TPM_INF_PORT_LEN = 0; 36static int TPM_INF_PORT_LEN;
37 37
38/* TPM header definitions */ 38/* TPM header definitions */
39enum infineon_tpm_header { 39enum infineon_tpm_header {