Switch from GPLv2 to GPLv2+
[fw/altos] / src / stmf0 / ao_usb_stm.c
index 63b35b249b55217074033b557d72867db422997d..cbedb9962231fa972256c33f0ee18bedef92aba2 100644 (file)
@@ -3,7 +3,8 @@
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -83,7 +84,9 @@ static uint8_t        ao_usb_ep0_out_len;
 /* Buffer description tables */
 static union stm_usb_bdt       *ao_usb_bdt;
 /* USB address of end of allocated storage */
+#if AO_USB_DIRECTIO
 static uint16_t        ao_usb_sram_addr;
+#endif
 
 /* Pointer to ep0 tx/rx buffers in USB memory */
 static uint16_t        *ao_usb_ep0_tx_buffer;
@@ -362,39 +365,43 @@ ao_usb_init_ep(uint8_t ep, uint32_t addr, uint32_t type, uint32_t stat_rx, uint3
 static void
 ao_usb_alloc_buffers(void)
 {
-       ao_usb_sram_addr = 0;
+       uint16_t sram_addr = 0;
 
        ao_usb_bdt = (void *) stm_usb_sram;
-       ao_usb_sram_addr += 8 * STM_USB_BDT_SIZE;
+       sram_addr += 8 * STM_USB_BDT_SIZE;
 
-       ao_usb_ep0_tx_buffer = ao_usb_packet_buffer_addr(ao_usb_sram_addr);
-       ao_usb_sram_addr += AO_USB_CONTROL_SIZE;
+       ao_usb_ep0_tx_buffer = ao_usb_packet_buffer_addr(sram_addr);
+       sram_addr += AO_USB_CONTROL_SIZE;
 
-       ao_usb_ep0_rx_buffer = ao_usb_packet_buffer_addr(ao_usb_sram_addr);
-       ao_usb_sram_addr += AO_USB_CONTROL_SIZE;
+       ao_usb_ep0_rx_buffer = ao_usb_packet_buffer_addr(sram_addr);
+       sram_addr += AO_USB_CONTROL_SIZE;
 
 
 #if AO_USB_HAS_INT
-       ao_usb_int_tx_offset = ao_usb_sram_addr;
-       ao_usb_sram_addr += AO_USB_INT_SIZE;
+       ao_usb_int_tx_offset = sram_addr;
+       sram_addr += AO_USB_INT_SIZE;
 #endif
 
 #if AO_USB_HAS_OUT
-       ao_usb_out_rx_buffer = ao_usb_packet_buffer_addr(ao_usb_sram_addr);
-       ao_usb_out_rx_offset = ao_usb_sram_addr;
-       ao_usb_sram_addr += AO_USB_OUT_SIZE;
+       ao_usb_out_rx_buffer = ao_usb_packet_buffer_addr(sram_addr);
+       ao_usb_out_rx_offset = sram_addr;
+       sram_addr += AO_USB_OUT_SIZE;
 #endif
 
 #if AO_USB_HAS_IN
-       ao_usb_in_tx_buffer = ao_usb_packet_buffer_addr(ao_usb_sram_addr);
-       ao_usb_in_tx_offset = ao_usb_sram_addr;
-       ao_usb_sram_addr += AO_USB_IN_SIZE;
+       ao_usb_in_tx_buffer = ao_usb_packet_buffer_addr(sram_addr);
+       ao_usb_in_tx_offset = sram_addr;
+       sram_addr += AO_USB_IN_SIZE;
 #endif
 
 #if AO_USB_HAS_IN2
-       ao_usb_in2_tx_buffer = ao_usb_packet_buffer_addr(ao_usb_sram_addr);
-       ao_usb_in2_tx_offset = ao_usb_sram_addr;
-       ao_usb_sram_addr += AO_USB_IN_SIZE;
+       ao_usb_in2_tx_buffer = ao_usb_packet_buffer_addr(sram_addr);
+       ao_usb_in2_tx_offset = sram_addr;
+       sram_addr += AO_USB_IN_SIZE;
+#endif
+
+#if AO_USB_DIRECTIO
+       ao_usb_sram_addr = sram_addr;
 #endif
 }
 
@@ -1185,14 +1192,6 @@ ao_usb_alloc(void)
        return buffer;
 }
 
-void
-ao_usb_free(uint16_t *addr)
-{
-       uint16_t        offset = ao_usb_packet_buffer_offset(addr);
-       if (offset < ao_usb_sram_addr)
-               ao_usb_sram_addr = offset;
-}
-
 void
 ao_usb_write(uint16_t *buffer, uint16_t len)
 {