From patchwork Wed Apr 24 22:14:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wulff X-Patchwork-Id: 13642562 Received: from mx0a-0068d901.pphosted.com (mx0a-0068d901.pphosted.com [205.220.168.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A983E15FA70; Wed, 24 Apr 2024 22:15:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.168.35 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713996921; cv=fail; b=Old7uYRea+fytyy1bNNyEjwHQsZ7GDbQdRSytfS5u3u++3EYUP+9IKLmg0xd1pqhuY0Ezjodz82hbRe0RnZKWc47aVAJYiXX9HTS5Y/z04TeaScTct+40JKuaNxdSLkIGJX5QnXFWZxlvwzjWoTkRpUGTH7h/kXjoLwwslFMyRk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713996921; c=relaxed/simple; bh=iocbcIDEZW7SOGQ+hUYocWe9D78pt5pTaNfwmfo9Mro=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=u0dY7mzMrAvYZlDQoK4YpTDM+8aSojMIxNvOvJMxuL0vsghtCUnSD0zBcbznHuoOh5FVaOKlaBSKkQC9sSYNbBacQxALAeS43z60rAw1Z2D6qEQ+v2Lg0rYkcMd5KD7G9zv+HGfnaYGs4nm0aKLT8JFoKND5ZDUijvhzlF+VpQ8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=biamp.com; spf=pass smtp.mailfrom=biamp.com; dkim=pass (2048-bit key) header.d=biamp.com header.i=@biamp.com header.b=JBjWALFV; dkim=pass (2048-bit key) header.d=biamp.com header.i=@biamp.com header.b=e6C+PwTA; arc=fail smtp.client-ip=205.220.168.35 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=biamp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=biamp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=biamp.com header.i=@biamp.com header.b="JBjWALFV"; dkim=pass (2048-bit key) header.d=biamp.com header.i=@biamp.com header.b="e6C+PwTA" Received: from pps.filterd (m0278264.ppops.net [127.0.0.1]) by mx0b-0068d901.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 43OAU2cl028125; Wed, 24 Apr 2024 15:15:02 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=biamp.com; h= from:to:cc:subject:date:message-id:content-type :content-transfer-encoding:mime-version; s=proofpoint; bh=HS65Vr ZOowJuMIjMztvWiAqOyu9KWF99n3S2eLEu0RQ=; b=JBjWALFVrv0Uig97/J9wu3 D4LBMPoIrHNVdJ0syD/gxLMMQOvRLAk6zMp6zhe82LS1kXzlXaZmbOOUwBcJJeBq oaewciFGEfKv1NN5SoE1hl0UrCTSATDn1c7bGSiU7hgnq3x1HteDAgeHjTnO1O5u bWM1EKcqndTpXa9BveItQJDRMWBV/kkhgrzZ1iqj+fTDD6vheibT7KgZr+yiCigb ltV0nmx/ln1lHv8JMexWSEw4eWHW4NZV5Ob/XqDMavoU4EqfK2hfx6AdEqZ8rP3d 926h/7UE8HIze6qLEnWggqDUavtGjaNUyAStbKnpPTZkFo4thEE/zPKx2z/HBojg == Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2169.outbound.protection.outlook.com [104.47.59.169]) by mx0b-0068d901.pphosted.com (PPS) with ESMTPS id 3xmcrg3aup-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 24 Apr 2024 15:15:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T3YOVz1x46d2Rgo/0+ohbB0cjr5L/bkn1wv4lx0JDmrm/vtFXArSpNHgrJI7rZMqZQHdvN9On0mL51HeGdIYJSZ5EFgGcgpqZ0Wr0Cvjj+9ekLFGMvReDEs2QJfJzEcwRiW9qCuLNMN8w/jhI53rzF+0yLW3CWK0tjppr8amrWyold8GFgvi4PHTP8usQbRnBtQgPbY51k6Erw9RiC3TAkhErX57bdnFWu+CdGYUQDCfXeInDJxY+NIvbY0naxnzbZ+IWNQepwQ6fwZdwQfIqunYK0TtcnwqRK35NxAVWaUiamP0MKfzh7h0Qhy6weihkMHbMbnwViUSyHCJAMvwsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HS65VrZOowJuMIjMztvWiAqOyu9KWF99n3S2eLEu0RQ=; b=SmzR/yopRc/+UwY8fUZGthard3Y1LmQKK7nnav/Y/8sOSNYFRYUT9+7to4p9z29D54yy3vlkYl2inTEbgO7ZMdyU9oVxdD0dwgD2NCsqg41L2brBoc9KoJAeyTw4jd+BV1KZd/SueJ2RHnkhdlqlfFAT7CGgNW19fz3ORAyHBRDJJ1KjTeO99dvlxr6yFfumYTqYdSEeBsdqbtTxR9YUA7Mhg2hp+P/2f6npxGqU/NyRu+5IqP3Enw4QLTY/IKjq04+7fU/RotHo1WOM4U562/1tlqGjQ2smJlg8UhCi5FGxGTpNdf3KvK8VDmrCPvKY0wbh0RNCwEj56sDf+6zgTQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=biamp.com; dmarc=pass action=none header.from=biamp.com; dkim=pass header.d=biamp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=biamp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HS65VrZOowJuMIjMztvWiAqOyu9KWF99n3S2eLEu0RQ=; b=e6C+PwTALVrpGLJ84ATH9uIaCMxNqFRVsKcWVnZyXlu4A5E99BoT9OtEyMe6kd07ytMGcBBusOR7/inG9uR29YQHeADBympAL1XwUTtejadZLty33s+RLKmbN90Mpf0OrQ08TFYD+JOVJQQ3IkwfuYxEse+jJFa3eMkZDyiPtzTLNyzSD1lW29LY+ljUL0O0UCIaELUg6lAr2WpzUlorIntM2sp3gXvNumKySBR52V0TcbMPszpbVN4ErHWOMqvMklmNgLg/k3lDMw+pk+ghZJcQpiZO1B/LNG4ihGCaN5reTrnCFlSZUrrhdy85520T2CD0kKQx2kdbBOr2uU5YIA== Received: from CO1PR17MB5419.namprd17.prod.outlook.com (2603:10b6:303:ec::17) by IA1PR17MB6925.namprd17.prod.outlook.com (2603:10b6:208:44c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.22; Wed, 24 Apr 2024 22:14:59 +0000 Received: from CO1PR17MB5419.namprd17.prod.outlook.com ([fe80::f48:ee61:a81b:d555]) by CO1PR17MB5419.namprd17.prod.outlook.com ([fe80::f48:ee61:a81b:d555%4]) with mapi id 15.20.7519.021; Wed, 24 Apr 2024 22:14:59 +0000 From: Chris Wulff To: "linux-usb@vger.kernel.org" CC: Greg Kroah-Hartman , Christian Brauner , Paul Cercueil , Jan Kara , Jeff Layton , Dmitry Antipov , David Sands , "linux-kernel@vger.kernel.org" , "linux-api@vger.kernel.org" , Chris Wulff Subject: [PATCH v3] usb: gadget: f_fs: add capability for dfu run-time descriptor Thread-Topic: [PATCH v3] usb: gadget: f_fs: add capability for dfu run-time descriptor Thread-Index: AQHalokpimGT++aQ2k6Ic/g3VTUYsQ== Date: Wed, 24 Apr 2024 22:14:58 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CO1PR17MB5419:EE_|IA1PR17MB6925:EE_ x-ms-office365-filtering-correlation-id: 88b269f1-e786-4d73-2573-08dc64abfacc x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230031|366007|376005|1800799015|38070700009; x-microsoft-antispam-message-info: =?iso-8859-1?q?/H6jM8Ana/zzCRg5BQ50DBwKRV?= =?iso-8859-1?q?BrsgPl1Pam4vh1as3pKapdMMmYWmDPz+Rmw/LfIVQwKHZPhq1+yudIVmtXlC?= =?iso-8859-1?q?MeHXYiu8VojotZj2ca6GD7YefrPIFIGkHRQ9aSqZZbQ6qyE/Mtwq7x+CUUwn?= =?iso-8859-1?q?v3bPMDyTr8gX//4Ya9V3aHjC+Le5Q0ECzfZiycfXzQTv1ymBNoDAdk5phmGK?= =?iso-8859-1?q?QjSPoYGDclSx+fdfBG9o5OsOSbNJVheceL85ljg3xHi8Z29uhc9kanCIoU4u?= =?iso-8859-1?q?RJ1LrqIxIjZj3npDLf2h3Utx+TyItlbpJ5bjIsRFhNgeBh5IbwmRsdl2UZkE?= =?iso-8859-1?q?u92oqUBktt/Vf/MnqxUV6cfMMq1rZMprYMNMEx7SdRueYljTAmFVaiy3GF4I?= =?iso-8859-1?q?bYfLhZgL5mayLqzMS2Drs9r9UKoveUOBBkhlbxfpe1JhT1bPiYUKUvCuJX+d?= =?iso-8859-1?q?hSU7GRSRADzUN/u8ovjYA4vTTGgqU+6vO36y2PRqCuDufVJixJG5eLeCEveu?= =?iso-8859-1?q?4wbkzO00WVi1Ij57dWlVVcwbNEoUeuKPhjvUSm1z4KC5JRMSCfr4HT15n6Iy?= =?iso-8859-1?q?n9UiBJuJ3EUR3RQ7TlnMNYww+8GLD3X4stDf/O5j+MooGpJtrJIzuaixpWhw?= =?iso-8859-1?q?grNsVwX1qd9M4bepeo6Z+W4f5ABKrfETrDdd3cZW8nWSE7g+5vkUNE9Zfqe8?= =?iso-8859-1?q?d0KPqB+uA8fjVGfSWcy1Y5LsGNBQAC9yd7kuRldJ8EI13hMzyqOqjWoJS3kN?= =?iso-8859-1?q?XboKmyyBTRjx2Ivk9dQBXA+b6hzmclLOsmXQ9gE/urnfs3j4l3HCALPbBdz9?= =?iso-8859-1?q?tCUiNo6FGKXNyPV7GmNs7pcVmHGBj9ao2iXcqhn4JavsK7pJkKoO1v/xq/Hi?= =?iso-8859-1?q?3RmXIwB9Nl3OSNw2DOUILrC0iNB7fefpLLLSzmsssKIpYHQDjTbtPAs75cfq?= =?iso-8859-1?q?GJ0WeMtLioVNC8lGHv8B3gsn7J2+ZkvchsST8+lUBCtiP2zVfOdy37mndRVh?= =?iso-8859-1?q?QNhCtsGwlfzdej+qFDEfi+K7AdWX2Qvc9ZqN+z9nGnnnuPhpG2KkblzSMl1Y?= =?iso-8859-1?q?H+Kq/OVAmlEIvraCFRl4TbIIgDbhX/6wKrfV8Vjd9uu0iPBxy1z/elh5r++P?= =?iso-8859-1?q?wWdBuTi/5wHqgx3b9iUx364M6vKX3imPcMNM+QG9jgKauW4DpesJ9fwLgmos?= =?iso-8859-1?q?aGhrj+UkwV/cRF3UiEiWm80Kez8TZT9n5z6PiI+3Wzq062TGwMIyI8JvML5D?= =?iso-8859-1?q?08I+Aq8afyqpcYbBLbmvaOVdoUiZW6nDFZM8urp4Vy25S1gtSA8qPY1Zj2tA?= =?iso-8859-1?q?mW+faTlettacf6/SpjtRd+VqV3SYbgw6wHHVZTbNFBCcDcKGRcYwxuAypB3w?= =?iso-8859-1?q?eH/eYDETF87a7JapbEyA=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR17MB5419.namprd17.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(376005)(1800799015)(38070700009);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?pLrESmVjDqxxkmtwDbptNLr?= =?iso-8859-1?q?Xzpzuq6kCVtKQOX/DnMwRTsS3ZRFtNEQqbyUl/hZpVBADLJEmIc/DzQkm/aV?= =?iso-8859-1?q?WBbwVk2v7u1zLV2zu652dwY6qSuxS8cnCHSsqelOXXY3aWCCF92cRi7PWkeJ?= =?iso-8859-1?q?FfJpzRKebEEDwBwqSo3hWRuDrAPcaYrcoD0ZlrxLdELQGMa2Dvyfbycc1+im?= =?iso-8859-1?q?KhNWzT8ISCZJ7IMZrYy+Q8ACNhhzyE0dTrU19AsS6ktzEI6P57NN/EWnPsOP?= =?iso-8859-1?q?i4iYGM5LK0Vs92bpk0JaAN62qDaGhr3h0QEy0B19iOM79vO0bwDBrilKiwlj?= =?iso-8859-1?q?y3IHEJwOP0QtZdPxXcuOMFzDPgqy4Yy1qePRNdXBVJ/TDtoSbjhyXAGHgBAe?= =?iso-8859-1?q?9b4HXzWlxgRhYvXXrN9vfB9ye2OayPvusCPU4ZmQqTpW/6K3vTMxy8qrZs77?= =?iso-8859-1?q?14IKdn9X8WmD/81jPak1q0FCBDI9oZoX12aTxyHif/wkmvBxMNu6aaRBc56g?= =?iso-8859-1?q?SlZ220WyRwR15nefe4zt6SW7v+MBuAsGrL3oDvq0QD/NyammvWGzlo7sBHY0?= =?iso-8859-1?q?BHCfLgY1/sWFz2CrHZ9DRIl3w5NiBbXdgpGkUXJ6pgNGngNOGSREUqVyTjaX?= =?iso-8859-1?q?NK71Ea30T+ZGXrn9On/WecS4KGd72aHCSsg5gXg5atdpaGLWJOX6Ddu4KVO1?= =?iso-8859-1?q?iQOd5aGJnqVPn9RfsH5u93ftf4v5aifwBt75LZSglhxkz1VtwEU07m9gCX4H?= =?iso-8859-1?q?IDm/QKO8a9HvHFEDPgJQzhuu70R7LjF2YmaAOXE8l5DNnS2DTfsWuppdBrdi?= =?iso-8859-1?q?3chALObaIA+/g0G9+wwADwUnRs6wOPuCG3JyISp2PPFuNHFhhjuB7PROK9ch?= =?iso-8859-1?q?o8sjJ/wXRv/2Dmu5hic9xLh/ALoqjTV7mHAcr+YZpm6wjN6OLWEPdhuHUFdD?= =?iso-8859-1?q?ZIdA+JrceUZtGBFXR1EbHTRIz3SOsYK45GTce77koqn1Q4BipOLYffNaULnZ?= =?iso-8859-1?q?q284HphMkNKJyBhVumjjonJYSuOvZALWp5ubTlJlFueWVxGFwSdYRte+WarR?= =?iso-8859-1?q?leIIxHbTneB89svAhYnxOGvkJSlQUVQ9KAun3z11nFx4docPOgTU2m+syUOW?= =?iso-8859-1?q?i/VAaCJx/J52NQMFHtpLwThMJkydjL64qZkmREDtzx5noLEu2txduTI5mmUP?= =?iso-8859-1?q?ScciCAsrqEZCtJT/9vt45lOtxlBat6/AqBswXdk/huC/wBdMjBGwZ/Nqvj+b?= =?iso-8859-1?q?wv+nT4M//C/miQDWAZ9SG9ByfUIOWjnIG0MUjRDevge7MDk9PoQwRa1xco1/?= =?iso-8859-1?q?crXUyZBM8iyI7pCAmzuU3n8TWwCaE6jJZCc5ABxyE6gpirtwX4vY/YjqKG8M?= =?iso-8859-1?q?Ngxtm/lGzZi7w95T6SZYKD+eBYFOB0atDGHMH7wL9Gd5DuUlTsNS5WSObTQe?= =?iso-8859-1?q?UYPz7Lco9Gqtpt+HciiByad1NL106dJUFh1y0dqf2lU+sPrZ5q9hy0YM2Wft?= =?iso-8859-1?q?HGsJJDs14kRuoHQL1WjFaW6YZfTCqlsflqdCCSzW6n5v2pwBj7TeKJO7HCrl?= =?iso-8859-1?q?2DQTxaydM3lZbr5VwNhWhnds7F3hsMMkrho183G/yP3rGE+KTGlF8XhctKJs?= =?iso-8859-1?q?oInGER4bwmJAGnfbN?= Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-OriginatorOrg: biamp.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CO1PR17MB5419.namprd17.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 88b269f1-e786-4d73-2573-08dc64abfacc X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Apr 2024 22:14:58.9075 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 341ac572-066c-46f6-bf06-b2d0c7ddf1be X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: WCBbZLHLS2+P4jBF8iITCLryPW0bf5saQV/lXtUz6NfdPeODj7zp1ZuxAW669jZ/WtZz4XwY4QKAD7liK2oHig== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR17MB6925 X-Proofpoint-ORIG-GUID: BzTDxwGfd18FFd6eKPd8erFCiS6KW5W8 X-Proofpoint-GUID: BzTDxwGfd18FFd6eKPd8erFCiS6KW5W8 From: David Sands Add the ability for FunctionFS driver to be able to create DFU Run-Time descriptors. Signed-off-by: David Sands Co-developed-by: Chris Wulff Signed-off-by: Chris Wulff --- v3: Documentation, additional constants and constant order fixed v2: https://lore.kernel.org/linux-usb/CO1PR17MB54198D086B61F7392FA9075FE10E2@CO1PR17MB5419.namprd17.prod.outlook.com/ v1: https://lore.kernel.org/linux-usb/CO1PR17MB5419AC3907C74E28D80C5021E1082@CO1PR17MB5419.namprd17.prod.outlook.com/ drivers/usb/gadget/function/f_fs.c | 12 ++++++++++-- include/uapi/linux/usb/ch9.h | 9 +++++++-- include/uapi/linux/usb/functionfs.h | 25 +++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index bffbc1dc651f..4cc3f3601cf0 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -2467,7 +2467,7 @@ typedef int (*ffs_os_desc_callback)(enum ffs_os_desc_type entity, static int __must_check ffs_do_single_desc(char *data, unsigned len, ffs_entity_callback entity, - void *priv, int *current_class) + void *priv, int *current_class, int *current_subclass) { struct usb_descriptor_header *_ds = (void *)data; u8 length; @@ -2524,6 +2524,7 @@ static int __must_check ffs_do_single_desc(char *data, unsigned len, if (ds->iInterface) __entity(STRING, ds->iInterface); *current_class = ds->bInterfaceClass; + *current_subclass = ds->bInterfaceSubClass; } break; @@ -2548,6 +2549,12 @@ static int __must_check ffs_do_single_desc(char *data, unsigned len, if (length != sizeof(struct ccid_descriptor)) goto inv_length; break; + } else if (*current_class == USB_CLASS_APP_SPEC && + *current_subclass == USB_SUBCLASS_DFU) { + pr_vdebug("dfu functional descriptor\n"); + if (length != sizeof(struct usb_dfu_functional_descriptor)) + goto inv_length; + break; } else { pr_vdebug("unknown descriptor: %d for class %d\n", _ds->bDescriptorType, *current_class); @@ -2610,6 +2617,7 @@ static int __must_check ffs_do_descs(unsigned count, char *data, unsigned len, const unsigned _len = len; unsigned long num = 0; int current_class = -1; + int current_subclass = -1; for (;;) { int ret; @@ -2629,7 +2637,7 @@ static int __must_check ffs_do_descs(unsigned count, char *data, unsigned len, return _len - len; ret = ffs_do_single_desc(data, len, entity, priv, - ¤t_class); + ¤t_class, ¤t_subclass); if (ret < 0) { pr_debug("%s returns %d\n", __func__, ret); return ret; diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h index 44d73ba8788d..7f155fba0c1f 100644 --- a/include/uapi/linux/usb/ch9.h +++ b/include/uapi/linux/usb/ch9.h @@ -254,6 +254,9 @@ struct usb_ctrlrequest { #define USB_DT_DEVICE_CAPABILITY 0x10 #define USB_DT_WIRELESS_ENDPOINT_COMP 0x11 #define USB_DT_WIRE_ADAPTER 0x21 +/* From USB Device Firmware Upgrade Specification, Revision 1.1 */ +#define USB_DT_DFU_FUNCTIONAL 0x21 +/* these are from the Wireless USB spec */ #define USB_DT_RPIPE 0x22 #define USB_DT_CS_RADIO_CONTROL 0x23 /* From the T10 UAS specification */ @@ -263,6 +266,7 @@ struct usb_ctrlrequest { /* From the USB 3.1 spec */ #define USB_DT_SSP_ISOC_ENDPOINT_COMP 0x31 + /* Conventional codes for class-specific descriptors. The convention is * defined in the USB "Common Class" Spec (3.11). Individual class specs * are authoritative for their usage, not the "common class" writeup. @@ -329,9 +333,10 @@ struct usb_device_descriptor { #define USB_CLASS_USB_TYPE_C_BRIDGE 0x12 #define USB_CLASS_MISC 0xef #define USB_CLASS_APP_SPEC 0xfe -#define USB_CLASS_VENDOR_SPEC 0xff +#define USB_SUBCLASS_DFU 0x01 -#define USB_SUBCLASS_VENDOR_SPEC 0xff +#define USB_CLASS_VENDOR_SPEC 0xff +#define USB_SUBCLASS_VENDOR_SPEC 0xff /*-------------------------------------------------------------------------*/ diff --git a/include/uapi/linux/usb/functionfs.h b/include/uapi/linux/usb/functionfs.h index 9f88de9c3d66..6d2061500184 100644 --- a/include/uapi/linux/usb/functionfs.h +++ b/include/uapi/linux/usb/functionfs.h @@ -37,6 +37,31 @@ struct usb_endpoint_descriptor_no_audio { __u8 bInterval; } __attribute__((packed)); +/** + * struct usb_dfu_functional_descriptor - DFU Functional descriptor + * @bLength: Size of the descriptor (bytes) + * @bDescriptorType: USB_DT_DFU_FUNCTIONAL + * @bmAttributes: DFU attributes + * @wDetachTimeOut: Maximum time to wait after DFU_DETACH (ms, le16) + * @wTransferSize: Maximum number of bytes per control-write (le16) + * @bcdDFUVersion: DFU Spec version (BCD, le16) + */ +struct usb_dfu_functional_descriptor { + __u8 bLength; + __u8 bDescriptorType; + __u8 bmAttributes; + __le16 wDetachTimeOut; + __le16 wTransferSize; + __le16 bcdDFUVersion; +} __attribute__ ((packed)); + +/* from DFU functional descriptor bmAttributes */ +#define DFU_FUNC_ATT_WILL_DETACH (1 << 3) +#define DFU_FUNC_ATT_MANIFEST_TOLERANT (1 << 2) +#define DFU_FUNC_ATT_CAN_UPLOAD (1 << 1) +#define DFU_FUNC_ATT_CAN_DOWNLOAD (1 << 0) + + struct usb_functionfs_descs_head_v2 { __le32 magic; __le32 length;