[PATCH] tpm: read return code issue
authorKylene Hall <kjhall@us.ibm.com>
Fri, 24 Jun 2005 05:01:53 +0000 (22:01 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Fri, 24 Jun 2005 07:05:25 +0000 (00:05 -0700)
Replace an erroneous return code for the read function when no data is
available.

Signed-of-by: Kylene Hall <kjhall@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/char/tpm/tpm.c

index ff170963c641214a6fccf4803d092eb242ef987d..7b1f67d9f301839835502964b8ba4793397613eb 100644 (file)
@@ -489,29 +489,19 @@ ssize_t tpm_read(struct file * file, char __user * buf,
                 size_t size, loff_t * off)
 {
        struct tpm_chip *chip = file->private_data;
-       int ret_size = -ENODATA;
+       int ret_size;
 
-       if (atomic_read(&chip->data_pending) != 0) {    /* Result available */
-               down(&chip->timer_manipulation_mutex);
-               del_singleshot_timer_sync(&chip->user_read_timer);
-               up(&chip->timer_manipulation_mutex);
+       del_singleshot_timer_sync(&chip->user_read_timer);
+       ret_size = atomic_read(&chip->data_pending);
+       atomic_set(&chip->data_pending, 0);
+       if (ret_size > 0) {     /* relay data */
+               if (size < ret_size)
+                       ret_size = size;
 
                down(&chip->buffer_mutex);
-
-               ret_size = atomic_read(&chip->data_pending);
-               atomic_set(&chip->data_pending, 0);
-
-               if (ret_size == 0)      /* timeout just occurred */
-                       ret_size = -ETIME;
-               else if (ret_size > 0) {        /* relay data */
-                       if (size < ret_size)
-                               ret_size = size;
-
-                       if (copy_to_user((void __user *) buf,
-                                        chip->data_buffer, ret_size)) {
-                               ret_size = -EFAULT;
-                       }
-               }
+               if (copy_to_user
+                   ((void __user *) buf, chip->data_buffer, ret_size))
+                       ret_size = -EFAULT;
                up(&chip->buffer_mutex);
        }