From patchwork Tue Jan 17 03:03:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hayes Wang X-Patchwork-Id: 44477 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1534994wrn; Mon, 16 Jan 2023 19:23:45 -0800 (PST) X-Google-Smtp-Source: AMrXdXuZY2KRSr54ZBXkq2XxC6cmRTtAJHdzM0xcWaGoVWFwRN/cUSvJbmsyY0EBcTLqUvuQi9vH X-Received: by 2002:a05:6a20:8f0f:b0:b8:5515:9004 with SMTP id b15-20020a056a208f0f00b000b855159004mr1967875pzk.8.1673925825554; Mon, 16 Jan 2023 19:23:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673925825; cv=none; d=google.com; s=arc-20160816; b=g9QidSTsguSNhc5kby0s0tQKXNLvY05Gjf+VbOuZlY8JAKame/OWPgtbOPTRdj4A+o 5YoK2lfcn1tTe6yTqdT6FaLGUhIzhWSfzkt9K7gn23gexEFHXGJjF9916Aro8vAeAleD Q39torWxNLCye6uYX46s1J2Ck4AzPZnhJmbKtM+1Dq+OLPX+wCIoe3jPIz50HYE9G5t8 KfLGW+tZzLDW0HHY8CRXs+3QNW1hues2fjSKrzucJj/yMwWmHZNsJD4Uu9NFSZmZBkUK srw7J3I0+126gIY+DPpPIGzjDj24APoCXgbLC0ILOqJbHREieVbh9r31e+6WyCLgkx4q ZdeA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g27-20020a63521b000000b00491ad1ca2f2si30478303pgb.835.2023.01.16.19.23.28; Mon, 16 Jan 2023 19:23:45 -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 + 99 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 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_tw?b?Q2xlYW4sIGJhc2VzOiAyMDIzLzEvMTYgpFWkyCAxMToz?= =?big5_tw?b?OTowMA==?= 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755165403096264460?= X-GMAIL-MSGID: =?utf-8?q?1755238446434353542?= 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 Reviewed-by: Simon Horman --- 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;