kernels/linux-2.4.0/net/irda/irnet/irnet_irda.c
/*------------------------------------------------------------------*/
/*
 * Post an event to the control channel...
 * Put the event in the log, and then wait all process blocked on read
 * so they can read the log...
 */
Post an event to the control channel
Put the event in the log, and then wait all process blocked on read
so they can read the log
Post an event to the control channel Put the event in the log and then wait all process blocked on read so they can read the log
static void
irnet_post_event(irnet_socket *	ap,
		 irnet_event	event,
		 __u32		addr,
		 char *		name)
{
  unsigned long		flags;		
  int			index;		
  DENTER(CTRL_TRACE, "(ap=0x%X, event=%d, addr=%08x, name=``%s'')\n",
	 (unsigned int) ap, event, addr, name);
  spin_lock_irqsave(&irnet_events.spinlock, flags);
  index = irnet_events.index;
  irnet_events.log[index].event = event;
  irnet_events.log[index].addr = addr;
  if(name)
    strcpy(irnet_events.log[index].name, name);
  else
    irnet_events.log[index].name[0] = '\0';
  if((ap != (irnet_socket *) NULL) && (ap->ppp_open))
    irnet_events.log[index].unit = ppp_unit_number(&ap->chan);
  else
    irnet_events.log[index].unit = -1;
  irnet_events.index = (index + 1) % IRNET_MAX_EVENTS;
  DEBUG(CTRL_INFO, "New event index is %d\n", irnet_events.index);
  spin_unlock_irqrestore(&irnet_events.spinlock, flags);
  wake_up_interruptible_all(&irnet_events.rwait);
  DEXIT(CTRL_TRACE, "\n");
}
static void irnet_post_event ( irnet_socket * ap , irnet_event event , __u32 addr , char * name ) { unsigned long flags ; int index ; DENTER ( CTRL_TRACE , " \n " , ( unsigned int ) ap , event , addr , name ) ; spin_lock_irqsave ( & irnet_events . spinlock , flags ) ; index = irnet_events . index ; irnet_events . log [ index ] . event = event ; irnet_events . log [ index ] . addr = addr ; if ( name ) strcpy ( irnet_events . log [ index ] . name , name ) ; else irnet_events . log [ index ] . name [ 0 ] = ' \0 ' ; if ( ( ap != ( irnet_socket * ) NULL ) && ( ap -> ppp_open ) ) irnet_events . log [ index ] . unit = ppp_unit_number ( & ap -> chan ) ; else irnet_events . log [ index ] . unit = -1 ; irnet_events . index = ( index + 1 ) % IRNET_MAX_EVENTS ; DEBUG ( CTRL_INFO , " \n " , irnet_events . index ) ; spin_unlock_irqrestore ( & irnet_events . spinlock , flags ) ; wake_up_interruptible_all ( & irnet_events . rwait ) ; DEXIT ( CTRL_TRACE , " \n " ) ; }
Post an event to the control channel...
Post an event to the control channel ...
/* For spinlock */ /* In the log */ /* Protect this section via spinlock.
   * Note : as we are the only event producer, we only need to exclude
   * ourself when touching the log, which is nice and easy.
   */ /* Copy the event in the log */ /* Try to copy IrDA nickname */ /* Try to get ppp unit number */ /* Increment the index
   * Note that we increment the index only after the event is written,
   * to make sure that the readers don't get garbage... */ /* Spin lock end */ /* Now : wake up everybody waiting for events... */