save memory (3)
authorNIIBE Yutaka <gniibe@fsij.org>
Wed, 11 May 2011 00:31:16 +0000 (09:31 +0900)
committerNIIBE Yutaka <gniibe@fsij.org>
Wed, 11 May 2011 00:31:16 +0000 (09:31 +0900)
ChangeLog
src/usb-icc.c

index 0a06f83..df3db93 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,8 @@
 2011-05-11  NIIBE Yutaka  <gniibe@fsij.org>
 
-       * src/flash.c (keystore_pool): Remove.  Use &_keystore_pool.
+       * src/usb-icc.c (icc_thread): Remove.  Use chThdSelf ().
 
+       * src/flash.c (keystore_pool): Remove.  Use &_keystore_pool.
        * src/ac.c (auth_status): Don't assign 0 as it's automatically
        cleared.
 
index ba32433..f4f8c7c 100644 (file)
@@ -112,8 +112,6 @@ static uint8_t *icc_chain_p;
  */
 static int icc_tx_size;
 
-static Thread *icc_thread;
-
 #define EV_RX_DATA_READY (eventmask_t)1  /* USB Rx data available  */
 /* EV_EXEC_FINISHED == 2 */
 #define EV_TX_FINISHED (eventmask_t)4  /* USB Tx finished  */
@@ -125,8 +123,12 @@ void
 EP1_IN_Callback (void)
 {
   if (icc_next_p == NULL)
-    /* The sequence of Bulk-IN transactions finished */
-    chEvtSignalI (icc_thread, EV_TX_FINISHED);
+    {
+      Thread *me = chThdSelf ();
+
+      /* The sequence of Bulk-IN transactions finished */
+      chEvtSignalI (me, EV_TX_FINISHED);
+    }
   else if (icc_next_p == &icc_buffer[icc_tx_size])
     /* It was multiple of USB_LL_BUF_SIZE */
     {
@@ -217,8 +219,12 @@ EP2_OUT_Callback (void)
          icc_prepare_receive (0);
        }
       else
-       /* Notify icc_thread */
-       chEvtSignalI (icc_thread, EV_RX_DATA_READY);
+       {
+         Thread *me = chThdSelf ();
+
+         /* Notify myself */
+         chEvtSignalI (me, EV_RX_DATA_READY);
+       }
     }
 }
 
@@ -305,8 +311,12 @@ icc_power_on (void)
   int size_atr;
 
   if (gpg_thread == NULL)
-    gpg_thread = chThdCreateStatic (waGPGthread, sizeof(waGPGthread),
-                                   NORMALPRIO, GPGthread, (void *)icc_thread);
+    {
+      Thread *me = chThdSelf ();
+
+      gpg_thread = chThdCreateStatic (waGPGthread, sizeof(waGPGthread),
+                                     NORMALPRIO, GPGthread, (void *)me);
+    }
 
   size_atr = sizeof (ATR);
   icc_buffer[0] = ICC_DATA_BLOCK_RET;
@@ -681,7 +691,6 @@ USBthread (void *arg)
 {
   (void)arg;
 
-  icc_thread = chThdSelf ();
   chEvtClear (ALL_EVENTS);
 
   icc_state = ICC_STATE_START;