Change error code ENODEV to ENXIO for the case of no such device.
Change-Id: I4d5daa1c4b402f608ae217819ae79a4afb6f6fc5
snprintf(buf, PATH_BUF_MAX, "%s%d%s", SYSFS_ADC_PATH, device, "/name");
if ((fd = open(buf, O_RDONLY)) < 0) {
_E("Cannot open %s, errno : %d", buf, errno);
- return -ENODEV;
+ return -ENXIO;
}
if ((bytes = read(fd, buf, PATH_BUF_MAX)) == -1) {
snprintf(fName, PATH_BUF_MAX, "%s%s%s%d%s%d%s", "/sys/devices/", devName, "/iio:device", device, "/in_voltage", channel, "_raw");
if ((fd = open(fName, O_RDONLY)) < 0) {
_E("Error[%d]: can't open adc%d channel, %s--[%d]\n", errno, channel, __FUNCTION__, __LINE__);
- return -ENODEV;
+ return -ENXIO;
}
bytes = read(fd, voltage, ADC_BUF_MAX);
if (bytes == -1) {
char errmsg[MAX_ERR_LEN];
strerror_r(errno, errmsg, MAX_ERR_LEN);
_E("Can't Open /sys/class/gpio/export :%s\n", errmsg);
- return -ENODEV;
+ return -ENXIO;
}
len = snprintf(gpio_export, GPIO_BUFFER_MAX, "%d", gpiopin);
char errmsg[MAX_ERR_LEN];
strerror_r(errno, errmsg, MAX_ERR_LEN);
_E("Can't Open /sys/class/gpio/gpio%d/direction: %s\n", gpiopin, errmsg);
- return -ENODEV;
+ return -ENXIO;
}
if (dir == GPIO_DIRECTION_OUT)
char errmsg[MAX_ERR_LEN];
strerror_r(errno, errmsg, MAX_ERR_LEN);
_E("Can't Open /sys/class/gpio/gpio%d/direction: %s\n", gpiopin, errmsg);
- return -ENODEV;
+ return -ENXIO;
}
len = read(fd, &gpio_buf, GPIO_BUFFER_MAX);
char errmsg[MAX_ERR_LEN];
strerror_r(errno, errmsg, MAX_ERR_LEN);
_E("Can't Open /sys/class/gpio/gpio%d/edge: %s\n", gpiopin, errmsg);
- return -ENODEV;
+ return -ENXIO;
}
if (edge == GPIO_EDGE_NONE)
char errmsg[MAX_ERR_LEN];
strerror_r(errno, errmsg, MAX_ERR_LEN);
_E("Can't Open /sys/class/gpio/gpio%d/edge: %s\n", gpiopin, errmsg);
- return -ENODEV;
+ return -ENXIO;
}
len = read(fd, &gpio_buf, GPIO_BUFFER_MAX);
char errmsg[MAX_ERR_LEN];
strerror_r(errno, errmsg, MAX_ERR_LEN);
_E("Can't Open /sys/class/gpio/gpio%d/value: %s\n", gpiopin, errmsg);
- return -ENODEV;
+ return -ENXIO;
}
if (value == 1)
char errmsg[MAX_ERR_LEN];
strerror_r(errno, errmsg, MAX_ERR_LEN);
_E("Can't Open /sys/class/gpio/gpio%d pin value: %s\n", gpiopin, errmsg);
- return -ENODEV;
+ return -ENXIO;
}
len = read(fd, &gpio_buf, 1);
char errmsg[MAX_ERR_LEN];
strerror_r(errno, errmsg, MAX_ERR_LEN);
_E("Can't Open /sys/class/gpio/unexport %s\n", errmsg);
- return -ENODEV;
+ return -ENXIO;
}
len = snprintf(gpio_unexport, GPIO_BUFFER_MAX, "%d", gpiopin);
char errmsg[MAX_ERR_LEN];
strerror_r(errno, errmsg, MAX_ERR_LEN);
_E("Can't Open /sys/class/gpio/gpio%d pin value: %s\n", gpiopin, errmsg);
- return -ENODEV;
+ return -ENXIO;
}
return fd;
char errmsg[MAX_ERR_LEN];
strerror_r(errno, errmsg, MAX_ERR_LEN);
_E("Can't Open %s : %s", i2c_dev, errmsg);
- return -ENODEV;
+ return -ENXIO;
}
*fd = new_fd;
char errmsg[MAX_ERR_LEN];
strerror_r(errno, errmsg, MAX_ERR_LEN);
_E("Can't Open %s, errmsg : %s", pwm_dev, errmsg);
- return -ENODEV;
+ return -ENXIO;
}
len = snprintf(pwm_buf, sizeof(pwm_buf), "%d", channel);
char errmsg[MAX_ERR_LEN];
strerror_r(errno, errmsg, MAX_ERR_LEN);
_E("Can't Open %s, errmsg : %s", pwm_dev, errmsg);
- return -ENODEV;
+ return -ENXIO;
}
len = snprintf(pwm_buf, sizeof(pwm_buf), "%d", channel);
char errmsg[MAX_ERR_LEN];
strerror_r(errno, errmsg, MAX_ERR_LEN);
_E("Can't Open %s, errmsg : %s", pwm_dev, errmsg);
- return -ENODEV;
+ return -ENXIO;
}
len = snprintf(pwm_buf, sizeof(pwm_buf), "%d", period);
char errmsg[MAX_ERR_LEN];
strerror_r(errno, errmsg, MAX_ERR_LEN);
_E("Can't Open %s, errmsg : %s", pwm_dev, errmsg);
- return -ENODEV;
+ return -ENXIO;
}
status = read(fd, pwm_buf, PWM_BUF_MAX);
char errmsg[MAX_ERR_LEN];
strerror_r(errno, errmsg, MAX_ERR_LEN);
_E("Can't Open %s, errmsg : %s", pwm_dev, errmsg);
- return -ENODEV;
+ return -ENXIO;
}
len = snprintf(pwm_buf, sizeof(pwm_buf), "%d", duty_cycle);
char errmsg[MAX_ERR_LEN];
strerror_r(errno, errmsg, MAX_ERR_LEN);
_E("Can't Open %s, errmsg : %s", pwm_dev, errmsg);
- return -ENODEV;
+ return -ENXIO;
}
status = read(fd, pwm_buf, PWM_BUF_MAX);
char errmsg[MAX_ERR_LEN];
strerror_r(errno, errmsg, MAX_ERR_LEN);
_E("Can't Open %s, errmsg : %s", pwm_dev, errmsg);
- return -ENODEV;
+ return -ENXIO;
}
if (polarity == PWM_POLARITY_NORMAL)
char errmsg[MAX_ERR_LEN];
strerror_r(errno, errmsg, MAX_ERR_LEN);
_E("Can't Open %s, errmsg : %s", pwm_dev, errmsg);
- return -ENODEV;
+ return -ENXIO;
}
status = read(fd, pwm_buf, PWM_BUF_MAX);
char errmsg[MAX_ERR_LEN];
strerror_r(errno, errmsg, MAX_ERR_LEN);
_E("Can't Open %s, errmsg : %s", pwm_dev, errmsg);
- return -ENODEV;
+ return -ENXIO;
}
len = snprintf(pwm_buf, sizeof(pwm_buf), "%d", enable);
char errmsg[MAX_ERR_LEN];
strerror_r(errno, errmsg, MAX_ERR_LEN);
_E("Can't Open %s, errmsg : %s", pwm_dev, errmsg);
- return -ENODEV;
+ return -ENXIO;
}
status = read(fd, pwm_buf, PWM_BUF_MAX);
char errmsg[MAX_ERR_LEN];
strerror_r(errno, errmsg, MAX_ERR_LEN);
_E("Can't Open %s, errmsg : %s", spi_dev, errmsg);
- return -ENODEV;
+ return -ENXIO;
}
*fd = new_fd;
char errmsg[MAX_ERR_LEN];
strerror_r(errno, errmsg, MAX_ERR_LEN);
_E("Can't Open %s, errmsg : %s", SYSFS_SPI_BUFSIZ, errmsg);
- return -ENODEV;
+ return -ENXIO;
}
status = read(fd, spi_buf, SPI_BUFFER_MAX);
snprintf(fName, PATH_BUF_MAX, SYSFS_UART_PATH "%d", port);
if ((fd = open(fName, O_RDWR | O_NOCTTY | O_NONBLOCK)) < 0) {
_E("Error[%d]: can't open %s, %s--[%d]\n", errno, fName, __FUNCTION__, __LINE__);
- return -ENOENT;
+ return -ENXIO;
}
*file_hndl = fd;
return 0;