static int i2c_sbcon_init(struct device *dev) { struct i2c_sbcon_context *context = dev->driver_data; const struct i2c_sbcon_config *config = dev->config->config_info; i2c_bitbang_init(&context->bitbang, &io_fns, config->sbcon); dev->driver_api = &api; return 0; }
static int i2c_gpio_init(struct device *dev) { struct i2c_gpio_context *context = dev->driver_data; const struct i2c_gpio_config *config = dev->config->config_info; context->gpio = device_get_binding(config->gpio_name); if (!context->gpio) { return -EINVAL; } context->sda_pin = config->sda_pin; context->scl_pin = config->scl_pin; i2c_bitbang_init(&context->bitbang, &io_fns, context); /* * Set driver_api at very end of init so if we return early with error * then the device can't be found later by device_get_binding. This is * important because driver framework ignores errors from init * functions. */ dev->driver_api = &api; return 0; }