diff options
author | Kylene Hall <kjhall@us.ibm.com> | 2005-06-24 01:01:53 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-24 03:05:25 -0400 |
commit | 5b44bd58063f7839f42a4047843e93e1fbf73cda (patch) | |
tree | 4973ce84fd225eec4333507f62192e3a5b8b4edd /drivers/char/tpm/tpm.c | |
parent | f87ea32ae2a986acc5258ad736ab0b55937c9489 (diff) |
[PATCH] tpm: read return code issue
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>
Diffstat (limited to 'drivers/char/tpm/tpm.c')
-rw-r--r-- | drivers/char/tpm/tpm.c | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c index ff170963c641..7b1f67d9f301 100644 --- a/drivers/char/tpm/tpm.c +++ b/drivers/char/tpm/tpm.c | |||
@@ -489,29 +489,19 @@ ssize_t tpm_read(struct file * file, char __user * buf, | |||
489 | size_t size, loff_t * off) | 489 | size_t size, loff_t * off) |
490 | { | 490 | { |
491 | struct tpm_chip *chip = file->private_data; | 491 | struct tpm_chip *chip = file->private_data; |
492 | int ret_size = -ENODATA; | 492 | int ret_size; |
493 | 493 | ||
494 | if (atomic_read(&chip->data_pending) != 0) { /* Result available */ | 494 | del_singleshot_timer_sync(&chip->user_read_timer); |
495 | down(&chip->timer_manipulation_mutex); | 495 | ret_size = atomic_read(&chip->data_pending); |
496 | del_singleshot_timer_sync(&chip->user_read_timer); | 496 | atomic_set(&chip->data_pending, 0); |
497 | up(&chip->timer_manipulation_mutex); | 497 | if (ret_size > 0) { /* relay data */ |
498 | if (size < ret_size) | ||
499 | ret_size = size; | ||
498 | 500 | ||
499 | down(&chip->buffer_mutex); | 501 | down(&chip->buffer_mutex); |
500 | 502 | if (copy_to_user | |
501 | ret_size = atomic_read(&chip->data_pending); | 503 | ((void __user *) buf, chip->data_buffer, ret_size)) |
502 | atomic_set(&chip->data_pending, 0); | 504 | ret_size = -EFAULT; |
503 | |||
504 | if (ret_size == 0) /* timeout just occurred */ | ||
505 | ret_size = -ETIME; | ||
506 | else if (ret_size > 0) { /* relay data */ | ||
507 | if (size < ret_size) | ||
508 | ret_size = size; | ||
509 | |||
510 | if (copy_to_user((void __user *) buf, | ||
511 | chip->data_buffer, ret_size)) { | ||
512 | ret_size = -EFAULT; | ||
513 | } | ||
514 | } | ||
515 | up(&chip->buffer_mutex); | 505 | up(&chip->buffer_mutex); |
516 | } | 506 | } |
517 | 507 | ||