11// Copyright 2011-2021 Tyler Gilbert and Stratify Labs, Inc; see LICENSE.md
22
3-
43#include <errno.h>
54#include <fcntl.h>
65#include <stddef.h>
@@ -247,9 +246,17 @@ int fifo_close(const devfs_handle_t *handle) {
247246 return fifo_close_local (config , state );
248247}
249248
250- int fifo_open_local (const fifo_config_t * config , fifo_state_t * state ) { return 0 ; }
249+ int fifo_open_local (const fifo_config_t * config , fifo_state_t * state ) {
250+ MCU_UNUSED_ARGUMENT (config );
251+ MCU_UNUSED_ARGUMENT (state );
252+ return 0 ;
253+ }
251254
252- int fifo_close_local (const fifo_config_t * config , fifo_state_t * state ) { return 0 ; }
255+ int fifo_close_local (const fifo_config_t * config , fifo_state_t * state ) {
256+ MCU_UNUSED_ARGUMENT (config );
257+ MCU_UNUSED_ARGUMENT (state );
258+ return 0 ;
259+ }
253260
254261int fifo_ioctl_local (
255262 const fifo_config_t * config ,
@@ -288,6 +295,14 @@ int fifo_ioctl_local(
288295 fifo_data_transmitted (config , state ); // something might be waiting to write the fifo
289296 return 0 ;
290297 case I_FIFO_SETATTR :
298+
299+ if ( attr -> o_flags & FIFO_FLAG_INIT ){
300+ state -> transfer_handler .read = NULL ;
301+ state -> transfer_handler .write = NULL ;
302+ fifo_flush (state );
303+ fifo_data_transmitted (config , state ); // something might be waiting to write the fifo
304+ }
305+
291306 if (attr -> o_flags & FIFO_FLAG_SET_WRITEBLOCK ) {
292307 if (attr -> o_flags & FIFO_FLAG_IS_OVERFLOW ) {
293308 fifo_set_writeblock (state , 0 );
@@ -301,6 +316,7 @@ int fifo_ioctl_local(
301316 fifo_data_transmitted (config , state ); // something might be waiting to write the
302317 // fifo
303318 }
319+
304320 return 0 ;
305321 }
306322 return SYSFS_SET_RETURN (EINVAL );
0 commit comments