static int __devinit isl9519q_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct isl_platform_data *pdata; struct isl9519q_struct *isl_chg; int ret; ret = 0; pdata = client->dev.platform_data; pr_debug("\n"); if (pdata == NULL) { dev_err(&client->dev, "%s no platform data\n", __func__); ret = -EINVAL; goto out; } if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA)) { ret = -EIO; goto out; } isl_chg = kzalloc(sizeof(*isl_chg), GFP_KERNEL); if (!isl_chg) { ret = -ENOMEM; goto out; } spin_lock_init(&isl_chg->lock); INIT_DELAYED_WORK(&isl_chg->charge_work, isl9519q_worker); isl_chg->client = client; isl_chg->chgcurrent = pdata->chgcurrent; isl_chg->term_current = pdata->term_current; isl_chg->input_current = pdata->input_current; isl_chg->max_system_voltage = pdata->max_system_voltage; isl_chg->min_system_voltage = pdata->min_system_voltage; isl_chg->valid_n_gpio = pdata->valid_n_gpio; /* h/w ignores lower 7 bits of charging current and input current */ isl_chg->chgcurrent &= ~0x7F; isl_chg->input_current &= ~0x7F; /** * ISL is Notified by PMIC to start/stop charging, rather than * handling interrupt from ISL for End-Of-Chargring, and * monitoring the charge-current periodically. The valid_n_gpio * is also not used, dc-present is detected by PMIC. */ isl_chg->notify_by_pmic = (client->irq == 0); i2c_set_clientdata(client, isl_chg); if (pdata->chg_detection_config) { ret = pdata->chg_detection_config(); if (ret) { dev_err(&client->dev, "%s valid config failed ret=%d\n", __func__, ret); goto free_isl_chg; } } isl_chg->max_system_voltage &= MAX_VOLTAGE_REG_MASK; isl_chg->min_system_voltage &= MIN_VOLTAGE_REG_MASK; if (isl_chg->max_system_voltage == 0) isl_chg->max_system_voltage = DEFAULT_MAX_VOLTAGE_REG_VALUE; if (isl_chg->min_system_voltage == 0) isl_chg->min_system_voltage = DEFAULT_MIN_VOLTAGE_REG_VALUE; ret = isl9519q_hwinit(isl_chg); if (ret) goto free_isl_chg; if (isl_chg->notify_by_pmic) ret = isl9519q_init_ext_chg(isl_chg); else ret = isl9519q_init_adapter(isl_chg); if (ret) goto free_isl_chg; the_isl_chg = isl_chg; create_debugfs_entries(isl_chg); pr_info("OK.\n"); return 0; free_isl_chg: kfree(isl_chg); out: return ret; }
static int __devinit smb349_probe(struct i2c_client *client, const struct i2c_device_id *id) { const struct smb349_platform_data *pdata; struct smb349_struct *smb349_chg; int ret = 0; pdata = client->dev.platform_data; if (pdata == NULL) { dev_err(&client->dev, "%s no platform data\n", __func__); ret = -EINVAL; goto out; } if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { ret = -EIO; goto out; } smb349_chg = kzalloc(sizeof(*smb349_chg), GFP_KERNEL); if (!smb349_chg) { ret = -ENOMEM; goto out; } smb349_chg->client = client; smb349_chg->chg_current_ma = pdata->chg_current_ma; ret = gpio_request(pdata->chg_susp_gpio, "smb349_suspend"); if (ret) { dev_err(&client->dev, "%s gpio_request failed for %d ret=%d\n", __func__, pdata->chg_susp_gpio, ret); goto free_smb349_chg; } smb349_chg->chg_susp_gpio = pdata->chg_susp_gpio; ret = gpio_request(pdata->en_n_gpio, "smb349_charger_enable"); if (ret) { dev_err(&client->dev, "%s gpio_request failed for %d ret=%d\n", __func__, pdata->en_n_gpio, ret); goto chg_susp_gpio_fail; } smb349_chg->en_n_gpio = pdata->en_n_gpio; i2c_set_clientdata(client, smb349_chg); ret = smb349_hwinit(smb349_chg); if (ret) goto free_smb349_chg; ret = smb349_init_ext_chg(smb349_chg); if (ret) goto chg_en_gpio_fail; the_smb349_chg = smb349_chg; create_debugfs_entries(smb349_chg); INIT_WORK(&smb349_chg->hwinit_work, hwinit_worker); pr_info("OK connector present = %d\n", smb349_chg->present); return 0; chg_en_gpio_fail: gpio_free(smb349_chg->en_n_gpio); chg_susp_gpio_fail: gpio_free(smb349_chg->chg_susp_gpio); free_smb349_chg: kfree(smb349_chg); out: return ret; }
static int __devinit isl9519q_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct isl_platform_data *pdata; struct isl9519q_struct *isl_chg; int ret; ret = 0; pdata = client->dev.platform_data; pr_debug("\n"); if (pdata == NULL) { dev_err(&client->dev, "%s no platform data\n", __func__); ret = -EINVAL; goto out; } if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA)) { ret = -EIO; goto out; } isl_chg = kzalloc(sizeof(*isl_chg), GFP_KERNEL); if (!isl_chg) { ret = -ENOMEM; goto out; } spin_lock_init(&isl_chg->lock); INIT_DELAYED_WORK(&isl_chg->charge_work, isl9519q_worker); isl_chg->client = client; isl_chg->chgcurrent = pdata->chgcurrent; isl_chg->term_current = pdata->term_current; isl_chg->input_current = pdata->input_current; isl_chg->max_system_voltage = pdata->max_system_voltage; isl_chg->min_system_voltage = pdata->min_system_voltage; isl_chg->valid_n_gpio = pdata->valid_n_gpio; isl_chg->chgcurrent &= ~0x7F; isl_chg->input_current &= ~0x7F; isl_chg->notify_by_pmic = (client->irq == 0); i2c_set_clientdata(client, isl_chg); if (pdata->chg_detection_config) { ret = pdata->chg_detection_config(); if (ret) { dev_err(&client->dev, "%s valid config failed ret=%d\n", __func__, ret); goto free_isl_chg; } } isl_chg->max_system_voltage &= MAX_VOLTAGE_REG_MASK; isl_chg->min_system_voltage &= MIN_VOLTAGE_REG_MASK; if (isl_chg->max_system_voltage == 0) isl_chg->max_system_voltage = DEFAULT_MAX_VOLTAGE_REG_VALUE; if (isl_chg->min_system_voltage == 0) isl_chg->min_system_voltage = DEFAULT_MIN_VOLTAGE_REG_VALUE; ret = isl9519q_hwinit(isl_chg); if (ret) goto free_isl_chg; if (isl_chg->notify_by_pmic) ret = isl9519q_init_ext_chg(isl_chg); else ret = isl9519q_init_adapter(isl_chg); if (ret) goto free_isl_chg; the_isl_chg = isl_chg; create_debugfs_entries(isl_chg); pr_info("OK.\n"); return 0; free_isl_chg: kfree(isl_chg); out: return ret; }