From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754066AbbJ0Grn (ORCPT ); Tue, 27 Oct 2015 02:47:43 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:22666 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751367AbbJ0Grm (ORCPT ); Tue, 27 Oct 2015 02:47:42 -0400 X-AuditID: cbfec7f4-f79c56d0000012ee-7b-562f1e0be7f5 Subject: Re: [PATCH v4 5/7] usb: gadget: f_midi: set altsettings only for MIDIStreaming interface To: Felipe Tonello , Robert Baldyga References: <1445878509-12084-1-git-send-email-eu@felipetonello.com> <1445878509-12084-6-git-send-email-eu@felipetonello.com> <562EA969.5000107@hackerion.com> Cc: USB list , Kernel development list , Felipe Balbi , Greg Kroah-Hartman , Andrzej Pietrasiewicz , Clemens Ladisch From: Robert Baldyga Message-id: <562F1E0A.30703@samsung.com> Date: Tue, 27 Oct 2015 07:47:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-version: 1.0 In-reply-to: Content-type: text/plain; charset=utf-8 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrJLMWRmVeSWpSXmKPExsVy+t/xq7rccvphBjtXiFjMetnOYnHwfr3F khMPmSw6559lt2hevJ7N4vKuOWwWi5a1Mlvc/feJ0YHD4+7Xh+weR3YeY/P4saKf2WP/3DXs Hn1bVjF6HL+xncnj8ya5APYoLpuU1JzMstQifbsErowbCzvZCubwV9z5Po21gbGHp4uRk0NC wESiZeptFghbTOLCvfVsXYxcHEICSxklNm+4yAThPGOUWDBtCyNIlbBAssT9k/OAEhwcIgKh EvM/KkPUvGSUmP7kHFg3s0A3k8T9phNsIA1sAjoSW75PAGvmFdCQmPzuO1icRUBVov38LCYQ W1QgQmLihAZWiBpBiR+T74GdxCkQLHHm2Bl2kGXMAuoSU6bkgoSZBeQlNq95yzyBUWAWko5Z CFWzkFQtYGRexSiaWppcUJyUnmuoV5yYW1yal66XnJ+7iRESAV92MC4+ZnWIUYCDUYmH16BC L0yINbGsuDL3EKMEB7OSCG/+T6AQb0piZVVqUX58UWlOavEhRmkOFiVx3rm73ocICaQnlqRm p6YWpBbBZJk4OKUaGOtWbkuRcy/beWVh5MLQxUnfDy3vUVSePbWntHhPlPW0Jf+qPldsf+WR WFrxmTXadZ173fNtCxdXBD4zvbc2ZktHQbCsR/Pef2c0nBRfbmN9U8U1gev+N6k1e8yPXHpy vFvl1ranCy893qKf/uHnEXmOoNsvjp754f1r554y860NivtyTfpD1FSVWIozEg21mIuKEwHK RycrfAIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/26/2015 11:53 PM, Felipe Tonello wrote: > Hi Robert, > > On Mon, Oct 26, 2015 at 10:30 PM, Robert Baldyga > wrote: >> On 10/26/2015 05:55 PM, Felipe F. Tonello wrote: >>> This avoids duplication of USB requests for OUT endpoint and >>> re-enabling endpoints. >>> >>> Signed-off-by: Felipe F. Tonello >>> --- >>> drivers/usb/gadget/function/f_midi.c | 4 ++++ >>> 1 file changed, 4 insertions(+) >>> >>> diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/function/f_midi.c >>> index 0e9cdeb..a617df3 100644 >>> --- a/drivers/usb/gadget/function/f_midi.c >>> +++ b/drivers/usb/gadget/function/f_midi.c >>> @@ -323,6 +323,10 @@ static int f_midi_set_alt(struct usb_function *f, unsigned intf, unsigned alt) >>> unsigned i; >>> int err; >>> >>> + /* We don't care if it is not MIDIStreaming interface */ >>> + if (intf != ms_interface_desc.bInterfaceNumber) >>> + return 0; >>> + >> >> These global descriptors are overwritten in bind() of each instance of >> f_midi, so you have no guarantee that your bInterfaceNumber is correct >> for your current instance. Instead you should store value obtained from >> usb_interface_id() during bind(). > > Ok. > > But then this interface descriptors shouldn't be global static, > because they will always reflect the latest bind() only. Right? They are copied for each instance of USB function, so they are actually template to fill and copy in bind(). I'm currently working on some patches changing a bit behavior of set_alt() to make it clearer, but for now the only way to distinguish between altsettings properly is to store bInterfaceNumber value for each function instance in its bind(). Best regards, Robert > >> >>> err = f_midi_start_ep(midi, f, midi->in_ep); >>> if (err) >>> return err; >>> > > Felipe