From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Michael Nazzareno Trimarchi <michael@amarulasolutions.com>
Cc: Felipe Balbi <balbi@kernel.org>, USB list <linux-usb@vger.kernel.org>
Subject: Re: f_hid GET_REPORT extension
Date: Mon, 27 Jun 2022 13:44:48 +0200 [thread overview]
Message-ID: <YrmYMO+u4EqSjTZ8@kroah.com> (raw)
In-Reply-To: <CAOf5uw=X=y7BZZpdW-89orU=aL5oc01b19q7CvvQpXfOjm+m3Q@mail.gmail.com>
On Mon, Jun 27, 2022 at 10:02:27AM +0200, Michael Nazzareno Trimarchi wrote:
> Hi Greg
>
> On Mon, Jun 27, 2022 at 9:21 AM Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> >
> > On Mon, Jun 27, 2022 at 09:06:05AM +0200, Michael Nazzareno Trimarchi wrote:
> > > Hi Felipe and Greg
> > >
> > > I'm starting to write some code to extend the GET_REPORT and let the
> > > userspace on the device side to pre-fill the answer on this request.
> > > Right now the answer is always 0. The idea is to create a sysfs
> > > support to fill reports struct on report request on the host side.
> > > This will help to
> > > emulate devices that export features report for example. As far as I
> > > understand the hidg side just use read and write and read is used to
> > > extract
> > > the result of SET_REPORT is that the gadget is properly configured. Is
> > > it the right direction?
> >
> > Without code, it is very hard to understand what you are doing here,
> > sorry.
> >
>
> Agree, I need only a suggestion what is the best way to expose it
>
> > Also, why sysfs?
>
> Let me clarify this point. Right now the userspace manage the set_report
>
> static ssize_t f_hidg_read(struct file *file, char __user *buffer,
> size_t count, loff_t *ptr)
> {
> struct f_hidg *hidg = file->private_data;
>
> if (hidg->use_out_ep)
> return f_hidg_intout_read(file, buffer, count, ptr);
> else
> return f_hidg_ssreport_read(file, buffer, count, ptr);
> }
>
> The report can be write from usb side and read on gadget side if use_out_ep
> is 0 (this is a configuration). Now, the answer to set_report is done
> sync on request
> and the usb message is buffered on the kernel side. During the
> get_report as far I understand we should reply
> the same way on bus. The idea is handle the type and report number and
> find it on a list of report that must be prepared
> on the gadget side. The hidg ops interface need to handle report
> preparation so I was thinking in two solutions:
> - sysfs kind of interface
> - ioctl like interface
sysfs is good for "one value per file", but not good for interactions
where you have back/forth from userspace to the kernel. ioctls are good
for "do something in the kernel and get this value back" type of
operation. configfs is good for initializing data for something before
you "finalize" it. So it all depends on what your userspace
interaction is going to be here as to what interface to use.
prototype it and see what works.
greg k-h
next prev parent reply other threads:[~2022-06-27 12:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-27 7:06 f_hid GET_REPORT extension Michael Nazzareno Trimarchi
2022-06-27 7:21 ` Greg Kroah-Hartman
2022-06-27 8:02 ` Michael Nazzareno Trimarchi
2022-06-27 11:44 ` Greg Kroah-Hartman [this message]
2022-06-27 12:08 ` Michael Nazzareno Trimarchi
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=YrmYMO+u4EqSjTZ8@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=balbi@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=michael@amarulasolutions.com \
/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