• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ power_supply_register函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中power_supply_register函数的典型用法代码示例。如果您正苦于以下问题:C++ power_supply_register函数的具体用法?C++ power_supply_register怎么用?C++ power_supply_register使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了power_supply_register函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: pm8941_charger_init

static int __init pm8941_charger_init(void)
{
	int err;

	printk("pm8941_charger_init +\n");

	err = power_supply_register(NULL, &usb_psy);
	if (err < 0) {
		printk("power_supply_register usb failed rc = %d\n", err);
	}

	err = power_supply_register(NULL, &main_psy);
	if (err < 0) {
		printk("power_supply_register ac failed rc = %d\n", err);
	}

	//Eason: AICL work around +++
	INIT_DELAYED_WORK(&AICLWorker,checkAICL); 
	//Eason: AICL work around ---

	create_pm8941_proc_file();

	
	return err;
}
开发者ID:blackjack4it,项目名称:android_kernel_asus_padfone_s,代码行数:25,代码来源:axc_PM8941Charger.c


示例2: pcf50633_mbc_probe

static int pcf50633_mbc_probe(struct platform_device *pdev)
{
	struct power_supply_config psy_cfg = {};
	struct pcf50633_mbc *mbc;
	int i;
	u8 mbcs1;

	mbc = devm_kzalloc(&pdev->dev, sizeof(*mbc), GFP_KERNEL);
	if (!mbc)
		return -ENOMEM;

	platform_set_drvdata(pdev, mbc);
	mbc->pcf = dev_to_pcf50633(pdev->dev.parent);

	/* Set up IRQ handlers */
	for (i = 0; i < ARRAY_SIZE(mbc_irq_handlers); i++)
		pcf50633_register_irq(mbc->pcf, mbc_irq_handlers[i],
					pcf50633_mbc_irq_handler, mbc);

	psy_cfg.supplied_to		= mbc->pcf->pdata->batteries;
	psy_cfg.num_supplicants		= mbc->pcf->pdata->num_batteries;
	psy_cfg.drv_data		= mbc;

	/* Create power supplies */
	mbc->adapter = power_supply_register(&pdev->dev,
					     &pcf50633_mbc_adapter_desc,
					     &psy_cfg);
	if (IS_ERR(mbc->adapter)) {
		dev_err(mbc->pcf->dev, "failed to register adapter\n");
		return PTR_ERR(mbc->adapter);
	}

	mbc->usb = power_supply_register(&pdev->dev, &pcf50633_mbc_usb_desc,
					 &psy_cfg);
	if (IS_ERR(mbc->usb)) {
		dev_err(mbc->pcf->dev, "failed to register usb\n");
		power_supply_unregister(mbc->adapter);
		return PTR_ERR(mbc->usb);
	}

	mbc->ac = power_supply_register(&pdev->dev, &pcf50633_mbc_ac_desc,
					&psy_cfg);
	if (IS_ERR(mbc->ac)) {
		dev_err(mbc->pcf->dev, "failed to register ac\n");
		power_supply_unregister(mbc->adapter);
		power_supply_unregister(mbc->usb);
		return PTR_ERR(mbc->ac);
	}

	if (sysfs_create_group(&pdev->dev.kobj, &mbc_attr_group))
		dev_err(mbc->pcf->dev, "failed to create sysfs entries\n");

	mbcs1 = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCS1);
	if (mbcs1 & PCF50633_MBCS1_USBPRES)
		pcf50633_mbc_irq_handler(PCF50633_IRQ_USBINS, mbc);
	if (mbcs1 & PCF50633_MBCS1_ADAPTPRES)
		pcf50633_mbc_irq_handler(PCF50633_IRQ_ADPINS, mbc);

	return 0;
}
开发者ID:Lyude,项目名称:linux,代码行数:60,代码来源:pcf50633-charger.c


示例3: battery_probe

static int __devinit battery_probe(struct platform_device *dev)
{
   int ret;

   printk("%s:\n",__FUNCTION__);

   ret = power_supply_register(&dev->dev, &psy_ac);
   if (ret)
      goto err_psy_reg_ac;
   ret = power_supply_register(&dev->dev, &psy_usb);
   if (ret)
      goto err_psy_reg_usb;
   ret = power_supply_register(&dev->dev, &psy_battery);
   if (ret)
      goto err_psy_reg_battery;

   printk("%s: return 0\n",__FUNCTION__);
   return 0;

err_psy_reg_battery:
   power_supply_unregister(&psy_usb);
err_psy_reg_usb:
   power_supply_unregister(&psy_ac);
err_psy_reg_ac:

   printk("%s: return %d\n",__FUNCTION__, ret);
   return ret;
}
开发者ID:CVlaspoel,项目名称:VSMC-i9105p,代码行数:28,代码来源:fake_battery.c


示例4: lp8788_psy_register

static int lp8788_psy_register(struct platform_device *pdev,
				struct lp8788_charger *pchg)
{
	pchg->charger.name = LP8788_CHARGER_NAME;
	pchg->charger.type = POWER_SUPPLY_TYPE_MAINS;
	pchg->charger.properties = lp8788_charger_prop;
	pchg->charger.num_properties = ARRAY_SIZE(lp8788_charger_prop);
	pchg->charger.get_property = lp8788_charger_get_property;
	pchg->charger.supplied_to = battery_supplied_to;
	pchg->charger.num_supplicants = ARRAY_SIZE(battery_supplied_to);

	if (power_supply_register(&pdev->dev, &pchg->charger))
		return -EPERM;

	pchg->battery.name = LP8788_BATTERY_NAME;
	pchg->battery.type = POWER_SUPPLY_TYPE_BATTERY;
	pchg->battery.properties = lp8788_battery_prop;
	pchg->battery.num_properties = ARRAY_SIZE(lp8788_battery_prop);
	pchg->battery.get_property = lp8788_battery_get_property;

	if (power_supply_register(&pdev->dev, &pchg->battery)) {
		power_supply_unregister(&pchg->charger);
		return -EPERM;
	}

	return 0;
}
开发者ID:AICP,项目名称:kernel_moto_shamu,代码行数:27,代码来源:lp8788-charger.c


示例5: htc_battery_probe

static int htc_battery_probe(struct platform_device *pdev)
{
	struct rpc_request_hdr req;	
	struct htc_get_batt_info_rep {
		struct rpc_reply_hdr hdr;
		struct battery_info_reply info;
	} rep;

	int rc;

	endpoint = msm_rpc_connect(APP_BATT_PROG, APP_BATT_VER, 0);
	if (IS_ERR(endpoint)) {
		printk(KERN_ERR "%s: init rpc failed! rc = %ld\n",
		       __FUNCTION__, PTR_ERR(endpoint));
		return PTR_ERR(endpoint);
	}

	/* must do this or we won't get cable status updates */
	rc = msm_rpc_call_reply(endpoint, HTC_PROCEDURE_GET_BATT_INFO,
				&req, sizeof(req),
				&rep, sizeof(rep),
				5 * HZ);
	if (rc < 0)
		printk(KERN_ERR "%s: get info failed\n", __FUNCTION__);

	power_supply_register(&pdev->dev, &ac_supply);
	power_supply_register(&pdev->dev, &usb_supply);

	return 0;
}
开发者ID:Conap30,项目名称:htc_kernel_desirec_bfs,代码行数:30,代码来源:htc_power_supply.c


示例6: adbattery_init

static int __init adbattery_init(void)
{
    int ret = 0;

    adbattery_pdev = platform_device_register_simple("battery", 0, NULL, 0);
    if (IS_ERR(adbattery_pdev))
        return PTR_ERR(adbattery_pdev);
    ret = power_supply_register(&adbattery_pdev->dev, &adbattery_bat);
    if (ret)
        goto bat_failed;
    ret = power_supply_register(&adbattery_pdev->dev, &adbattery_ac);
    if (ret)
        goto ac_failed;
    ret = power_supply_register(&adbattery_pdev->dev, &adbattery_usb);
    if (ret)
        goto usb_failed;
    printk(KERN_INFO "adbattery: android dummy battery driver loaded\n");
    goto success;

bat_failed:
    power_supply_unregister(&adbattery_bat);
ac_failed:
    power_supply_unregister(&adbattery_ac);
usb_failed:
    power_supply_unregister(&adbattery_usb);
    platform_device_unregister(adbattery_pdev);
success:
    return ret;
}
开发者ID:werty100,项目名称:android_kernel_boxer8_ouya,代码行数:29,代码来源:android_battery.c


示例7: olpc_bat_init

static int __init olpc_bat_init(void)
{
	int ret = 0;
	uint8_t status;

	if (!olpc_platform_info.ecver)
		return -ENXIO;

	/*
	 * 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 */

	bat_pdev = platform_device_register_simple("olpc-battery", 0, NULL, 0);
	if (IS_ERR(bat_pdev))
		return PTR_ERR(bat_pdev);

	ret = power_supply_register(&bat_pdev->dev, &olpc_ac);
	if (ret)
		goto ac_failed;

	olpc_bat.name = bat_pdev->name;

	ret = power_supply_register(&bat_pdev->dev, &olpc_bat);
	if (ret)
		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;

	goto success;

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);
ac_failed:
	platform_device_unregister(bat_pdev);
success:
	return ret;
}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:59,代码来源:olpc_battery.c


示例8: zeus_power_probe

static int zeus_power_probe(struct platform_device *pdev)
{

	power_supply_register(&pdev->dev, &ac_supply);
	power_supply_register(&pdev->dev, &usb_supply);

	return 0;
}
开发者ID:R-N,项目名称:boston-2.6.32.x,代码行数:8,代码来源:zeus_power_supply.c


示例9: wm8350_power_probe

static __devinit int wm8350_power_probe(struct platform_device *pdev)
{
	struct wm8350 *wm8350 = platform_get_drvdata(pdev);
	struct wm8350_power *power = &wm8350->power;
	struct wm8350_charger_policy *policy = power->policy;
	struct power_supply *usb = &power->usb;
	struct power_supply *battery = &power->battery;
	struct power_supply *ac = &power->ac;
	int ret;

	ac->name = "wm8350-ac";
	ac->type = POWER_SUPPLY_TYPE_MAINS;
	ac->properties = wm8350_ac_props;
	ac->num_properties = ARRAY_SIZE(wm8350_ac_props);
	ac->get_property = wm8350_ac_get_prop;
	ret = power_supply_register(&pdev->dev, ac);
	if (ret)
		return ret;

	battery->name = "wm8350-battery";
	battery->properties = wm8350_bat_props;
	battery->num_properties = ARRAY_SIZE(wm8350_bat_props);
	battery->get_property = wm8350_bat_get_property;
	battery->use_for_apm = 1;
	ret = power_supply_register(&pdev->dev, battery);
	if (ret)
		goto battery_failed;

	usb->name = "wm8350-usb",
	usb->type = POWER_SUPPLY_TYPE_USB;
	usb->properties = wm8350_usb_props;
	usb->num_properties = ARRAY_SIZE(wm8350_usb_props);
	usb->get_property = wm8350_usb_get_prop;
	ret = power_supply_register(&pdev->dev, usb);
	if (ret)
		goto usb_failed;

	ret = device_create_file(&pdev->dev, &dev_attr_charger_state);
	if (ret < 0)
		dev_warn(wm8350->dev, "failed to add charge sysfs: %d\n", ret);
	ret = 0;

	wm8350_init_charger(wm8350);
	if (wm8350_charger_config(wm8350, policy) == 0) {
		wm8350_reg_unlock(wm8350);
		wm8350_set_bits(wm8350, WM8350_POWER_MGMT_5, WM8350_CHG_ENA);
		wm8350_reg_lock(wm8350);
	}

	return ret;

usb_failed:
	power_supply_unregister(battery);
battery_failed:
	power_supply_unregister(ac);

	return ret;
}
开发者ID:Medvedroid,项目名称:OT_903D-kernel-2.6.35.7,代码行数:58,代码来源:wm8350_power.c


示例10: bq3060_battery_probe

static int bq3060_battery_probe(struct i2c_client *client,
                                const struct i2c_device_id *id)
{
    struct bq3060_device_info *di;
    int retval = 0;

    u8 buf[2];

    di = kzalloc(sizeof(*di), GFP_KERNEL);
    if (!di) {
        dev_err(&client->dev, "failed to allocate device info data\n");
        retval = -ENOMEM;
        goto batt_failed_2;
    }
    i2c_set_clientdata(client, di);
    di->dev = &client->dev;
    di->bat.name = "bq3060-battery";
    di->client = client;
    /* 4 seconds between monotor runs interval */
    di->interval = msecs_to_jiffies(1 * 1000);

    gpio_request(DC_CHECK_PIN,"dc_check");
    gpio_direction_input(DC_CHECK_PIN);
    bq3060_powersupply_init(di);
    buf[0] = 0x41;
    buf[1] = 0x00;
    bq3060_write(di->client,0x00,buf,2);
    buf[0] = 0x21;
    buf[1] = 0x00;
    bq3060_write(di->client,0x00,buf,2);
    retval = power_supply_register(&client->dev, &di->bat);
    if (retval) {
        dev_err(&client->dev, "failed to register battery\n");
        goto batt_failed_4;
    }
    //retval = power_supply_register(&client->dev, &di->usb);
    if (retval) {
        dev_err(&client->dev, "failed to register usb battery\n");
        goto batt_failed_4;
    }
    retval = power_supply_register(&client->dev, &di->ac);
    if (retval) {
        dev_err(&client->dev, "failed to register ac adapter\n");
        goto batt_failed_4;
    }
    INIT_DELAYED_WORK(&di->work, bq3060_battery_work);
    schedule_delayed_work(&di->work, di->interval);
    dev_info(&client->dev, "support ver. %s enabled\n", DRIVER_VERSION);

    return 0;

batt_failed_4:
    kfree(di);
batt_failed_2:
    return retval;
}
开发者ID:avila-devlogic,项目名称:D33_KK_Kernel,代码行数:56,代码来源:bq3060_battery.c


示例11: goldfish_battery_probe

static int goldfish_battery_probe(struct platform_device *pdev)
{
	int ret;
	struct resource *r;
	struct goldfish_battery_data *data;
	struct power_supply_config psy_cfg = {};

	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
	if (data == NULL)
		return -ENOMEM;

	spin_lock_init(&data->lock);

	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (r == NULL) {
		dev_err(&pdev->dev, "platform_get_resource failed\n");
		return -ENODEV;
	}

	data->reg_base = devm_ioremap(&pdev->dev, r->start, resource_size(r));
	if (data->reg_base == NULL) {
		dev_err(&pdev->dev, "unable to remap MMIO\n");
		return -ENOMEM;
	}

	data->irq = platform_get_irq(pdev, 0);
	if (data->irq < 0) {
		dev_err(&pdev->dev, "platform_get_irq failed\n");
		return -ENODEV;
	}

	ret = devm_request_irq(&pdev->dev, data->irq,
			       goldfish_battery_interrupt,
			       IRQF_SHARED, pdev->name, data);
	if (ret)
		return ret;

	psy_cfg.drv_data = data;

	data->ac = power_supply_register(&pdev->dev, &ac_desc, &psy_cfg);
	if (IS_ERR(data->ac))
		return PTR_ERR(data->ac);

	data->battery = power_supply_register(&pdev->dev, &battery_desc,
						&psy_cfg);
	if (IS_ERR(data->battery)) {
		power_supply_unregister(data->ac);
		return PTR_ERR(data->battery);
	}

	platform_set_drvdata(pdev, data);

	GOLDFISH_BATTERY_WRITE(data, BATTERY_INT_ENABLE, BATTERY_INT_MASK);
	return 0;
}
开发者ID:avagin,项目名称:linux,代码行数:55,代码来源:goldfish_battery.c


示例12: lp8727_register_psy

static int lp8727_register_psy(struct lp8727_chg *pchg)
{
	struct lp8727_psy *psy;

	psy = devm_kzalloc(pchg->dev, sizeof(*psy), GFP_KERNEL);
	if (!psy)
		return -ENOMEM;

	pchg->psy = psy;

	psy->ac.name = "ac";
	psy->ac.type = POWER_SUPPLY_TYPE_MAINS;
	psy->ac.properties = lp8727_charger_prop;
	psy->ac.num_properties = ARRAY_SIZE(lp8727_charger_prop);
	psy->ac.get_property = lp8727_charger_get_property;
	psy->ac.supplied_to = battery_supplied_to;
	psy->ac.num_supplicants = ARRAY_SIZE(battery_supplied_to);

	if (power_supply_register(pchg->dev, &psy->ac))
		goto err_psy_ac;

	psy->usb.name = "usb";
	psy->usb.type = POWER_SUPPLY_TYPE_USB;
	psy->usb.properties = lp8727_charger_prop;
	psy->usb.num_properties = ARRAY_SIZE(lp8727_charger_prop);
	psy->usb.get_property = lp8727_charger_get_property;
	psy->usb.supplied_to = battery_supplied_to;
	psy->usb.num_supplicants = ARRAY_SIZE(battery_supplied_to);

	if (power_supply_register(pchg->dev, &psy->usb))
		goto err_psy_usb;

	psy->batt.name = "main_batt";
	psy->batt.type = POWER_SUPPLY_TYPE_BATTERY;
	psy->batt.properties = lp8727_battery_prop;
	psy->batt.num_properties = ARRAY_SIZE(lp8727_battery_prop);
	psy->batt.get_property = lp8727_battery_get_property;
	psy->batt.external_power_changed = lp8727_charger_changed;

	if (power_supply_register(pchg->dev, &psy->batt))
		goto err_psy_batt;

	return 0;

err_psy_batt:
	power_supply_unregister(&psy->usb);
err_psy_usb:
	power_supply_unregister(&psy->ac);
err_psy_ac:
	return -EPERM;
}
开发者ID:03199618,项目名称:linux,代码行数:51,代码来源:lp8727_charger.c


示例13: ec_battery_probe

static int ec_battery_probe(struct platform_device *pdev)
{
	struct ec_battery_info *chip;
	int ret;

	chip = kzalloc(sizeof(*chip), GFP_KERNEL);
	if (!chip) {
		dev_err(&pdev->dev, "mem alloc failed\n");
		return -ENOMEM;
	}

	chip->pdev = pdev;
	platform_set_drvdata(pdev, chip);
	mutex_init(&chip->lock);

	chip->bat.name = "byt_battery";
	chip->bat.type = POWER_SUPPLY_TYPE_BATTERY;
	chip->bat.properties = ec_battery_props;
	chip->bat.num_properties = ARRAY_SIZE(ec_battery_props);
	chip->bat.get_property = ec_get_battery_property;
	ret = power_supply_register(&pdev->dev, &chip->bat);
	if (ret) {
		dev_err(&pdev->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 = ec_charger_properties;
	chip->chrg.num_properties = ARRAY_SIZE(ec_charger_properties);
	chip->chrg.get_property = ec_get_charger_property;
	ret = power_supply_register(&pdev->dev, &chip->chrg);
	if (ret) {
		dev_err(&pdev->dev, "failed to register charger: %d\n", ret);
		goto probe_failed_2;
	}

	/* register for EC SCI events */
	chip->nb.notifier_call = &byt_ec_evt_batt_callback;
	byt_ec_evt_register_notify(&chip->nb);

	return 0;

probe_failed_2:
	power_supply_unregister(&chip->bat);
probe_failed_1:
	kfree(chip);
	return ret;
}
开发者ID:BitOBSessiOn,项目名称:android_kernel_asus_P01M,代码行数:49,代码来源:byt_ec_battery.c


示例14: exynos5_manta_battery_late_init

static int __init exynos5_manta_battery_late_init(void)
{
	int ret;
	struct usb_phy *usb_xceiv;

	ret = power_supply_register(NULL, &manta_battery_psy);
	if (ret)
		pr_err("%s: failed to register power_supply\n",
		       __func__);

	ret = request_threaded_irq(gpio_to_irq(GPIO_OTG_VBUS_SENSE),
				   NULL, ta_int_intr,
				   IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |
				   IRQF_ONESHOT, "usb_vbus", NULL);
	if (ret) {
		pr_err("%s: usb_vbus irq register failed, ret=%d\n",
		       __func__, ret);
	} else {
		ret = enable_irq_wake(gpio_to_irq(GPIO_OTG_VBUS_SENSE));
		if (ret)
			pr_warn("%s: failed to enable irq_wake for usb_vbus\n",
				__func__);
	}

	ret = request_threaded_irq(gpio_to_irq(GPIO_VBUS_POGO_5V), NULL,
				   ta_int_intr,
				   IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |
				   IRQF_ONESHOT, "pogo_vbus", NULL);
	if (ret) {
		pr_err("%s: pogo_vbus irq register failed, ret=%d\n",
		       __func__, ret);
	} else {
		ret = enable_irq_wake(gpio_to_irq(GPIO_VBUS_POGO_5V));
		if (ret)
			pr_warn("%s: failed to enable irq_wake for pogo_vbus\n",
				__func__);
	}

	ret = register_pm_notifier(&exynos5_manta_battery_pm_notifier_block);
	if (ret)
		pr_warn("%s: failed to register PM notifier; ret=%d\n",
			__func__, ret);

	usb_xceiv = usb_get_transceiver();

	if (!usb_xceiv) {
		pr_err("%s: No USB transceiver found\n", __func__);
	} else {
		ret = usb_register_notifier(usb_xceiv, &manta_bat_usb_nb);

		if (ret) {
			pr_err("%s: usb_register_notifier on transceiver %s failed\n",
			       __func__, dev_name(usb_xceiv->dev));
		}
	}

	/* get initial charger status */
	change_charger_status(false, false);
	return 0;
}
开发者ID:advx9600,项目名称:kernel-4.4-RuiEr,代码行数:60,代码来源:board-manta-battery.c


示例15: sample_battery_init

int sample_battery_init(void)
{
	int ret;

	memset(&sample_battery_psy, 0, sizeof(sample_battery_psy));
	sample_battery_psy.name = "sample_battery";
	sample_battery_psy.type = POWER_SUPPLY_TYPE_BATTERY;
	sample_battery_psy.properties = sample_battery_props;
	sample_battery_psy.num_properties = ARRAY_SIZE(sample_battery_props);
	sample_battery_psy.get_property = sample_battery_get_property;
	sample_battery_psy.external_power_changed =
	    sample_battery_ext_power_changed;

	ret = power_supply_register(NULL, &sample_battery_psy);
	if (ret) {
		printk("ERROR: power_supply_register failed (ret=%d)\n", ret);
		return ret;
	}
	printk("Sample battery registered\n");

	init_timer(&sample_battery_timer);

	sample_battery_timer.function = sample_battery_timer_func;
	sample_battery_timer.expires = jiffies + msecs_to_jiffies(interval);
	add_timer(&sample_battery_timer);

	return 0;
}
开发者ID:hiro-sakamoto,项目名称:linux_emu,代码行数:28,代码来源:sample_battery.c


示例16: twl4030_madc_battery_probe

static int twl4030_madc_battery_probe(struct platform_device *pdev)
{
	struct twl4030_madc_battery *twl4030_madc_bat;
	struct twl4030_madc_bat_platform_data *pdata = pdev->dev.platform_data;
	struct power_supply_config psy_cfg = {};
	int ret = 0;

	twl4030_madc_bat = devm_kzalloc(&pdev->dev, sizeof(*twl4030_madc_bat),
				GFP_KERNEL);
	if (!twl4030_madc_bat)
		return -ENOMEM;

	twl4030_madc_bat->channel_temp = iio_channel_get(&pdev->dev, "temp");
	if (IS_ERR(twl4030_madc_bat->channel_temp)) {
		ret = PTR_ERR(twl4030_madc_bat->channel_temp);
		goto err;
	}

	twl4030_madc_bat->channel_ichg = iio_channel_get(&pdev->dev, "ichg");
	if (IS_ERR(twl4030_madc_bat->channel_ichg)) {
		ret = PTR_ERR(twl4030_madc_bat->channel_ichg);
		goto err_temp;
	}

	twl4030_madc_bat->channel_vbat = iio_channel_get(&pdev->dev, "vbat");
	if (IS_ERR(twl4030_madc_bat->channel_vbat)) {
		ret = PTR_ERR(twl4030_madc_bat->channel_vbat);
		goto err_ichg;
	}

	/* sort charging and discharging calibration data */
	sort(pdata->charging, pdata->charging_size,
		sizeof(struct twl4030_madc_bat_calibration),
		twl4030_cmp, NULL);
	sort(pdata->discharging, pdata->discharging_size,
		sizeof(struct twl4030_madc_bat_calibration),
		twl4030_cmp, NULL);

	twl4030_madc_bat->pdata = pdata;
	platform_set_drvdata(pdev, twl4030_madc_bat);
	psy_cfg.drv_data = twl4030_madc_bat;
	twl4030_madc_bat->psy = power_supply_register(&pdev->dev,
						      &twl4030_madc_bat_desc,
						      &psy_cfg);
	if (IS_ERR(twl4030_madc_bat->psy)) {
		ret = PTR_ERR(twl4030_madc_bat->psy);
		goto err_vbat;
	}

	return 0;

err_vbat:
	iio_channel_release(twl4030_madc_bat->channel_vbat);
err_ichg:
	iio_channel_release(twl4030_madc_bat->channel_ichg);
err_temp:
	iio_channel_release(twl4030_madc_bat->channel_temp);
err:
	return ret;
}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:60,代码来源:twl4030_madc_battery.c


示例17: rt_battery_probe

static int rt_battery_probe(struct platform_device *pdev)
{
    struct rt_battery_info *rbi;
    int ret;

    rbi = devm_kzalloc(&pdev->dev, sizeof(*rbi), GFP_KERNEL);
    if (!rbi)
        return -ENOMEM;
    rbi->dev = &pdev->dev;
    rbi->chg_status = POWER_SUPPLY_STATUS_DISCHARGING;
    rbi->batt_present = 1;
    platform_set_drvdata(pdev, rbi);

    rbi->psy.name = RT_BATT_NAME;
    rbi->psy.type = POWER_SUPPLY_TYPE_BATTERY;
    rbi->psy.set_property = rt_battery_set_property;
    rbi->psy.get_property = rt_battery_get_property;
    rbi->psy.properties = rt_battery_props;
    rbi->psy.num_properties = ARRAY_SIZE(rt_battery_props);
    ret = power_supply_register(&pdev->dev, &rbi->psy);
    if (ret < 0) {
        dev_err(&pdev->dev, "battery supply registered fail\n");
        goto out_dev;
    }
    dev_info(&pdev->dev, "driver successfully loaded\n");
    return 0;
out_dev:
    return ret;
}
开发者ID:jack-ma,项目名称:popmetal-android-kernel-3.10,代码行数:29,代码来源:rt-battery.c


示例18: test_power_init

static int __init test_power_init(void)
{
	int i;
	int ret;
	struct device_node *dev_node;

	dev_node = of_find_node_by_name(NULL, "test-power");

	if (IS_ERR_OR_NULL(dev_node)) {
		pr_info("not find %s dev node\n",  __func__);
		return 0;
	}
	if (!of_device_is_available(dev_node)) {
		pr_info("test power disabled\n");
		return 0;
	}

	for (i = 0; i < ARRAY_SIZE(test_power_supplies); i++) {
		ret = power_supply_register(NULL, &test_power_supplies[i]);
		if (ret) {
			pr_err("%s: failed to register %s\n", __func__,
				test_power_supplies[i].name);
			goto failed;
		}
	}

	module_initialized = true;
	return 0;
failed:
	while (--i >= 0)
		power_supply_unregister(&test_power_supplies[i]);
	return ret;
}
开发者ID:jack-ma,项目名称:popmetal-android-kernel-3.10,代码行数:33,代码来源:test_power.c


示例19: twl4030_madc_battery_probe

static int twl4030_madc_battery_probe(struct platform_device *pdev)
{
	struct twl4030_madc_battery *twl4030_madc_bat;
	struct twl4030_madc_bat_platform_data *pdata = pdev->dev.platform_data;

	twl4030_madc_bat = kzalloc(sizeof(*twl4030_madc_bat), GFP_KERNEL);
	if (!twl4030_madc_bat)
		return -ENOMEM;

	twl4030_madc_bat->psy.name = "twl4030_battery";
	twl4030_madc_bat->psy.type = POWER_SUPPLY_TYPE_BATTERY;
	twl4030_madc_bat->psy.properties = twl4030_madc_bat_props;
	twl4030_madc_bat->psy.num_properties =
					ARRAY_SIZE(twl4030_madc_bat_props);
	twl4030_madc_bat->psy.get_property = twl4030_madc_bat_get_property;
	twl4030_madc_bat->psy.external_power_changed =
					twl4030_madc_bat_ext_changed;

	/* sort charging and discharging calibration data */
	sort(pdata->charging, pdata->charging_size,
		sizeof(struct twl4030_madc_bat_calibration),
		twl4030_cmp, NULL);
	sort(pdata->discharging, pdata->discharging_size,
		sizeof(struct twl4030_madc_bat_calibration),
		twl4030_cmp, NULL);

	twl4030_madc_bat->pdata = pdata;
	platform_set_drvdata(pdev, twl4030_madc_bat);
	power_supply_register(&pdev->dev, &twl4030_madc_bat->psy);

	return 0;
}
开发者ID:03199618,项目名称:linux,代码行数:32,代码来源:twl4030_madc_battery.c


示例20: bq27x00_powersupply_init

static int bq27x00_powersupply_init(struct bq27x00_device_info *di)
{
	int ret;

	di->bat.type = POWER_SUPPLY_TYPE_BATTERY;
	di->chip = BQ27425;
	if (di->chip == BQ27425) {
		di->bat.properties = bq27425_battery_props;
		di->bat.num_properties = ARRAY_SIZE(bq27425_battery_props);
	} else {
		di->bat.properties = bq27x00_battery_props;
		di->bat.num_properties = ARRAY_SIZE(bq27x00_battery_props);
	}
	di->bat.get_property = bq27x00_battery_get_property;
	di->bat.external_power_changed = bq27x00_external_power_changed;

	INIT_DELAYED_WORK(&di->work, bq27x00_battery_poll);
	mutex_init(&di->lock);

	ret = power_supply_register(di->dev, &di->bat);
	if (ret) {
		dev_err(di->dev, "failed to register battery: %d\n", ret);
		return ret;
	}

	dev_info(di->dev, "support ver. %s enabled\n", DRIVER_VERSION);

	bq27x00_update(di);

	return 0;
}
开发者ID:dflow81,项目名称:android_kernel_samsung_goyawifi,代码行数:31,代码来源:bq27x00_battery.c



注:本文中的power_supply_register函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ power_supply_show_property函数代码示例发布时间:2022-05-30
下一篇:
C++ power_manage函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap