drivers/usbdev/gadget/f_mass_storage.c
int fmass_register_notify(void(*notify)(void *context, int status), void *context)
{
  int i;
  struct fmass_notify *f_notify = g_notify.notify;
  struct mtx *notify_mtx        = &g_notify.notify_mtx;

  fmass_notify_init();

  mtx_lock(notify_mtx);
  for (i = 0; i < MAX_NOFIFY_NUM ; i++)
    {
      if (f_notify[i].is_used == 0)
        {
          f_notify[i].is_used    = 1;
          f_notify[i].notifycb   = notify;
          f_notify[i].notifydata = context;
          break;
        }
    }
  mtx_unlock(notify_mtx);
  return (i < MAX_NOFIFY_NUM) ? (i) : (-1);
}
/* status 0: disconnect  1: connect */
status 0: disconnect  1: connect
status 0 : disconnect 1 : connect
int fmass_register_notify(void(*notify)(void *context, int status), void *context)
{
  int i;
  struct fmass_notify *f_notify = g_notify.notify;
  struct mtx *notify_mtx        = &g_notify.notify_mtx;
  fmass_notify_init();
  mtx_lock(notify_mtx);
  for (i = 0; i < MAX_NOFIFY_NUM ; i++)
    {
      if (f_notify[i].is_used == 0)
        {
          f_notify[i].is_used    = 1;
          f_notify[i].notifycb   = notify;
          f_notify[i].notifydata = context;
          break;
        }
    }
  mtx_unlock(notify_mtx);
  return (i < MAX_NOFIFY_NUM) ? (i) : (-1);
}
int fmass_register_notify ( void ( * notify ) ( void * context , int status ) , void * context ) { int i ; struct fmass_notify * f_notify = g_notify . notify ; struct mtx * notify_mtx = & g_notify . notify_mtx ; fmass_notify_init ( ) ; mtx_lock ( notify_mtx ) ; for ( i = 0 ; i < MAX_NOFIFY_NUM ; i ++ ) { if ( f_notify [ i ] . is_used == 0 ) { f_notify [ i ] . is_used = 1 ; f_notify [ i ] . notifycb = notify ; f_notify [ i ] . notifydata = context ; break ; } } mtx_unlock ( notify_mtx ) ; return ( i < MAX_NOFIFY_NUM ) ? ( i ) : ( -1 ) ; }
status 0: disconnect  1: connect
status 0 : disconnect 1 : connect