Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4061462iog; Tue, 28 Jun 2022 08:14:27 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s/RUMMLmtxdjy3dkPPGW9M/mSZ5gxMqr8G8qgbwHT80s9Bs/Lb9klO/wcBSZOJc8uAGBJc X-Received: by 2002:a17:90b:3148:b0:1ed:75:47b with SMTP id ip8-20020a17090b314800b001ed0075047bmr101249pjb.9.1656429267647; Tue, 28 Jun 2022 08:14:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656429267; cv=none; d=google.com; s=arc-20160816; b=ggsDXs6tfkRg8VcUEqM3p4ppT1y49Yki3dG5JxEdun/HO0gNoIXhZzqnitDTiEvJ4a +3pN4uV9qn8JgMGAa0A/EJ+ILVi03Sv1B3MzYaYeG7ZtvfJDZakbIZgZvjTBvCy8xgcK T5bdAvL6NHc3+px5wewl7gajtnVuriLMf3cF7aqoaSAtMJ743vYqpTW99HuArLzUG68H upwv0TW8L8r5KiCXhPccdQVfERZlr9hFUFdR9ajVmtuP4G97+7FsLlPsqXiTCc3tYPT8 wdQjGphNU0tQrAmtIlLo+3ajOEqnvW6Q2CVz1FpT1a/BwrI5JDO3h9TYLUGRVBfdEuzO zDjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=lZy8i7KIPgbieS1FjKYhcC+kAsbrgR2/HvDLJ+CEUEw=; b=bpdms5wNPkTiBovSJk7TRASAsNdVIyNhj2nzwLUjqp9899+B4R3Hs8mMzqJiIFGPfY XlJT1dCiiBkHaC3JtXdXBJ8Cv4TaF+f4+DjFjQdwpyhIoaPyEzy4YDrq/85d1BKeDcOf Z2/w9kUOX6LCWzMfSyElOT+2TlVk7ZHP0OHNeYHegOS2wRB3y1nSJHEUKN19lPGbdk+W DlR8wOezHHyb7EzvNXIMmQhgkjQFB4T6AdmCYH9VhXEpHagq4zJ8nfhlEBL3qS1Z943d v6IT+VjJPYl1hNKhr6hLBQ9cWqDvB9p/7KQtmgP7kkYPs+270ENK/8pcrjAyjeyLOua9 9bWg== 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 j185-20020a638bc2000000b0040cf5d7ec8csi16869278pge.269.2022.06.28.08.14.14; Tue, 28 Jun 2022 08:14:27 -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 S232060AbiF1OwI (ORCPT + 99 others); Tue, 28 Jun 2022 10:52:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237068AbiF1OwG (ORCPT ); Tue, 28 Jun 2022 10:52:06 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id DEE3732062 for ; Tue, 28 Jun 2022 07:52:05 -0700 (PDT) Received: (qmail 156938 invoked by uid 1000); 28 Jun 2022 10:52:05 -0400 Date: Tue, 28 Jun 2022 10:52:05 -0400 From: Alan Stern To: Neal Liu Cc: Felipe Balbi , Greg Kroah-Hartman , Roger Quadros , Miaohe Lin , Wesley Cheng , "Eric W . Biederman" , Matthew Wilcox , Nikita Yushchenko , Cai Huoqing , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, BMC-SW@aspeedtech.com Subject: Re: [PATCH v3] usb: gadget: f_mass_storage: Make CD-ROM emulation works with Windows OS Message-ID: References: <20220628021436.3252262-1-neal_liu@aspeedtech.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220628021436.3252262-1-neal_liu@aspeedtech.com> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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 On Tue, Jun 28, 2022 at 10:14:36AM +0800, Neal Liu wrote: > 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 > --- Reviewed-by: Alan Stern > 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 >