Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3090171rwb; Mon, 15 Aug 2022 17:53:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR6P7jAwXt1CYlUT68SYEf4UZ60HVhyFAArEX0EKKeaSkSryowY0ZU4HwRZODc3Ysftuk3p8 X-Received: by 2002:a17:907:c14:b0:730:9d15:c9bc with SMTP id ga20-20020a1709070c1400b007309d15c9bcmr12150723ejc.752.1660611195754; Mon, 15 Aug 2022 17:53:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611195; cv=none; d=google.com; s=arc-20160816; b=o9xQ6maiJ0D4H/uiq9CW1E94jXkdQ+5omsgozoDhob19RyYVJZ/IlCOoGSiV7RYP43 mARL0Z5egQz3CkDHRhx1LupCPHAt/xyIYre6Xvs6BIuouDdSvTZ6vdL9895LgHgZOQuy UPwrmcKSOVQKbfwkYq3QjdcJlLEiPl3+6OAh0UKpnszQKRnHDJ0h12t82XNWtHYczojJ uZyJ6XG1BhW6i/jyStyU93/ycre8BP9oxJ0n8pA5a3v5+4WajKWOZ5xatgwPY5qgsTIV EgduELYgkrbCoBvyZWoHgOcpzpBRLSZlZfqY3DunJlrMxoa0MN4LsteOmqZFrobOI1qT 9D5w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uJpgDo7Xtymt7EFQRcLDjdEc022zVedrr2JcpZLcmMc=; b=Tgt1R7xeZfeinu4ddZdY3KHTokaSln0TYLjwcXBJvwmgU82cy06g8Z0kalJrWbvV+e zizDHHn0LYKH//UxDqb1wIedvPn0mAO15L/vElE0c/1ocDZZsgBkkROF+Nefm4697xGq XpM9mXvj1rZhpjdM9POQNK9M4BB/K+ilgdUlEQbRU5Vf3vZblfkBq2An61dTmeEd9wtM nGsXtnVNAVoec+pOqpi+tGfMuDWfJTeEZVUwePIxX4Iq9vbjT3LS5bGvnyNsAADkPHZu tysDTmTytEeZEQHTYKpQrOmkRrpcCbyuvVG8x7IHAGpQiOy+05Jcxv9P1gR0i07sboS3 EkEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WNsdW8JY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c11-20020a056402120b00b00443e3eed926si2112540edw.185.2022.08.15.17.52.51; Mon, 15 Aug 2022 17:53:15 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WNsdW8JY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350835AbiHPATO (ORCPT + 99 others); Mon, 15 Aug 2022 20:19:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357013AbiHPAM5 (ORCPT ); Mon, 15 Aug 2022 20:12:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2DD1175E17; Mon, 15 Aug 2022 13:29:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9239761135; Mon, 15 Aug 2022 20:29:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8259DC433D6; Mon, 15 Aug 2022 20:29:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660595384; bh=8xVoADYwIv4LNKJ9F7p8sP2HeEkSfNtj+oTvGTxCvuo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WNsdW8JYTkMpXfD3WD/77FBrPUfbDYD7NZBPPP/AdPbkAbx4uGQ+KJhRHfk00+E+A VQ1AqBhFgFDK5TlSlmoD5bji6obzFKb8sLZPlLS28RKTkHqbvwLXnUIpPinNIP8jpj zSceSbxcPKunym3MDPpPvMCw3Sqey3PELcHX5qEg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , Neal Liu , Sasha Levin Subject: [PATCH 5.19 0747/1157] usb: gadget: f_mass_storage: Make CD-ROM emulation works with Windows OS Date: Mon, 15 Aug 2022 20:01:43 +0200 Message-Id: <20220815180509.347232682@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Neal Liu [ Upstream commit 3b91edd624ab1ab694deef513a45eb9e9d49d75f ] 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") Reviewed-by: Alan Stern Signed-off-by: Neal Liu Link: https://lore.kernel.org/r/20220628021436.3252262-1-neal_liu@aspeedtech.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- 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.35.1