linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ingo Rohloff <ingo.rohloff@lauterbach.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, linux-hotplug@vger.kernel.org
Subject: Re: [PATCH] USB: usbfs: Suppress emission of uevents for interfaces handled via usbfs
Date: Thu, 10 Oct 2019 12:53:08 +0000	[thread overview]
Message-ID: <20191010130913.5af35519@ingpc3.intern.lauterbach.com> (raw)
In-Reply-To: <20191010102411.GA541845@kroah.com>

Hello Greg

> > +	else {
> > +		/* suppress uevents for devices handled by usbfs */
> > +		dev_set_uevent_suppress(&intf->dev, 1);
> >  		err = usb_driver_claim_interface(&usbfs_driver, intf, ps);
> > +		if (err != 0)  
> > +			dev_set_uevent_suppress(&intf->dev, 0);

> Did checkpatch let this go through?  Shouldn't that be:
> 		if (err)

I actually wanted it the way it is, but it really might not be the best option.
Let me explain:
The main goal was to suppress bind/unbind uevents produced by libusb
or any other user space program which calls
ioctl USBDEVFS_CLAIMINTERFACE/USBDEVFS_RELEASEINTERFACE .

Now I can suppress uevents produced by usb_driver_claim_interface
with the code above.
But I was not sure how to handle the call to usb_driver_release_interface 
from devio.c/releaseintf()

The strategy I used was: 
1) Set suppression of uevents when user space program tries to claim interface
2) If claiming the interface works, then KEEP uevents suppressed,
   otherwise undo suppression.
   That's why its "if err !=0"; error happened => undo suppression.
3) When interface is released make sure suppression is undone AFTER unbinding the driver.

Thinking about your comment: It might be better + simpler to just use
1) Suppress uevents when calling usb_driver_claim_interface. Undo suppression right after the call.
2) Suppress uevents when calling usb_driver_release_interface. Undo suppression right after the call.

The main semantic problem I do not know about: 
Is it correct to modify uevent suppression of an USB interface device 
even if it CANNOT be claimed by usbfs ?
I grepped the source code for usage of dev_set_uevent_suppress, but it seems not to be 100%
clear how that should be used (sometimes uevents are only suppressed temporarily to implement
a delay, sometimes they are actually kept suppressed).

I will prepare/send an alternative.

with best regards
  Ingo

PS:
> ...
> No need for this in the changelog body :)

I should have read the documentation about how to send correct E-Mails for patches more intensively.
I just found out about "git send-email" and had not set it up (did now...). I am sorry.

> And did you send this patch twice?

Unfortunately yes: I was struggling how to format this correctly.

      reply	other threads:[~2019-10-10 12:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-09  9:21 [PATCH] USB: usbfs: Suppress emission of uevents for interfaces handled via usbfs Ingo Rohloff
2019-10-09 10:38 ` Ingo Rohloff
2019-10-10 10:24   ` Greg KH
2019-10-10 12:53     ` Ingo Rohloff [this message]

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=20191010130913.5af35519@ingpc3.intern.lauterbach.com \
    --to=ingo.rohloff@lauterbach.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-hotplug@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).