]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Renames num_open to is_open, as only one process can open the file at a time.
authorRajiv Andrade <srajiv@linux.vnet.ibm.com>
Fri, 10 Oct 2008 22:04:02 +0000 (09:04 +1100)
committerJames Morris <jmorris@namei.org>
Fri, 10 Oct 2008 22:04:02 +0000 (09:04 +1100)
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>
drivers/char/tpm/tpm.c
drivers/char/tpm/tpm.h

index ceba6082bd968373c0bb926b26c7eae7a99443a1..dfd4e7fc350bf4a16dd5751aca37b90cc483f8d2 100644 (file)
@@ -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);
index e885148b4cfbd0b177f77b87e6e629511db16983..2756cab9aee3e06ca1b79090767e28985a4e2a50 100644 (file)
@@ -90,7 +90,7 @@ struct tpm_chip {
        struct device *dev;     /* Device stuff */
 
        int dev_num;            /* /dev/tpm# */
-       int num_opens;          /* only one allowed */
+       unsigned long is_open;  /* only one allowed */
        int time_expired;
 
        /* Data passed to and from the tpm via the read/write calls */