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.5 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 7C814C433ED for ; Fri, 16 Apr 2021 06:50:30 +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 D877D61006 for ; Fri, 16 Apr 2021 06:50:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D877D61006 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kroah.com 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 1lXIIs-00024d-TC; Fri, 16 Apr 2021 02:50:10 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1lXIIq-00024W-Ez for kernelnewbies@kernelnewbies.org; Fri, 16 Apr 2021 02:50:08 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 8EAEB5C0143; Fri, 16 Apr 2021 02:50:05 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Fri, 16 Apr 2021 02:50:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kroah.com; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=6B5xeip8hzilgni1zM0P1Iprrx9 pRHd2i3+ttvKNjX0=; b=oE3VspWFM6x9gUZ4I14W3P+/rERzlyTPZAITyizjvGj A+zuBxxymQ5vljtYvCfCVA3CYsRNmrBsd8jrmtc5iNZIlFZ0LUoYMEbgMKAXCXQH ZNNfgzW9j55ot9jDERWob7QoGD4RtL8kvm721dUYnNzVZ9QvMkLIoHyaU1yxUHwF tJ1R+NrmGg3lTVbMUOPbvWjNM1D5WmT6IeqCcjX8Tg1ln4QST8WVUWTSPhmo49SA A/hvkKfHKVuj0x8krPew8umZgdmHFWEXLdjUxj1LuQK0A/ylfBhw2hBQs2DYlXYJ V/wt/UVcZW5xmdmq22qaOqToIbFbWSaKR+yDYIJQmpg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=6B5xei p8hzilgni1zM0P1Iprrx9pRHd2i3+ttvKNjX0=; b=T4xuuLmmPwN++5g63IBawN X4WDlwVNojvj4ciY0TCv4mhoAOVYTpxCbPHnbrs/vUJRXW9EYqdeRZVegRPpCspX L/clbtWT5uMshbf8SwoVQ1BdcRnzIYeSiM4uUF5bRoSKjX88CUTe4MVxbv2NWY56 JyjpHj5QXE8nvd5S0aDjBrA50lwZiDXit1LGPtwTwvW3KY+1yGrJ7UGnqXtnSDhn vqClkDPNukQWE9TYHvPBaiyt2SP5pDmF0iZ+IQLLthAegskAy+btgFamxabVKkMr B7mFq6E4MQhAlBYjjSWO8Acw9gVrfzO34K39e71jgf7YC4INmLV3o0dy8PQ5Hchw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudelgedgudduhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepifhrvghg ucfmjfcuoehgrhgvgheskhhrohgrhhdrtghomheqnecuggftrfgrthhtvghrnhepveeuhe ejgfffgfeivddukedvkedtleelleeghfeljeeiueeggeevueduudekvdetnecukfhppeek fedrkeeirdejgedrieegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhepghhrvghgsehkrhhorghhrdgtohhm X-ME-Proxy: Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) by mail.messagingengine.com (Postfix) with ESMTPA id EF1A124006A; Fri, 16 Apr 2021 02:50:04 -0400 (EDT) Date: Fri, 16 Apr 2021 08:50:02 +0200 From: Greg KH To: Mark Bolhuis Subject: Re: HID Monitor Driver Advice Message-ID: References: <43f7b6ac-0fa9-7e36-6d8c-f0fc54d4566d@gmail.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 Thu, Apr 15, 2021 at 08:27:58PM +0100, Mark Bolhuis wrote: > On 15/04/2021 16:44, Greg KH wrote: > > Why do you need a kernel driver at all? Why not just use the userspace > > hid access and control stuff that way from an application? > > > If you write your own driver, you can do that from within the driver I > > think. But again, what's wrong with userspace? > > > > thanks, > > > > greg k-h > > A couple reasons. These might be misplaced since I'm very new to kernel > programming. > > I would like to create very simple user space scripts and programs on top of > it. I'd like to change settings with nothing more than an `echo 200 > > brightness`. Something has to keep track of an internal state, which I'd > rather not happen in userspace apps, so I decided on a driver. That's nice, but creating random user/kernel apis for a single device like this is generally not a good idea. Also we do not like to have kernel drivers for things that can be done in userspace. Single-use drivers like this that can be done in userspace, should be done in userspace. We have lots of ways to write userspace USB drivers, look at the uhid stuff, and also there is libusb to do this on all operating systems. > I'd like to eventually use linux/backlight.h to control brightness which, > correct me if I'm wrong, has to be used from a kernel driver. Or is this an > unsuitable use case? If you want to tie it into the backlight api, then yes, a kernel driver is the way to go, as that is what drivers are for (to provide a unified user/kernel api). But if you want to do other things like it sounds like you do beyond just backlight interfaces, then you might want to just do it all in userspace. good luck! greg k-h _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies