On Tue, Jan 22, 2008 at 10:21:34AM -0500, Alan Stern wrote:
> On Tue, 22 Jan 2008, Oliver Neukum wrote:
>
> > Am Montag, 21. Januar 2008 22:43:25 schrieb Sarah Sharp:
> > > + dev->connect_time = jiffies;
> > > + dev->active_duration = -jiffies;
> > > #endif
> > > if (root_hub) /* Root hub always ok [and always wired] */
> > > dev->authorized = 1;
> > > diff --git a/include/linux/usb.h b/include/linux/usb.h
> > > index 5fc8ff7..b031455 100644
> > > --- a/include/linux/usb.h
> > > +++ b/include/linux/usb.h
> > > @@ -419,12 +419,15 @@ struct usb_device {
> > > u32 quirks; /* quirks of the whole device */
> > > atomic_t urbnum; /* number of URBs submitted for
> > > the whole device */
> > >
> > > + unsigned long active_duration; /* total time device is not
> > > suspended */
> > > +
> >
> > Somehow assigning -jiffies to an unsigned variable doesn't appeal to me.
>
> I agree. In fact, reading through the patch I got the distinct
> impression that the value stored in active_duration was the negative of
> the value I would have used. Thus, I would have called the field
> something like active_start_or_duration. The idea is that while the
> device is active it stores an effective start time, and while the
> device is suspended it stores a duration.
>
> If the device is active then the total active duration is calculated as
>
> jiffies - udev->active_start_or_duration
>
> If the device is suspended then the total active duration
> is simply
>
> udev->active_start_or_duration
>
> When suspending or resuming the device you set
>
> udev->active_start_or_duration = jiffies -
> udev->active_start_or_duration;
>
> which converts between an effective start time and a duration.
>
> This may not be quite as clean as your approach, but IMO it is more
> easily understandable.
Yes, I believe that is a correct approach. However, I still had to draw myself
a diagram and do some simple algebra to convince myself that it was correct. So
I don't think your approach is easier to understand, we just think differently.
:)
Sarah
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html