- it is checked by the caller.
- the check is meaningless even if handle is not opened.
Change-Id: Id22083b04f4e95a0788a32f1cbc2929c08dd8c31
Signed-off-by: Segwon <segwon.han@samsung.com>
int peripheral_interface_i2c_close(peripheral_i2c_h i2c)
{
- int status;
-
- _D("fd : %d", i2c->fd);
- RETVM_IF(i2c->fd < 0, -EINVAL, "Invalid fd");
-
- status = close(i2c->fd);
+ int status = close(i2c->fd);
CHECK_ERROR(status);
return 0;
int peripheral_interface_i2c_read(peripheral_i2c_h i2c, uint8_t *data, uint32_t length)
{
- int status;
-
- RETVM_IF(i2c->fd < 0, -EINVAL, "Invalid fd : %d", i2c->fd);
-
- status = read(i2c->fd, data, length);
+ int status = read(i2c->fd, data, length);
CHECK_ERROR(status);
return 0;
int peripheral_interface_i2c_write(peripheral_i2c_h i2c, uint8_t *data, uint32_t length)
{
- int status;
-
- RETVM_IF(i2c->fd < 0, -EINVAL, "Invalid fd : %d", i2c->fd);
-
- status = write(i2c->fd, data, length);
+ int status = write(i2c->fd, data, length);
CHECK_ERROR(status);
return 0;
int peripheral_interface_i2c_smbus_ioctl(peripheral_i2c_h i2c, struct i2c_smbus_ioctl_data *data)
{
- int status;
-
- RETVM_IF(i2c->fd < 0, -EINVAL, "Invalid fd : %d", i2c->fd);
-
- status = ioctl(i2c->fd, I2C_SMBUS, data);
+ int status = ioctl(i2c->fd, I2C_SMBUS, data);
CHECK_ERROR(status);
return 0;
int peripheral_interface_spi_close(peripheral_spi_h spi)
{
- int status;
-
- _D("fd : %d", spi->fd);
- RETVM_IF(spi->fd < 0, -EINVAL, "Invalid fd");
-
- status = close(spi->fd);
+ int status = close(spi->fd);
CHECK_ERROR(status);
return 0;
int peripheral_interface_spi_set_mode(peripheral_spi_h spi, peripheral_spi_mode_e mode)
{
- int status;
-
- _D("fd : %d, mode : %d", spi->fd, mode);
- RETVM_IF(spi->fd < 0, -EINVAL, "Invalid fd");
-
- status = ioctl(spi->fd, SPI_IOC_WR_MODE, &mode);
+ int status = ioctl(spi->fd, SPI_IOC_WR_MODE, &mode);
CHECK_ERROR(status);
return 0;
int peripheral_interface_spi_set_bit_order(peripheral_spi_h spi, peripheral_spi_bit_order_e bit_order)
{
- int status;
-
- _D("fd : %d, lsb : %d", spi->fd, bit_order);
- RETVM_IF(spi->fd < 0, -EINVAL, "Invalid fd");
-
- status = ioctl(spi->fd, SPI_IOC_WR_LSB_FIRST, &bit_order);
+ int status = ioctl(spi->fd, SPI_IOC_WR_LSB_FIRST, &bit_order);
CHECK_ERROR(status);
return 0;
int peripheral_interface_spi_set_bits_per_word(peripheral_spi_h spi, uint8_t bits)
{
- int status;
-
- _D("fd : %d, bits : %d", spi->fd, bits);
- RETVM_IF(spi->fd < 0, -EINVAL, "Invalid fd");
-
- status = ioctl(spi->fd, SPI_IOC_WR_BITS_PER_WORD, &bits);
+ int status = ioctl(spi->fd, SPI_IOC_WR_BITS_PER_WORD, &bits);
CHECK_ERROR(status);
return 0;
int peripheral_interface_spi_set_frequency(peripheral_spi_h spi, uint32_t freq)
{
- int status;
-
- _D("fd : %d, freq : %d", spi->fd, freq);
- RETVM_IF(spi->fd < 0, -EINVAL, "Invalid fd");
-
- status = ioctl(spi->fd, SPI_IOC_WR_MAX_SPEED_HZ, &freq);
+ int status = ioctl(spi->fd, SPI_IOC_WR_MAX_SPEED_HZ, &freq);
CHECK_ERROR(status);
return 0;
int status;
struct spi_ioc_transfer xfer;
- RETVM_IF(spi->fd < 0, -EINVAL, "Invalid fd : %d", spi->fd);
-
memset(&xfer, 0, sizeof(struct spi_ioc_transfer));
xfer.rx_buf = (unsigned long)rxbuf;
xfer.len = length;
int status;
struct spi_ioc_transfer xfer;
- RETVM_IF(spi->fd < 0, -EINVAL, "Invalid fd : %d", spi->fd);
-
memset(&xfer, 0, sizeof(struct spi_ioc_transfer));
xfer.tx_buf = (unsigned long)txbuf;
xfer.len = length;
int status;
struct spi_ioc_transfer xfer;
- RETVM_IF(spi->fd < 0, -EINVAL, "Invalid fd : %d", spi->fd);
-
if (!txbuf || !rxbuf) return -EINVAL;
memset(&xfer, 0, sizeof(xfer));
{
int status;
- _D("file_hndl : %d", uart->fd);
-
- if (uart->fd < 0) {
- _E("Invalid NULL parameter");
- return -EINVAL;
- }
-
status = peripheral_interface_uart_flush(uart);
CHECK_ERROR(status);
int peripheral_interface_uart_flush(peripheral_uart_h uart)
{
- int ret;
-
- if (!uart->fd) {
- _E("Invalid NULL parameter");
- return -EINVAL;
- }
-
- ret = tcflush(uart->fd, TCIOFLUSH);
+ int ret = tcflush(uart->fd, TCIOFLUSH);
CHECK_ERROR(ret);
return 0;
int ret;
struct termios tio;
- _D("file_hndl : %d, baud : %d", uart->fd, baud);
-
- memset(&tio, 0, sizeof(tio));
- if (!uart->fd) {
- _E("Invalid NULL parameter");
- return -EINVAL;
- }
-
- if (baud > PERIPHERAL_UART_BAUD_RATE_230400) {
- _E("Invalid parameter");
- return -EINVAL;
- }
-
ret = tcgetattr(uart->fd, &tio);
CHECK_ERROR(ret);
int ret;
struct termios tio;
- _D("file_hndl : %d, bytesize : %d", uart->fd, byte_size);
-
- if (!uart->fd) {
- _E("Invalid NULL parameter");
- return -EINVAL;
- }
-
- if (byte_size > PERIPHERAL_UART_BYTE_SIZE_8BIT) {
- _E("Invalid bytesize parameter");
- return -EINVAL;
- }
-
ret = tcgetattr(uart->fd, &tio);
CHECK_ERROR(ret);
-
/* set byte size */
tio.c_cflag &= ~CSIZE;
tio.c_cflag |= byteinfo[byte_size];
int ret;
struct termios tio;
- _D("file_hndl : %d, parity : %d", uart->fd, parity);
-
- if (!uart->fd) {
- _E("Invalid NULL parameter");
- return -EINVAL;
- }
-
ret = tcgetattr(uart->fd, &tio);
CHECK_ERROR(ret);
int ret;
struct termios tio;
- _D("file_hndl : %d, stopbits : %d", uart->fd, stop_bits);
-
- if (!uart->fd) {
- _E("Invalid NULL parameter");
- return -EINVAL;
- }
-
ret = tcgetattr(uart->fd, &tio);
CHECK_ERROR(ret);
int ret;
struct termios tio;
- _D("file_hndl : %d, xonxoff : %d, rtscts : %d", uart->fd, xonxoff, rtscts);
-
- if (!uart->fd) {
- _E("Invalid NULL parameter");
- return -EINVAL;
- }
-
ret = tcgetattr(uart->fd, &tio);
CHECK_ERROR(ret);
int peripheral_interface_uart_read(peripheral_uart_h uart, uint8_t *buf, uint32_t length)
{
- int ret;
-
- if (!uart->fd) {
- _E("Invalid NULL parameter");
- return -EINVAL;
- }
-
- ret = read(uart->fd, (void *)buf, length);
+ int ret = read(uart->fd, (void *)buf, length);
CHECK_ERROR(ret);
return ret;
int peripheral_interface_uart_write(peripheral_uart_h uart, uint8_t *buf, uint32_t length)
{
- int ret;
-
- if (!uart->fd) {
- _E("Invalid NULL parameter");
- return -EINVAL;
- }
-
- ret = write(uart->fd, buf, length);
+ int ret = write(uart->fd, buf, length);
CHECK_ERROR(ret);
return ret;