diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/fan.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/fan.h index 0c6680b7..bf750132 100644 --- a/packages/base/any/onlp/src/onlp/module/inc/onlp/fan.h +++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/fan.h @@ -113,6 +113,22 @@ int onlp_fan_init(void); */ int onlp_fan_info_get(onlp_oid_t id, onlp_fan_info_t* rv); +/** + * @brief Retrieve the fan's operational status. + * @param id The fan OID. + * @param rv [out] Receives the fan's operations status flags. + * @notes Only operational state needs to be returned - + * PRESENT/FAILED + */ +int onlp_fan_status_get(onlp_oid_t id, uint32_t* rv); + +/** + * @brief Retrieve the fan's OID hdr. + * @param id The fan OID. + * @param rv [out] Receives the OID header. + */ +int onlp_fan_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* hdr); + /** * @brief Set the fan speed in RPMs. * @param id The fan OID. diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/led.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/led.h index 1c99843e..31503857 100644 --- a/packages/base/any/onlp/src/onlp/module/inc/onlp/led.h +++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/led.h @@ -112,6 +112,20 @@ int onlp_led_init(void); */ int onlp_led_info_get(onlp_oid_t id, onlp_led_info_t* rv); +/** + * @brief Get the LED operational status. + * @param id The LED OID + * @param rv [out] Receives the operational status. + */ +int onlp_led_status_get(onlp_oid_t id, uint32_t* rv); + +/** + * @brief Get the LED header. + * @param id The LED OID + * @param rv [out] Receives the header. + */ +int onlp_led_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv); + /** * @brief Turn an LED on or off. * @param id The LED OID diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/onlp.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/onlp.h index d1e223a8..266bf3ee 100644 --- a/packages/base/any/onlp/src/onlp/module/inc/onlp/onlp.h +++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/onlp.h @@ -49,6 +49,10 @@ typedef enum onlp_status_e { } \ } while(0) +#define ONLP_FAILURE(_rv) ((_rv) < 0) +#define ONLP_SUCCESS(_rv) (!(ONLP_FAILURE(_rv))) +#define ONLP_UNSUPPORTED(_rv) \ + ((_rv) == ONLP_STATUS_E_UNSUPPORTED) /** * @brief Initialize all subsystems. diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/fani.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/fani.h index 76807822..53a2372f 100644 --- a/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/fani.h +++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/fani.h @@ -39,6 +39,22 @@ int onlp_fani_init(void); */ int onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* rv); +/** + * @brief Retrieve the fan's operational status. + * @param id The fan OID. + * @param rv [out] Receives the fan's operations status flags. + * @notes Only operational state needs to be returned - + * PRESENT/FAILED + */ +int onlp_fani_status_get(onlp_oid_t id, uint32_t* rv); + +/** + * @brief Retrieve the fan's OID hdr. + * @param id The fan OID. + * @param rv [out] Receives the OID header. + */ +int onlp_fani_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* hdr); + /** * @brief Set the fan speed in RPM. * @param id The fan OID diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/ledi.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/ledi.h index 7d5bb545..c673ac32 100644 --- a/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/ledi.h +++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/ledi.h @@ -39,6 +39,20 @@ int onlp_ledi_init(void); */ int onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* rv); +/** + * @brief Get the LED operational status. + * @param id The LED OID + * @param rv [out] Receives the operational status. + */ +int onlp_ledi_status_get(onlp_oid_t id, uint32_t* rv); + +/** + * @brief Get the LED header. + * @param id The LED OID + * @param rv [out] Receives the header. + */ +int onlp_ledi_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv); + /** * @brief Turn an LED on or off * @param id The LED OID diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/psui.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/psui.h index e9f75da5..36a3a806 100644 --- a/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/psui.h +++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/psui.h @@ -39,6 +39,20 @@ int onlp_psui_init(void); */ int onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* rv); +/** + * @brief Get the PSU's operational status. + * @param id The PSU OID. + * @param rv [out] Receives the operational status. + */ +int onlp_psui_status_get(onlp_oid_t id, uint32_t* rv); + +/** + * @brief Get the PSU's oid header. + * @param id The PSU OID. + * @param rv [out] Receives the header. + */ +int onlp_psui_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv); + /** * @brief Generic PSU ioctl * @param id The PSU OID diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/thermali.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/thermali.h index fd2a29af..53175346 100644 --- a/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/thermali.h +++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/thermali.h @@ -40,6 +40,20 @@ int onlp_thermali_init(void); */ int onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* rv); +/** + * @brief Retrieve the thermal's operational status. + * @param id The thermal oid. + * @param rv [out] Receives the operational status. + */ +int onlp_thermali_status_get(onlp_oid_t id, uint32_t* rv); + +/** + * @brief Retrieve the thermal's oid header. + * @param id The thermal oid. + * @param rv [out] Receives the header. + */ +int onlp_thermali_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv); + /** * @brief Generic ioctl. */ diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/psu.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/psu.h index 0095ccdb..e51bd354 100644 --- a/packages/base/any/onlp/src/onlp/module/inc/onlp/psu.h +++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/psu.h @@ -96,6 +96,20 @@ int onlp_psu_init(void); */ int onlp_psu_info_get(onlp_oid_t id, onlp_psu_info_t* rv); +/** + * @brief Get the PSU's operational status. + * @param id The PSU OID. + * @param rv [out] Receives the operational status. + */ +int onlp_psu_status_get(onlp_oid_t id, uint32_t* rv); + +/** + * @brief Get the PSU's oid header. + * @param id The PSU OID. + * @param rv [out] Receives the header. + */ +int onlp_psu_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv); + /** * @brief Issue a PSU ioctl. * @param id The PSU OID diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/thermal.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/thermal.h index 6f73ab20..11453861 100644 --- a/packages/base/any/onlp/src/onlp/module/inc/onlp/thermal.h +++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/thermal.h @@ -115,6 +115,19 @@ int onlp_thermal_init(void); */ int onlp_thermal_info_get(onlp_oid_t id, onlp_thermal_info_t* rv); +/** + * @brief Retrieve the thermal's operational status. + * @param id The thermal oid. + * @param rv [out] Receives the operational status. + */ +int onlp_thermal_status_get(onlp_oid_t id, uint32_t* rv); + +/** + * @brief Retrieve the thermal's oid header. + * @param id The thermal oid. + * @param rv [out] Receives the header. + */ +int onlp_thermal_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv); /** * @brief Thermal driver ioctl. diff --git a/packages/base/any/onlp/src/onlp/module/src/fan.c b/packages/base/any/onlp/src/onlp/module/src/fan.c index f85a782a..3ef8a75e 100644 --- a/packages/base/any/onlp/src/onlp/module/src/fan.c +++ b/packages/base/any/onlp/src/onlp/module/src/fan.c @@ -119,6 +119,37 @@ onlp_fan_info_get_locked__(onlp_oid_t oid, onlp_fan_info_t* fip) } ONLP_LOCKED_API2(onlp_fan_info_get, onlp_oid_t, oid, onlp_fan_info_t*, fip); +static int +onlp_fan_status_get_locked__(onlp_oid_t oid, uint32_t* status) +{ + int rv = onlp_fani_status_get(oid, status); + if(ONLP_SUCCESS(rv)) { + return rv; + } + if(ONLP_UNSUPPORTED(rv)) { + onlp_fan_info_t fi; + rv = onlp_fani_info_get(oid, &fi); + *status = fi.status; + } + return rv; +} +ONLP_LOCKED_API2(onlp_fan_status_get, onlp_oid_t, oid, uint32_t*, status); + +static int +onlp_fan_hdr_get_locked__(onlp_oid_t oid, onlp_oid_hdr_t* hdr) +{ + int rv = onlp_fani_hdr_get(oid, hdr); + if(ONLP_SUCCESS(rv)) { + return rv; + } + if(ONLP_UNSUPPORTED(rv)) { + onlp_fan_info_t fi; + rv = onlp_fani_info_get(oid, &fi); + memcpy(hdr, &fi.hdr, sizeof(fi.hdr)); + } + return rv; +} +ONLP_LOCKED_API2(onlp_fan_hdr_get, onlp_oid_t, oid, onlp_oid_hdr_t*, hdr); static int onlp_fan_present__(onlp_oid_t id, onlp_fan_info_t* info) diff --git a/packages/base/any/onlp/src/onlp/module/src/led.c b/packages/base/any/onlp/src/onlp/module/src/led.c index 50f85809..e914ee69 100644 --- a/packages/base/any/onlp/src/onlp/module/src/led.c +++ b/packages/base/any/onlp/src/onlp/module/src/led.c @@ -84,6 +84,38 @@ onlp_led_info_get_locked__(onlp_oid_t id, onlp_led_info_t* info) } ONLP_LOCKED_API2(onlp_led_info_get, onlp_oid_t, id, onlp_led_info_t*, info); +static int +onlp_led_status_get_locked__(onlp_oid_t id, uint32_t* status) +{ + int rv = onlp_ledi_status_get(id, status); + if(ONLP_SUCCESS(rv)) { + return rv; + } + if(ONLP_UNSUPPORTED(rv)) { + onlp_led_info_t li; + rv = onlp_ledi_info_get(id, &li); + *status = li.status; + } + return rv; +} +ONLP_LOCKED_API2(onlp_led_status_get, onlp_oid_t, id, uint32_t*, status); + +static int +onlp_led_hdr_get_locked__(onlp_oid_t id, onlp_oid_hdr_t* hdr) +{ + int rv = onlp_ledi_hdr_get(id, hdr); + if(ONLP_SUCCESS(rv)) { + return rv; + } + if(ONLP_UNSUPPORTED(rv)) { + onlp_led_info_t li; + rv = onlp_ledi_info_get(id, &li); + memcpy(hdr, &li.hdr, sizeof(li.hdr)); + } + return rv; +} +ONLP_LOCKED_API2(onlp_led_hdr_get, onlp_oid_t, id, onlp_oid_hdr_t*, hdr); + static int onlp_led_set_locked__(onlp_oid_t id, int on_or_off) { diff --git a/packages/base/any/onlp/src/onlp/module/src/oids.c b/packages/base/any/onlp/src/onlp/module/src/oids.c index f2f495f1..9bac8979 100644 --- a/packages/base/any/onlp/src/onlp/module/src/oids.c +++ b/packages/base/any/onlp/src/onlp/module/src/oids.c @@ -90,41 +90,25 @@ oid_type_SYS_hdr_get__(onlp_oid_t oid, onlp_oid_hdr_t* hdr) static int oid_type_THERMAL_hdr_get__(onlp_oid_t oid, onlp_oid_hdr_t* hdr) { - int rv; - onlp_thermal_info_t ti; - rv = onlp_thermal_info_get(oid, &ti); - memcpy(hdr, &ti.hdr, sizeof(ti.hdr)); - return rv; + return onlp_thermal_hdr_get(oid, hdr); } static int oid_type_FAN_hdr_get__(onlp_oid_t oid, onlp_oid_hdr_t* hdr) { - int rv; - onlp_fan_info_t fi; - rv = onlp_fan_info_get(oid, &fi); - memcpy(hdr, &fi.hdr, sizeof(fi.hdr)); - return rv; + return onlp_fan_hdr_get(oid, hdr); } static int oid_type_LED_hdr_get__(onlp_oid_t oid, onlp_oid_hdr_t* hdr) { - int rv; - onlp_led_info_t li; - rv = onlp_led_info_get(oid, &li); - memcpy(hdr, &li.hdr, sizeof(li.hdr)); - return rv; + return onlp_led_hdr_get(oid, hdr); } static int oid_type_PSU_hdr_get__(onlp_oid_t oid, onlp_oid_hdr_t* hdr) { - int rv; - onlp_psu_info_t pi; - rv = onlp_psu_info_get(oid, &pi); - memcpy(hdr, &pi.hdr, sizeof(pi.hdr)); - return rv; + return onlp_psu_hdr_get(oid, hdr); } static int diff --git a/packages/base/any/onlp/src/onlp/module/src/psu.c b/packages/base/any/onlp/src/onlp/module/src/psu.c index 6b826111..76baf3fe 100644 --- a/packages/base/any/onlp/src/onlp/module/src/psu.c +++ b/packages/base/any/onlp/src/onlp/module/src/psu.c @@ -60,6 +60,37 @@ onlp_psu_info_get_locked__(onlp_oid_t id, onlp_psu_info_t* info) } ONLP_LOCKED_API2(onlp_psu_info_get, onlp_oid_t, id, onlp_psu_info_t*, info); +static int +onlp_psu_status_get_locked__(onlp_oid_t id, uint32_t* status) +{ + int rv = onlp_psui_status_get(id, status); + if(ONLP_SUCCESS(rv)) { + return rv; + } + if(ONLP_UNSUPPORTED(rv)) { + onlp_psu_info_t pi; + rv = onlp_psu_info_get(id, &pi); + *status = pi.status; + } + return rv; +} +ONLP_LOCKED_API2(onlp_psu_status_get, onlp_oid_t, id, uint32_t*, status); + +static int +onlp_psu_hdr_get_locked__(onlp_oid_t id, onlp_oid_hdr_t* hdr) +{ + int rv = onlp_psui_hdr_get(id, hdr); + if(ONLP_SUCCESS(rv)) { + return rv; + } + if(ONLP_UNSUPPORTED(rv)) { + onlp_psu_info_t pi; + rv = onlp_psui_info_get(id, &pi); + memcpy(hdr, &pi.hdr, sizeof(pi.hdr)); + } + return rv; +} +ONLP_LOCKED_API2(onlp_psu_hdr_get, onlp_oid_t, id, onlp_oid_hdr_t*, hdr); int onlp_psu_vioctl_locked__(onlp_oid_t id, va_list vargs) { diff --git a/packages/base/any/onlp/src/onlp/module/src/thermal.c b/packages/base/any/onlp/src/onlp/module/src/thermal.c index 10813a81..316f1280 100644 --- a/packages/base/any/onlp/src/onlp/module/src/thermal.c +++ b/packages/base/any/onlp/src/onlp/module/src/thermal.c @@ -96,6 +96,37 @@ onlp_thermal_info_get_locked__(onlp_oid_t oid, onlp_thermal_info_t* info) } ONLP_LOCKED_API2(onlp_thermal_info_get, onlp_oid_t, oid, onlp_thermal_info_t*, info); +static int +onlp_thermal_status_get_locked__(onlp_oid_t id, uint32_t* status) +{ + int rv = onlp_thermali_status_get(id, status); + if(ONLP_SUCCESS(rv)) { + return rv; + } + if(ONLP_UNSUPPORTED(rv)) { + onlp_thermal_info_t ti; + rv = onlp_thermali_info_get(id, &ti); + *status = ti.status; + } + return rv; +} +ONLP_LOCKED_API2(onlp_thermal_status_get, onlp_oid_t, id, uint32_t*, status); + +static int +onlp_thermal_hdr_get_locked__(onlp_oid_t id, onlp_oid_hdr_t* hdr) +{ + int rv = onlp_thermali_hdr_get(id, hdr); + if(ONLP_SUCCESS(rv)) { + return rv; + } + if(ONLP_UNSUPPORTED(rv)) { + onlp_thermal_info_t ti; + rv = onlp_thermali_info_get(id, &ti); + memcpy(hdr, &ti.hdr, sizeof(ti.hdr)); + } + return rv; +} +ONLP_LOCKED_API2(onlp_thermal_hdr_get, onlp_oid_t, id, onlp_oid_hdr_t*, hdr); int onlp_thermal_ioctl(int code, ...) { diff --git a/packages/base/any/onlp/src/onlp_platform_defaults/module/src/fani.c b/packages/base/any/onlp/src/onlp_platform_defaults/module/src/fani.c index 3ef9e111..715de62f 100644 --- a/packages/base/any/onlp/src/onlp_platform_defaults/module/src/fani.c +++ b/packages/base/any/onlp/src/onlp_platform_defaults/module/src/fani.c @@ -32,6 +32,8 @@ */ __ONLP_DEFAULTI_IMPLEMENTATION(onlp_fani_init(void)); __ONLP_DEFAULTI_IMPLEMENTATION(onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info)); +__ONLP_DEFAULTI_IMPLEMENTATION(onlp_fani_status_get(onlp_oid_t id, uint32_t* status)); +__ONLP_DEFAULTI_IMPLEMENTATION(onlp_fani_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* hdr)); __ONLP_DEFAULTI_IMPLEMENTATION(onlp_fani_rpm_set(onlp_oid_t id, int rpm)); __ONLP_DEFAULTI_IMPLEMENTATION(onlp_fani_percentage_set(onlp_oid_t id, int p)); __ONLP_DEFAULTI_IMPLEMENTATION(onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode)); diff --git a/packages/base/any/onlp/src/onlp_platform_defaults/module/src/ledi.c b/packages/base/any/onlp/src/onlp_platform_defaults/module/src/ledi.c index 461130b2..cb404ff3 100644 --- a/packages/base/any/onlp/src/onlp_platform_defaults/module/src/ledi.c +++ b/packages/base/any/onlp/src/onlp_platform_defaults/module/src/ledi.c @@ -27,6 +27,8 @@ __ONLP_DEFAULTI_IMPLEMENTATION(onlp_ledi_init(void)); __ONLP_DEFAULTI_IMPLEMENTATION(onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* rv)); +__ONLP_DEFAULTI_IMPLEMENTATION(onlp_ledi_status_get(onlp_oid_t id, uint32_t* rv)); +__ONLP_DEFAULTI_IMPLEMENTATION(onlp_ledi_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv)); __ONLP_DEFAULTI_IMPLEMENTATION(onlp_ledi_set(onlp_oid_t id, int on_or_off)); __ONLP_DEFAULTI_IMPLEMENTATION(onlp_ledi_ioctl(onlp_oid_t id, va_list vargs)); __ONLP_DEFAULTI_IMPLEMENTATION(onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode)); diff --git a/packages/base/any/onlp/src/onlp_platform_defaults/module/src/psui.c b/packages/base/any/onlp/src/onlp_platform_defaults/module/src/psui.c index ce534c88..5ef6d408 100644 --- a/packages/base/any/onlp/src/onlp_platform_defaults/module/src/psui.c +++ b/packages/base/any/onlp/src/onlp_platform_defaults/module/src/psui.c @@ -28,4 +28,6 @@ __ONLP_DEFAULTI_IMPLEMENTATION(onlp_psui_init(void)); __ONLP_DEFAULTI_IMPLEMENTATION(onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* rv)); +__ONLP_DEFAULTI_IMPLEMENTATION(onlp_psui_status_get(onlp_oid_t id, uint32_t* rv)); +__ONLP_DEFAULTI_IMPLEMENTATION(onlp_psui_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv)); __ONLP_DEFAULTI_IMPLEMENTATION(onlp_psui_ioctl(onlp_oid_t pid, va_list vargs)); diff --git a/packages/base/any/onlp/src/onlp_platform_defaults/module/src/thermali.c b/packages/base/any/onlp/src/onlp_platform_defaults/module/src/thermali.c index 3593961c..7117fbe9 100644 --- a/packages/base/any/onlp/src/onlp_platform_defaults/module/src/thermali.c +++ b/packages/base/any/onlp/src/onlp_platform_defaults/module/src/thermali.c @@ -28,4 +28,6 @@ __ONLP_DEFAULTI_IMPLEMENTATION(onlp_thermali_init(void)); __ONLP_DEFAULTI_IMPLEMENTATION(onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* rv)); +__ONLP_DEFAULTI_IMPLEMENTATION(onlp_thermali_status_get(onlp_oid_t id, uint32_t* rv)); +__ONLP_DEFAULTI_IMPLEMENTATION(onlp_thermali_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv)); __ONLP_DEFAULTI_IMPLEMENTATION(onlp_thermali_ioctl(int code, va_list vargs));