Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp4223538rwb; Mon, 16 Jan 2023 20:28:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXuBZuNOzeM8hHtsVgLKiikH2qySzhHwGE+HxP67Yzqjz5PLO1dHzLUBeKeDfAOFUGzLN0eR X-Received: by 2002:a05:6402:1c0c:b0:499:46c0:1269 with SMTP id ck12-20020a0564021c0c00b0049946c01269mr1587766edb.14.1673929697957; Mon, 16 Jan 2023 20:28:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673929697; cv=none; d=google.com; s=arc-20160816; b=bW2XorT3Dzm61Sh+ka6sBrsEeuvJIsT21er6rk4ot82jTFRNE/oyXqBgbVJLl5vnSo oKn2PBcdS7ywxhtKtL69NxuCPUO4i+rEhhOdYrHNSoQXk73JZ8VlYGlpl4YG41otHUkd TC6Nb/G2OVFKGSSm0eZl2emaRxtOOeoizljRAEA9r2rSrkxYJHKIPt1H5HX/pmxVc+ok BqGGv+IAF/bRjPsM7bYiryfqqcl4C8VGmHUMEnRUTrTnAF3EAKA+1vhSxrd7u2fD8Ogu JmJhUP1yo8R1ziPZ4zMYL8aJS1Cwf6nhfPZdrH769M9y0J81gTqA7kzhugOI/ajKbzMQ WCag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :authenticated-by; bh=AHe+9dfGfutw/cq3MGf9TRHmE5IdikP2CDfiROg9x64=; b=uJ1PDct/b20jypAkKVK7K4gRoZBtYYGpjv+X8ADUPX1jRmgPFlWIHc1a2D0QoOXNyY Tj5oX7lTDv7x0wUpPfiF/oCHDN7V0VPYj4Kv0n240rMZ+mLLcZWq31SH2CxV5heIBxS9 9whD/4nSIILnXJHeYpHTWjsabynHH/LtDJjIbRdE78k9LEZK4wXTYkwHiKT8b1mKbaJ9 WSR56r9A3kH/O2DZaemISPEKrbibeTH9Do3M6ESG69vXWMSZcnvznZOPU5ZRuxyyz3L/ UH5iKLTXjnkKQxd/k+fhdLfGA/cERaI+UcwbNByR9f3TurUu47DMpfW67nJhsYKv9f/n AkGw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f20-20020a056402355400b0049e28a9411bsi3372530edd.259.2023.01.16.20.28.06; Mon, 16 Jan 2023 20:28:17 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232024AbjAQDG2 (ORCPT + 49 others); Mon, 16 Jan 2023 22:06:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235296AbjAQDG1 (ORCPT ); Mon, 16 Jan 2023 22:06:27 -0500 Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3B4FD1D938; Mon, 16 Jan 2023 19:06:24 -0800 (PST) Authenticated-By: X-SpamFilter-By: ArmorX SpamTrap 5.77 with qID 30H35j5uA013582, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexh36506.realtek.com.tw[172.21.6.27]) by rtits2.realtek.com.tw (8.15.2/2.81/5.90) with ESMTPS id 30H35j5uA013582 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=FAIL); Tue, 17 Jan 2023 11:05:45 +0800 Received: from RTEXMBS04.realtek.com.tw (172.21.6.97) by RTEXH36506.realtek.com.tw (172.21.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.9; Tue, 17 Jan 2023 11:05:45 +0800 Received: from fc34.localdomain (172.22.228.98) by RTEXMBS04.realtek.com.tw (172.21.6.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Tue, 17 Jan 2023 11:05:44 +0800 From: Hayes Wang To: , CC: , , , , , Hayes Wang Subject: [PATCH net-next v2] r8152: avoid to change cfg for all devices Date: Tue, 17 Jan 2023 11:03:44 +0800 Message-ID: <20230117030344.4581-396-nic_swsd@realtek.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230116075951.1988-1-hayeswang@realtek.com> References: <20230116075951.1988-1-hayeswang@realtek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [172.22.228.98] X-ClientProxiedBy: RTEXH36505.realtek.com.tw (172.21.6.25) To RTEXMBS04.realtek.com.tw (172.21.6.97) X-KSE-ServerInfo: RTEXMBS04.realtek.com.tw, 9 X-KSE-AntiSpam-Interceptor-Info: trusted connection X-KSE-Antiphishing-Info: Clean X-KSE-Antiphishing-ScanningType: Deterministic X-KSE-Antiphishing-Method: None X-KSE-Antiphishing-Bases: 01/17/2023 02:42:00 X-KSE-AttachmentFiltering-Interceptor-Info: no applicable attachment filtering rules found X-KSE-Antivirus-Interceptor-Info: scan successful X-KSE-Antivirus-Info: =?big5?B?Q2xlYW4sIGJhc2VzOiAyMDIzLzEvMTYgpFWkyCAxMTozOTowMA==?= X-KSE-BulkMessagesFiltering-Scan-Result: protection disabled X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS 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 The rtl8152_cfgselector_probe() should set the USB configuration to the vendor mode only for the devices which the driver (r8152) supports. Otherwise, no driver would be used for such devices. Fixes: ec51fbd1b8a2 ("r8152: add USB device driver for config selection") Signed-off-by: Hayes Wang --- v2: fix a typo for the comment. drivers/net/usb/r8152.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index a26d3127a4fe..4c5c1df5d7a4 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -9500,9 +9500,8 @@ static int rtl_fw_init(struct r8152 *tp) return 0; } -u8 rtl8152_get_version(struct usb_interface *intf) +static u8 __rtl_get_hw_ver(struct usb_device *udev) { - struct usb_device *udev = interface_to_usbdev(intf); u32 ocp_data = 0; __le32 *tmp; u8 version; @@ -9571,10 +9570,19 @@ u8 rtl8152_get_version(struct usb_interface *intf) break; default: version = RTL_VER_UNKNOWN; - dev_info(&intf->dev, "Unknown version 0x%04x\n", ocp_data); + dev_info(&udev->dev, "Unknown version 0x%04x\n", ocp_data); break; } + return version; +} + +u8 rtl8152_get_version(struct usb_interface *intf) +{ + u8 version; + + version = __rtl_get_hw_ver(interface_to_usbdev(intf)); + dev_dbg(&intf->dev, "Detected version 0x%04x\n", version); return version; @@ -9870,6 +9878,12 @@ static int rtl8152_cfgselector_probe(struct usb_device *udev) struct usb_host_config *c; int i, num_configs; + /* Switch the device to vendor mode, if and only if the vendor mode + * driver supports it. + */ + if (__rtl_get_hw_ver(udev) == RTL_VER_UNKNOWN) + return 0; + /* The vendor mode is not always config #1, so to find it out. */ c = udev->config; num_configs = udev->descriptor.bNumConfigurations; -- 2.38.1