Add privilege check in all public APIs
[platform/core/api/peripheral-io.git] / src / peripheral_adc.c
index 788d813..e4b7623 100644 (file)
@@ -56,6 +56,7 @@ static inline void cleanup_handlep(peripheral_adc_h *handle)
  */
 int peripheral_adc_open(int device, int channel, peripheral_adc_h *adc)
 {
+       RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
        RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "ADC feature is not supported");
        RETVM_IF(adc == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid adc handle");
        RETVM_IF(device < 0, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid adc device number");
@@ -89,6 +90,7 @@ int peripheral_adc_open(int device, int channel, peripheral_adc_h *adc)
  */
 int peripheral_adc_close(peripheral_adc_h adc)
 {
+       RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
        RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "ADC feature is not supported");
        RETVM_IF(adc == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "adc handle is NULL");
 
@@ -102,6 +104,7 @@ int peripheral_adc_close(peripheral_adc_h adc)
  */
 int peripheral_adc_read(peripheral_adc_h adc, uint32_t *value)
 {
+       RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
        RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "ADC feature is not supported");
        RETVM_IF(adc == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "adc handle is NULL");
        RETVM_IF(value == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "adc read value is invalid");