summaryrefslogtreecommitdiffstats
path: root/drivers/char/tpm/tpm.c
diff options
context:
space:
mode:
authorRajiv Andrade <srajiv@linux.vnet.ibm.com>2008-10-11 09:04:02 +1100
committerJames Morris <jmorris@namei.org>2008-10-11 09:04:02 +1100
commitdc36d32cc5bea5e985294c79995e10a159c3019a (patch)
tree0eb2fb1c0127cab4275a70ef1b22fc3f22fe716a /drivers/char/tpm/tpm.c
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/tpm.c')
-rw-r--r--drivers/char/tpm/tpm.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index ceba6082bd9..dfd4e7fc350 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)
goto err_out;
}
- if (chip->num_opens) {
+ if (test_and_set_bit(0, &chip->is_open)) {
dev_dbg(chip->dev, "Another process owns this TPM\n");
rc = -EBUSY;
goto err_out;
}
- chip->num_opens++;
get_device(chip->dev);
spin_unlock(&driver_lock);
chip->data_buffer = kmalloc(TPM_BUFSIZE * sizeof(u8), GFP_KERNEL);
if (chip->data_buffer == NULL) {
- chip->num_opens--;
+ clear_bit(0, &chip->is_open);
put_device(chip->dev);
return -ENOMEM;
}
@@ -1016,7 +1015,7 @@ int tpm_release(struct inode *inode, struct file *file)
file->private_data = NULL;
del_singleshot_timer_sync(&chip->user_read_timer);
atomic_set(&chip->data_pending, 0);
- chip->num_opens--;
+ clear_bit(0, &chip->is_open);
put_device(chip->dev);
kfree(chip->data_buffer);
spin_unlock(&driver_lock);