Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp4059341ioo; Wed, 25 May 2022 14:01:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgfl99unwnJCtCpyL/74LkV2uV3svIAE2Ds00GA5xk1gREOgU3zPDLk2ggSC1bociz888t X-Received: by 2002:a17:907:7f16:b0:6fe:dcc0:3b23 with SMTP id qf22-20020a1709077f1600b006fedcc03b23mr16155875ejc.478.1653512479692; Wed, 25 May 2022 14:01:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653512479; cv=none; d=google.com; s=arc-20160816; b=V3YF+NSv2ONiTHnyqxJJTdifZpSjPoLFVT8KS3MIWv2La+JZCxaWHttrL0oe1mQhjU PDhIAwornLP2oQui36/PuPiGHKmIeCDqCKv1V60lXdc6tE1ZRvmSAaUQY8M91Zq3mMMm B8CuDxlongOOWOdOqRIm7iGy6TXuVyNMPO9IBPMMFYqWRqzT/aEu1Iou+nmUngPaQSIv jRYOaUObrk48nza60GtQ7uRwh46WVVNaAfBRS7lsck0EMEmbAW8DU+EUsZVq+oI6wQVU rrTrQ1N80Hhd24MbLWQkmH5Pmv0iKGHj8C1z4RWoaL1/FS7YORA7aXqhi22TokksYvp0 AoFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :subject:cc:to:mime-version:user-agent:from:date:message-id :dkim-signature; bh=0ClCObzZM0JGjb5K73U4ZwKmob5kESvLI8Z4kupojhc=; b=nZDIE/WobN4616X8TGxgJ08AX63S3QFFiFBrmyNMFVKy8CtX2GsWusCIWnzPDDtgMu vPrg7EKKoFHqnMUDBbszHkpRW4fqcvcqsxjLm+PI8oCVOPszxOjHUHgJjjJeXRECPn7c cJVyR4gwWOir5lfwhvsiYbY7PTg3/S1eHL79WWZDfTqMQU9gZgC84PUpT1v4sdLKeDhX IZWXJBO0gBCr77XCPRQR9ftDXGz+XxE3DlLm1oKx4zXNtci24GdrmQ/qeU3RYyeVWxBB vM24ITG9e1gq3uE8qyfhUNP0rcxk/7I4cCvPb3VCni6qWXA5T3SG2mO72UiRhRsxh9it FxrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Ybpk9Ztl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b11-20020a05640202cb00b0042ab3a8f0afsi1601155edx.238.2022.05.25.14.00.37; Wed, 25 May 2022 14:01:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Ybpk9Ztl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237326AbiEXMYH (ORCPT + 99 others); Tue, 24 May 2022 08:24:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233958AbiEXMYF (ORCPT ); Tue, 24 May 2022 08:24:05 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6A4A939DA for ; Tue, 24 May 2022 05:24:04 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id eg11so22799844edb.11 for ; Tue, 24 May 2022 05:24:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-transfer-encoding; bh=0ClCObzZM0JGjb5K73U4ZwKmob5kESvLI8Z4kupojhc=; b=Ybpk9ZtlkSHU53GPoO2SyDZAWpT3mBN2ihVW2C2gROI4GeXiuSpJI79zRdfGWoqcsp 0Y0t4+jKws5CdTty5eMHiscQHbN72wh6I8SqOPcDncVWQKABcpEAV1IEzz46ytKJByZK xDH4rWB8OasOqyDKVumCfPJaZ+kaiUan8NULlYZgW4GxkhB2N/LykyhyxRaJ9sbh1mzF okRSWjbgpU3lg7aXgcfjUc2h/aezerZcfOjyuh5IZKEgScdCX1ex2ce1xtGFzVZQ/kpT VbWUjwWhR6vD9YtrZy4Jla+m/DUOy07Zr/I5YY3+dwBe/Ku874Y6/7c0ZFDwkjI292SQ 413A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-transfer-encoding; bh=0ClCObzZM0JGjb5K73U4ZwKmob5kESvLI8Z4kupojhc=; b=nTaKurGcPLDwqpEI3XKvJaJqjG8BwLvARrHmektG0IkcvmeTpA3nQPmqdp02iINDSN XHOGx+8vyvCuMv0SgIg8iL6vAonTL+RGa0+PKFMXMaiOPmHc2Bo2SzXYf1LuOFeJunB2 rJdfnTRHelRIWsdUW33fuTcBEh/G/BJo66lsxJyWLLe/Ar6ZSaxJyQrwZFwz+QtSqZb0 ZCLeHq/C1V/aUab9d3gM527MYQINqqB+Ud/fr9Urtvz/cujRu6ajLqDBj02VKAC3oS7V QyBu1urwboLs7wA+X5GOi4bqTnKBXZ2aILPBhrlEiPmrTJ9hzVLxVA73aWhp+Hhs6Krj HMAw== X-Gm-Message-State: AOAM530QWLt+sbMm1KDBChKmghKTB7CqaO3DbDJsLAe19NNp4yIz7p1y irb5pGanO+FW/mAZnmLIkgo= X-Received: by 2002:a05:6402:d05:b0:425:b5c8:faeb with SMTP id eb5-20020a0564020d0500b00425b5c8faebmr28352093edb.273.1653395043293; Tue, 24 May 2022 05:24:03 -0700 (PDT) Received: from [93.172.10.244] (93-172-10-244.bb.netvision.net.il. [93.172.10.244]) by smtp.gmail.com with ESMTPSA id e3-20020a170906648300b006f3ef214e12sm7197154ejm.120.2022.05.24.05.24.01 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 24 May 2022 05:24:02 -0700 (PDT) Message-ID: <628CCE44.6020007@gmail.com> Date: Tue, 24 May 2022 15:23:32 +0300 From: Eli Billauer User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.12) Gecko/20100907 Fedora/3.0.7-1.fc12 Thunderbird/3.0.7 MIME-Version: 1.0 To: Greg KH CC: Zheyu Ma , arnd@arndb.de, Linux Kernel Mailing List Subject: Re: [PATCH v2] char: xillybus: Check endpoint type before allocing References: <20220514114819.2773691-1-zheyuma97@gmail.com> <628BBEEB.9010306@gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23/05/22 20:15, Greg KH wrote: >> Rather, it works like this: The driver uses the EP 1 IN and OUT endpoints to >> > query the device for a data structure, which contains information on the >> > device's communication channels. The driver sets up device files >> > accordingly, and it also gets informed on which bulk OUT endpoints are >> > present. >> > >> > For what it's worth, I think it's fairly safe to assume that if a device >> > returns a legal data structure (which passes a CRC test), it's a XillyUSB >> > device. >> > Why? You still need to verify that the requested endpoints match up > with what the device really has. > OK. So to summarize: EP 1 IN and EP 1 OUT are always present in XillyUSB devices. On top of these, there might be additional bulk OUT endpoints. The driver resolves which ones in setup_channels(), by scanning a data blob it has received from the device. This takes place in the for-loop inside this function. When (out_desc & 0x80) is true for a given @i in the loop, the device has a bulk OUT endpoint with address i+2 (e.g. if this condition is met for i==2, the device has a bulk OUT EP 4). So it seems like setup_channels() would be the right place to make this check, since it's called during the device's probe. I guess it would likewise make sense to check for EP 1 IN and OUT in xillyusb_setup_base_eps(). Thanks, Eli