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=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 4AD73C2BCA1 for ; Fri, 7 Jun 2019 15:02:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1F5B820840 for ; Fri, 7 Jun 2019 15:02:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729613AbfFGPCp (ORCPT ); Fri, 7 Jun 2019 11:02:45 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:35028 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1728682AbfFGPCp (ORCPT ); Fri, 7 Jun 2019 11:02:45 -0400 Received: (qmail 4174 invoked by uid 2102); 7 Jun 2019 11:02:44 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 7 Jun 2019 11:02:44 -0400 Date: Fri, 7 Jun 2019 11:02:44 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Andrey Konovalov cc: Felipe Balbi , USB list , Alexander Potapenko , Dmitry Vyukov Subject: Re: Pass transfer_buffer to gadget drivers In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org On Fri, 7 Jun 2019, Andrey Konovalov wrote: > > > The problem is that I want to receive that data (from the data stage) > > > from within my gadget driver module. But it's not passed to the > > > setup() callback. And the question is: how do I do that then? > > > > I just caught up on this thread... > > > > The answer is simple: The gadget driver's setup() callback routine > > submits a request for endpoint 0. The Data Stage data is sent or > > received (depending on the direction encoded in the Setup information) > > by this request. > > Ah, OK, got it, thanks! > > Although while looking at the dummy_hcd implementation, I saw that it > accesses usb->transfer_buffer in case USB_REQ_GET_STATUS in > handle_control_request(), which is called right before the setup() > callback is called. So the data already available there without any > additional requests. Is this an implementation detail that is specific > to dummy_hcd? Yes, it is. dummy-hcd is unusual in that it combines both a USB host controller and a USB device controller in a single driver. Normal UDC drivers do handle USB_REQ_GET_STATUS on their own without requiring the use of an explicit usb_request, because they handle the entire transfer internally and don't involve the gadget driver. However, they don't have access to any transfer_buffer; all they can do is exchange packets with the host. Alan Stern