Skip to content

Commit 6a8aefe

Browse files
Merge pull request #31 from emanuelemessina/timer-methods-mutability
Removed mutable borrow in readonly generic timer methods
2 parents 6f287c1 + ccd45a4 commit 6a8aefe

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.sh text eol=lf

cortex-ar/src/generic_timer/el0.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ impl super::GenericTimer for El0PhysicalTimer {
3030
register::Cntfrq::read().0
3131
}
3232

33-
fn counter(&mut self) -> u64 {
33+
fn counter(&self) -> u64 {
3434
register::CntPct::read().0
3535
}
3636

37-
fn counter_compare(&mut self) -> u64 {
37+
fn counter_compare(&self) -> u64 {
3838
register::CntpCval::read().0
3939
}
4040

@@ -94,11 +94,11 @@ impl super::GenericTimer for El0VirtualTimer {
9494
register::Cntfrq::read().0
9595
}
9696

97-
fn counter(&mut self) -> u64 {
97+
fn counter(&self) -> u64 {
9898
register::CntVct::read().0
9999
}
100100

101-
fn counter_compare(&mut self) -> u64 {
101+
fn counter_compare(&self) -> u64 {
102102
register::CntvCval::read().0
103103
}
104104

cortex-ar/src/generic_timer/el1.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ impl GenericTimer for El1PhysicalTimer {
3838
self.0.frequency_hz()
3939
}
4040

41-
fn counter(&mut self) -> u64 {
41+
fn counter(&self) -> u64 {
4242
self.0.counter()
4343
}
4444

45-
fn counter_compare(&mut self) -> u64 {
45+
fn counter_compare(&self) -> u64 {
4646
self.0.counter_compare()
4747
}
4848

@@ -138,11 +138,11 @@ impl GenericTimer for El1VirtualTimer {
138138
self.0.frequency_hz()
139139
}
140140

141-
fn counter(&mut self) -> u64 {
141+
fn counter(&self) -> u64 {
142142
self.0.counter()
143143
}
144144

145-
fn counter_compare(&mut self) -> u64 {
145+
fn counter_compare(&self) -> u64 {
146146
self.0.counter_compare()
147147
}
148148

cortex-ar/src/generic_timer/el2.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ impl GenericTimer for El2PhysicalTimer {
3434
self.0.frequency_hz()
3535
}
3636

37-
fn counter(&mut self) -> u64 {
37+
fn counter(&self) -> u64 {
3838
self.0.counter()
3939
}
4040

41-
fn counter_compare(&mut self) -> u64 {
41+
fn counter_compare(&self) -> u64 {
4242
self.0.counter_compare()
4343
}
4444

@@ -105,11 +105,11 @@ impl GenericTimer for El2VirtualTimer {
105105
self.0.frequency_hz()
106106
}
107107

108-
fn counter(&mut self) -> u64 {
108+
fn counter(&self) -> u64 {
109109
self.0.counter()
110110
}
111111

112-
fn counter_compare(&mut self) -> u64 {
112+
fn counter_compare(&self) -> u64 {
113113
self.0.counter_compare()
114114
}
115115

@@ -166,11 +166,11 @@ impl super::GenericTimer for El2HypPhysicalTimer {
166166
register::Cntfrq::read().0
167167
}
168168

169-
fn counter(&mut self) -> u64 {
169+
fn counter(&self) -> u64 {
170170
register::CntPct::read().0
171171
}
172172

173-
fn counter_compare(&mut self) -> u64 {
173+
fn counter_compare(&self) -> u64 {
174174
register::CnthpCval::read().0
175175
}
176176

cortex-ar/src/generic_timer/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ pub trait GenericTimer {
2828
///
2929
/// Note that speculative reads are allowed and reads may occur out of
3030
/// order. Add ISB and DSB fences before/after this call as required.
31-
fn counter(&mut self) -> u64;
31+
fn counter(&self) -> u64;
3232

3333
/// Get the counter compare value.
34-
fn counter_compare(&mut self) -> u64;
34+
fn counter_compare(&self) -> u64;
3535

3636
/// Set the counter compare value.
3737
///

0 commit comments

Comments
 (0)