* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: DongGi Jang <dg0402.jang@samsung.com>
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* See the License for the specific language governing permissions and
* limitations under the License.
*
-*/
+*/
#include <string.h>
#include <errno.h>
+#include "devman_error.h"
#include "devlog.h"
#include "device_engine.h"
API int device_get_property(devtype_t devtype, int property, int *value)
{
struct device *dev = NULL;
-retry:
+ int ret = -1;
+
+ retry:
if (dev != NULL) {
dev = dev->next;
if (dev == NULL) {
- errno = ENODEV;
- return -1;
+ DBG("devtype cannot find");
+ errno = EPERM;
+ return DEVMAN_ERROR_OPERATION_FAILED;
}
}
dev = find_device(dev, devtype);
if (dev == NULL) {
DBG("devtype cannot find");
- errno = ENODEV;
- return -1;
+ errno = EPERM;
+ return DEVMAN_ERROR_OPERATION_FAILED;
}
if (dev->get_int == NULL) {
DBG("get_int of %s is null", dev->devname);
goto retry;
}
- if (dev->get_int(property, value) == -1) {
+ ret = dev->get_int(property, value);
+ if (ret == -ENODEV) {
+ DBG("not support driver");
+ errno = ENODEV;
+ return DEVMAN_ERROR_NOT_SUPPORTED;
+ }
+ if (ret == -1) {
DBG("get_int of %s return fails", dev->devname);
goto retry;
}
errno = 0;
- return 0;
+ return ret;
}
API int device_set_property(devtype_t devtype, int property, int value)
{
struct device *dev = NULL;
-retry:
+ int ret = -1;
+
+ retry:
if (dev != NULL) {
dev = dev->next;
if (dev == NULL) {
- return -1;
+ DBG("devtype cannot find");
+ errno = EPERM;
+ return DEVMAN_ERROR_OPERATION_FAILED;
}
}
dev = find_device(dev, devtype);
if (dev == NULL) {
DBG("devtype cannot find");
- errno = ENODEV;
- return -1;
+ errno = EPERM;
+ return DEVMAN_ERROR_OPERATION_FAILED;
}
if (dev->set_int == NULL) {
- errno = EPERM;
+ DBG("set_int of %s is null", dev->devname);
goto retry;
}
- if (dev->set_int(property, value) == -1) {
- errno = EACCES;
+ ret = dev->set_int(property, value);
+ if (ret == -ENODEV) {
+ DBG("not support driver");
+ errno = ENODEV;
+ return DEVMAN_ERROR_NOT_SUPPORTED;
+ }
+ if (ret == -1) {
+ DBG("set_int of %s return fails", dev->devname);
goto retry;
}
errno = 0;
- return 0;
+ return ret;
}