It's not that complex. All we're really talking about is a bit of extraIf your device requires power management, and you know it requires powerLike it or not, power management is far from trivial, and people
management, why not just implement power management? [...]
writing device drivers have limited resources. [...]
code to cleanup and configure hardware state; things that the driver
author already knows how to do. S3 might require a bit more
initialisation if firmware needs to be reloaded or more extensive
configuration needs to be done, but if there's firmware to be loaded,
there is a reasonably good probability that we loaded it from Linux to
start with anyway.
You are assuming a perfect world where driver authors have complete
knowledge of their devices. In reality, many drivers (including
those I have the mixed pleasure of maintaining) are based at least
in part on reverse engineering, and managing power states may well
fall into the domain of things not yet sufficiently reverse
engineered.
Also, in your argument you neglected a few cases:Then you as a generic routine that does nothing but return success
- What if my device does not require power management?
(potentially shared with other drivers that are in the same situation).
But if I just write an empty routine like that I open myself up to
criticism along the lines of "writing dummy routines just in order
to shut up kernel warnings". BTDT.
- What if I don't know whether my device requires power management?The questions are straight forward: Is there hardware state that needs
to be configured if you've just booted the computer and nothing else has
touched it? If so, that needs to be done in a resume method. Do you need
to clean up state prior to doing the things in the resume method, or
otherwise do things to quiesce the driver? If so, they will need to be
done in the suspend method. The result will be roughly similar to what
you do for module load/unload, except maybe less complete in some cases.
I don't doubt your basic assessment. However it doesn't translate that
easily into a real implementation. In my case, I maintain a USB driver,
so I have to deal with USB specifics of suspend/resume which happen not
to be that well documented. My driver provides an isdn4linux device but
isdn4linux knows nothing about suspend/resume so I am on my own on how
to reconcile the two. The device itself, though in turn far from trivial,
is actually the least of my worries.