From patchwork Mon Jan 16 07:59:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hayes Wang X-Patchwork-Id: 44016 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1071528wrn; Mon, 16 Jan 2023 00:02:46 -0800 (PST) X-Google-Smtp-Source: AMrXdXv9qUWBiyqlSOvD80ECAENRwaWrzi2JJk1/fW0AVElL4Y2Rv14ubRqXlYNerb6dGYttFK5R X-Received: by 2002:a05:6a00:1a:b0:58b:b93d:73ed with SMTP id h26-20020a056a00001a00b0058bb93d73edmr13713505pfk.3.1673856165996; Mon, 16 Jan 2023 00:02:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673856165; cv=none; d=google.com; s=arc-20160816; b=F2EKD0sDXBStHpQ1qkQ1fG1kHEJsDT4NGak047hj46iR5+xBsRmy2xQyYSrkt8zvps 2VNM1zM6PudHsl2zehuOgEzEFh+fQtgKjNRzo3FGZw794pc+RQQIcqLgvSHPgKTyoZvI 7VuqWj6F5auvA8/C/1QAf382KAaYtk7qsi6S8x9bSLyjnPkNldv4LGwWyffpxPAZpgme +Pw1NVxyPo4BYheUWsr5j3d6UjfU2SwllBveiQayv3dlIR2oukcQvPUApq2GhqXdfc2l ncuYez+U84liKKNZ8QHVT4Xe+vcOBVwS6gkeydPixuvAbEgNEFCGp4POhOWjIM95rFiC USnw== 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 :message-id:date:subject:cc:to:from:authenticated-by; bh=s7AHiXLFPyel6mCu3sipYAkulQdyklFrM63yi+p/eUo=; b=PLWnbmCCe/bMhuUuXqGaseq3dHX9s8qMWWX7598PWrPWyEXf2N6NiESMryUspuzAjW blvxKXVwovDSDCTuY1Fy5o0vCDpRI1uy3EfbR88YvwaiIxwL63mh6FpaJqlAQ0y1OLZ/ rE49QXMjRfk/i29PG2hdQdPQRjnJVA+zqXIOseeVxFALmKKeCRkWE/2jmS4qHBWDdOpN q0z16OLQAKh79NvI/TNzouy0M+NzMEorUxCRLg6XwQ+0rrAKoVz+0dFDKm4573+JMR56 MrHMi8Od53sfZIOp4UtXRrAsWi4FllU7bpBqkPbDOrx7d6n8pRmgnl1l2yaN+JpbFWPg 3NMQ== 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 f3-20020a056a00238300b005627f4b21absi31043631pfc.296.2023.01.16.00.02.34; Mon, 16 Jan 2023 00:02: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 S232149AbjAPIBy (ORCPT + 99 others); Mon, 16 Jan 2023 03:01:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232200AbjAPIBR (ORCPT ); Mon, 16 Jan 2023 03:01:17 -0500 Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AB1651205D; Mon, 16 Jan 2023 00:00:52 -0800 (PST) Authenticated-By: X-SpamFilter-By: ArmorX SpamTrap 5.77 with qID 30G806AA0003786, 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 30G806AA0003786 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=FAIL); Mon, 16 Jan 2023 16:00:06 +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; Mon, 16 Jan 2023 16:00:06 +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; Mon, 16 Jan 2023 16:00:05 +0800 From: Hayes Wang To: , , CC: , , , , Hayes Wang Subject: [PATCH net-next] r8152: avoid to change cfg for all devices Date: Mon, 16 Jan 2023 15:59:51 +0800 Message-ID: <20230116075951.1988-1-hayeswang@realtek.com> X-Mailer: git-send-email 2.38.1 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/16/2023 07:09: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?Q2xlYW4sIGJhc2VzOiAyMDIzLzEvMTYgpFekyCAwNjow?= =?big5_tw?b?MDowMA==?= 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?1755165403096264460?= 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 --- 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 66e70b5f8417..24be9449e4fc 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; @@ -9869,6 +9877,12 @@ static int rtl8152_cfgselector_probe(struct usb_device *udev) struct usb_host_config *c; int i, num_configs; + /* Swtich 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;