Lines Matching +full:valid +full:- +full:mask
1 // SPDX-License-Identifier: GPL-2.0
45 /// PHY is in full-duplex mode.
47 /// PHY is in half-duplex mode.
62 /// - Referencing a `phy_device` using this struct asserts that you are in
64 /// - This struct always has a valid `self.0.mdio.dev`.
82 /// - the pointer must point at a valid `phy_device`, and the caller
85 /// - `(*ptr).mdio.dev` must be a valid.
86 unsafe fn from_raw<'a>(ptr: *mut bindings::phy_device) -> &'a mut Self { in from_raw()
89 // SAFETY: by the function requirements the pointer is valid and we have unique access for in from_raw()
95 pub fn phy_id(&self) -> u32 { in phy_id()
103 pub fn state(&self) -> DeviceState { in state()
126 pub fn is_link_up(&self) -> bool { in is_link_up()
136 /// Gets the current auto-negotiation configuration.
138 /// It returns true if auto-negotiation is enabled.
139 pub fn is_autoneg_enabled(&self) -> bool { in is_autoneg_enabled()
148 /// Gets the current auto-negotiation state.
150 /// It returns true if auto-negotiation is completed.
151 pub fn is_autoneg_completed(&self) -> bool { in is_autoneg_completed()
184 pub fn read<R: reg::Register>(&mut self, reg: R) -> Result<u16> { in read()
189 pub fn write<R: reg::Register>(&mut self, reg: R, val: u16) -> Result { in write()
194 pub fn read_paged(&mut self, page: u16, regnum: u16) -> Result<u16> { in read_paged()
196 // SAFETY: `phydev` is pointing to a valid object by the type invariant of `Self`. in read_paged()
209 // SAFETY: `phydev` is pointing to a valid object by the type invariant of `Self`. in resolve_aneg_linkmode()
215 pub fn genphy_soft_reset(&mut self) -> Result { in genphy_soft_reset()
217 // SAFETY: `phydev` is pointing to a valid object by the type invariant of `Self`. in genphy_soft_reset()
223 pub fn init_hw(&mut self) -> Result { in init_hw()
225 // SAFETY: `phydev` is pointing to a valid object by the type invariant of `Self`. in init_hw()
230 /// Starts auto-negotiation.
231 pub fn start_aneg(&mut self) -> Result { in start_aneg()
233 // SAFETY: `phydev` is pointing to a valid object by the type invariant of `Self`. in start_aneg()
239 pub fn genphy_resume(&mut self) -> Result { in genphy_resume()
241 // SAFETY: `phydev` is pointing to a valid object by the type invariant of `Self`. in genphy_resume()
247 pub fn genphy_suspend(&mut self) -> Result { in genphy_suspend()
249 // SAFETY: `phydev` is pointing to a valid object by the type invariant of `Self`. in genphy_suspend()
255 pub fn genphy_read_status<R: reg::Register>(&mut self) -> Result<u16> { in genphy_read_status()
260 pub fn genphy_update_link(&mut self) -> Result { in genphy_update_link()
262 // SAFETY: `phydev` is pointing to a valid object by the type invariant of `Self`. in genphy_update_link()
268 pub fn genphy_read_lpa(&mut self) -> Result { in genphy_read_lpa()
270 // SAFETY: `phydev` is pointing to a valid object by the type invariant of `Self`. in genphy_read_lpa()
276 pub fn genphy_read_abilities(&mut self) -> Result { in genphy_read_abilities()
278 // SAFETY: `phydev` is pointing to a valid object by the type invariant of `Self`. in genphy_read_abilities()
285 fn as_ref(&self) -> &kernel::device::Device { in as_ref()
287 // SAFETY: The struct invariant ensures that `mdio.dev` is valid. in as_ref()
317 ) -> core::ffi::c_int { in soft_reset_callback()
320 // where we hold `phy_device->lock`, so the accessors on in soft_reset_callback()
331 unsafe extern "C" fn probe_callback(phydev: *mut bindings::phy_device) -> core::ffi::c_int { in probe_callback()
348 ) -> core::ffi::c_int { in get_features_callback()
351 // where we hold `phy_device->lock`, so the accessors on in get_features_callback()
362 unsafe extern "C" fn suspend_callback(phydev: *mut bindings::phy_device) -> core::ffi::c_int { in suspend_callback()
365 // `Device` are okay to call even though `phy_device->lock` in suspend_callback()
376 unsafe extern "C" fn resume_callback(phydev: *mut bindings::phy_device) -> core::ffi::c_int { in resume_callback()
379 // `Device` are okay to call even though `phy_device->lock` in resume_callback()
392 ) -> core::ffi::c_int { in config_aneg_callback()
395 // where we hold `phy_device->lock`, so the accessors on in config_aneg_callback()
408 ) -> core::ffi::c_int { in read_status_callback()
411 // where we hold `phy_device->lock`, so the accessors on in read_status_callback()
424 ) -> core::ffi::c_int { in match_phy_device_callback()
426 // where we hold `phy_device->lock`, so the accessors on in match_phy_device_callback()
439 ) -> i32 { in read_mmd_callback()
442 // where we hold `phy_device->lock`, so the accessors on in read_mmd_callback()
459 ) -> i32 { in write_mmd_callback()
462 // where we hold `phy_device->lock`, so the accessors on in write_mmd_callback()
475 // where we hold `phy_device->lock`, so the accessors on in link_change_notify_callback()
489 /// `self.0` is always in a valid state.
504 pub const fn create_phy_driver<T: Driver>() -> DriverVTable { in create_phy_driver()
585 /// The default id and mask are zero.
589 fn soft_reset(_dev: &mut Device) -> Result { in soft_reset()
593 /// Sets up device-specific structures during discovery.
594 fn probe(_dev: &mut Device) -> Result { in probe()
599 fn get_features(_dev: &mut Device) -> Result { in get_features()
605 fn match_phy_device(_dev: &Device) -> bool { in match_phy_device()
609 /// Configures the advertisement and resets auto-negotiation
610 /// if auto-negotiation is enabled.
611 fn config_aneg(_dev: &mut Device) -> Result { in config_aneg()
616 fn read_status(_dev: &mut Device) -> Result<u16> { in read_status()
621 fn suspend(_dev: &mut Device) -> Result { in suspend()
626 fn resume(_dev: &mut Device) -> Result { in resume()
631 fn read_mmd(_dev: &mut Device, _devnum: u8, _regnum: u16) -> Result<u16> { in read_mmd()
636 fn write_mmd(_dev: &mut Device, _devnum: u8, _regnum: u16, _val: u16) -> Result { in write_mmd()
664 ) -> Result<Self> { in register()
681 // SAFETY: The type invariants guarantee that `self.drivers` is valid. in drop()
695 mask: DeviceMask, field
699 /// Creates a new instance with the exact match mask.
700 pub const fn new_with_exact_mask(id: u32) -> Self { in new_with_exact_mask()
703 mask: DeviceMask::Exact, in new_with_exact_mask()
707 /// Creates a new instance with the model match mask.
708 pub const fn new_with_model_mask(id: u32) -> Self { in new_with_model_mask()
711 mask: DeviceMask::Model, in new_with_model_mask()
715 /// Creates a new instance with the vendor match mask.
716 pub const fn new_with_vendor_mask(id: u32) -> Self { in new_with_vendor_mask()
719 mask: DeviceMask::Vendor, in new_with_vendor_mask()
723 /// Creates a new instance with a custom match mask.
724 pub const fn new_with_custom_mask(id: u32, mask: u32) -> Self { in new_with_custom_mask()
727 mask: DeviceMask::Custom(mask), in new_with_custom_mask()
732 pub const fn new_with_driver<T: Driver>() -> Self { in new_with_driver()
736 /// Get a `mask` as u32.
737 pub const fn mask_as_int(&self) -> u32 { in mask_as_int()
738 self.mask.as_int() in mask_as_int()
743 pub const fn mdio_device_id(&self) -> bindings::mdio_device_id { in mdio_device_id()
746 phy_id_mask: self.mask.as_int(), in mdio_device_id()
763 const fn as_int(&self) -> u32 { in as_int()
768 DeviceMask::Custom(mask) => *mask, in as_int()
840 /// fn init(module: &'static ThisModule) -> Result<Self> {
902 fn init(module: &'static ThisModule) -> Result<Self> {