Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2228631ybl; Sat, 11 Jan 2020 12:04:04 -0800 (PST) X-Google-Smtp-Source: APXvYqzWnP4rA/3ctWiZD4w1uV0QtZwbSXDe8dkRws3p1WFBPCIAiaXM15rj9V+w72eYhR1urnCG X-Received: by 2002:a54:4713:: with SMTP id k19mr7315200oik.113.1578773044041; Sat, 11 Jan 2020 12:04:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578773044; cv=none; d=google.com; s=arc-20160816; b=gzy5c0vH2CVSN1dMBW28RouuaLJRHzojwCCyYpj50ileCSPsOVLkxIP8VAkG978cNz DLFpeLPi2K4V12Eq+3ORIAtWeFh2S5bTTk1TlQsffKo9pgY0PIwPNkqQNcqLkYcV2J7O beLFYddkbIcTkGrgqi4C+DkjMW0YIZPSwChXJiQqldymdIbDP82jPuxddkZsIfOhDUqY C21II6vCfJL6N7B0Cs9Mk+AvJDbMHzJhzFlafMTwiWIX7snhyJAPfZ9eBjh7rvrseg45 5buF6kMBBTowJlk98bcMewLGEIjarsNxjIHwAPgJ/IP9Y/DGRYtR8PTZSCoMGyE2oK3Z ow1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=WcPxfnwgZQM+SqNvKZQXAOIugzwmILeetQp/FQmCiOU=; b=n5vN0+46PgMCfUz0c858W2KwIYLs0YrX8ZWC3FIH8fQbL9mTih7Aj7+uzwbXREH/mC RhthsnKVVuCUdphQCFRSeSjDn/Hjm0CDHUg4dY553xBZU7cBjV+/x/YBTvw+DHZ4oyW6 qW5KmAYZfSDcbMPEnp1/R04OcBk6fm+L48makSqscFSxH5oAoxGFReQwaeOB2BA6EHEH ABYkbCllqwHA+tMKJeJFmFEp6DrSGHD2q+gK53VZ/C/Uf+io9R6qL9Li41jYL+CT34U5 nneVvcSSzJu8U5XdjCoA0VSZvBok6kT7puuRObfWNEPv7Y0p1Uxv492OkR2VNJoOlb/z owEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FOYJSJFj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l8si3319151oii.249.2020.01.11.12.03.39; Sat, 11 Jan 2020 12:04:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FOYJSJFj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731069AbgAKUB6 (ORCPT + 99 others); Sat, 11 Jan 2020 15:01:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:55762 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731003AbgAKUB6 (ORCPT ); Sat, 11 Jan 2020 15:01:58 -0500 Received: from localhost (unknown [62.119.166.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 95E482082E; Sat, 11 Jan 2020 20:01:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578772917; bh=HhPDLLL17aVBcq2CTWlrH10b+8vgm49G9JMbYET2lFo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FOYJSJFj+K/oMzKqDmSGXkXeIpuo9sB4qFxR2ePfRaENgzjXVkSMkNIf0km7XjgHz 2OYWiiUFGIZEraIOKnR0lgCxgfoC0JqGQqQvGhd5SBskmaNYeFDa3DhDL3cdt3Pvt+ eW6yTlKbEkKWAn77iYSHKXXnSYmZb8H3EnOSQYN0= Date: Sat, 11 Jan 2020 20:31:56 +0100 From: Greg Kroah-Hartman To: Andrey Konovalov Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Alan Stern , Jonathan Corbet , Felipe Balbi , Dmitry Vyukov , Alexander Potapenko , Marco Elver Subject: Re: [PATCH v4 1/1] usb: gadget: add raw-gadget interface Message-ID: <20200111193156.GC435222@kroah.com> References: <6cd46f8512dc12e20667c2b02d487591868cb20f.1576697098.git.andreyknvl@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6cd46f8512dc12e20667c2b02d487591868cb20f.1576697098.git.andreyknvl@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 18, 2019 at 08:26:57PM +0100, Andrey Konovalov wrote: > USB Raw Gadget is a kernel module that provides a userspace interface for > the USB Gadget subsystem. Essentially it allows to emulate USB devices > from userspace. Enabled with CONFIG_USB_RAW_GADGET. Raw Gadget is > currently a strictly debugging feature and shouldn't be used in > production. > > Raw Gadget is similar to GadgetFS, but provides a more low-level and > direct access to the USB Gadget layer for the userspace. The key > differences are: > > 1. Every USB request is passed to the userspace to get a response, while > GadgetFS responds to some USB requests internally based on the provided > descriptors. However note, that the UDC driver might respond to some > requests on its own and never forward them to the Gadget layer. > > 2. GadgetFS performs some sanity checks on the provided USB descriptors, > while Raw Gadget allows you to provide arbitrary data as responses to > USB requests. > > 3. Raw Gadget provides a way to select a UDC device/driver to bind to, > while GadgetFS currently binds to the first available UDC. > > 4. Raw Gadget uses predictable endpoint names (handles) across different > UDCs (as long as UDCs have enough endpoints of each required transfer > type). > > 5. Raw Gadget has ioctl-based interface instead of a filesystem-based one. > > Signed-off-by: Andrey Konovalov This looks good to me, with the one minor problem below that you can fix with a follow-on patch. This should probably go through Felipe's tree though, so I'll wait for him to review the gadget side and then queue it up in his tree: > +/* The type of event fetched with the USB_RAW_IOCTL_EVENT_FETCH ioctl. */ > +enum usb_raw_event_type { > + USB_RAW_EVENT_INVALID, > + > + /* This event is queued when the driver has bound to a UDC. */ > + USB_RAW_EVENT_CONNECT, > + > + /* This event is queued when a new control request arrived to ep0. */ > + USB_RAW_EVENT_CONTROL, > + > + /* The list might grow in the future. */ > +}; You have to manually specify the enum values in the .h file for all entries in order to assure that both userspace and the kernel will be in sync with the same values. I think that's documented in the "how to write an ioctl interface" document that is somewhere in Documentation/... thanks, greg k-h