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=-5.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 19F5CC433F5 for ; Fri, 17 Sep 2021 14:17:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E843860F93 for ; Fri, 17 Sep 2021 14:17:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232644AbhIQOS6 (ORCPT ); Fri, 17 Sep 2021 10:18:58 -0400 Received: from mail.msweet.org ([173.255.209.91]:33628 "EHLO mail.msweet.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231259AbhIQOS6 (ORCPT ); Fri, 17 Sep 2021 10:18:58 -0400 Received: from smtpclient.apple (unknown [206.214.229.168]) by mail.msweet.org (Postfix) with ESMTPSA id C503D81FE8; Fri, 17 Sep 2021 14:17:35 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.msweet.org C503D81FE8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=msweet.org; s=default; t=1631888256; bh=atiLdMkEoVobeO8+J8csYNRYvD8TmyH99ZP+5t/MaPM=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=HU7toqUD9odeShLaYJJ2EJkSEDNNyAiGooh/HbF5FzZZ/o6ULfUFEh5/fZsuR2ZDA z0vnCUFoKppeeoUEWjpTvzL+sA/xGDbtqNo2no5ZnfJfcq2Ue1sEOGRIkSnFPzNbsX B80u6gMPE0g9yJjWgeSFarGSE2/qrrs2/4cSpxnw= Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.0.1.1.10\)) Subject: Re: How to register a new "function" in configfs? From: Michael Sweet In-Reply-To: Date: Fri, 17 Sep 2021 10:17:33 -0400 Cc: linux-usb@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <3C27F76A-CE48-49E3-9078-CBE02B4E287E@msweet.org> References: To: Ajay Garg X-Mailer: Apple Mail (2.3693.0.1.1.10) Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Ajay, It is really hard to help further without seeing source code... I assume you've verified that your gadget driver module is loaded? And in your code: - Did you use the MODULE_LICENSE, MODULE_AUTHOR, and MODULE_DESCRIPTION = macros to define your driver metadata? - Did you use the module_init and module_exit macros? > On Sep 15, 2021, at 9:51 AM, Ajay Garg wrote: >=20 > Any pointers, please? >=20 > On Sat, 11 Sep 2021, 20:28 Ajay Garg, wrote: > Hi Michael, >=20 > Thanks for the reply. >=20 > I am a bit of old-school, and would prefer things in one place only > (in the kernel) :) > Thus : >=20 > a) > I wish to have all the endpoints configuration/management in the > kernel only (like done in drivers/usb/gadget/function/f_serial.c, > drivers/usb/gadget/function/u_serial.c). >=20 > b) > Only the attributes like vendorId/productId would be in configfs, to > help setup the device. >=20 > c) > No user-space management of kernel objects. >=20 >=20 > Either-way, I think that my issue of "function exposure" would remain > the same, irrespective of whether we use configfs for managing the > kernel-objects (please correct me if I am wrong). >=20 >=20 > Thanks again for your time, look forward to listening back ! >=20 >=20 > Thanks and Regards, > Ajay >=20 > On Sat, Sep 11, 2021 at 8:01 PM Michael Sweet = wrote: > > > > Ajay, > > > > Quick question (as someone who has been down this road), do you need = to do a kernel driver or could you just use the functionfs support to = implement everything in userspace? I found that path to be much easier = and less error-prone (and one of these days I'm going to be contributing = some documentation changes to make some things clearer...) and I was = able to get my IPP-USB implementation up and running very quickly. > > > > > > > On Sep 11, 2021, at 1:43 AM, Ajay Garg = wrote: > > > > > > Hi All. > > > > > > As a first step, I have been able to load a gadget on configfs, = which > > > binds to the function "gser" (thus loading up the usb_f_serial = module > > > when the gadget mounts). Things work well till here. > > > > > > Now, I have written a brand-new gadget-side device-driver, trying = to > > > create a new function "gusb", via DECLARE_USB_FUNCTION_INIT. > > > However, now when I try to load the gadget for binding to "gusb", = I > > > get the error that the function cannot be found. > > > > > > Seems that firing up a new gadget-side driver, that registers a = new > > > function via DECLARE_USB_FUNCTION_INIT, is not enough to make the = new > > > function visible across the kernel. > > > > > > Kindly let know what I am missing. > > > Will be grateful for pointers. > > > > > > > > > Thanks and Regards, > > > Ajay > > > > > > > ________________________ > > Michael Sweet > > > > > > ________________________ Michael Sweet