On Tue, Jan 22, 2008 at 09:34:56AM +0100, 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 believe everything is fine because active_duration, connected_duration, and jiffies are all unsigned longs. There are other drivers in the kernel that compute durations with unsigned longs, like drivers/md/dm.c. It's just unsigned math, right? I tested the statistics with devices that were connected before jiffies wrapped (five minutes after I booted the system). The statistics looked correct while testing with various scenarios like suspending after jiffies wrapped, or suspending and then resuming a device before jiffies wrapped and suspending the device after it wrapped. The user does have to watch out for devices that are connected and always active, since at some point active_duration will wrap and it will seem like the device has been active longer than it was connected. But I think Arjan can work around this in PowerTOP. Sarah Sharp - 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