本文整理汇总了C++中power_supply_unregister函数的典型用法代码示例。如果您正苦于以下问题:C++ power_supply_unregister函数的具体用法?C++ power_supply_unregister怎么用?C++ power_supply_unregister使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了power_supply_unregister函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: pm860x_charger_probe
static int pm860x_charger_probe(struct platform_device *pdev)
{
struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
struct pm860x_charger_info *info;
int ret;
int count;
int i;
int j;
info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
if (!info)
return -ENOMEM;
count = pdev->num_resources;
for (i = 0, j = 0; i < count; i++) {
info->irq[j] = platform_get_irq(pdev, i);
if (info->irq[j] < 0)
continue;
j++;
}
info->irq_nums = j;
info->chip = chip;
info->i2c =
(chip->id == CHIP_PM8607) ? chip->client : chip->companion;
info->i2c_8606 =
(chip->id == CHIP_PM8607) ? chip->companion : chip->client;
if (!info->i2c_8606) {
dev_err(&pdev->dev, "Missed I2C address of 88PM8606!\n");
ret = -EINVAL;
goto out;
}
info->dev = &pdev->dev;
/* set init value for the case we are not using battery */
set_vchg_threshold(info, VCHG_NORMAL_LOW, VCHG_OVP_LOW);
mutex_init(&info->lock);
platform_set_drvdata(pdev, info);
info->usb.name = "usb";
info->usb.type = POWER_SUPPLY_TYPE_USB;
info->usb.supplied_to = pm860x_supplied_to;
info->usb.num_supplicants = ARRAY_SIZE(pm860x_supplied_to);
info->usb.properties = pm860x_usb_props;
info->usb.num_properties = ARRAY_SIZE(pm860x_usb_props);
info->usb.get_property = pm860x_usb_get_prop;
ret = power_supply_register(&pdev->dev, &info->usb);
if (ret)
goto out;
pm860x_init_charger(info);
for (i = 0; i < ARRAY_SIZE(info->irq); i++) {
ret = request_threaded_irq(info->irq[i], NULL,
pm860x_irq_descs[i].handler,
IRQF_ONESHOT, pm860x_irq_descs[i].name, info);
if (ret < 0) {
dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n",
info->irq[i], ret);
goto out_irq;
}
}
return 0;
out_irq:
power_supply_unregister(&info->usb);
while (--i >= 0)
free_irq(info->irq[i], info);
out:
return ret;
}
开发者ID:GAXUSXX,项目名称:G935FGaXusKernel2,代码行数:72,代码来源:88pm860x_charger.c
示例2: SM5414_charger_probe
static int __devinit SM5414_charger_probe(
struct i2c_client *client,
const struct i2c_device_id *id)
{
struct i2c_adapter *adapter =
to_i2c_adapter(client->dev.parent);
struct sec_charger_info *charger;
int ret = 0;
dev_info(&client->dev,
"%s: SM5414 Charger Driver Loading\n", __func__);
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE))
return -EIO;
charger = kzalloc(sizeof(*charger), GFP_KERNEL);
if (!charger)
return -ENOMEM;
charger->client = client;
if (client->dev.of_node) {
void * pdata = kzalloc(sizeof(sec_battery_platform_data_t), GFP_KERNEL);
if (!pdata)
goto err_free1;
charger->pdata = pdata;
if (SM5414_charger_parse_dt(charger))
dev_err(&client->dev,
"%s : Failed to get charger dt\n", __func__);
} else
charger->pdata = client->dev.platform_data;
i2c_set_clientdata(client, charger);
charger->siop_level = 100;
charger->psy_chg.name = "SM5414";
charger->psy_chg.type = POWER_SUPPLY_TYPE_UNKNOWN;
charger->psy_chg.get_property = SM5414_chg_get_property;
charger->psy_chg.set_property = SM5414_chg_set_property;
charger->psy_chg.properties = SM5414_charger_props;
charger->psy_chg.num_properties = ARRAY_SIZE(SM5414_charger_props);
charger->is_slow_charging = false;
if (charger->pdata->chg_gpio_init) {
if (!charger->pdata->chg_gpio_init()) {
dev_err(&client->dev,
"%s: Failed to Initialize GPIO\n", __func__);
goto err_free;
}
}
if (!SM5414_hal_chg_init(charger->client)) {
dev_err(&client->dev,
"%s: Failed to Initialize Charger\n", __func__);
goto err_free;
}
ret = power_supply_register(&client->dev, &charger->psy_chg);
if (ret) {
dev_err(&client->dev,
"%s: Failed to Register psy_chg\n", __func__);
goto err_free;
}
if (charger->pdata->chg_irq) {
INIT_DELAYED_WORK_DEFERRABLE(
&charger->isr_work, SM5414_chg_isr_work);
ret = request_threaded_irq(charger->pdata->chg_irq,
NULL, SM5414_chg_irq_thread,
charger->pdata->chg_irq_attr,
"charger-irq", charger);
if (ret) {
dev_err(&client->dev,
"%s: Failed to Reqeust IRQ\n", __func__);
goto err_supply_unreg;
}
ret = enable_irq_wake(charger->pdata->chg_irq);
if (ret < 0)
dev_err(&client->dev,
"%s: Failed to Enable Wakeup Source(%d)\n",
__func__, ret);
}
ret = SM5414_chg_create_attrs(charger->psy_chg.dev);
if (ret) {
dev_err(&client->dev,
"%s : Failed to create_attrs\n", __func__);
goto err_req_irq;
}
dev_dbg(&client->dev,
"%s: SM5414 Charger Driver Loaded\n", __func__);
return 0;
err_req_irq:
if (charger->pdata->chg_irq)
free_irq(charger->pdata->chg_irq, charger);
err_supply_unreg:
power_supply_unregister(&charger->psy_chg);
//.........这里部分代码省略.........
开发者ID:adis1313,项目名称:android_kernel_samsung_msm8974,代码行数:101,代码来源:sm5414_charger.c
示例3: aml1216_battery_probe
//.........这里部分代码省略.........
}
supply->irq = aml1216_battery->pmu_irq_id;
b = supply->battery_info;
b->technology = aml1216_battery->pmu_battery_technology;
b->voltage_max_design = aml1216_battery->pmu_init_chgvol;
b->energy_full_design = aml1216_battery->pmu_battery_cap;
b->voltage_min_design = c->ocv_empty * 1000;
b->use_for_apm = 1;
b->name = aml1216_battery->pmu_battery_name;
} else
AML1216_ERR(" NO BATTERY_PARAMETERS FOUND\n");
c->soft_limit_to99 = g_aml1216_init->soft_limit_to99;
c->coulomb_type = COULOMB_BOTH;
supply->charge_timeout_retry = g_aml1216_init->charge_timeout_retry;
aml1216_update_state(c);
#ifdef CONFIG_AMLOGIC_USB
INIT_WORK(&aml1216_otg_work, aml1216_otg_work_fun);
if (aml1216_charger_job.flag) {
aml1216_usb_charger(NULL, aml1216_charger_job.value, NULL);
aml1216_charger_job.flag = 0;
}
if (aml1216_otg_job.flag) {
aml1216_otg_change(NULL, aml1216_otg_job.value, NULL);
aml1216_otg_job.flag = 0;
}
#endif
if (supply->irq) {
INIT_WORK(&supply->irq_work, aml1216_irq_work_func);
ret = request_irq(supply->irq,
aml1216_irq_handler,
IRQF_DISABLED | IRQF_SHARED,
AML1216_IRQ_NAME,
supply);
if (ret) {
AML1216_DBG("request irq failed, ret:%d, irq:%d\n",
ret, supply->irq);
}
}
ret = aml1216_first_init(supply);
if (ret)
goto err_charger_init;
aml1216_battery_setup_psy(supply);
ret = power_supply_register(&pdev->dev, &supply->batt);
if (ret)
goto err_ps_register;
ret = power_supply_register(&pdev->dev, &supply->ac);
if (ret) {
power_supply_unregister(&supply->batt);
goto err_ps_register;
}
ret = power_supply_register(&pdev->dev, &supply->usb);
if (ret) {
power_supply_unregister(&supply->ac);
power_supply_unregister(&supply->batt);
goto err_ps_register;
}
ret = aml1216_supply_create_attrs(&supply->batt);
if (ret)
return ret;
platform_set_drvdata(pdev, supply);
supply->interval = msecs_to_jiffies(AML1216_WORK_CYCLE);
INIT_DELAYED_WORK(&supply->work, aml1216_charging_monitor);
schedule_delayed_work(&supply->work, supply->interval);
#ifdef CONFIG_HAS_EARLYSUSPEND
aml1216_early_suspend.suspend = aml1216_earlysuspend;
aml1216_early_suspend.resume = aml1216_lateresume;
aml1216_early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 2;
aml1216_early_suspend.param = supply;
register_early_suspend(&aml1216_early_suspend);
wake_lock_init(&aml1216_lock, WAKE_LOCK_SUSPEND, "aml1216");
#endif
if (aml1216_battery)
power_supply_changed(&supply->batt); /* update battery status */
aml1216_dump_all_register(NULL);
AML1216_DBG("call %s exit, ret:%d", __func__, ret);
return ret;
err_ps_register:
free_irq(supply->irq, supply);
cancel_delayed_work_sync(&supply->work);
err_charger_init:
kfree(supply->battery_info);
kfree(supply);
input_unregister_device(aml1216_power_key);
kfree(aml1216_power_key);
AML1216_DBG("call %s exit, ret:%d", __func__, ret);
return ret;
}
开发者ID:gcsuri,项目名称:linux-wetek-3.14.y,代码行数:101,代码来源:aml1216-sply.c
示例4: ulpmc_battery_probe
static int ulpmc_battery_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct ulpmc_chip_info *chip;
struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
int ret = 0;
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE)) {
dev_err(&client->dev,
"SM bus doesn't support BYTE transactions\n");
return -EIO;
}
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA)) {
dev_err(&client->dev,
"SM bus doesn't support WORD transactions\n");
return -EIO;
}
/* check if the device is accessible */
ret = ulpmc_read_reg16(client, ULPMC_FG_REG_CNTL);
if (ret < 0) {
dev_err(&client->dev,
"I2C read error:%s error:%d\n", __func__, ret);
return -EIO;
} else {
dev_err(&client->dev, "FG control reg:%x\n", ret);
}
chip = kzalloc(sizeof(*chip), GFP_KERNEL);
if (!chip) {
dev_err(&client->dev, "failed to allocate memory\n");
return -ENOMEM;
}
chip->client = client;
chip->pdata = client->dev.platform_data;
i2c_set_clientdata(client, chip);
INIT_DELAYED_WORK(&chip->work, ulpmc_battery_monitor);
mutex_init(&chip->lock);
chip->bat.name = "byt-battery";
chip->bat.type = POWER_SUPPLY_TYPE_BATTERY;
chip->bat.properties = ulpmc_battery_props;
chip->bat.num_properties = ARRAY_SIZE(ulpmc_battery_props);
chip->bat.get_property = ulpmc_get_battery_property;
ret = power_supply_register(&client->dev, &chip->bat);
if (ret) {
dev_err(&client->dev, "failed to register battery: %d\n", ret);
goto probe_failed_1;
}
chip->chrg.name = "byt-charger";
chip->chrg.type = POWER_SUPPLY_TYPE_MAINS;
chip->chrg.properties = ulpmc_charger_properties;
chip->chrg.num_properties = ARRAY_SIZE(ulpmc_charger_properties);
chip->chrg.get_property = ulpmc_get_charger_property;
ret = power_supply_register(&client->dev, &chip->chrg);
if (ret) {
dev_err(&client->dev, "failed to register charger: %d\n", ret);
goto probe_failed_2;
}
/* get extcon device */
chip->edev = extcon_get_extcon_dev(chip->pdata->extcon_devname);
if (!chip->edev) {
dev_err(&client->dev, "failed to get extcon device\n");
} else {
chip->nb.notifier_call = &ulpmc_extcon_callback;
ret = extcon_register_notifier(chip->edev, &chip->nb);
if (ret)
dev_err(&client->dev,
"failed to register extcon notifier:%d\n", ret);
}
/* get irq and register */
ulpmc_init_irq(chip);
/* schedule status monitoring worker */
schedule_delayed_work(&chip->work, STATUS_MON_JIFFIES);
return 0;
probe_failed_2:
power_supply_unregister(&chip->bat);
probe_failed_1:
kfree(chip);
return ret;
}
开发者ID:DanBjorklund,项目名称:ME302C,代码行数:88,代码来源:byt_ulpmc_battery.c
示例5: max17047_fuelgauge_i2c_probe
//.........这里部分代码省略.........
rawsoc, fg_data->full_soc, firstsoc);
if (fg_data->pdata->psy_name)
fg_data->fuelgauge.name =
fg_data->pdata->psy_name;
else
fg_data->fuelgauge.name = "max17047-fuelgauge";
#if defined(CONFIG_MACH_GC1)
fg_data->prev_status = POWER_SUPPLY_STATUS_DISCHARGING;
#endif
fg_data->fuelgauge.type = POWER_SUPPLY_TYPE_UNKNOWN;
fg_data->fuelgauge.properties = max17047_fuelgauge_props;
fg_data->fuelgauge.num_properties =
ARRAY_SIZE(max17047_fuelgauge_props);
fg_data->fuelgauge.get_property = max17047_get_property;
fg_data->fuelgauge.set_property = max17047_set_property;
ret = power_supply_register(&client->dev, &fg_data->fuelgauge);
if (ret) {
pr_err("%s: failed power supply register\n", __func__);
goto err_psy_reg_fg;
}
/* Initialize fuelgauge registers */
max17047_reg_init(fg_data);
/* Initialize fuelgauge alert */
max17047_alert_init(fg_data);
INIT_DELAYED_WORK_DEFERRABLE(&fg_data->update_work,
max17047_update_work);
/* Request IRQ */
fg_data->irq = gpio_to_irq(fg_data->pdata->irq_gpio);
ret = gpio_request(fg_data->pdata->irq_gpio, "fuelgauge-irq");
if (ret) {
pr_err("%s: failed requesting gpio %d\n", __func__,
fg_data->pdata->irq_gpio);
goto err_irq;
}
gpio_direction_input(fg_data->pdata->irq_gpio);
gpio_free(fg_data->pdata->irq_gpio);
ret = request_threaded_irq(fg_data->irq, NULL,
max17047_fuelgauge_isr, IRQF_TRIGGER_FALLING,
"max17047-alert", fg_data);
if (ret < 0) {
pr_err("%s: fail to request max17047 irq: %d: %d\n",
__func__, fg_data->irq, ret);
goto err_irq;
}
ret = enable_irq_wake(fg_data->irq);
if (ret < 0) {
pr_err("%s: failed enable irq wake %d\n", __func__,
fg_data->irq);
goto err_enable_irq;
}
#ifdef DEBUG_FUELGAUGE_POLLING
INIT_DELAYED_WORK_DEFERRABLE(&fg_data->polling_work,
max17047_polling_work);
schedule_delayed_work(&fg_data->polling_work, 0);
#else
max17047_test_read(fg_data);
#endif
pr_info("%s: probe complete\n", __func__);
#if defined(CONFIG_TARGET_LOCALE_KOR)
#ifdef CONFIG_DEBUG_FS
fg_data->fg_debugfs_dir =
debugfs_create_dir("fg_debug", NULL);
if (fg_data->fg_debugfs_dir) {
if (!debugfs_create_file("max17047_regs", 0644,
fg_data->fg_debugfs_dir,
fg_data, &max17047_debugfs_fops))
pr_err("%s : debugfs_create_file, error\n", __func__);
if (!debugfs_create_file("default_data", 0644,
fg_data->fg_debugfs_dir,
fg_data, &max17047_debugfs_fops2))
pr_err("%s : debugfs_create_file2, error\n", __func__);
} else
pr_err("%s : debugfs_create_dir, error\n", __func__);
#endif
#endif
return 0;
err_enable_irq:
free_irq(fg_data->irq, fg_data);
err_irq:
power_supply_unregister(&fg_data->fuelgauge);
err_psy_reg_fg:
wake_lock_destroy(&fg_data->update_wake_lock);
mutex_destroy(&fg_data->irq_lock);
kfree(fg_data);
return ret;
}
开发者ID:ameswilliam,项目名称:starkissed-kernel-ekgc100,代码行数:101,代码来源:max17047_fuelgauge.c
示例6: sec_fuelgauge_probe
//.........这里部分代码省略.........
fuelgauge->client = client;
fuelgauge->pdata = client->dev.platform_data;
i2c_set_clientdata(client, fuelgauge);
fuelgauge->psy_fg.name = "sec-fuelgauge";
fuelgauge->psy_fg.type = POWER_SUPPLY_TYPE_UNKNOWN;
fuelgauge->psy_fg.get_property = sec_fg_get_property;
fuelgauge->psy_fg.set_property = sec_fg_set_property;
fuelgauge->psy_fg.properties = sec_fuelgauge_props;
fuelgauge->psy_fg.num_properties =
ARRAY_SIZE(sec_fuelgauge_props);
fuelgauge->capacity_max = fuelgauge->pdata->capacity_max;
raw_soc_val.intval = SEC_FUELGAUGE_CAPACITY_TYPE_RAW;
sec_hal_fg_get_property(fuelgauge->client,
POWER_SUPPLY_PROP_CAPACITY, &raw_soc_val);
raw_soc_val.intval /= 10;
fuelgauge->is_reset = false;
if(raw_soc_val.intval > fuelgauge->pdata->capacity_max)
sec_fg_calculate_dynamic_scale(fuelgauge);
if (!fuelgauge->pdata->fg_gpio_init()) {
dev_err(&client->dev,
"%s: Failed to Initialize GPIO\n", __func__);
goto err_free;
}
if (!sec_hal_fg_init(fuelgauge->client)) {
dev_err(&client->dev,
"%s: Failed to Initialize Fuelgauge\n", __func__);
goto err_free;
}
ret = power_supply_register(&client->dev, &fuelgauge->psy_fg);
if (ret) {
dev_err(&client->dev,
"%s: Failed to Register psy_fg\n", __func__);
goto err_free;
}
if (fuelgauge->pdata->fg_irq) {
INIT_DELAYED_WORK_DEFERRABLE(
&fuelgauge->isr_work, sec_fg_isr_work);
ret = request_threaded_irq(fuelgauge->pdata->fg_irq,
NULL, sec_fg_irq_thread,
fuelgauge->pdata->fg_irq_attr,
"fuelgauge-irq", fuelgauge);
if (ret) {
dev_err(&client->dev,
"%s: Failed to Reqeust IRQ\n", __func__);
goto err_supply_unreg;
}
ret = enable_irq_wake(fuelgauge->pdata->fg_irq);
if (ret < 0)
dev_err(&client->dev,
"%s: Failed to Enable Wakeup Source(%d)\n",
__func__, ret);
}
fuelgauge->is_fuel_alerted = false;
if (fuelgauge->pdata->fuel_alert_soc >= 0) {
if (sec_hal_fg_fuelalert_init(fuelgauge->client,
fuelgauge->pdata->fuel_alert_soc))
wake_lock_init(&fuelgauge->fuel_alert_wake_lock,
WAKE_LOCK_SUSPEND, "fuel_alerted");
else {
dev_err(&client->dev,
"%s: Failed to Initialize Fuel-alert\n",
__func__);
goto err_irq;
}
}
fuelgauge->initial_update_of_soc = true;
ret = sec_fg_create_attrs(fuelgauge->psy_fg.dev);
if (ret) {
dev_err(&client->dev,
"%s : Failed to create_attrs\n", __func__);
goto err_irq;
}
dev_dbg(&client->dev,
"%s: SEC Fuelgauge Driver Loaded\n", __func__);
return 0;
err_irq:
if (fuelgauge->pdata->fg_irq)
free_irq(fuelgauge->pdata->fg_irq, fuelgauge);
wake_lock_destroy(&fuelgauge->fuel_alert_wake_lock);
err_supply_unreg:
power_supply_unregister(&fuelgauge->psy_fg);
err_free:
mutex_destroy(&fuelgauge->fg_lock);
kfree(fuelgauge);
return ret;
}
开发者ID:Adrioid83,项目名称:jflte_xxx,代码行数:101,代码来源:sec_fuelgauge.c
示例7: imx6_usb_remove_charger
/*
* imx6_usb_remove_charger - remove a USB charger
* @charger: the charger to be removed
*
* Unregister the chargers power supply.
*/
void imx6_usb_remove_charger(struct usb_charger *charger)
{
power_supply_unregister(&charger->psy);
}
开发者ID:FEDEVEL,项目名称:imx6rex-linux-3.10.17,代码行数:10,代码来源:imx6_usb_charger.c
示例8: twl4030_bci_probe
//.........这里部分代码省略.........
return -ENOMEM;
bci->dev = &pdev->dev;
bci->irq_chg = platform_get_irq(pdev, 0);
bci->irq_bci = platform_get_irq(pdev, 1);
platform_set_drvdata(pdev, bci);
bci->ac.name = "twl4030_ac";
bci->ac.type = POWER_SUPPLY_TYPE_MAINS;
bci->ac.properties = twl4030_charger_props;
bci->ac.num_properties = ARRAY_SIZE(twl4030_charger_props);
bci->ac.get_property = twl4030_bci_get_property;
ret = power_supply_register(&pdev->dev, &bci->ac);
if (ret) {
dev_err(&pdev->dev, "failed to register ac: %d\n", ret);
goto fail_register_ac;
}
bci->usb.name = "twl4030_usb";
bci->usb.type = POWER_SUPPLY_TYPE_USB;
bci->usb.properties = twl4030_charger_props;
bci->usb.num_properties = ARRAY_SIZE(twl4030_charger_props);
bci->usb.get_property = twl4030_bci_get_property;
bci->usb_reg = regulator_get(bci->dev, "bci3v1");
ret = power_supply_register(&pdev->dev, &bci->usb);
if (ret) {
dev_err(&pdev->dev, "failed to register usb: %d\n", ret);
goto fail_register_usb;
}
ret = request_threaded_irq(bci->irq_chg, NULL,
twl4030_charger_interrupt, IRQF_ONESHOT, pdev->name,
bci);
if (ret < 0) {
dev_err(&pdev->dev, "could not request irq %d, status %d\n",
bci->irq_chg, ret);
goto fail_chg_irq;
}
ret = request_threaded_irq(bci->irq_bci, NULL,
twl4030_bci_interrupt, IRQF_ONESHOT, pdev->name, bci);
if (ret < 0) {
dev_err(&pdev->dev, "could not request irq %d, status %d\n",
bci->irq_bci, ret);
goto fail_bci_irq;
}
INIT_WORK(&bci->work, twl4030_bci_usb_work);
bci->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
if (!IS_ERR_OR_NULL(bci->transceiver)) {
bci->usb_nb.notifier_call = twl4030_bci_usb_ncb;
usb_register_notifier(bci->transceiver, &bci->usb_nb);
}
/* Enable interrupts now. */
reg = ~(u32)(TWL4030_ICHGLOW | TWL4030_ICHGEOC | TWL4030_TBATOR2 |
TWL4030_TBATOR1 | TWL4030_BATSTS);
ret = twl_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, reg,
TWL4030_INTERRUPTS_BCIIMR1A);
if (ret < 0) {
dev_err(&pdev->dev, "failed to unmask interrupts: %d\n", ret);
goto fail_unmask_interrupts;
}
reg = ~(u32)(TWL4030_VBATOV | TWL4030_VBUSOV | TWL4030_ACCHGOV);
ret = twl_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, reg,
TWL4030_INTERRUPTS_BCIIMR2A);
if (ret < 0)
dev_warn(&pdev->dev, "failed to unmask interrupts: %d\n", ret);
twl4030_charger_enable_ac(true);
twl4030_charger_enable_usb(bci, true);
twl4030_charger_enable_backup(pdata->bb_uvolt,
pdata->bb_uamp);
return 0;
fail_unmask_interrupts:
if (!IS_ERR_OR_NULL(bci->transceiver)) {
usb_unregister_notifier(bci->transceiver, &bci->usb_nb);
usb_put_phy(bci->transceiver);
}
free_irq(bci->irq_bci, bci);
fail_bci_irq:
free_irq(bci->irq_chg, bci);
fail_chg_irq:
power_supply_unregister(&bci->usb);
fail_register_usb:
power_supply_unregister(&bci->ac);
fail_register_ac:
platform_set_drvdata(pdev, NULL);
kfree(bci);
return ret;
}
开发者ID:AllenDou,项目名称:linux,代码行数:101,代码来源:twl4030_charger.c
示例9: max8903_probe
static __devinit int max8903_probe(struct platform_device *pdev)
{
struct max8903_platform_data *pdata = dev_get_platdata(&pdev->dev);
struct max8903_info *info;
int ret;
dev_info(&pdev->dev, "%s : MAX8903 Charger Driver Loading\n", __func__);
info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info)
return -ENOMEM;
platform_set_drvdata(pdev, info);
info->dev = &pdev->dev;
info->pdata = pdata;
info->psy_bat.name = "max8903-charger",
info->psy_bat.type = POWER_SUPPLY_TYPE_BATTERY,
info->psy_bat.properties = max8903_battery_props,
info->psy_bat.num_properties = ARRAY_SIZE(max8903_battery_props),
info->psy_bat.get_property = max8903_get_property,
info->psy_bat.set_property = max8903_set_property,
ret = power_supply_register(&pdev->dev, &info->psy_bat);
if (ret) {
dev_err(info->dev, "Failed to register psy_bat\n");
goto err_kfree;
}
if (pdata->cfg_gpio) {
ret = pdata->cfg_gpio();
if (ret) {
dev_err(info->dev, "failed to configure GPIO\n");
goto err_kfree;
}
}
if (gpio_is_valid(pdata->gpio_curr_adj)) {
if (!pdata->gpio_curr_adj) {
dev_err(info->dev, "gpio_curr_adj defined as 0\n");
WARN_ON(!pdata->gpio_curr_adj);
ret = -EIO;
goto err_kfree;
}
gpio_request(pdata->gpio_curr_adj, "MAX8903 gpio_curr_adj");
}
if (gpio_is_valid(pdata->gpio_ta_en)) {
if (!pdata->gpio_ta_en) {
dev_err(info->dev, "gpio_ta_en defined as 0\n");
WARN_ON(!pdata->gpio_ta_en);
ret = -EIO;
goto err_kfree;
}
gpio_request(pdata->gpio_ta_en, "MAX8903 gpio_ta_en");
}
if (gpio_is_valid(pdata->gpio_ta_nconnected)) {
if (!pdata->gpio_ta_nconnected) {
dev_err(info->dev, "gpio_ta_nconnected defined as 0\n");
WARN_ON(!pdata->gpio_ta_nconnected);
ret = -EIO;
goto err_kfree;
}
gpio_request(pdata->gpio_ta_nconnected,
"MAX8903 TA_nCONNECTED");
}
if (gpio_is_valid(pdata->gpio_ta_nchg)) {
if (!pdata->gpio_ta_nchg) {
dev_err(info->dev, "gpio_ta_nchg defined as 0\n");
WARN_ON(!pdata->gpio_ta_nchg);
ret = -EIO;
goto err_kfree;
}
gpio_request(pdata->gpio_ta_nchg,
"MAX8903 gpio_ta_nchg");
}
#if 0
info->irq_chg_ing = gpio_to_irq(pdata->gpio_chg_ing);
ret = request_threaded_irq(info->irq_chg_ing, NULL,
max8922_chg_ing_irq,
IRQF_TRIGGER_RISING | IRQF_ONESHOT,
"chg_ing", info);
if (ret)
dev_err(&pdev->dev, "%s: fail to request chg_ing IRQ:"
" %d: %d\n", __func__, info->irq_chg_ing, ret);
#endif
return 0;
err_kfree:
power_supply_unregister(&info->psy_bat);
platform_set_drvdata(pdev, NULL);
kfree(info);
return ret;
}
开发者ID:mogchen,项目名称:Homura-Note,代码行数:97,代码来源:max8903_charger.c
示例10: tosa_bat_probe
static int __devinit tosa_bat_probe(struct platform_device *dev)
{
int ret;
int i;
if (!machine_is_tosa())
return -ENODEV;
for (i = 0; i < ARRAY_SIZE(gpios); i++) {
ret = gpio_request(gpios[i].gpio, gpios[i].name);
if (ret) {
i--;
goto err_gpio;
}
if (gpios[i].output)
ret = gpio_direction_output(gpios[i].gpio,
gpios[i].value);
else
ret = gpio_direction_input(gpios[i].gpio);
if (ret)
goto err_gpio;
}
mutex_init(&tosa_bat_main.work_lock);
mutex_init(&tosa_bat_jacket.work_lock);
INIT_WORK(&bat_work, tosa_bat_work);
ret = power_supply_register(&dev->dev, &tosa_bat_main.psy);
if (ret)
goto err_psy_reg_main;
ret = power_supply_register(&dev->dev, &tosa_bat_jacket.psy);
if (ret)
goto err_psy_reg_jacket;
ret = power_supply_register(&dev->dev, &tosa_bat_bu.psy);
if (ret)
goto err_psy_reg_bu;
ret = request_irq(gpio_to_irq(TOSA_GPIO_BAT0_CRG),
tosa_bat_gpio_isr,
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
"main full", &tosa_bat_main);
if (ret)
goto err_req_main;
ret = request_irq(gpio_to_irq(TOSA_GPIO_BAT1_CRG),
tosa_bat_gpio_isr,
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
"jacket full", &tosa_bat_jacket);
if (ret)
goto err_req_jacket;
ret = request_irq(gpio_to_irq(TOSA_GPIO_JACKET_DETECT),
tosa_bat_gpio_isr,
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
"jacket detect", &tosa_bat_jacket);
if (!ret) {
schedule_work(&bat_work);
return 0;
}
free_irq(gpio_to_irq(TOSA_GPIO_BAT1_CRG), &tosa_bat_jacket);
err_req_jacket:
free_irq(gpio_to_irq(TOSA_GPIO_BAT0_CRG), &tosa_bat_main);
err_req_main:
power_supply_unregister(&tosa_bat_bu.psy);
err_psy_reg_bu:
power_supply_unregister(&tosa_bat_jacket.psy);
err_psy_reg_jacket:
power_supply_unregister(&tosa_bat_main.psy);
err_psy_reg_main:
/* see comment in tosa_bat_remove */
cancel_work_sync(&bat_work);
i--;
err_gpio:
for (; i >= 0; i--)
gpio_free(gpios[i].gpio);
return ret;
}
开发者ID:nos1609,项目名称:Chrono_Kernel-1,代码行数:84,代码来源:tosa_battery.c
示例11: pmic_battery_probe
static int pmic_battery_probe(struct platform_device *pdev)
{
int retval = 0;
struct mc13892_dev_info *di;
pmic_event_callback_t bat_event_callback;
pmic_version_t pmic_version;
/* Only apply battery driver for MC13892 V2.0 due to ENGR108085 */
pmic_version = pmic_get_version();
if (pmic_version.revision < 20) {
pr_debug("Battery driver is only applied for MC13892 V2.0\n");
return -1;
}
if (machine_is_mx50_arm2()) {
pr_debug("mc13892 charger is not used for this platform\n");
return -1;
}
di = kzalloc(sizeof(*di), GFP_KERNEL);
if (!di) {
retval = -ENOMEM;
goto di_alloc_failed;
}
platform_set_drvdata(pdev, di);
di->charger.name = "mc13892_charger";
di->charger.type = POWER_SUPPLY_TYPE_MAINS;
di->charger.properties = mc13892_charger_props;
di->charger.num_properties = ARRAY_SIZE(mc13892_charger_props);
di->charger.get_property = mc13892_charger_get_property;
retval = power_supply_register(&pdev->dev, &di->charger);
if (retval) {
dev_err(di->dev, "failed to register charger\n");
goto charger_failed;
}
INIT_DELAYED_WORK(&chg_work, chg_thread);
chg_wq = create_singlethread_workqueue("mxc_chg");
if (!chg_wq) {
retval = -ESRCH;
goto workqueue_failed;
}
INIT_DELAYED_WORK(&di->monitor_work, mc13892_battery_work);
di->monitor_wqueue = create_singlethread_workqueue(dev_name(&pdev->dev));
if (!di->monitor_wqueue) {
retval = -ESRCH;
goto workqueue_failed;
}
queue_delayed_work(di->monitor_wqueue, &di->monitor_work, HZ * 10);
di->dev = &pdev->dev;
di->bat.name = "mc13892_bat";
di->bat.type = POWER_SUPPLY_TYPE_BATTERY;
di->bat.properties = mc13892_battery_props;
di->bat.num_properties = ARRAY_SIZE(mc13892_battery_props);
di->bat.get_property = mc13892_battery_get_property;
di->bat.use_for_apm = 1;
di->battery_status = POWER_SUPPLY_STATUS_UNKNOWN;
retval = power_supply_register(&pdev->dev, &di->bat);
if (retval) {
dev_err(di->dev, "failed to register battery\n");
goto batt_failed;
}
bat_event_callback.func = charger_online_event_callback;
bat_event_callback.param = (void *) di;
pmic_event_subscribe(EVENT_CHGDETI, bat_event_callback);
retval = sysfs_create_file(&pdev->dev.kobj, &dev_attr_enable.attr);
if (retval) {
printk(KERN_ERR
"Battery: Unable to register sysdev entry for Battery");
goto workqueue_failed;
}
chg_wa_is_active = 1;
chg_wa_timer = 0;
disable_chg_timer = 0;
pmic_stop_coulomb_counter();
pmic_calibrate_coulomb_counter();
goto success;
workqueue_failed:
power_supply_unregister(&di->charger);
charger_failed:
power_supply_unregister(&di->bat);
batt_failed:
kfree(di);
di_alloc_failed:
success:
dev_dbg(di->dev, "%s battery probed!\n", __func__);
return retval;
return 0;
}
开发者ID:AvalueAES,项目名称:rev-sa01,代码行数:100,代码来源:pmic_battery.c
示例12: tosa_bat_probe
static int __devinit tosa_bat_probe(struct platform_device *dev)
{
int ret;
if (!machine_is_tosa())
return -ENODEV;
ret = gpio_request_array(tosa_bat_gpios, ARRAY_SIZE(tosa_bat_gpios));
if (ret)
return ret;
mutex_init(&tosa_bat_main.work_lock);
mutex_init(&tosa_bat_jacket.work_lock);
INIT_WORK(&bat_work, tosa_bat_work);
ret = power_supply_register(&dev->dev, &tosa_bat_main.psy);
if (ret)
goto err_psy_reg_main;
ret = power_supply_register(&dev->dev, &tosa_bat_jacket.psy);
if (ret)
goto err_psy_reg_jacket;
ret = power_supply_register(&dev->dev, &tosa_bat_bu.psy);
if (ret)
goto err_psy_reg_bu;
ret = request_irq(gpio_to_irq(TOSA_GPIO_BAT0_CRG),
tosa_bat_gpio_isr,
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
"main full", &tosa_bat_main);
if (ret)
goto err_req_main;
ret = request_irq(gpio_to_irq(TOSA_GPIO_BAT1_CRG),
tosa_bat_gpio_isr,
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
"jacket full", &tosa_bat_jacket);
if (ret)
goto err_req_jacket;
ret = request_irq(gpio_to_irq(TOSA_GPIO_JACKET_DETECT),
tosa_bat_gpio_isr,
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
"jacket detect", &tosa_bat_jacket);
if (!ret) {
schedule_work(&bat_work);
return 0;
}
free_irq(gpio_to_irq(TOSA_GPIO_BAT1_CRG), &tosa_bat_jacket);
err_req_jacket:
free_irq(gpio_to_irq(TOSA_GPIO_BAT0_CRG), &tosa_bat_main);
err_req_main:
power_supply_unregister(&tosa_bat_bu.psy);
err_psy_reg_bu:
power_supply_unregister(&tosa_bat_jacket.psy);
err_psy_reg_jacket:
power_supply_unregister(&tosa_bat_main.psy);
err_psy_reg_main:
/* see comment in tosa_bat_remove */
cancel_work_sync(&bat_work);
gpio_free_array(tosa_bat_gpios, ARRAY_SIZE(tosa_bat_gpios));
return ret;
}
开发者ID:openube,项目名称:android_kernel_sony_c2305,代码行数:66,代码来源:tosa_battery.c
示例13: pda_power_probe
//.........这里部分代码省略.........
if (transceiver && !pdata->is_ac_online) {
pdata->is_ac_online = otg_is_ac_online;
}
#endif
if (pdata->is_ac_online) {
ret = power_supply_register(&pdev->dev, &pda_psy_ac);
if (ret) {
dev_err(dev, "failed to register %s power supply\n",
pda_psy_ac.name);
goto ac_supply_failed;
}
if (ac_irq) {
ret = request_irq(ac_irq->start, power_changed_isr,
get_irq_flags(ac_irq), ac_irq->name,
&pda_psy_ac);
if (ret) {
dev_err(dev, "request ac irq failed\n");
goto ac_irq_failed;
}
} else {
polling = 1;
}
}
if (pdata->is_usb_online) {
ret = power_supply_register(&pdev->dev, &pda_psy_usb);
if (ret) {
dev_err(dev, "failed to register %s power supply\n",
pda_psy_usb.name);
goto usb_supply_failed;
}
if (usb_irq) {
ret = request_irq(usb_irq->start, power_changed_isr,
get_irq_flags(usb_irq),
usb_irq->name, &pda_psy_usb);
if (ret) {
dev_err(dev, "request usb irq failed\n");
goto usb_irq_failed;
}
} else {
polling = 1;
}
}
#ifdef CONFIG_USB_OTG_UTILS
if (transceiver && pdata->use_otg_notifier) {
otg_nb.notifier_call = otg_handle_notification;
ret = usb_register_notifier(transceiver, &otg_nb);
if (ret) {
dev_err(dev, "failure to register otg notifier\n");
goto otg_reg_notifier_failed;
}
polling = 0;
}
#endif
if (polling) {
dev_dbg(dev, "will poll for status\n");
setup_timer(&polling_timer, polling_timer_func, 0);
mod_timer(&polling_timer,
jiffies + msecs_to_jiffies(pdata->polling_interval));
}
if (ac_irq || usb_irq)
device_init_wakeup(&pdev->dev, 1);
return 0;
#ifdef CONFIG_USB_OTG_UTILS
otg_reg_notifier_failed:
if (pdata->is_usb_online && usb_irq)
free_irq(usb_irq->start, &pda_psy_usb);
#endif
usb_irq_failed:
if (pdata->is_usb_online)
power_supply_unregister(&pda_psy_usb);
usb_supply_failed:
if (pdata->is_ac_online && ac_irq)
free_irq(ac_irq->start, &pda_psy_ac);
#ifdef CONFIG_USB_OTG_UTILS
if (transceiver)
usb_put_transceiver(transceiver);
#endif
ac_irq_failed:
if (pdata->is_ac_online)
power_supply_unregister(&pda_psy_ac);
ac_supply_failed:
if (ac_draw) {
regulator_put(ac_draw);
ac_draw = NULL;
}
if (pdata->exit)
pdata->exit(dev);
init_failed:
wrongid:
return ret;
}
开发者ID:darcyg,项目名称:ap_project_v2,代码行数:101,代码来源:pda_power.c
示例14: olpc_battery_probe
static int olpc_battery_probe(struct platform_device *pdev)
{
int ret;
uint8_t status;
/*
* We've seen a number of EC protocol changes; this driver requires
* the latest EC protocol, supported by 0x44 and above.
*/
if (olpc_platform_info.ecver < 0x44) {
printk(KERN_NOTICE "OLPC EC version 0x%02x too old for "
"battery driver.\n", olpc_platform_info.ecver);
return -ENXIO;
}
ret = olpc_ec_cmd(EC_BAT_STATUS, NULL, 0, &status, 1);
if (ret)
return ret;
/* Ignore the status. It doesn't actually matter */
olpc_ac = power_supply_register(&pdev->dev, &olpc_ac_desc, NULL);
if (IS_ERR(olpc_ac))
return PTR_ERR(olpc_ac);
if (olpc_board_at_least(olpc_board_pre(0xd0))) { /* XO-1.5 */
olpc_bat_desc.properties = olpc_xo15_bat_props;
olpc_bat_desc.num_properties = ARRAY_SIZE(olpc_xo15_bat_props);
} else { /* XO-1 */
olpc_bat_desc.properties = olpc_xo1_bat_props;
olpc_bat_desc.num_properties = ARRAY_SIZE(olpc_xo1_bat_props);
}
olpc_bat = power_supply_register(&pdev->dev, &olpc_bat_desc, NULL);
if (IS_ERR(olpc_bat)) {
ret = PTR_ERR(olpc_bat);
goto battery_failed;
}
ret = device_create_bin_file(&olpc_bat->dev, &olpc_bat_eeprom);
if (ret)
goto eeprom_failed;
ret = device_create_file(&olpc_bat->dev, &olpc_bat_error);
if (ret)
goto error_failed;
if (olpc_ec_wakeup_available()) {
device_set_wakeup_capable(&olpc_ac->dev, true);
device_set_wakeup_capable(&olpc_bat->dev, true);
}
return 0;
error_failed:
device_remove_bin_file(&olpc_bat->dev, &olpc_bat_eeprom);
eeprom_failed:
power_supply_unregister(olpc_bat);
battery_failed:
power_supply_unregister(olpc_ac);
return ret;
}
开发者ID:19Dan01,项目名称:linux,代码行数:62,代码来源:olpc_battery.c
示例15: sec_battery_probe
//.........这里部分代码省略.........
battery->psy_ac.name = "ac",
battery->psy_ac.type = POWER_SUPPLY_TYPE_MAINS,
battery->psy_ac.supplied_to = supply_list,
battery->psy_ac.num_supplicants = ARRAY_SIZE(supply_list),
battery->psy_ac.properties = sec_power_props,
battery->psy_ac.num_properties = ARRAY_SIZE(sec_power_props),
battery->psy_ac.get_property = sec_ac_get_property;
/* init power supplier framework */
ret = power_supply_register(&pdev->dev, &battery->psy_bat);
if (ret) {
pr_err("%s: Failed to Register psy_bat\n",
__func__);
goto err_wake_lock;
}
ret = power_supply_register(&pdev->dev, &battery->psy_usb);
if (ret) {
pr_err("%s: Failed to Register psy_usb\n",
__func__);
goto err_supply_unreg_bat;
}
ret = power_supply_register(&pdev->dev, &battery->psy_ac);
if (ret) {
pr_err("%s: Failed to Register psy_ac\n", __func__);
goto err_supply_unreg_usb;
}
/* create work queue */
battery->monitor_wqueue =
create_singlethread_workqueue(dev_name(&pdev->dev));
if (!battery->monitor_wqueue) {
pr_err("%s: Fail to Create Workqueue\n", __func__);
goto err_supply_unreg_ac;
}
INIT_WORK(&battery->monitor_work, sec_bat_monitor_work);
INIT_WORK(&battery->cable_work, sec_bat_cable_work);
if (battery->pdata->bat_gpio_irq) {
irq = gpio_to_irq(battery->pdata->bat_gpio_irq);
ret = request_threaded_irq(irq, NULL,
sec_bat_irq_thread,
battery->pdata->bat_irq_attr,
"battery-irq", battery);
if (ret) {
pr_err("%s: Failed to Reqeust IRQ\n", __func__);
return ret;
}
ret = enable_irq_wake(irq);
if (ret < 0)
pr_err("%s: Failed to Enable Wakeup Source(%d)\n"
, __func__, ret);
}
ret = sec_bat_create_attrs(battery->psy_bat.dev);
if (ret) {
pr_err("%s : Failed to create_attrs\n", __func__);
goto err_supply_unreg_ac;
}
switch (pdata->polling_type) {
case SEC_BATTERY_MONITOR_WORKQUEUE:
INIT_DELAYED_WORK_DEFERRABLE(&battery->polling_work,
sec_bat_polling_work);
break;
case SEC_BATTERY_MONITOR_ALARM:
battery->last_poll_time = alarm_get_elapsed_realtime();
alarm_init(&battery->polling_alarm,
ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP,
sec_bat_alarm);
break;
default:
break;
}
wake_lock(&battery->monitor_wake_lock);
queue_work(battery->monitor_wqueue, &battery->monitor_work);
pdata->initial_check();
pr_debug("%s: SEC Battery Driver Loaded\n", __func__);
return 0;
err_supply_unreg_ac:
power_supply_unregister(&battery->psy_ac);
err_supply_unreg_usb:
power_supply_unregister(&battery->psy_usb);
err_supply_unreg_bat:
power_supply_unregister(&battery->psy_bat);
err_wake_lock:
wake_lock_destroy(&battery->monitor_wake_lock);
wake_lock_destroy(&battery->cable_wake_lock);
wake_lock_destroy(&battery->vbus_wake_lock);
mutex_destroy(&battery->adclock);
kfree(battery);
return ret;
}
开发者ID:1yankeedt,项目名称:D710BST_FL24_Kernel,代码行数:101,代码来源:sec_battery.c
示例16: max8925_power_probe
static int max8925_power_probe(struct platform_device *pdev)
{
struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
struct max8925_power_pdata *pdata = NULL;
struct max8925_power_info *info;
int ret;
pdata = max8925_power_dt_init(pdev);
if (!pdata) {
dev_err(&pdev->dev, "platform data isn't assigned to "
"power supply\n");
return -EINVAL;
}
info = kzalloc(sizeof(struct max8925_power_info), GFP_KERNEL);
if (!info)
return -ENOMEM;
info->chip = chip;
info->gpm = chip->i2c;
info->adc = chip->adc;
platform_set_drvdata(pdev, info);
info->ac.name = "max8925-ac";
info->ac.type = POWER_SUPPLY_TYPE_MAINS;
info->ac.properties = max8925_ac_props;
info->ac.num_properties = ARRAY_SIZE(max8925_ac_props);
info->ac.get_property = max8925_ac_get_prop;
info->ac.supplied_to = pdata->supplied_to;
info->ac.num_supplicants = pdata->num_supplicants;
ret = power_supply_register(&pdev->dev, &info->ac);
if (ret)
goto out;
info->ac.dev->parent = &pdev->dev;
info->usb.name = "max8925-usb";
info->usb.type = POWER_SUPPLY_TYPE_USB;
info->usb.properties = max8925_usb_props;
info->usb.num_properties = ARRAY_SIZE(max8925_usb_props);
info->usb.get_property = max8925_usb_get_prop;
info->usb.supplied_to = pdata->supplied_to;
info->usb.num_supplicants = pdata->num_supplicants;
ret = power_supply_register(&pdev->dev, &info->usb);
if (ret)
goto out_usb;
info->usb.dev->parent = &pdev->dev;
info->battery.name = "max8925-battery";
info->battery.type = POWER_SUPPLY_TYPE_BATTERY;
info->battery.properties = max8925_battery_props;
info->battery.num_properties = ARRAY_SIZE(max8925_battery_props);
info->battery.get_property = max8925_bat_get_prop;
ret = power_supply_register(&pdev->dev, &info->battery);
if (ret)
goto out_battery;
info->battery.dev->parent = &pdev->dev;
info->batt_detect = pdata->batt_detect;
info->topoff_threshold = pdata->topoff_threshold;
info->fast_charge = pdata->fast_charge;
info->set_charger = pdata->set_charger;
info->no_temp_support = pdata->no_temp_support;
info->no_insert_detect = pdata->no_insert_detect;
max8925_init_charger(chip, info);
return 0;
out_battery:
power_supply_unregister(&info->battery);
out_usb:
power_supply_unregister(&info->ac);
out:
kfree(info);
return ret;
}
开发者ID:AdrianHuang,项目名称:linux-3.8.13,代码行数:74,代码来源:max8925_power.c
|
请发表评论