Can I reboot a USB device within a driver's probe function?

Greg KH gregkh at linuxfoundation.org
Mon Sep 14 04:17:50 EDT 2020


On Mon, Sep 14, 2020 at 10:03:49AM +0200, Thierry Seegers wrote:
> Hi, thanks for the reply.
> 
> > > One can even have this script executed automatically through a
> > > ".rules" file. So far so good. My question is: can I write a driver
> > > that will perform the same thing?
> >
> > Yes, but why?  We pushed most of this logic out to userspace as it is
> > easier to handle there.  Why do you want a kernel driver for this?
> 
> Here's my (perhaps incorrect thought) as to why doing this in a driver would
> be desirable. In the case of the Python script executed through a .rules file,
> the script can't know which device this is in response to.

Then you need to fix your script, as it can be determined from the
environment variables that are passed to it by udev.  Otherwise udev and
scripts that trigger off of device discovery would not work very well :)

> Contrast with a driver where if two devices are connected at the same time, two
> separate instances of the driver code would be executed for each
> specific device.

Same for userspace scripts.

good luck!

greg k-h



More information about the Kernelnewbies mailing list