aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/tpm
diff options
context:
space:
mode:
authorRajiv Andrade <srajiv@linux.vnet.ibm.com>2008-10-10 18:04:02 -0400
committerJames Morris <jmorris@namei.org>2008-10-10 18:04:02 -0400
commitdc36d32cc5bea5e985294c79995e10a159c3019a (patch)
tree0eb2fb1c0127cab4275a70ef1b22fc3f22fe716a /drivers/char/tpm
parentf89c5edb86abfac4c914f4eb808b07684164eca0 (diff)
Renames num_open to is_open, as only one process can open the file at a time.
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com> Signed-off-by: Rajiv Andrade <srajiv@linux.vnet.ibm.com> Cc: "Serge E. Hallyn" <serue@us.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'drivers/char/tpm')
-rw-r--r--drivers/char/tpm/tpm.c7
-rw-r--r--drivers/char/tpm/tpm.h2
2 files changed, 4 insertions, 5 deletions
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index ceba6082bd96..dfd4e7fc350b 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -978,20 +978,19 @@ int tpm_open(struct inode *inode, struct file *file)
978 goto err_out; 978 goto err_out;
979 } 979 }
980 980
981 if (chip->num_opens) { 981 if (test_and_set_bit(0, &chip->is_open)) {
982 dev_dbg(chip->dev, "Another process owns this TPM\n"); 982 dev_dbg(chip->dev, "Another process owns this TPM\n");
983 rc = -EBUSY; 983 rc = -EBUSY;
984 goto err_out; 984 goto err_out;
985 } 985 }
986 986
987 chip->num_opens++;
988 get_device(chip->dev); 987 get_device(chip->dev);
989 988
990 spin_unlock(&driver_lock); 989 spin_unlock(&driver_lock);
991 990
992 chip->data_buffer = kmalloc(TPM_BUFSIZE * sizeof(u8), GFP_KERNEL); 991 chip->data_buffer = kmalloc(TPM_BUFSIZE * sizeof(u8), GFP_KERNEL);
993 if (chip->data_buffer == NULL) { 992 if (chip->data_buffer == NULL) {
994 chip->num_opens--; 993 clear_bit(0, &chip->is_open);
995 put_device(chip->dev); 994 put_device(chip->dev);
996 return -ENOMEM; 995 return -ENOMEM;
997 } 996 }
@@ -1016,7 +1015,7 @@ int tpm_release(struct inode *inode, struct file *file)
1016 file->private_data = NULL; 1015 file->private_data = NULL;
1017 del_singleshot_timer_sync(&chip->user_read_timer); 1016 del_singleshot_timer_sync(&chip->user_read_timer);
1018 atomic_set(&chip->data_pending, 0); 1017 atomic_set(&chip->data_pending, 0);
1019 chip->num_opens--; 1018 clear_bit(0, &chip->is_open);
1020 put_device(chip->dev); 1019 put_device(chip->dev);
1021 kfree(chip->data_buffer); 1020 kfree(chip->data_buffer);
1022 spin_unlock(&driver_lock); 1021 spin_unlock(&driver_lock);
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index e885148b4cfb..2756cab9aee3 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -90,7 +90,7 @@ struct tpm_chip {
90 struct device *dev; /* Device stuff */ 90 struct device *dev; /* Device stuff */
91 91
92 int dev_num; /* /dev/tpm# */ 92 int dev_num; /* /dev/tpm# */
93 int num_opens; /* only one allowed */ 93 unsigned long is_open; /* only one allowed */
94 int time_expired; 94 int time_expired;
95 95
96 /* Data passed to and from the tpm via the read/write calls */ 96 /* Data passed to and from the tpm via the read/write calls */