From: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
To: Krzysztof Opasiak <k.opasiak-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
Cc: "Amit Pundir"
<amit.pundir-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
"Mike Lockwood"
<lockwood-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>,
"Benoit Goby" <benoit-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>,
"Colin Cross" <ccross-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>,
"Arve Hjønnevåg" <arve-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>,
"Peter Oh" <poh-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>,
"Greg Hackmann"
<ghackmann-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
"Badhri Jagan Sridharan"
<Badhri-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
"Android Kernel Team"
<kernel-team-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>,
"Greg Kroah-Hartman"
<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
"Jonathan Corbet" <corbet-T1hC0tSOHrs@public.gmane.org>,
"Felipe Balbi" <balbi-l0cyMroinI0@public.gmane.org>,
"Andrzej Pietrasiewicz"
<andrzej.p-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
"Laurent Pinchart"
<laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>,
"Yegor Yefremov"
<yegorslists-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>,
"Philippe Reynes"
<tremyfr-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
"John Stultz"
<john.stultz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
"Sumit Semwal"
<sumit.semwal-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Subject: Re: [RFC][PATCH 2/2] usb: gadget: configfs: notify userspace of usb state changes
Date: Thu, 13 Aug 2015 17:07:42 -0500 [thread overview]
Message-ID: <20150813220742.GA25159@saruman.tx.rr.com> (raw)
In-Reply-To: <55CCF319.1070604-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 4624 bytes --]
Hi,
On Thu, Aug 13, 2015 at 09:42:17PM +0200, Krzysztof Opasiak wrote:
> Hello,
>
> On 08/13/2015 09:12 PM, Amit Pundir wrote:
> >This is more of an RFC than an actual submission. There are few
> >scattered #ifdefs..#endifs here and there which still need to be
> >taken care of before going for actual submission.
> >
> >Currently there is no way with the upstream ConfigFS gadget to
> >communicate state changes (connected, disconnected, configured), at
> >the gadget level. Instead such state changes are handled function by
> >function independently I presume. This is problematic, because some
> >coordination between the functions, across the state changes, may be
> >desired at the userspace level. Thus to address this issue, this
> >patch send uevents to allow userspace to be notified of these usb
> >state changes, allowing userspace to respond and configure the
> >configfs gadget appropriately.
> >
> >This patch is based on an Android patchset originaly authored by
> >Badhri Jagan Sridharan<Badhri-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org> to send uevent notifications
> >to Android userpace for USB state changes. I've folded his patches
> >together and modified it enough that I don't want him to be blamed for
> >any mistakes I've made condensing his patches down.
> >
> >This patch introduces USB_CONFIGFS_UEVENT Kconfig to handle userspace
> >notifications of usb state changes, and add setup and disconnect
> >functions to intercept the setup requests from the usb_core. It also
> >creates a sysfs device class entry and a device attribute (state) to
> >read and respond to gadget's current state from userspace. As of now
> >this sysfs device class (/sys/class/android_usb) and gadget device
> >(/sys/class/android_usb/android0) with state attribute
> >(/sys/class/android_usb/android0/state) are strictly tied up to
> >facilitate Android userspace requests. But going forward we may want
> >to bring all function devices (hid, printer etc) under a unified usb
> >gadget device class e.g. /sys/class/usb_gadget/g_{func0,func1} etc..
> >
> >Also I think it make sense to add this state attribute to the configfs
> >usb gadget itself i.e. have something like /config/usb_gadget/g1/state
> >to read USB gadget's current state. Since it is going to be consistent
> >throughout all the functions tied up to that gadget.
> >
> >Again this is just an initial RFC, thoughts and feedback would be
> >greatly appreciated.
> >
> >Cc: Mike Lockwood<lockwood-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>
> >Cc: Benoit Goby<benoit-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>
> >Cc: Colin Cross<ccross-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>
> >Cc: Arve Hjønnevåg<arve-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>
> >Cc: Peter Oh<poh-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
> >Cc: Greg Hackmann<ghackmann-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
> >Cc: Badhri Jagan Sridharan<Badhri-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
> >Cc: Android Kernel Team<kernel-team-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>
> >Cc: Greg Kroah-Hartman<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>
> >Cc: Jonathan Corbet<corbet-T1hC0tSOHrs@public.gmane.org>
> >Cc: Felipe Balbi<balbi-l0cyMroinI0@public.gmane.org>
> >Cc: Andrzej Pietrasiewicz<andrzej.p-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
> >Cc: Laurent Pinchart<laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
> >Cc: Yegor Yefremov<yegorslists-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
> >Cc: Philippe Reynes<tremyfr-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> >Cc: John Stultz<john.stultz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> >Cc: Sumit Semwal<sumit.semwal-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> >Signed-off-by: Amit Pundir<amit.pundir-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>
> Generally I agree that there should be some way of notifying userspace about
yes, and we already have a sysfs file for that. See udc-core.c:
static void usb_gadget_state_work(struct work_struct *work)
{
struct usb_gadget *gadget = work_to_gadget(work);
struct usb_udc *udc = gadget->udc;
if (udc)
sysfs_notify(&udc->dev.kobj, NULL, "state");
}
void usb_gadget_set_state(struct usb_gadget *gadget,
enum usb_device_state state)
{
gadget->state = state;
schedule_work(&gadget->work);
}
EXPORT_SYMBOL_GPL(usb_gadget_set_state);
If it's not working for any UDC, it just means the UDC needs to be
patched and if we're missing any state, it means that either the UDC
can't provide that IRQ, or we need to add more states to that
enumeration (which I find unlikely).
--
balbi
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
prev parent reply other threads:[~2015-08-13 22:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-13 19:12 [RFC][PATCH 0/2] usb: gadget: add MTP function and Uevent userspace notifications Amit Pundir
2015-08-13 19:12 ` [RFC][PATCH 1/2] usb: gadget: configfs: add MTP function Amit Pundir
[not found] ` <1439493140-22207-2-git-send-email-amit.pundir-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-08-13 19:34 ` Krzysztof Opasiak
2015-08-13 19:57 ` Greg Kroah-Hartman
[not found] ` <20150813195748.GB30092-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2015-08-13 20:23 ` Krzysztof Opasiak
2015-08-13 20:41 ` Krzysztof Opasiak
[not found] ` <55CD0108.4060303-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-08-14 9:53 ` Amit Pundir
2015-08-13 19:12 ` [RFC][PATCH 2/2] usb: gadget: configfs: notify userspace of usb state changes Amit Pundir
2015-08-13 19:42 ` Krzysztof Opasiak
[not found] ` <55CCF319.1070604-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-08-13 22:07 ` Felipe Balbi [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=20150813220742.GA25159@saruman.tx.rr.com \
--to=balbi-l0cymroini0@public.gmane.org \
--cc=Badhri-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
--cc=amit.pundir-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=andrzej.p-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
--cc=arve-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org \
--cc=benoit-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org \
--cc=ccross-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org \
--cc=corbet-T1hC0tSOHrs@public.gmane.org \
--cc=ghackmann-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=john.stultz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=k.opasiak-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
--cc=kernel-team-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org \
--cc=laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org \
--cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=lockwood-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org \
--cc=poh-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
--cc=sumit.semwal-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=tremyfr-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=yegorslists-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.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 NNTP newsgroup(s).