On Thu, 10 Mar 2005 09:35:36 -0800, Nish Aravamudan
<[EMAIL PROTECTED]> wrote:
> On Wed, 9 Mar 2005 16:42:01 -0800, Greg KH <[EMAIL PROTECTED]> wrote:
> > ChangeSet 1.2035, 2005/03/09 10:12:19-08:00, [EMAIL PROTECTED]
> >
> > [PATCH] Add TPM hardware enablement driver
> 
> <snip>
> 
> > +void tpm_time_expired(unsigned long ptr)
> > +{
> > +       int *exp = (int *) ptr;
> > +       *exp = 1;
> > +}
> > +
> > +EXPORT_SYMBOL_GPL(tpm_time_expired);
> 
> <snip>
> 
> > +       down(&chip->timer_manipulation_mutex);
> > +       chip->time_expired = 0;
> > +       init_timer(&chip->device_timer);
> > +       chip->device_timer.function = tpm_time_expired;
> > +       chip->device_timer.expires = jiffies + 2 * 60 * HZ;
> > +       chip->device_timer.data = (unsigned long) &chip->time_expired;
> > +       add_timer(&chip->device_timer);
> > +       up(&chip->timer_manipulation_mutex);
> > +
> > +       do {
> > +               u8 status = inb(chip->vendor->base + 1);
> > +               if ((status & chip->vendor->req_complete_mask) ==
> > +                   chip->vendor->req_complete_val) {
> > +                       down(&chip->timer_manipulation_mutex);
> > +                       del_singleshot_timer_sync(&chip->device_timer);
> > +                       up(&chip->timer_manipulation_mutex);
> > +                       goto out_recv;
> > +               }
> > +               set_current_state(TASK_UNINTERRUPTIBLE);
> > +               schedule_timeout(TPM_TIMEOUT);
> > +               rmb();
> > +       } while (!chip->time_expired);
> 
> <snip>
> 
> It seems like this use of schedule_timeout() and the others are a bit
> excessive. In this case, a timer is set to go off in 2 hours or so,
> with tpm_time_expired() as the callback. tpm_time_expired(), it seems
> just takes data and sets it to 1, which in this case is
> chip->time_expired (and is similar in the other cases). We then loop
> while (!chip->time_expired), which to me means until
> chip->device_timer goes off, checking if the request is complete every
> 5 milliseconds. The chip->device_timer doesn't really do anything,
> does it? It just guarantees a maximum time (of 2 hours). Couldn't the

Sorry for the slight exaggeration :) Not 2 hours, but 2 minutes :)
still, a long time.

-Nish
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to