mirror of
https://github.com/Telecominfraproject/OpenNetworkLinux.git
synced 2025-12-26 01:37:04 +00:00
Add optional OID id validators.
You can pre-validate your OID ids prior to any other calls to your module. If onlp_<type>_id_validate() returns ONLP_STATUS_OK then the ID will be passed to your implementation. If onlp_<type>_id_validate() returns ONLP_STATUS_E_INVALID then it will not be passed to your implementation. The goal here is to avoid all of the boilerplate ID bounds checking in all of the platform implemenations that use static OID info arrays. Instead of validating in each function you should provide a single onlp_<type>_id_validate() and assume the ID is valid in all other functions. The default implementation returns ONLP_STATUS_OK for backwards compatibility.
This commit is contained in:
@@ -49,6 +49,12 @@ int onlp_psui_hw_init(uint32_t flags);
|
||||
*/
|
||||
int onlp_psui_sw_denit(void);
|
||||
|
||||
/**
|
||||
* @brief Validate a PSU OID.
|
||||
* @param id The id.
|
||||
*/
|
||||
int onlp_psui_id_validate(onlp_oid_id_t id);
|
||||
|
||||
/**
|
||||
* @brief Get the PSU's oid header.
|
||||
* @param id The PSU OID.
|
||||
|
||||
@@ -49,6 +49,12 @@ int onlp_thermali_hw_init(uint32_t flags);
|
||||
*/
|
||||
int onlp_thermali_sw_denit(void);
|
||||
|
||||
/**
|
||||
* @brief Validate a thermal oid.
|
||||
* @param id The thermal id.
|
||||
*/
|
||||
int onlp_thermali_id_validate(onlp_oid_id_t id);
|
||||
|
||||
/**
|
||||
* @brief Retrieve the thermal's oid header.
|
||||
* @param id The thermal oid.
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION_OPTIONAL(onlp_ledi_sw_init(void));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION_OPTIONAL(onlp_ledi_hw_init(uint32_t flags));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION_OPTIONAL(onlp_ledi_sw_denit(void));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION_OPTIONAL(onlp_ledi_id_validate(onlp_oid_id_t id));
|
||||
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_ledi_info_get(onlp_oid_id_t id, onlp_led_info_t* rv));
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION_OPTIONAL(onlp_psui_sw_init(void));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION_OPTIONAL(onlp_psui_hw_init(uint32_t flags));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION_OPTIONAL(onlp_psui_sw_denit(void));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION_OPTIONAL(onlp_psui_id_validate(onlp_oid_id_t id));
|
||||
|
||||
/**
|
||||
* simulate hdr_get for older platforms which don't support it.
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION_OPTIONAL(onlp_thermali_sw_init(void));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION_OPTIONAL(onlp_thermali_hw_init(uint32_t flags));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION_OPTIONAL(onlp_thermali_sw_denit(void));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION_OPTIONAL(onlp_thermali_id_validate(onlp_oid_id_t id));
|
||||
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_thermali_info_get(onlp_oid_id_t id, onlp_thermal_info_t* rv));
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user