Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1954346ima; Thu, 25 Oct 2018 07:31:24 -0700 (PDT) X-Google-Smtp-Source: AJdET5fg8lBYX+jy70vbctiJ6GuaGLf4YfZWL+OaIxG2MkzDxqYpWKJYOghyTxzKhIzlejHwGYap X-Received: by 2002:a65:664e:: with SMTP id z14-v6mr1622737pgv.347.1540477884167; Thu, 25 Oct 2018 07:31:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540477884; cv=none; d=google.com; s=arc-20160816; b=DgCWCt7kAdGZ6/r1BJNCSQRYjl+UMyMMmMvdQnTNv7J69Hz9EAVmGSQRs+0wqcp5oN SstFwf9eUBL0CbL71+JfluMc5w7UabfyDZ32+8L5DbjH4uGo/1DdbmCaCSNKw0V9e/nZ gnAJLADqr46Wla+PqXvbBdAQeVtNmzcv/uQLiEr544VsK9ptjyEtVo+LgdG5fIeMMWi1 PG4vFmQOKtgi6S4pi6ZC1cuOF+bN69hql1MnujYwUM07Giui5563skyPE6fzhT0RHL0f NnpWtuPdsOXEfITdx+IkMwqaqLq5nAjp5GDryLdUP2uYhXFPL4FM1kH1F9YMeU8492Eq ffmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vt/F0H+TWfhav0z0B7uP+mGJVzvKbB9anCbUE0ed8vQ=; b=Vjz1EZKX1ImIUCnN+OcerePkv0b/C5BFbJW0CihBQ9kgJ+0mN9FjCO0el6Xp6+Hqd7 GIZrbO8l0UHLy5YheX2ZK9kRB3fUWOwkNNSpI01h452rKLcUFK3uqCNPHC51zTH7RKMt 8gjE+k4nvJXnBPItfpnpkq8r7xOnzjQGXrHWSxMP7Vh2N0feAgWPzCygpfrjCC37ymA1 yBhgGZb3d4CLzxXz41LAxIdOsS3B5qlnerAUda8cYrxHraPQhN6kTHdOQyhT633bsvu7 CjA6yAquncaQqPWn7qDmftykcRUfVHHF4Yl5UAHjNkJ/VUfW0ApekGN8koxOgP3dlBep enlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EGg0tb2t; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y19-v6si8400454pgj.442.2018.10.25.07.30.51; Thu, 25 Oct 2018 07:31:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EGg0tb2t; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730333AbeJYWwE (ORCPT + 99 others); Thu, 25 Oct 2018 18:52:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:33846 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730290AbeJYWwC (ORCPT ); Thu, 25 Oct 2018 18:52:02 -0400 Received: from sasha-vm.mshome.net (unknown [167.98.65.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AA86F2086D; Thu, 25 Oct 2018 14:19:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540477144; bh=jUDEOz+4hOjFo/kCO84R5YCx+Dn+pkLtkURv9wqVWMM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EGg0tb2taqpJeaHYYO0bJPO1PCSv4vxQbIn6Jg179Io+7uSFP11c45H6Sfqpgca6Z wj/n9I+Q6pwZAzhZyzknxPBV0mKjrO0oDuAcKpPcnzPaXPoQCSrc1Wr30V3hR8kzRS ONkhJOJCJTPn0l6rQVOYh+CZ5LPdaTA+T5oSa/O8= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Bj=C3=B8rn=20Mork?= , Johan Hovold , Sasha Levin Subject: [PATCH AUTOSEL 3.18 04/98] USB: qcserial: Fix support for HP lt4112 LTE/HSPA+ Gobi 4G Modem Date: Thu, 25 Oct 2018 10:17:19 -0400 Message-Id: <20181025141853.214051-4-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025141853.214051-1-sashal@kernel.org> References: <20181025141853.214051-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bjørn Mork [ Upstream commit 59536da34513c594af2a6fd35ba65ea45b6960a1 ] The DEVICE_HWI type was added under the faulty assumption that Huawei devices based on Qualcomm chipsets and firmware use the static USB interface numbering known from Gobi devices. But this model does not apply to Huawei devices like the HP branded lt4112 (Huawei me906e). Huawei firmwares will dynamically assign interface numbers. Functions are renumbered when the firmware is reconfigured. Fix by changing the DEVICE_HWI type to use a simplified version of Huawei's subclass + protocol scheme: Blacklisting known network interface combinations and assuming the rest are serial. Reported-and-tested-by: Muri Nicanor Tested-by: Martin Hauke Cc: Fixes: e7181d005e84 ("USB: qcserial: Add support for HP lt4112 LTE/HSPA+ Gobi 4G Modem") Signed-off-by: Bjørn Mork Signed-off-by: Johan Hovold Signed-off-by: Sasha Levin --- drivers/usb/serial/qcserial.c | 54 ++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c index adc372411019..7e8014304b33 100644 --- a/drivers/usb/serial/qcserial.c +++ b/drivers/usb/serial/qcserial.c @@ -190,6 +190,10 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id) __u8 ifnum; int altsetting = -1; + /* we only support vendor specific functions */ + if (intf->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC) + goto done; + nintf = serial->dev->actconfig->desc.bNumInterfaces; dev_dbg(dev, "Num Interfaces = %d\n", nintf); ifnum = intf->desc.bInterfaceNumber; @@ -309,29 +313,39 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id) break; case QCSERIAL_HWI: /* - * Huawei layout: - * 0: AT-capable modem port - * 1: DM/DIAG - * 2: AT-capable modem port - * 3: CCID-compatible PCSC interface - * 4: QMI/net - * 5: NMEA + * Huawei devices map functions by subclass + protocol + * instead of interface numbers. The protocol identify + * a specific function, while the subclass indicate a + * specific firmware source + * + * This is a blacklist of functions known to be + * non-serial. The rest are assumed to be serial and + * will be handled by this driver */ - switch (ifnum) { - case 0: - case 2: - dev_dbg(dev, "Modem port found\n"); - break; - case 1: - dev_dbg(dev, "DM/DIAG interface found\n"); - break; - case 5: - dev_dbg(dev, "NMEA GPS interface found\n"); - break; - default: - /* don't claim any unsupported interface */ + switch (intf->desc.bInterfaceProtocol) { + /* QMI combined (qmi_wwan) */ + case 0x07: + case 0x37: + case 0x67: + /* QMI data (qmi_wwan) */ + case 0x08: + case 0x38: + case 0x68: + /* QMI control (qmi_wwan) */ + case 0x09: + case 0x39: + case 0x69: + /* NCM like (huawei_cdc_ncm) */ + case 0x16: + case 0x46: + case 0x76: altsetting = -1; break; + default: + dev_dbg(dev, "Huawei type serial port found (%02x/%02x/%02x)\n", + intf->desc.bInterfaceClass, + intf->desc.bInterfaceSubClass, + intf->desc.bInterfaceProtocol); } break; default: -- 2.17.1