static int max8997_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct max8997_dev *max8997; struct max8997_platform_data *pdata = i2c->dev.platform_data; int ret = 0; max8997 = kzalloc(sizeof(struct max8997_dev), GFP_KERNEL); if (max8997 == NULL) return -ENOMEM; i2c_set_clientdata(i2c, max8997); max8997->dev = &i2c->dev; max8997->i2c = i2c; max8997->type = id->driver_data; max8997->irq = i2c->irq; if (!pdata) goto err; max8997->irq_base = pdata->irq_base; max8997->ono = pdata->ono; max8997->wakeup = pdata->wakeup; mutex_init(&max8997->iolock); max8997->rtc = i2c_new_dummy(i2c->adapter, I2C_ADDR_RTC); i2c_set_clientdata(max8997->rtc, max8997); max8997->haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC); i2c_set_clientdata(max8997->haptic, max8997); max8997->muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC); i2c_set_clientdata(max8997->muic, max8997); pm_runtime_set_active(max8997->dev); max8997_irq_init(max8997); mfd_add_devices(max8997->dev, -1, max8997_devs, ARRAY_SIZE(max8997_devs), NULL, 0); /* * TODO: enable others (flash, muic, rtc, battery, ...) and * check the return value */ if (ret < 0) goto err_mfd; return ret; err_mfd: mfd_remove_devices(max8997->dev); i2c_unregister_device(max8997->muic); i2c_unregister_device(max8997->haptic); i2c_unregister_device(max8997->rtc); err: kfree(max8997); return ret; }
static void tegra_camera_disable(struct nvhost_device *ndev) { struct i2c_adapter *adapter; gpio_set_value_cansleep(TEGRA_CAMERA_GPIO_PMU, 0); gpio_set_value(TEGRA_CAMERA_GPIO_VI_GP3, 0); gpio_set_value(TEGRA_CAMERA_GPIO_CAM_PWR_EN, 0); gpio_free(TEGRA_CAMERA_GPIO_PMU); gpio_free(TEGRA_CAMERA_GPIO_VI_GP3); gpio_free(TEGRA_CAMERA_GPIO_CAM_PWR_EN); adapter = i2c_get_adapter(TEGRA_CAMERA_I2C_ADAPTER_ID); BUG_ON(!adapter); i2c_unregister_device(port_switch); i2c_unregister_device(port_expander); i2c_put_adapter(adapter); BUG_ON(!regulator); regulator_disable(regulator); regulator_put(regulator); regulator = NULL; /* Turn off relevant clocks. */ clk_disable(clk_vi); clk_disable(clk_vi_sensor); clk_disable(clk_csi); clk_disable(clk_isp); clk_disable(clk_csus); }
static int em28xx_dvb_fini(struct em28xx *dev) { struct em28xx_dvb *dvb; struct i2c_client *client; if (dev->is_audio_only) { /* Shouldn't initialize IR for this interface */ return 0; } if (!dev->board.has_dvb) { /* This device does not support the extension */ return 0; } if (!dev->dvb) return 0; em28xx_info("Closing DVB extension"); dvb = dev->dvb; client = dvb->i2c_client_tuner; em28xx_uninit_usb_xfer(dev, EM28XX_DIGITAL_MODE); if (dev->disconnected) { /* We cannot tell the device to sleep * once it has been unplugged. */ if (dvb->fe[0]) { prevent_sleep(&dvb->fe[0]->ops); dvb->fe[0]->exit = DVB_FE_DEVICE_REMOVED; } if (dvb->fe[1]) { prevent_sleep(&dvb->fe[1]->ops); dvb->fe[1]->exit = DVB_FE_DEVICE_REMOVED; } } /* remove I2C tuner */ if (client) { module_put(client->dev.driver->owner); i2c_unregister_device(client); } /* remove I2C demod */ client = dvb->i2c_client_demod; if (client) { module_put(client->dev.driver->owner); i2c_unregister_device(client); } em28xx_unregister_dvb(dvb); kfree(dvb); dev->dvb = NULL; kref_put(&dev->ref, em28xx_free_device); return 0; }
/* * In BTY, ACPI enumination will register all the camera i2c devices * which will cause v4l2_i2c_new_subdev_board() failed called in atomisp * driver. * Here we unregister the devices registered by ACPI */ static void atomisp_unregister_acpi_devices(struct atomisp_platform_data *pdata) { const char *subdev_name[] = { "3-0053", /* FFRD8 lm3554 */ "4-0036", /* ov2722 */ "4-0010", /* imx1xx Sensor*/ "4-0053", /* FFRD10 lm3554 */ "4-0054", /* imx1xx EEPROM*/ "4-000c", /* imx1xx driver*/ "2-0053", /* byt-crv2 lm3554*/ "2-0063", /* byt-crv2 lm3642*/ "2-0010", /* imx1xx driver*/ "2-0036", /* ov2722 driver*/ "2-003c", /* gc2235 driver*/ "2-0010", /* CHT OV5693 */ "4-003c", /* CHT AP1302 */ "1-0053", /* CHT lm3554 */ "4-001f", /* CHT m10mo */ #if 0 "INTCF0B:00", /* From ACPI ov2722 */ "INTCF1A:00", /* From ACPI imx175 */ "INTCF1C:00", /* From ACPI lm3554 */ #endif }; struct device *dev; struct i2c_client *client; struct i2c_board_info board_info; int i; /* search by device name */ for (i = 0; i < ARRAY_SIZE(subdev_name); i++) { dev = bus_find_device_by_name(&i2c_bus_type, NULL, subdev_name[i]); if (dev) { client = to_i2c_client(dev); board_info.flags = client->flags; board_info.addr = client->addr; board_info.irq = client->irq; strlcpy(board_info.type, client->name, sizeof(client->name)); i2c_unregister_device(client); } } #if 0 /* search by client name */ for (i = 0; i < ARRAY_SIZE(subdev_name); i++) { client = i2c_find_client_by_name(subdev_name[i]); if (client) { board_info.flags = client->flags; board_info.addr = client->addr; board_info.irq = client->irq; strlcpy(board_info.type, client->name, sizeof(client->name)); i2c_unregister_device(client); } } #endif }
void bmi_li3m02cm_remove(struct bmi_device *bdev) { struct bmi_li3m02cm *cam = bmi_device_get_drvdata (bdev); bmi_unregister_camera(bdev); i2c_unregister_device(cam->iox); i2c_unregister_device(cam->mt9t111); kfree (cam); return; }
static void __exit chromeos_laptop_exit(void) { if (als) i2c_unregister_device(als); if (tp) i2c_unregister_device(tp); if (ts) i2c_unregister_device(ts); }
static int max8925_remove(struct i2c_client *client) { struct max8925_chip *chip = i2c_get_clientdata(client); max8925_device_exit(chip); i2c_unregister_device(chip->adc); i2c_unregister_device(chip->rtc); return 0; }
static int max77693_i2c_remove(struct i2c_client *i2c) { struct max77693_dev *max77693 = i2c_get_clientdata(i2c); mfd_remove_devices(max77693->dev); i2c_unregister_device(max77693->muic); i2c_unregister_device(max77693->haptic); return 0; }
static int max77828_i2c_remove(struct i2c_client *i2c) { struct max77828_dev *max77828 = i2c_get_clientdata(i2c); mfd_remove_devices(max77828->dev); i2c_unregister_device(max77828->muic); i2c_unregister_device(max77828->led); kfree(max77828); return 0; }
static void sfe4001_fini(struct efx_nic *efx) { struct falcon_board *board = falcon_board(efx); EFX_INFO(efx, "%s\n", __func__); device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_flash_cfg); sfe4001_poweroff(efx); i2c_unregister_device(board->ioexp_client); i2c_unregister_device(board->hwmon_client); }
static void __exit chromeos_laptop_exit(void) { if (lumpy_tp) { i2c_unregister_device(lumpy_tp); lumpy_tp = NULL; } if (lumpy_als) { i2c_unregister_device(lumpy_als); lumpy_als = NULL; } }
static void pm800_pages_exit(struct pm80x_chip *chip) { struct pm80x_subchip *subchip; subchip = chip->subchip; if (subchip && subchip->power_page) i2c_unregister_device(subchip->power_page); if (subchip && subchip->gpadc_page) i2c_unregister_device(subchip->gpadc_page); }
static int max8997_i2c_remove(struct i2c_client *i2c) { struct max8997_dev *max8997 = i2c_get_clientdata(i2c); mfd_remove_devices(max8997->dev); i2c_unregister_device(max8997->muic); i2c_unregister_device(max8997->haptic); i2c_unregister_device(max8997->rtc); kfree(max8997); return 0; }
static int max77693_i2c_remove(struct i2c_client *i2c) { struct max77693_dev *max77693 = i2c_get_clientdata(i2c); mfd_remove_devices(max77693->dev); i2c_unregister_device(max77693->muic); i2c_unregister_device(max77693->haptic); max77693_irq_exit(max77693); mutex_destroy(&max77693->iolock); kfree(max77693); return 0; }
static void stmhdmi_i2c_disconnect(struct stm_hdmi *hdmi) { if(hdmi->edid_client) { i2c_unregister_device(hdmi->edid_client); hdmi->edid_client = 0; } if(hdmi->eddc_segment_reg_client) { i2c_unregister_device(hdmi->eddc_segment_reg_client); hdmi->eddc_segment_reg_client = 0; } }
int cx18_i2c_register(struct cx18 *cx, unsigned idx) { struct i2c_board_info info; struct i2c_client *c; u8 id, bus; int i; CX18_DEBUG_I2C("i2c client register\n"); if (idx >= ARRAY_SIZE(hw_driverids) || hw_driverids[idx] == 0) return -1; id = hw_driverids[idx]; bus = hw_bus[idx]; memset(&info, 0, sizeof(info)); strlcpy(info.type, hw_devicenames[idx], sizeof(info.type)); info.addr = hw_addrs[idx]; for (i = 0; i < I2C_CLIENTS_MAX; i++) if (cx->i2c_clients[i] == NULL) break; if (i == I2C_CLIENTS_MAX) { CX18_ERR("insufficient room for new I2C client!\n"); return -ENOMEM; } if (id != I2C_DRIVERID_TUNER) { c = i2c_new_device(&cx->i2c_adap[bus], &info); if (c->driver == NULL) i2c_unregister_device(c); else cx->i2c_clients[i] = c; return cx->i2c_clients[i] ? 0 : -ENODEV; } /* special tuner handling */ c = i2c_new_probed_device(&cx->i2c_adap[1], &info, cx->card_i2c->radio); if (c && c->driver == NULL) i2c_unregister_device(c); else if (c) cx->i2c_clients[i++] = c; c = i2c_new_probed_device(&cx->i2c_adap[1], &info, cx->card_i2c->demod); if (c && c->driver == NULL) i2c_unregister_device(c); else if (c) cx->i2c_clients[i++] = c; c = i2c_new_probed_device(&cx->i2c_adap[1], &info, cx->card_i2c->tv); if (c && c->driver == NULL) i2c_unregister_device(c); else if (c) cx->i2c_clients[i++] = c; return 0; }
/* This board uses an I2C expander to provider power to the PHY, which needs to * be turned on before the PHY can be used. * Context: Process context, rtnl lock held */ static int sfe4001_init(struct efx_nic *efx) { struct falcon_board *board = falcon_board(efx); int rc; #if defined(CONFIG_SENSORS_LM90) || defined(CONFIG_SENSORS_LM90_MODULE) board->hwmon_client = i2c_new_device(&board->i2c_adap, &sfe4001_hwmon_info); #else board->hwmon_client = i2c_new_dummy(&board->i2c_adap, sfe4001_hwmon_info.addr); #endif if (!board->hwmon_client) return -EIO; /* Raise board/PHY high limit from 85 to 90 degrees Celsius */ rc = i2c_smbus_write_byte_data(board->hwmon_client, MAX664X_REG_WLHO, 90); if (rc) goto fail_hwmon; board->ioexp_client = i2c_new_dummy(&board->i2c_adap, PCA9539); if (!board->ioexp_client) { rc = -EIO; goto fail_hwmon; } if (efx->phy_mode & PHY_MODE_SPECIAL) { /* PHY won't generate a 156.25 MHz clock and MAC stats fetch * will fail. */ falcon_stop_nic_stats(efx); } rc = sfe4001_poweron(efx); if (rc) goto fail_ioexp; rc = device_create_file(&efx->pci_dev->dev, &dev_attr_phy_flash_cfg); if (rc) goto fail_on; EFX_INFO(efx, "PHY is powered on\n"); return 0; fail_on: sfe4001_poweroff(efx); fail_ioexp: i2c_unregister_device(board->ioexp_client); fail_hwmon: i2c_unregister_device(board->hwmon_client); return rc; }
static void __exit ms6_wdt_exit(void) { if(ms6_data.client) { i2c_del_driver(&ms6_wdt_driver); i2c_unregister_device(ms6_data.client); } }
void smsi2c_unregister(void) { //need to save smsdev and check for null if (g_smsi2c_device) { #ifdef SMS_RK_TS /********************* * stop rk ts interface * smsi2c_ts_feed(void *, NULL, NULL); ************************/ rk29_hsadc_stop_transmit(); rk_ts_callback_setup(NULL, NULL, NULL); #endif #if 1 //wood, ++, @20140916 free_irq(gpio_to_irq(host_i2c_intr_pin), g_smsi2c_device); gpio_free(host_i2c_intr_pin); #endif if (g_smsi2c_device->coredev) { //need to save smsdev and check for null smscore_unregister_device(g_smsi2c_device->coredev); g_smsi2c_device->coredev = NULL; } i2c_unregister_device(g_smsi2c_device->client); i2c_put_adapter(g_smsi2c_device->adap); kfree(g_smsi2c_device); g_smsi2c_device = NULL; } }
static int max77686_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct max77686_dev *max77686 = NULL; struct max77686_platform_data *pdata = dev_get_platdata(&i2c->dev); unsigned int data; int ret = 0; if (i2c->dev.of_node) pdata = max77686_i2c_parse_dt_pdata(&i2c->dev); if (!pdata) { dev_err(&i2c->dev, "No platform data found.\n"); return -EIO; } max77686 = devm_kzalloc(&i2c->dev, sizeof(struct max77686_dev), GFP_KERNEL); if (max77686 == NULL) return -ENOMEM; i2c_set_clientdata(i2c, max77686); max77686->dev = &i2c->dev; max77686->i2c = i2c; max77686->type = id->driver_data; max77686->wakeup = pdata->wakeup; max77686->irq_gpio = pdata->irq_gpio; max77686->irq = i2c->irq; max77686->regmap = devm_regmap_init_i2c(i2c, &max77686_regmap_config); if (IS_ERR(max77686->regmap)) { ret = PTR_ERR(max77686->regmap); dev_err(max77686->dev, "Failed to allocate register map: %d\n", ret); return ret; } if (regmap_read(max77686->regmap, MAX77686_REG_DEVICE_ID, &data) < 0) { dev_err(max77686->dev, "device not found on this channel (this is not an error)\n"); return -ENODEV; } else dev_info(max77686->dev, "device found\n"); max77686->rtc = i2c_new_dummy(i2c->adapter, I2C_ADDR_RTC); i2c_set_clientdata(max77686->rtc, max77686); max77686_irq_init(max77686); ret = mfd_add_devices(max77686->dev, -1, max77686_devs, ARRAY_SIZE(max77686_devs), NULL, 0, NULL); if (ret < 0) { mfd_remove_devices(max77686->dev); i2c_unregister_device(max77686->rtc); } return ret; }
static int __devexit max732x_remove(struct i2c_client *client) { struct max732x_platform_data *pdata = client->dev.platform_data; struct max732x_chip *chip = i2c_get_clientdata(client); int ret; if (pdata->teardown) { ret = pdata->teardown(client, chip->gpio_chip.base, chip->gpio_chip.ngpio, pdata->context); if (ret < 0) { dev_err(&client->dev, "%s failed, %d\n", "teardown", ret); return ret; } } ret = gpiochip_remove(&chip->gpio_chip); if (ret) { dev_err(&client->dev, "%s failed, %d\n", "gpiochip_remove()", ret); return ret; } max732x_irq_teardown(chip); /* unregister any dummy i2c_client */ if (chip->client_dummy) i2c_unregister_device(chip->client_dummy); kfree(chip); return 0; }
static void __exit minnow_module_exit(void) { i2c_unregister_device(client); i2c_put_adapter(adap); pr_info("exited\n"); }
static int max77693_i2c_remove(struct i2c_client *i2c) { struct max77693_dev *max77693 = i2c_get_clientdata(i2c); mfd_remove_devices(max77693->dev); regmap_del_irq_chip(max77693->irq, max77693->irq_data_muic); regmap_del_irq_chip(max77693->irq, max77693->irq_data_charger); regmap_del_irq_chip(max77693->irq, max77693->irq_data_topsys); regmap_del_irq_chip(max77693->irq, max77693->irq_data_led); i2c_unregister_device(max77693->muic); i2c_unregister_device(max77693->haptic); return 0; }
/* ** Called at termination time to disable amp, etc... */ IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_Terminate(void) { DbgOut((DBL_VERBOSE, "ImmVibeSPI_ForceOut_Terminate.\n")); if (g_autotune_brake_enabled && g_workqueue) { destroy_workqueue(g_workqueue); g_workqueue = 0; } ImmVibeSPI_ForceOut_AmpDisable(0); /* From Xiaomi start */ kobject_del(vibe_kobj); gpio_direction_output(GPIO_VIBTONE_EN1, GPIO_LEVEL_LOW); gpio_free(GPIO_VIBTONE_EN1); /* From Xiaomi end */ /* Remove TS5000 driver */ i2c_del_driver(&drv2604_driver); /* Reverse i2c_new_device */ i2c_unregister_device(g_pTheClient); return VIBE_S_SUCCESS; }
static bool probe_monitoring_device(struct nouveau_i2c_port *i2c, struct i2c_board_info *info, void *data) { struct nouveau_therm_priv *priv = data; struct nvbios_therm_sensor *sensor = &priv->bios_sensor; struct i2c_client *client; request_module("%s%s", I2C_MODULE_PREFIX, info->type); client = i2c_new_device(&i2c->adapter, info); if (!client) return false; if (!client->dev.driver || to_i2c_driver(client->dev.driver)->detect(client, info)) { i2c_unregister_device(client); return false; } nv_info(priv, "Found an %s at address 0x%x (controlled by lm_sensors, " "temp offset %+i C)\n", info->type, info->addr, sensor->offset_constant); priv->ic = client; return true; }
static int sfn4111t_init(struct efx_nic *efx) { struct falcon_board *board = falcon_board(efx); int rc; board->hwmon_client = i2c_new_device(&board->i2c_adap, (board->minor < 5) ? &sfn4111t_a0_hwmon_info : &sfn4111t_r5_hwmon_info); if (!board->hwmon_client) return -EIO; rc = device_create_file(&efx->pci_dev->dev, &dev_attr_phy_flash_cfg); if (rc) goto fail_hwmon; if (efx->phy_mode & PHY_MODE_SPECIAL) /* PHY may not generate a 156.25 MHz clock and MAC * stats fetch will fail. */ falcon_stop_nic_stats(efx); return 0; fail_hwmon: i2c_unregister_device(board->hwmon_client); return rc; }
static void sfn4111t_fini(struct efx_nic *efx) { EFX_INFO(efx, "%s\n", __func__); device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_flash_cfg); i2c_unregister_device(falcon_board(efx)->hwmon_client); }
int ct36x_ts_remove(struct i2c_client *client) { struct ct36x_ts_info *ts; if (CT36X_TS_CORE_DEBUG) printk(">>>>> %s() called <<<<< \n", __FUNCTION__); ts = (struct ct36x_ts_info *)i2c_get_clientdata(client); /* Driver clean up */ disable_irq(ts->irq); cancel_work_sync(&ts->event_work); destroy_workqueue(ts->workqueue); input_free_device(ts->input); free_irq(ts->irq, ts); ct36x_platform_put_resource(ts); i2c_unregister_device(client); #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&ts->early_suspend); #endif remove_proc_entry(DRIVER_NAME, NULL); destroy_remove(client->dev, ts_com); ts_com->owner = NULL; return 0; }
static int efx_init_lm87(struct efx_nic *efx, struct i2c_board_info *info, const u8 *reg_values) { struct falcon_board *board = falcon_board(efx); struct i2c_client *client = i2c_new_device(&board->i2c_adap, info); int rc; if (!client) return -EIO; while (*reg_values) { u8 reg = *reg_values++; u8 value = *reg_values++; rc = i2c_smbus_write_byte_data(client, reg, value); if (rc) goto err; } board->hwmon_client = client; return 0; err: i2c_unregister_device(client); return rc; }
void inv_mpu_acpi_delete_mux_client(struct i2c_client *client) { struct inv_mpu6050_state *st = iio_priv(dev_get_drvdata(&client->dev)); if (st->mux_client) i2c_unregister_device(st->mux_client); }