Benjamin Herrenschmidt <b...@kernel.crashing.org> writes:

> On Fri, 2018-07-27 at 08:38 +1000, Benjamin Herrenschmidt wrote:
>> On Thu, 2018-07-26 at 14:01 +0300, Felipe Balbi wrote:
>> > Hi,
>> > 
>> > Benjamin Herrenschmidt <b...@kernel.crashing.org> writes:
>> > > This is just RFC at this stage, I was getting annoyed at the 
>> > > once-per-seconddebug message about unsupported command when using 
>> > > f_mass_storage as a CDROM,so I quickly hacked that up.
>> > > I'm not clearing the events per-se, I'm just sending events based on 
>> > > thestate of pending unit attentions, which seems to be enough to please 
>> > > Linuxon the other side, but definitely needs more testing or expert 
>> > > opinions.
>> > > If I find some spare cycle in the next few weeks I might add a few 
>> > > moreof the basic MMC commands so we at least support everything Linux 
>> > > throwsat us for a normal read-only CDROM.
>> > > Comments ?
>> > > Not-Yet-Signed-off-by: Benjamin Herrenschmidt 
>> > > <b...@kernel.crashing.org>--- 
>> > > drivers/usb/gadget/function/f_mass_storage.c | 49 +++++++++++++++++++- 1 
>> > > file changed, 48 insertions(+), 1 deletion(-)
>> > > diff --git a/drivers/usb/gadget/function/f_mass_storage.c 
>> > > b/drivers/usb/gadget/function/f_mass_storage.cindex 
>> > > 7b13928077c9..d8c83359f470 100644--- 
>> > > a/drivers/usb/gadget/function/f_mass_storage.c+++ 
>> > > b/drivers/usb/gadget/function/f_mass_storage.c@@ -1390,6 +1390,42 @@ 
>> > > static int do_mode_select(struct fsg_common *common, struct fsg_buffhd 
>> > > *bh)    return -EINVAL; } +static int 
>> > > do_get_event_status_notification(struct fsg_common *common,+             
>> > >                              struct fsg_buffhd *bh)+{+   struct fsg_lun  
>> > > *curlun = common->curlun;+      u8              *buf = (u8 *) bh->buf;+ 
>> > > bool            media_class;+   u8              event;+ int             
>> > > size;++ /* We only support media class */+      media_class = 
>> > > (common->cmnd[4] & 0x10) != 0;++  /* We just mirror the unit attentions 
>> > > */+       if (curlun->unit_attention_data == 
>> > > SS_NOT_READY_TO_READY_TRANSITION)+           event = 2; /* New media */+ 
>> > >     else if (curlun->unit_attention_data == SS_MEDIUM_NOT_PRESENT)+      
>> > >    event = 3;+     else+           event = 0;++    /* Fill common header 
>> > > */+       size = 4;+      buf[3] = 0x10; /* Support classes: media */+   
>> > >  if (media_class) {+             buf[2] = 4; /* Return media event */+   
>> > >         if (event == 0)+                        buf[2] |= 0x80; /* No 
>> > > Event Available */+               size += 8;+             buf[4] = 
>> > > event;+                buf[5] = 1; /* Active */+               buf[6] = 
>> > > buf[7] = 0;+   } else {+               buf[2] = 0; /* None of the req. 
>> > > classes supported */+   }+      return size;+}  
>> > > /*-------------------------------------------------------------------------*/
>> > >  @@ -1753,7 +1789,8 @@ static int check_command(struct fsg_common 
>> > > *common, int cmnd_size,   */     if (curlun && 
>> > > curlun->unit_attention_data != SS_NO_SENSE &&         common->cmnd[0] != 
>> > > INQUIRY &&-          common->cmnd[0] != REQUEST_SENSE) {+            
>> > > common->cmnd[0] != REQUEST_SENSE &&+            common->cmnd[0] != 
>> > > GET_EVENT_STATUS_NOTIFICATION) {                 curlun->sense_data = 
>> > > curlun->unit_attention_data;               curlun->unit_attention_data = 
>> > > SS_NO_SENSE;              return -EINVAL;@@ -2025,6 +2062,16 @@ static 
>> > > int do_scsi_command(struct fsg_common *common)                     reply 
>> > > = do_write(common);               break; +        case 
>> > > GET_EVENT_STATUS_NOTIFICATION:+            common->data_size_from_cmnd 
>> > > =+                  get_unaligned_be16(&common->cmnd[7]);+          
>> > > reply = check_command(common, 10, DATA_DIR_TO_HOST,+                     
>> > >              (1 << 1) | (1 << 4) | (3 << 7) | (1 << 9),+                 
>> > >                     0, "GET_EVENT_STATUS_NOTIFICATION");+             if 
>> > > (reply == 0)+                        reply = 
>> > > do_get_event_status_notification(common, bh);+          break;+         
>> > > /*       * Some mandatory commands that we recognize but don't 
>> > > implement.        * They don't mean much in this setting.  It's left as 
>> > > an exercise
>> > 
>> > html + plain text? C'mon Ben :)
>> 
>> No idea what happened ... ugh :-)
>> 
>> I'll resend when I get a chance (travelling now).
>
> Odd, I re-checked my outbox and it was sent as a normal text-plain as
> usual ... not sure what's up. I'll send again anyway.

Headers may help, perhaps?

Return-Path: <b...@kernel.crashing.org>
X-Original-To: felipe.ba...@linux.intel.com
Delivered-To: felipe.ba...@linux.intel.com
Received: from linux.intel.com [10.54.29.200]
        by pipin with IMAP (fetchmail-6.3.26)
        for <balbi@localhost> (single-drop); Wed, 11 Jul 2018 09:09:28 +0300 
(EEST)
Received: from orsmga002.jf.intel.com (orsmga002.jf.intel.com [10.7.209.21])
        (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
        (No client certificate requested)
        by linux.intel.com (Postfix) with ESMTPS id 26A575802A9
        for <felipe.ba...@linux.intel.com>; Tue, 10 Jul 2018 23:12:09 -0700 
(PDT)
Received: from fmsmga105.fm.intel.com ([10.1.193.10])
  by orsmga002-1.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jul 
2018 23:12:08 -0700
IronPort-PHdr: =?us-ascii?q?9a23=3A57oslh0Vfn658EVIsmDT+DRfVm0co7zxezQtwd8Z?=
 =?us-ascii?q?seIUL/ad9pjvdHbS+e9qxAeQG9mDtbQc06L/iOPJYSQ4+5GPsXQPItRndiQuro?=
 =?us-ascii?q?EopTEmG9OPEkbhLfTnPGQQFcVGU0J5rTngaRAGUMnxaEfPrXKs8DUcBgvwNRZv?=
 =?us-ascii?q?JuTyB4Xek9m72/q99pHPYghEniaxba9vJxiqsAvdsdUbj5F/Iagr0BvJpXVIe+?=
 =?us-ascii?q?VSxWx2IF+Yggjx6MSt8pN96ipco/0u+dJOXqX8ZKQ4UKdXDC86PGAv5c3krgfM?=
 =?us-ascii?q?QA2S7XYBSGoWkx5IAw/Y7BHmW5r6ryX3uvZh1CScIMb7Vq4/Vyi84Kh3SR/okC?=
 =?us-ascii?q?YHOCA/8GHLkcx7kaZXrAu8qxBj34LYZYeYP+d8cKzAZ9MXXWlPUNtRWSJfDI2z?=
 =?us-ascii?q?c4wBAOUaMOlCs4XwvUEDoAGiCQSuAu7k1z9GhmXx3a0/y+ksDB/J3AoiH90UtX?=
 =?us-ascii?q?TUrdP1P7oQX++r1qnI1yvMb/VN2Tjh6IjIdxEhruyQXbltdsfe0lcgFwXFjliL?=
 =?us-ascii?q?qozqISmV1uITvGif9eZvSfivhHQ8qwFxozivwMgshpPOhoIPxVDJ7CN0y5s2K9?=
 =?us-ascii?q?2gUEN2YNCpHIFOuy2ENIZ6WN4uT3totSs4zLANpIS1czIQyJs9wh7Sc/yHfJaM?=
 =?us-ascii?q?4hLkTOuRLi13hG57d76lmxmy61Kvyvb8Vsm11lZKoTBJkt7WtnACzxDT686HRe?=
 =?us-ascii?q?Vh/kq52DuC2Rrf5v9aLU03j6bXNoQtz74ym5YLtETMBC72mEH4jK+McUUk//Cl?=
 =?us-ascii?q?5P/5bbXgpp+RLIx0hR/kMqQohMO/Bf40PRQUX2eB4uS81Lzj/Uv2QLlQif02iK?=
 =?us-ascii?q?bZvIjAJcsHvq65HxNV0oE75haxETim1NUYnWEZI15fYx2IlYzpNErPIP3jCfe/?=
 =?us-ascii?q?glKskCpkxvzcP73hBInNIWbHkLv7Ybl97Etcm0IPyoVb5pRJGvQcO/jbRED8rp?=
 =?us-ascii?q?rbAwU/PgjyxPzoTJ1T24cfQW/HKKadOqKa5VGF4uM3Lq+GbYsfuR75Kv4497jv?=
 =?us-ascii?q?i2M0nRkWeqz/jrUNb3XtNPlgIUycYHykotobC2oMpQE+Se3mlBXWWzNVZ16xUr?=
 =?us-ascii?q?g66zV9A5ivFofCQI/rh6aOinToVqZKb3xLXwjfWUzjcJ+JDrJVMHqf?=
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0DvAwB4n0VbfTkB5D9cHQEBBQELAYMbB?=
 =?us-ascii?q?IIMKIN6iGOLWpIvV4YxCxMYAYZvITcVAQIBAQEBAQECARMBARY6L4I1JAGDBgR?=
 =?us-ascii?q?ECWICXwESglVLgXMNBapkezMfhD2DdIE4iHyBVz+IZYM4glUCh2OKC4deCgmPJ?=
 =?us-ascii?q?oFDhA+CbIUiASuRZ4FXIYFTfQiDJIM2AQmNJS0wegEBii+CSAEB?=
X-IPAS-Result: =?us-ascii?q?A0DvAwB4n0VbfTkB5D9cHQEBBQELAYMbBIIMKIN6iGOLWpI?=
 =?us-ascii?q?vV4YxCxMYAYZvITcVAQIBAQEBAQECARMBARY6L4I1JAGDBgRECWICXwESglVLg?=
 =?us-ascii?q?XMNBapkezMfhD2DdIE4iHyBVz+IZYM4glUCh2OKC4deCgmPJoFDhA+CbIUiASu?=
 =?us-ascii?q?RZ4FXIYFTfQiDJIM2AQmNJS0wegEBii+CSAEB?=
X-IronPort-AV: E=Sophos;i="5.51,337,1526367600"; 
   d="scan'208,217";a="121505201"
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from gate.crashing.org ([63.228.1.57])
  by mtab.intel.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 10 Jul 2018 23:11:55 
-0700
Received: from localhost (localhost.localdomain [127.0.0.1])
        by gate.crashing.org (8.14.1/8.14.1) with ESMTP id w6B6Bhjr032022;
        Wed, 11 Jul 2018 01:11:45 -0500
Message-ID: <72657ec1625d63f32b44277fcc342d847955745f.ca...@kernel.crashing.org>
Subject: [RFC PATCH] usb: gadget: mass_storage: Add
 GET_EVENT_STATUS_NOTIFICATION
From: Benjamin Herrenschmidt <b...@kernel.crashing.org>
To: linux-usb@vger.kernel.org, Felipe Balbi <felipe.ba...@linux.intel.com>
Date: Wed, 11 Jul 2018 16:11:43 +1000
Content-Type: multipart/alternative; boundary="=-dlrkufCl6ITIlrpPcVLl"
X-Mailer: Evolution 3.28.3 (3.28.3-1.fc28) 
Mime-Version: 1.0

-- 
balbi

Attachment: signature.asc
Description: PGP signature

Reply via email to