Minor log changes in interface module 33/133133/3 accepted/tizen/unified/20170613.194840 submit/tizen/20170613.105843
authorHyeongsik Min <hyeongsik.min@samsung.com>
Fri, 9 Jun 2017 04:44:09 +0000 (13:44 +0900)
committerHyeongsik Min <hyeongsik.min@samsung.com>
Tue, 13 Jun 2017 04:41:43 +0000 (04:41 +0000)
- Add log messages to open, close and configuration functon.
- Remove log messages in read and write function to prevent log
  spam.

Change-Id: Ie26d8335ba4633a9d4fd039bc5dd28c5d968bab4
Signed-off-by: Hyeongsik Min <hyeongsik.min@samsung.com>
src/interface/gpio.c
src/interface/i2c.c
src/interface/pwm.c
src/interface/spi.c
src/interface/uart.c

index 945daa3..8934b04 100644 (file)
@@ -32,6 +32,8 @@ int gpio_open(int gpiopin)
        int fd, len, status;
        char gpio_export[GPIO_BUFFER_MAX] = {0, };
 
+       _D("gpiopin : %d", gpiopin);
+
        fd = open(SYSFS_GPIO_DIR "/export", O_WRONLY);
        if (fd < 0) {
                char errmsg[MAX_ERR_LEN];
@@ -59,6 +61,8 @@ int gpio_set_direction(int gpiopin, gpio_direction_e dir)
        int fd, status;
        char gpio_dev[GPIO_BUFFER_MAX] = {0, };
 
+       _D("gpiopin : %d, dir : %d", gpiopin, dir);
+
        snprintf(gpio_dev, GPIO_BUFFER_MAX, SYSFS_GPIO_DIR"/gpio%d/direction", gpiopin);
        fd = open(gpio_dev, O_WRONLY);
        if (fd < 0) {
@@ -134,6 +138,8 @@ int gpio_set_edge_mode(int gpiopin, gpio_edge_e edge)
        int fd, status;
        char gpio_dev[GPIO_BUFFER_MAX] = {0, };
 
+       _D("gpiopin : %d, edge : %d", gpiopin, edge);
+
        snprintf(gpio_dev, GPIO_BUFFER_MAX, SYSFS_GPIO_DIR"/gpio%d/edge", gpiopin);
        fd = open(gpio_dev, O_WRONLY);
        if (fd < 0) {
@@ -286,6 +292,8 @@ int gpio_close(int gpiopin)
        int fd, len, status;
        char gpio_unexport[GPIO_BUFFER_MAX] = {0, };
 
+       _D("gpiopin : %d", gpiopin);
+
        fd = open(SYSFS_GPIO_DIR "/unexport", O_WRONLY);
        if (fd < 0) {
                char errmsg[MAX_ERR_LEN];
index 3162e61..1e40ca6 100644 (file)
@@ -32,6 +32,8 @@ int i2c_open(int bus, int *fd)
        int new_fd;
        char i2c_dev[I2C_BUFFER_MAX] = {0,};
 
+       _D("bus : %d", bus);
+
        snprintf(i2c_dev, sizeof(i2c_dev)-1, SYSFS_I2C_DIR"-%d", bus);
        new_fd = open(i2c_dev, O_RDWR);
 
@@ -50,8 +52,9 @@ int i2c_close(int fd)
 {
        int status;
 
-       if (fd < 0) return -EINVAL;
+       _D("fd : %d", fd);
 
+       if (fd < 0) return -EINVAL;
        status = close(fd);
 
        if (status < 0) {
@@ -68,7 +71,8 @@ int i2c_set_address(int fd, int address)
 {
        int status;
 
-       _D("slave address : %x", address);
+       _D("slave address : 0x%x", address);
+
        status = ioctl(fd, I2C_SLAVE, address);
 
        if (status < 0) {
@@ -85,7 +89,6 @@ int i2c_read(int fd, unsigned char *data, int length)
 {
        int status;
 
-       _D("fd : %d, length : %d", fd, length);
        status = read(fd, data, length);
 
        if (status != length) {
@@ -102,7 +105,6 @@ int i2c_write(int fd, const unsigned char *data, int length)
 {
        int status;
 
-       _D("fd : %d, length : %d", fd, length);
        status = write(fd, data, length);
 
        if (status != length) {
@@ -119,7 +121,6 @@ int i2c_smbus_ioctl(int fd, struct i2c_smbus_ioctl_data *data)
 {
        int status;
 
-       _D("fd : %d", fd);
        status = ioctl(fd, I2C_SMBUS, data);
        if (status < 0) {
                char errmsg[MAX_ERR_LEN];
index 31bfe37..f899b6b 100644 (file)
@@ -37,6 +37,8 @@ int pwm_open(int device, int channel)
        char pwm_dev[PATH_BUF_MAX] = {0};
        char pwm_buf[PWM_BUF_MAX] = {0};
 
+       _D("device : %d, channel : %d", device, channel);
+
        snprintf(pwm_dev, PATH_BUF_MAX, SYSFS_PWM_PATH "/pwmchip%d/export", device);
        fd = open(pwm_dev, O_WRONLY);
        if (fd < 0) {
@@ -64,6 +66,8 @@ int pwm_close(int device, int channel)
        char pwm_dev[PATH_BUF_MAX] = {0};
        char pwm_buf[PWM_BUF_MAX] = {0};
 
+       _D("device : %d, channel : %d", device, channel);
+
        snprintf(pwm_dev, PATH_BUF_MAX, SYSFS_PWM_PATH "/pwmchip%d/unexport", device);
        fd = open(pwm_dev, O_WRONLY);
        if (fd < 0) {
@@ -91,7 +95,8 @@ int pwm_set_period(int device, int channel, int period)
        char pwm_buf[PWM_BUF_MAX] = {0};
        char pwm_dev[PATH_BUF_MAX] = {0};
 
-       _D("Set period : %d, device : %d, channel : %d", period, device, channel);
+       _D("device : %d, channel : %d, period : %d", device, channel, period);
+
        snprintf(pwm_dev, PATH_BUF_MAX, SYSFS_PWM_PATH "/pwmchip%d/pwm%d/period", device, channel);
        fd = open(pwm_dev, O_WRONLY);
        if (fd < 0) {
@@ -147,7 +152,8 @@ int pwm_set_duty_cycle(int device, int channel, int duty_cycle)
        char pwm_buf[PWM_BUF_MAX] = {0};
        char pwm_dev[PATH_BUF_MAX] = {0};
 
-       _D("Set duty_cycle : %d, device : %d, channel : %d", duty_cycle, device, channel);
+       _D("device : %d, channel : %d, duty_cycle : %d", device, channel, duty_cycle);
+
        snprintf(pwm_dev, PATH_BUF_MAX, SYSFS_PWM_PATH "/pwmchip%d/pwm%d/duty_cycle", device, channel);
        fd = open(pwm_dev, O_WRONLY);
        if (fd < 0) {
@@ -202,7 +208,8 @@ int pwm_set_polarity(int device, int channel, pwm_polarity_e polarity)
        int fd, status;
        char pwm_dev[PATH_BUF_MAX] = {0};
 
-       _D("Set polarity : %d, device : %d, channel : %d", polarity, device, channel);
+       _D("device : %d, channel : %d, polarity : %d", device, channel, polarity);
+
        snprintf(pwm_dev, PATH_BUF_MAX, SYSFS_PWM_PATH "/pwmchip%d/pwm%d/polarity", device, channel);
        fd = open(pwm_dev, O_WRONLY);
        if (fd < 0) {
@@ -274,7 +281,8 @@ int pwm_set_enable(int device, int channel, bool enable)
        char pwm_buf[PWM_BUF_MAX] = {0};
        char pwm_dev[PATH_BUF_MAX] = {0};
 
-       _D("Set enable : %d, device : %d, channel : %d", enable, device, channel);
+       _D("device : %d, channel : %d, enable : %d", device, channel, enable);
+
        snprintf(pwm_dev, PATH_BUF_MAX, SYSFS_PWM_PATH "/pwmchip%d/pwm%d/enable", device, channel);
        fd = open(pwm_dev, O_WRONLY);
        if (fd < 0) {
index abe75a2..601be5c 100644 (file)
@@ -36,6 +36,8 @@ int spi_open(int bus, int cs, int *fd)
        int new_fd = 0;
        char spi_dev[SPI_BUFFER_MAX] = {0,};
 
+       _D("bus : %d, cs : %d", bus, cs);
+
        snprintf(spi_dev, sizeof(spi_dev)-1, SYSFS_SPI_DIR"%d.%d", bus, cs);
 
        new_fd = open(spi_dev, O_RDWR);
@@ -54,6 +56,8 @@ int spi_close(int fd)
 {
        int status;
 
+       _D("fd : %d", fd);
+
        if (fd < 0) return -EINVAL;
 
        status = close(fd);
@@ -71,6 +75,8 @@ int spi_set_mode(int fd, unsigned char mode)
 {
        int status;
 
+       _D("fd : %d, mode : %d", fd, mode);
+
        if (fd < 0) return -EINVAL;
 
        _D("Set mode : %d", mode);
@@ -108,6 +114,8 @@ int spi_set_lsb_first(int fd, unsigned char lsb)
 {
        int status;
 
+       _D("fd : %d, lsb : %d", fd, lsb);
+
        if (fd < 0) return -EINVAL;
 
        _D("Set lsb first : %d", lsb);
@@ -145,6 +153,8 @@ int spi_set_bits(int fd, unsigned char bits)
 {
        int status;
 
+       _D("fd : %d, bits : %d", fd, bits);
+
        if (fd < 0) return -EINVAL;
 
        _D("Set bit per word : %d", bits);
@@ -182,6 +192,8 @@ int spi_set_frequency(int fd, unsigned int freq)
 {
        int status;
 
+       _D("fd : %d, freq : %d", fd, freq);
+
        if (fd < 0) return -EINVAL;
 
        _D("Set frequency : %d", freq);
index 52fbe0e..2468c02 100644 (file)
@@ -48,6 +48,8 @@ int uart_open(int port, int *file_hndl)
        int fd;
        char fName[PATH_BUF_MAX] = {0};
 
+       _D("port : %d", port);
+
        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__);
@@ -59,6 +61,8 @@ int uart_open(int port, int *file_hndl)
 
 int uart_close(int file_hndl)
 {
+       _D("file_hndl : %d", file_hndl);
+
        if (!file_hndl) {
                _E("Error[%d]: Invalid parameter, %s--[%d]\n", errno, __FUNCTION__, __LINE__);
                return -EINVAL;
@@ -70,6 +74,7 @@ int uart_close(int file_hndl)
 int uart_flush(int file_hndl)
 {
        int ret;
+
        if (!file_hndl) {
                _E("Error[%d]: Invalid parameter, %s--[%d]\n", errno, __FUNCTION__, __LINE__);
                return -EINVAL;
@@ -89,6 +94,8 @@ int uart_set_baudrate(int file_hndl, uart_baudrate_e baud)
        int ret;
        struct termios tio;
 
+       _D("file_hndl : %d, baud : %d", file_hndl, baud);
+
        memset(&tio, 0, sizeof(tio));
        if (!file_hndl) {
                _E("Error[%d]: Invalid parameter, %s--[%d]\n", errno, __FUNCTION__, __LINE__);
@@ -127,6 +134,8 @@ int uart_set_mode(int file_hndl, uart_bytesize_e bytesize, uart_parity_e parity,
        int ret;
        struct termios tio;
 
+       _D("file_hndl : %d, bytesize : %d, parity : %d, stopbits : %d", file_hndl, bytesize, parity, stopbits);
+
        if (!file_hndl) {
                _E("Error[%d]: Invalid parameter, %s--[%d]\n", errno, __FUNCTION__, __LINE__);
                return -EINVAL;
@@ -192,6 +201,8 @@ int uart_set_flowcontrol(int file_hndl, bool xonxoff, bool rtscts)
        int ret;
        struct termios tio;
 
+       _D("file_hndl : %d, xonxoff : %d, rtscts : %d", file_hndl, xonxoff, rtscts);
+
        if (!file_hndl) {
                _E("Error[%d]: Invalid parameter, %s--[%d]\n", errno, __FUNCTION__, __LINE__);
                return -EINVAL;