kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Mark Bolhuis <mark@bolhuis.dev>
Cc: kernelnewbies@kernelnewbies.org
Subject: Re: HID Monitor Driver Advice
Date: Fri, 16 Apr 2021 08:50:02 +0200	[thread overview]
Message-ID: <YHkzmuWBLoQx8pzm@kroah.com> (raw)
In-Reply-To: <ba9b5a33-c92b-3a55-8bb9-11ecb117c3bf@bolhuis.dev>

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

  reply	other threads:[~2021-04-16  6:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-15 15:35 HID Monitor Driver Advice mark
2021-04-15 15:44 ` Greg KH
2021-04-15 19:27   ` Mark Bolhuis
2021-04-16  6:50     ` Greg KH [this message]
2021-04-16  7:46       ` Mark Bolhuis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YHkzmuWBLoQx8pzm@kroah.com \
    --to=greg@kroah.com \
    --cc=kernelnewbies@kernelnewbies.org \
    --cc=mark@bolhuis.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).