From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2B5FC433E2 for ; Mon, 14 Sep 2020 08:18:10 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EE88020EDD for ; Mon, 14 Sep 2020 08:18:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="D/XiB/8c" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EE88020EDD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94) (envelope-from ) id 1kHjgR-0000VS-5x; Mon, 14 Sep 2020 04:17:55 -0400 Received: from mail.kernel.org ([198.145.29.99]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1kHjgP-0000VL-DW for kernelnewbies@kernelnewbies.org; Mon, 14 Sep 2020 04:17:53 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EB0B520EDD; Mon, 14 Sep 2020 08:17:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600071471; bh=IEoidotSBhoOthMA7GmKZNh+qns3xNGJrcGnxqhSHBM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=D/XiB/8cShzzkc88Kx6A1sDvOHtjrjI3g3BrxNgdRTCytoeDljWq8PhipgxrfQYdd JLSABPrf674zGSbPOkDtXdXdQENXV7yBrGHQ2oWCWCR3l4Upj7NfZHlqJNm0OI5XJw NZ7KzUktt7NHCGyOe+bVN/sNwG6RkyW8J74/6Kjw= Date: Mon, 14 Sep 2020 10:17:50 +0200 From: Greg KH To: Thierry Seegers Subject: Re: Can I reboot a USB device within a driver's probe function? Message-ID: <20200914081750.GA1832024@kroah.com> References: <20200914052602.GA782969@kroah.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Cc: kernelnewbies@kernelnewbies.org X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org 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 _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies