Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3557239iog; Mon, 27 Jun 2022 19:57:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uT/LTMeTO6Zo/nMj+Jx4nBkUlZGvohhqgZH2E+B6KY6GbfD+qEr/RArX3w1O9HvxIfJDAk X-Received: by 2002:a05:6402:4411:b0:437:b723:72 with SMTP id y17-20020a056402441100b00437b7230072mr93889eda.38.1656385025082; Mon, 27 Jun 2022 19:57:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656385025; cv=none; d=google.com; s=arc-20160816; b=sV1or5DqJMHumCMi5R2BtwYeH20feSWH0kAbKoBqIs5ZG6khjyvB7s+4EQ7YK3W45R 1YyqZ3iroH322nz86NPn8H/EhMhgiFd48+6xbtLKDdntJUs4MGTN2Zm3cklVvHIZd0JN 5S5wXdNs6+rM3PEFZXb6YSc1+y64wO9l0Bz07VIVI15N0YHHGvecLqHS5vLUzPjkrElT Hs5fPiBRkPHienG7JgzoSDNZwebXfJ5LVZ1GuBitTluQ43pNzyuqaSCl6ixOAVrIb6mz dXHP9Pspyxy4elpn+nXdlHczdTaQYiLIXSeY8g83LVfbUXt6Ozvep8+klA59CB5NVq/G K6aQ== 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; bh=XW3c1ZLuo7ll1pyLufCfHugNZYh9hoVVzaFVnsksXPg=; b=c+prPfrz6rSKAe/Glbjx61RUFIiYofyNb2Kv5c6SnjmC1jxQJoz1KQ0yByo7EL81sM mYb6THSw0lcikBvhE34X/e+m5Hw1dlwr4BTUDuBG2vHBWhQHoSmEKoUMVxIgJpTGDWlk 8JgG5cmQbM3QoUkLiZDJTPYtlgx9HdTEZcduc/l026xnxLRfUyhUz/S7+5BdzrTc3VJb wa66uZGgLkpUs0+pithlZCksecLWy8LNPhmN83NGxLn5jzEEZ2wCMriMEj+Ujzo+ph/9 jDkLGZladjyCuNp7k2wQr6Zp3DOLLTEzhpOSYP56ssrDmqtd6SL6pycC4IMufd+dzok1 EcZg== 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 nb13-20020a1709071c8d00b006f3dae85820si14397540ejc.472.2022.06.27.19.56.39; Mon, 27 Jun 2022 19:57:05 -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; 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 S242992AbiF1CRP (ORCPT + 99 others); Mon, 27 Jun 2022 22:17:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241900AbiF1CRO (ORCPT ); Mon, 27 Jun 2022 22:17:14 -0400 Received: from twspam01.aspeedtech.com (twspam01.aspeedtech.com [211.20.114.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0BC623146; Mon, 27 Jun 2022 19:17:06 -0700 (PDT) Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 25S1wfO2055689; Tue, 28 Jun 2022 09:58:41 +0800 (GMT-8) (envelope-from neal_liu@aspeedtech.com) Received: from localhost.localdomain (192.168.10.10) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 28 Jun 2022 10:14:40 +0800 From: Neal Liu To: Felipe Balbi , Greg Kroah-Hartman , Alan Stern CC: Roger Quadros , Miaohe Lin , Wesley Cheng , "Eric W . Biederman" , Matthew Wilcox , Nikita Yushchenko , Cai Huoqing , , , Subject: [PATCH v3] usb: gadget: f_mass_storage: Make CD-ROM emulation works with Windows OS Date: Tue, 28 Jun 2022 10:14:36 +0800 Message-ID: <20220628021436.3252262-1-neal_liu@aspeedtech.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [192.168.10.10] X-ClientProxiedBy: TWMBX02.aspeed.com (192.168.0.24) To TWMBX02.aspeed.com (192.168.0.24) X-DNSRBL: X-MAIL: twspam01.aspeedtech.com 25S1wfO2055689 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS, T_SCC_BODY_TEXT_LINE,T_SPF_HELO_TEMPERROR 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 Add read TOC with format 1 to support CD-ROM emulation with Windows OS. This patch is tested on Windows OS Server 2019. Fixes: 89ada0fe669a ("usb: gadget: f_mass_storage: Make CD-ROM emulation work with Mac OS-X") Signed-off-by: Neal Liu --- v3: - ignore start_track value with format 1 - add fixes tags - revise comments properly v2: - revise comments drivers/usb/gadget/function/f_mass_storage.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c index 3a77bca0ebe1..e884f295504f 100644 --- a/drivers/usb/gadget/function/f_mass_storage.c +++ b/drivers/usb/gadget/function/f_mass_storage.c @@ -1192,13 +1192,14 @@ static int do_read_toc(struct fsg_common *common, struct fsg_buffhd *bh) u8 format; int i, len; + format = common->cmnd[2] & 0xf; + if ((common->cmnd[1] & ~0x02) != 0 || /* Mask away MSF */ - start_track > 1) { + (start_track > 1 && format != 0x1)) { curlun->sense_data = SS_INVALID_FIELD_IN_CDB; return -EINVAL; } - format = common->cmnd[2] & 0xf; /* * Check if CDB is old style SFF-8020i * i.e. format is in 2 MSBs of byte 9 @@ -1208,8 +1209,8 @@ static int do_read_toc(struct fsg_common *common, struct fsg_buffhd *bh) format = (common->cmnd[9] >> 6) & 0x3; switch (format) { - case 0: - /* Formatted TOC */ + case 0: /* Formatted TOC */ + case 1: /* Multi-session info */ len = 4 + 2*8; /* 4 byte header + 2 descriptors */ memset(buf, 0, len); buf[1] = len - 2; /* TOC Length excludes length field */ @@ -1250,7 +1251,7 @@ static int do_read_toc(struct fsg_common *common, struct fsg_buffhd *bh) return len; default: - /* Multi-session, PMA, ATIP, CD-TEXT not supported/required */ + /* PMA, ATIP, CD-TEXT not supported/required */ curlun->sense_data = SS_INVALID_FIELD_IN_CDB; return -EINVAL; } -- 2.25.1