From nobody Mon Sep 29 20:17:14 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C1A5C00140 for ; Tue, 16 Aug 2022 00:19:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352739AbiHPATP (ORCPT ); Mon, 15 Aug 2022 20:19:15 -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-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 wo= rk with Mac OS-X") Reviewed-by: Alan Stern Signed-off-by: Neal Liu Link: https://lore.kernel.org/r/20220628021436.3252262-1-neal_liu@aspeedtec= h.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/gad= get/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, s= truct fsg_buffhd *bh) u8 format; int i, len; =20 + format =3D common->cmnd[2] & 0xf; + if ((common->cmnd[1] & ~0x02) !=3D 0 || /* Mask away MSF */ - start_track > 1) { + (start_track > 1 && format !=3D 0x1)) { curlun->sense_data =3D SS_INVALID_FIELD_IN_CDB; return -EINVAL; } =20 - format =3D 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, str= uct fsg_buffhd *bh) format =3D (common->cmnd[9] >> 6) & 0x3; =20 switch (format) { - case 0: - /* Formatted TOC */ + case 0: /* Formatted TOC */ + case 1: /* Multi-session info */ len =3D 4 + 2*8; /* 4 byte header + 2 descriptors */ memset(buf, 0, len); buf[1] =3D len - 2; /* TOC Length excludes length field */ @@ -1250,7 +1251,7 @@ static int do_read_toc(struct fsg_common *common, str= uct fsg_buffhd *bh) return len; =20 default: - /* Multi-session, PMA, ATIP, CD-TEXT not supported/required */ + /* PMA, ATIP, CD-TEXT not supported/required */ curlun->sense_data =3D SS_INVALID_FIELD_IN_CDB; return -EINVAL; } --=20 2.35.1