Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 3060
b: refs/heads/master
c: 5b44bd5
h: refs/heads/master
v: v3
  • Loading branch information
Kylene Hall authored and Linus Torvalds committed Jun 24, 2005
1 parent 4cdc120 commit 20f2f42
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f87ea32ae2a986acc5258ad736ab0b55937c9489
refs/heads/master: 5b44bd58063f7839f42a4047843e93e1fbf73cda
30 changes: 10 additions & 20 deletions trunk/drivers/char/tpm/tpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 20f2f42

Please sign in to comment.