From c089e7e526cce4620cf8e1b16d6d62d692e6b814 Mon Sep 17 00:00:00 2001
From: Jorge Aparicio <jorge@japaric.io>
Date: Tue, 13 Jun 2017 23:44:08 -0500
Subject: [PATCH] rename Buffer.free to Buffer.release

---
 examples/blinky-blocking.rs  |  2 +-
 examples/concurrent-await.rs | 10 ++++------
 examples/gpio.rs             |  2 +-
 examples/led.rs              |  2 +-
 examples/usart1-rx-dma.rs    |  6 ++----
 examples/usart1-tx-dma.rs    |  6 ++----
 src/dma.rs                   | 10 +++++-----
 src/serial.rs                |  6 ++++++
 8 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/examples/blinky-blocking.rs b/examples/blinky-blocking.rs
index f6a5986..048caa4 100644
--- a/examples/blinky-blocking.rs
+++ b/examples/blinky-blocking.rs
@@ -20,7 +20,7 @@ extern crate cortex_m_rtfm as rtfm;
 #[macro_use]
 extern crate nb;
 
-use blue_pill::led::{Green, self};
+use blue_pill::led::{self, Green};
 use blue_pill::time::Hertz;
 use blue_pill::{Timer, stm32f103xx};
 use hal::prelude::*;
diff --git a/examples/concurrent-await.rs b/examples/concurrent-await.rs
index 4e67a9f..991c76c 100644
--- a/examples/concurrent-await.rs
+++ b/examples/concurrent-await.rs
@@ -100,12 +100,10 @@ fn idle(ref prio: P0, ref thr: T0) -> ! {
         }
     })();
 
-    let mut loopback = (|| {
-        loop {
-            let byte = await!(serial.read()).unwrap();
-            await!(serial.write()).unwrap();
-        }
-    })();
+    let mut loopback = (|| loop {
+                            let byte = await!(serial.read()).unwrap();
+                            await!(serial.write()).unwrap();
+                        })();
 
     // Resume the timer count
     timer.resume();
diff --git a/examples/gpio.rs b/examples/gpio.rs
index 4d2335f..7afa9d1 100644
--- a/examples/gpio.rs
+++ b/examples/gpio.rs
@@ -13,7 +13,7 @@ extern crate cortex_m_rt;
 #[macro_use]
 extern crate cortex_m_rtfm as rtfm;
 
-use blue_pill::gpio::{PB12, self};
+use blue_pill::gpio::{self, PB12};
 use blue_pill::stm32f103xx;
 use rtfm::{P0, T0, TMax};
 
diff --git a/examples/led.rs b/examples/led.rs
index a974521..62a10e8 100644
--- a/examples/led.rs
+++ b/examples/led.rs
@@ -13,7 +13,7 @@ extern crate cortex_m_rt;
 #[macro_use]
 extern crate cortex_m_rtfm as rtfm;
 
-use blue_pill::led::{Green, self};
+use blue_pill::led::{self, Green};
 use blue_pill::stm32f103xx;
 use rtfm::{P0, T0, TMax};
 
diff --git a/examples/usart1-rx-dma.rs b/examples/usart1-rx-dma.rs
index 989e429..d83318c 100644
--- a/examples/usart1-rx-dma.rs
+++ b/examples/usart1-rx-dma.rs
@@ -1,6 +1,4 @@
-//! Test the USART1 instance
-//!
-//! Connect the TX and RX pins to run this test
+//! Test receiving serial data using the DMA
 
 #![feature(const_fn)]
 #![feature(used)]
@@ -87,7 +85,7 @@ fn done(_task: DMA1_CHANNEL5, ref prio: P1, ref thr: T1) {
     let buffer = BUFFER.access(prio, thr);
     let dma1 = &DMA1.access(prio, thr);
 
-    buffer.free(dma1).unwrap();
+    buffer.release(dma1).unwrap();
 
     rtfm::bkpt();
 }
diff --git a/examples/usart1-tx-dma.rs b/examples/usart1-tx-dma.rs
index 5812205..42696a4 100644
--- a/examples/usart1-tx-dma.rs
+++ b/examples/usart1-tx-dma.rs
@@ -1,6 +1,4 @@
-//! Test the USART1 instance
-//!
-//! Connect the TX and RX pins to run this test
+//! Test sending serial data using the DMA
 
 #![feature(const_fn)]
 #![feature(used)]
@@ -88,7 +86,7 @@ fn done(_task: DMA1_CHANNEL4, ref prio: P1, ref thr: T1) {
     let buffer = BUFFER.access(prio, thr);
     let dma1 = &DMA1.access(prio, thr);
 
-    buffer.free(dma1).unwrap();
+    buffer.release(dma1).unwrap();
 
     rtfm::bkpt();
 }
diff --git a/src/dma.rs b/src/dma.rs
index 2e89db5..2df6712 100644
--- a/src/dma.rs
+++ b/src/dma.rs
@@ -178,10 +178,10 @@ impl<T, CHANNEL> Buffer<T, CHANNEL> {
     }
 }
 
-// FIXME these `free` methods probably want some of sort of barrier
+// FIXME these `release` methods probably want some of sort of barrier
 impl<T> Buffer<T, Dma1Channel4> {
-    /// Waits until this buffer is freed by the DMA
-    pub fn free(&self, dma1: &DMA1) -> nb::Result<(), Error> {
+    /// Waits until the DMA releases this buffer
+    pub fn release(&self, dma1: &DMA1) -> nb::Result<(), Error> {
         let status = self.status.get();
 
         if status == Status::Unlocked {
@@ -202,8 +202,8 @@ impl<T> Buffer<T, Dma1Channel4> {
 }
 
 impl<T> Buffer<T, Dma1Channel5> {
-    /// Waits until this buffer is freed by the DMA
-    pub fn free(&self, dma1: &DMA1) -> nb::Result<(), Error> {
+    /// Waits until the DMA releases this buffer
+    pub fn release(&self, dma1: &DMA1) -> nb::Result<(), Error> {
         let status = self.status.get();
 
         if status == Status::Unlocked {
diff --git a/src/serial.rs b/src/serial.rs
index c46badd..6b7d7c7 100644
--- a/src/serial.rs
+++ b/src/serial.rs
@@ -383,6 +383,9 @@ where
 
 impl<'a> Serial<'a, USART1> {
     /// Starts a DMA transfer to receive serial data into a `buffer`
+    ///
+    /// This will mutably lock the `buffer` preventing borrowing its contents
+    /// The `buffer` can be `release`d after the DMA transfer finishes
     // TODO support circular mode + half transfer interrupt as a double
     // buffering mode
     pub fn read_exact<B>(
@@ -416,6 +419,9 @@ impl<'a> Serial<'a, USART1> {
     }
 
     /// Starts a DMA transfer to send `buffer` through this serial port
+    ///
+    /// This will immutably lock the `buffer` preventing mutably borrowing its
+    /// contents. The `buffer` can be `release`d after the DMA transfer finishes
     pub fn write_all<B>(
         &self,
         dma1: &DMA1,
-- 
GitLab