return (i2c_feature == I2C_FEATURE_TRUE ? true : false);
}
-int peripheral_i2c_open(int bus, int address, peripheral_i2c_h *i2c)
+int peripheral_i2c_open_flags(int bus, int address, peripheral_open_flags_e flags, peripheral_i2c_h *i2c)
{
peripheral_i2c_h handle;
int ret = PERIPHERAL_ERROR_NONE;
return ret;
}
-int peripheral_i2c_open_flags(int bus, int address, peripheral_open_flags_e flags, peripheral_i2c_h *i2c)
+int peripheral_i2c_open(int bus, int address, peripheral_i2c_h *i2c)
{
- peripheral_i2c_h handle;
- int ret = PERIPHERAL_ERROR_NONE;
-
- RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "I2C feature is not supported");
- RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid i2c handle");
- RETVM_IF(bus < 0 || address < 0, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- handle = (peripheral_i2c_h)malloc(sizeof(struct _peripheral_i2c_s));
- if (handle == NULL) {
- _E("Failed to allocate peripheral_i2c_h");
- return PERIPHERAL_ERROR_OUT_OF_MEMORY;
- }
-
- ret = peripheral_direct_i2c_open(bus, address, &handle->fd);
- if (ret != PERIPHERAL_ERROR_NONE) {
- _E("Failed to open i2c communication, ret : %d", ret);
- free(handle);
- handle = NULL;
- }
-
- *i2c = handle;
-
- return ret;
+ return peripheral_i2c_open_flags(bus, address, PERIPHERAL_OPEN_FLAGS_PRIVATE, i2c);
}
int peripheral_i2c_close(peripheral_i2c_h i2c)