usb: gadget: f_mass_storage: Stop ums on START-STOP UNIT SCSI command
PATCH 1/1 usb: gadget: f_mass_storage: Stop ums on START-STOP UNIT SCSI command
Exit the UMS handler loop in case START-STOP UNIT SCSI command is received. This is sent e.g. by the util-linux eject(1) command and indicates to the device that it is supposed to spin down the media and enter low power state.
This effectively adds support for exitting the 'ums' command from host using 'eject /dev/sdN' that is on par with 'dfu-util -e' .
---
Cc: Lukasz Majewski <[email protected]>
Cc: Mattijs Korpershoek <[email protected]>
--- drivers/usb/gadget/f_mass_storage.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/gadget/f_mass_storage.c +7 -0
@@ -327,6 +327,7 @@ struct fsg_common { unsigned int short_packet_received:1; unsigned int bad_lun_okay:1; unsigned int running:1; + unsigned int eject:1;int thread_wakeup_needed;struct completion thread_notifier;
@@ -669,6 +670,10 @@ static int sleep_thread(struct fsg_common *common) }if (k ==10 ) { +/* Handle START-STOP UNIT */ +if (common->eject) +return -EPIPE ; +/* Handle CTRL+C */ if (ctrlc ())return -EPIPE ;
@@ -1325,6 +1330,8 @@ static int do_start_stop(struct fsg_common *common)return -EINVAL ; } + common->eject =1 ; +return 0 ; }
Signature · 1 line
2.42.0
Hi Marek,
Thank you for your patch.
Quoted 9 lines · Marek Vasut
Exit the UMS handler loop in case START-STOP UNIT SCSI command is received. This is sent e.g. by the util-linux eject(1) command and indicates to the device that it is supposed to spin down the media and enter low power state.
This effectively adds support for exitting the 'ums' command from host using 'eject
/dev/sdN' that is on par with 'dfu-util -e' .Signed-off-by Marek Vasut <[email protected]>
Quoted 41 lines
---
Cc: Lukasz Majewski <[email protected]>
Cc: Mattijs Korpershoek <[email protected]>--- drivers/usb/gadget/f_mass_storage.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/usb/gadget/f_mass_storage.c +7
-0@@ -327,6 +327,7 @@ struct fsg_common { unsigned int short_packet_received:1; unsigned int bad_lun_okay:1; unsigned int running:1; + unsigned int eject:1;int thread_wakeup_needed;struct completion thread_notifier;@@ -669,6 +670,10 @@ static int sleep_thread(struct fsg_common *common) }if (k ==10 ) { +/* Handle START-STOP UNIT */ +if (common->eject) +return -EPIPE ; +/* Handle CTRL+C */ if (ctrlc ())return -EPIPE ;@@ -1325,6 +1330,8 @@ static int do_start_stop(struct fsg_common *common)return -EINVAL ; } + common->eject =1 ; +return 0 ; }Signature · 1 line
2.42.0
Hi,
Quoted 9 lines · Marek Vasut
Exit the UMS handler loop in case START-STOP UNIT SCSI command is received. This is sent e.g. by the util-linux eject(1) command and indicates to the device that it is supposed to spin down the media and enter low power state.
This effectively adds support for exitting the 'ums' command from host using 'eject
/dev/sdN' that is on par with 'dfu-util -e' .[...]
Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-dfu (u-boot-dfu-next)
[1/1] usb: gadget: f_mass_storage: Stop ums on START-STOP UNIT SCSI command
https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/957e96e9fcccf26a2fe4101adbd6681578346460
--
Mattijs