|
11 | 11 | use core::fmt; |
12 | 12 |
|
13 | 13 | use super::{FDT_TAGSIZE, Fdt, FdtToken}; |
14 | | -use crate::error::{FdtError, FdtParseError}; |
15 | | -use crate::fdt::Status; |
| 14 | +use crate::error::FdtParseError; |
16 | 15 | use crate::fdt::property::{FdtPropIter, FdtProperty}; |
17 | 16 |
|
18 | | -const DEFAULT_ADDRESS_CELLS: u32 = 2; |
19 | | -const DEFAULT_SIZE_CELLS: u32 = 1; |
20 | | - |
21 | 17 | /// A node in a flattened device tree. |
22 | 18 | #[derive(Debug, Clone, Copy)] |
23 | 19 | pub struct FdtNode<'a> { |
@@ -206,114 +202,6 @@ impl<'a> FdtNode<'a> { |
206 | 202 | } |
207 | 203 | } |
208 | 204 |
|
209 | | - /// Returns the value of the standard `compatible` property. |
210 | | - /// |
211 | | - /// # Errors |
212 | | - /// |
213 | | - /// Returns an error if a property's name or value cannot be read. |
214 | | - pub fn compatible( |
215 | | - &self, |
216 | | - ) -> Result<Option<impl Iterator<Item = &'a str> + use<'a>>, FdtParseError> { |
217 | | - Ok(self |
218 | | - .property("compatible")? |
219 | | - .map(|property| property.as_str_list())) |
220 | | - } |
221 | | - |
222 | | - /// Returns the value of the standard `model` property. |
223 | | - /// |
224 | | - /// # Errors |
225 | | - /// |
226 | | - /// Returns an error if a property's name or value cannot be read, or the |
227 | | - /// value isn't a valid UTF-8 string. |
228 | | - pub fn model(&self) -> Result<Option<&'a str>, FdtError> { |
229 | | - Ok(if let Some(model) = self.property("model")? { |
230 | | - Some(model.as_str()?) |
231 | | - } else { |
232 | | - None |
233 | | - }) |
234 | | - } |
235 | | - |
236 | | - /// Returns the value of the standard `phandle` property. |
237 | | - /// |
238 | | - /// # Errors |
239 | | - /// |
240 | | - /// Returns an error if a property's name or value cannot be read, or the |
241 | | - /// value isn't a valid u32. |
242 | | - pub fn phandle(&self) -> Result<Option<u32>, FdtError> { |
243 | | - Ok(if let Some(property) = self.property("phandle")? { |
244 | | - Some(property.as_u32()?) |
245 | | - } else { |
246 | | - None |
247 | | - }) |
248 | | - } |
249 | | - |
250 | | - /// Returns the value of the standard `status` property. |
251 | | - /// |
252 | | - /// If there is no `status` property then `okay` is assumed. |
253 | | - /// |
254 | | - /// # Errors |
255 | | - /// |
256 | | - /// Returns an error if a property's name or value cannot be read, or the |
257 | | - /// value isn't a valid status. |
258 | | - pub fn status(&self) -> Result<Status, FdtError> { |
259 | | - Ok(if let Some(status) = self.property("status")? { |
260 | | - status.as_str()?.parse()? |
261 | | - } else { |
262 | | - Status::Okay |
263 | | - }) |
264 | | - } |
265 | | - |
266 | | - /// Returns the value of the standard `#address-cells` property. |
267 | | - /// |
268 | | - /// # Errors |
269 | | - /// |
270 | | - /// Returns an error if a property's name or value cannot be read, or the |
271 | | - /// value isn't a valid u32. |
272 | | - pub fn address_cells(&self) -> Result<u32, FdtError> { |
273 | | - Ok(if let Some(property) = self.property("#address-cells")? { |
274 | | - property.as_u32()? |
275 | | - } else { |
276 | | - DEFAULT_ADDRESS_CELLS |
277 | | - }) |
278 | | - } |
279 | | - |
280 | | - /// Returns the value of the standard `#size-cells` property. |
281 | | - /// |
282 | | - /// # Errors |
283 | | - /// |
284 | | - /// Returns an error if a property's name or value cannot be read, or the |
285 | | - /// value isn't a valid u32. |
286 | | - pub fn size_cells(&self) -> Result<u32, FdtError> { |
287 | | - Ok(if let Some(model) = self.property("#size-cells")? { |
288 | | - model.as_u32()? |
289 | | - } else { |
290 | | - DEFAULT_SIZE_CELLS |
291 | | - }) |
292 | | - } |
293 | | - |
294 | | - /// Returns the value of the standard `virtual-reg` property. |
295 | | - /// |
296 | | - /// # Errors |
297 | | - /// |
298 | | - /// Returns an error if a property's name or value cannot be read, or the |
299 | | - /// value isn't a valid u32. |
300 | | - pub fn virtual_reg(&self) -> Result<Option<u32>, FdtError> { |
301 | | - Ok(if let Some(property) = self.property("virtual-reg")? { |
302 | | - Some(property.as_u32()?) |
303 | | - } else { |
304 | | - None |
305 | | - }) |
306 | | - } |
307 | | - |
308 | | - /// Returns whether the standard `dma-coherent` property is present. |
309 | | - /// |
310 | | - /// # Errors |
311 | | - /// |
312 | | - /// Returns an error if a property can't be read. |
313 | | - pub fn dma_coherent(&self) -> Result<bool, FdtError> { |
314 | | - Ok(self.property("dma-coherent")?.is_some()) |
315 | | - } |
316 | | - |
317 | 205 | pub(crate) fn fmt_recursive(&self, f: &mut fmt::Formatter<'_>, indent: usize) -> fmt::Result { |
318 | 206 | let name = self.name().map_err(|_| fmt::Error)?; |
319 | 207 | if name.is_empty() { |
|
0 commit comments