当前位置: 首页>>代码示例>>C++>>正文


C++ i2c_new_dummy函数代码示例

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


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

示例1: max8925_probe

static int __devinit max8925_probe(struct i2c_client *client,
				   const struct i2c_device_id *id)
{
	struct max8925_platform_data *pdata = client->dev.platform_data;
	static struct max8925_chip *chip;

	if (!pdata) {
		pr_info("%s: platform data is missing\n", __func__);
		return -EINVAL;
	}

	chip = kzalloc(sizeof(struct max8925_chip), GFP_KERNEL);
	if (chip == NULL)
		return -ENOMEM;
	chip->i2c = client;
	chip->dev = &client->dev;
	i2c_set_clientdata(client, chip);
	dev_set_drvdata(chip->dev, chip);
	mutex_init(&chip->io_lock);

	chip->rtc = i2c_new_dummy(chip->i2c->adapter, RTC_I2C_ADDR);
	i2c_set_clientdata(chip->rtc, chip);

	chip->adc = i2c_new_dummy(chip->i2c->adapter, ADC_I2C_ADDR);
	i2c_set_clientdata(chip->adc, chip);

	max8925_device_init(chip, pdata);

	return 0;
}
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:30,代码来源:max8925-i2c.c

示例2: pm800_pages_init

static int pm800_pages_init(struct pm80x_chip *chip)
{
	struct pm80x_subchip *subchip;
	struct i2c_client *client = chip->client;

	subchip = chip->subchip;
	/* PM800 block power: i2c addr 0x31 */
	if (subchip->power_page_addr) {
		subchip->power_page =
		    i2c_new_dummy(client->adapter, subchip->power_page_addr);
		subchip->regmap_power =
		    devm_regmap_init_i2c(subchip->power_page,
					 &pm80x_regmap_config);
		i2c_set_clientdata(subchip->power_page, chip);
	} else
		dev_info(chip->dev,
			 "PM800 block power 0x31: No power_page_addr\n");

	/* PM800 block GPADC: i2c addr 0x32 */
	if (subchip->gpadc_page_addr) {
		subchip->gpadc_page = i2c_new_dummy(client->adapter,
						    subchip->gpadc_page_addr);
		subchip->regmap_gpadc =
		    devm_regmap_init_i2c(subchip->gpadc_page,
					 &pm80x_regmap_config);
		i2c_set_clientdata(subchip->gpadc_page, chip);
	} else
		dev_info(chip->dev,
			 "PM800 block GPADC 0x32: No gpadc_page_addr\n");

	return 0;
}
开发者ID:AmesianX,项目名称:netlink-mmap,代码行数:32,代码来源:88pm800.c

示例3: max8997_i2c_probe

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;
}
开发者ID:303750856,项目名称:linux-3.1,代码行数:60,代码来源:max8997.c

示例4: sfe4001_init

/* 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;
}
开发者ID:A2109devs,项目名称:lenovo_a2109a_kernel,代码行数:55,代码来源:falcon_boards.c

示例5: max77843_chg_init

/* Charger and Charger regulator use same regmap. */
static int max77843_chg_init(struct max77843 *max77843)
{
	int ret;

	max77843->i2c_chg = i2c_new_dummy(max77843->i2c->adapter, I2C_ADDR_CHG);
	if (!max77843->i2c_chg) {
		dev_err(&max77843->i2c->dev,
				"Cannot allocate I2C device for Charger\n");
		return PTR_ERR(max77843->i2c_chg);
	}
	i2c_set_clientdata(max77843->i2c_chg, max77843);

	max77843->regmap_chg = devm_regmap_init_i2c(max77843->i2c_chg,
			&max77843_charger_regmap_config);
	if (IS_ERR(max77843->regmap_chg)) {
		ret = PTR_ERR(max77843->regmap_chg);
		goto err_chg_i2c;
	}

	return 0;

err_chg_i2c:
	i2c_unregister_device(max77843->i2c_chg);

	return ret;
}
开发者ID:19Dan01,项目名称:linux,代码行数:27,代码来源:max77843.c

示例6: max77686_i2c_probe

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;
}
开发者ID:BozkurTR,项目名称:kernel,代码行数:60,代码来源:max77686.c

示例7: max8998_i2c_probe

static int max8998_i2c_probe(struct i2c_client *i2c,
			    const struct i2c_device_id *id)
{
	struct max8998_platform_data *pdata = i2c->dev.platform_data;
	struct max8998_dev *max8998;
	int ret = 0;

	max8998 = kzalloc(sizeof(struct max8998_dev), GFP_KERNEL);
	if (max8998 == NULL)
		return -ENOMEM;

	i2c_set_clientdata(i2c, max8998);
	max8998->dev = &i2c->dev;
	max8998->i2c = i2c;
	max8998->irq = i2c->irq;
	max8998->type = id->driver_data;
	if (pdata) {
		max8998->ono = pdata->ono;
		max8998->irq_base = pdata->irq_base;
		max8998->wakeup = pdata->wakeup;
	}
	mutex_init(&max8998->iolock);

	max8998->rtc = i2c_new_dummy(i2c->adapter, RTC_I2C_ADDR);
	i2c_set_clientdata(max8998->rtc, max8998);

	max8998_irq_init(max8998);

	pm_runtime_set_active(max8998->dev);

	switch (id->driver_data) {
	case TYPE_LP3974:
		ret = mfd_add_devices(max8998->dev, -1,
				lp3974_devs, ARRAY_SIZE(lp3974_devs),
				NULL, 0);
		break;
	case TYPE_MAX8998:
		ret = mfd_add_devices(max8998->dev, -1,
				max8998_devs, ARRAY_SIZE(max8998_devs),
				NULL, 0);
		break;
	default:
		ret = -EINVAL;
	}

	if (ret < 0)
		goto err;

	return ret;

err:
	mfd_remove_devices(max8998->dev);
	max8998_irq_exit(max8998);
	i2c_unregister_device(max8998->rtc);
	kfree(max8998);
	return ret;
}
开发者ID:119-org,项目名称:hi3518-osdrv,代码行数:57,代码来源:max8998.c

示例8: s5m87xx_i2c_probe

static int s5m87xx_i2c_probe(struct i2c_client *i2c,
			    const struct i2c_device_id *id)
{
	struct s5m_platform_data *pdata = i2c->dev.platform_data;
	struct s5m87xx_dev *s5m87xx;
	int ret = 0;

	if (!pdata)
		return -EINVAL;

	s5m87xx = kzalloc(sizeof(struct s5m87xx_dev), GFP_KERNEL);
	if (s5m87xx == NULL)
		return -ENOMEM;

	i2c_set_clientdata(i2c, s5m87xx);
	s5m87xx->dev = &i2c->dev;
	s5m87xx->i2c = i2c;
	s5m87xx->irq = gpio_to_irq(pdata->irq_gpio);
	s5m87xx->type = id->driver_data;

	if (pdata) {
		s5m87xx->device_type = pdata->device_type;
		s5m87xx->ono = pdata->ono;
		s5m87xx->irq_base = pdata->irq_base;
		s5m87xx->wakeup = pdata->wakeup;
	}

	mutex_init(&s5m87xx->iolock);

	s5m87xx->rtc = i2c_new_dummy(i2c->adapter, RTC_I2C_ADDR);
	i2c_set_clientdata(s5m87xx->rtc, s5m87xx);

	if (pdata && pdata->cfg_pmic_irq)
		pdata->cfg_pmic_irq();

	s5m_irq_init(s5m87xx);

	pm_runtime_set_active(s5m87xx->dev);

	ret = mfd_add_devices(s5m87xx->dev, -1,
				s5m87xx_devs, ARRAY_SIZE(s5m87xx_devs),
				NULL, 0);

	if (ret < 0)
		goto err;

	dev_info(s5m87xx->dev ,"S5M87xx MFD probe done!!! \n");
	return ret;

err:
	mfd_remove_devices(s5m87xx->dev);
	s5m_irq_exit(s5m87xx);
	i2c_unregister_device(s5m87xx->rtc);
	kfree(s5m87xx);
	return ret;
}
开发者ID:DerTeufel,项目名称:SGS3-Sourcedrops,代码行数:56,代码来源:s5m-core.c

示例9: pm860x_probe

static int __devinit pm860x_probe(struct i2c_client *client,
				  const struct i2c_device_id *id)
{
	struct pm860x_platform_data *pdata = client->dev.platform_data;
	struct pm860x_chip *chip;
	int ret;

	if (!pdata) {
		pr_info("No platform data in %s!\n", __func__);
		return -EINVAL;
	}

	chip = kzalloc(sizeof(struct pm860x_chip), GFP_KERNEL);
	if (chip == NULL)
		return -ENOMEM;

	chip->id = verify_addr(client);
	chip->regmap = regmap_init_i2c(client, &pm860x_regmap_config);
	if (IS_ERR(chip->regmap)) {
		ret = PTR_ERR(chip->regmap);
		dev_err(&client->dev, "Failed to allocate register map: %d\n",
				ret);
		kfree(chip);
		return ret;
	}
	chip->client = client;
	i2c_set_clientdata(client, chip);
	chip->dev = &client->dev;
	dev_set_drvdata(chip->dev, chip);

	/*
	 * Both client and companion client shares same platform driver.
	 * Driver distinguishes them by pdata->companion_addr.
	 * pdata->companion_addr is only assigned if companion chip exists.
	 * At the same time, the companion_addr shouldn't equal to client
	 * address.
	 */
	if (pdata->companion_addr && (pdata->companion_addr != client->addr)) {
		chip->companion_addr = pdata->companion_addr;
		chip->companion = i2c_new_dummy(chip->client->adapter,
						chip->companion_addr);
		chip->regmap_companion = regmap_init_i2c(chip->companion,
							&pm860x_regmap_config);
		if (IS_ERR(chip->regmap_companion)) {
			ret = PTR_ERR(chip->regmap_companion);
			dev_err(&chip->companion->dev,
				"Failed to allocate register map: %d\n", ret);
			return ret;
		}
		i2c_set_clientdata(chip->companion, chip);
	}

	pm860x_device_init(chip, pdata);
	return 0;
}
开发者ID:33d,项目名称:linux-2.6.21-hh20,代码行数:55,代码来源:88pm860x-i2c.c

示例10: bcm590xx_i2c_probe

static int bcm590xx_i2c_probe(struct i2c_client *i2c_pri,
                              const struct i2c_device_id *id)
{
    struct bcm590xx *bcm590xx;
    int ret;

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

    i2c_set_clientdata(i2c_pri, bcm590xx);
    bcm590xx->dev = &i2c_pri->dev;
    bcm590xx->i2c_pri = i2c_pri;

    bcm590xx->regmap_pri = devm_regmap_init_i2c(i2c_pri,
                           &bcm590xx_regmap_config_pri);
    if (IS_ERR(bcm590xx->regmap_pri)) {
        ret = PTR_ERR(bcm590xx->regmap_pri);
        dev_err(&i2c_pri->dev, "primary regmap init failed: %d\n", ret);
        return ret;
    }

    /* Secondary I2C slave address is the base address with A(2) asserted */
    bcm590xx->i2c_sec = i2c_new_dummy(i2c_pri->adapter,
                                      i2c_pri->addr | BIT(2));
    if (IS_ERR_OR_NULL(bcm590xx->i2c_sec)) {
        dev_err(&i2c_pri->dev, "failed to add secondary I2C device\n");
        return -ENODEV;
    }
    i2c_set_clientdata(bcm590xx->i2c_sec, bcm590xx);

    bcm590xx->regmap_sec = devm_regmap_init_i2c(bcm590xx->i2c_sec,
                           &bcm590xx_regmap_config_sec);
    if (IS_ERR(bcm590xx->regmap_sec)) {
        ret = PTR_ERR(bcm590xx->regmap_sec);
        dev_err(&bcm590xx->i2c_sec->dev,
                "secondary regmap init failed: %d\n", ret);
        goto err;
    }

    ret = mfd_add_devices(&i2c_pri->dev, -1, bcm590xx_devs,
                          ARRAY_SIZE(bcm590xx_devs), NULL, 0, NULL);
    if (ret < 0) {
        dev_err(&i2c_pri->dev, "failed to add sub-devices: %d\n", ret);
        goto err;
    }

    return 0;

err:
    i2c_unregister_device(bcm590xx->i2c_sec);
    return ret;
}
开发者ID:raoy1990,项目名称:linux,代码行数:53,代码来源:bcm590xx.c

示例11: si_8348_init

int si_8348_init(void)
{
	struct i2c_client *client;
	int idx;
	int ret = -EFAULT;

	pr_info("%s driver starting!!\n", MHL_DRIVER_NAME);

#if 0
	/* "Hotplug" the MHL transmitter device onto the 2nd I2C bus */
	i2c_bus_adapter = i2c_get_adapter(HDMI_I2C_CHANNEL);
	if (i2c_bus_adapter == NULL) {
		pr_err("%s() failed to get i2c adapter\n", __func__);
		goto done;
	}

	for (idx = 0; idx < ARRAY_SIZE(device_addresses); idx++) {
		if (idx == 0) {
			client = i2c_new_device(i2c_bus_adapter, &si_8348_i2c_boardinfo[idx]);
			device_addresses[idx].client = client;
		} else {
			device_addresses[idx].client = i2c_new_dummy(i2c_bus_adapter,
								     device_addresses[idx].
								     dev_addr);
		}
		/* TODO: FD, TBC, device_addresses should be initialized with care... */
		if (device_addresses[idx].client == NULL) {
			pr_err("[ERROR] %s():%d failed !\n", __func__, __LINE__);
			goto err_exit;
		}
	}

	ret = i2c_add_driver(&si_8348_mhl_tx_i2c_driver);
	if (ret < 0) {
		pr_info("[ERROR] %s():%d failed !\n", __func__, __LINE__);
		goto err_exit;
	}

	goto done;

 err_exit:
/*
	for (idx = 0; idx < ARRAY_SIZE(device_addresses); idx++) {
		if (device_addresses[idx].client != NULL)
			i2c_unregister_device(device_addresses[idx].client);
	}
*/
 done:
	MHL_TX_DBG_INFO(dev_context, "returning %d\n", ret);
#endif
	return ret;
}
开发者ID:Swapnil133609,项目名称:Zeus_exp,代码行数:52,代码来源:platform.c

示例12: max8907c_i2c_probe

static int max8907c_i2c_probe(struct i2c_client *i2c,
			      const struct i2c_device_id *id)
{
	struct max8907c *max8907c;
	struct max8907c_platform_data *pdata = i2c->dev.platform_data;
	int ret;
	int i;

	max8907c = kzalloc(sizeof(struct max8907c), GFP_KERNEL);
	if (max8907c == NULL)
		return -ENOMEM;

	max8907c->dev = &i2c->dev;
	dev_set_drvdata(max8907c->dev, max8907c);

	max8907c->i2c_power = i2c;
	i2c_set_clientdata(i2c, max8907c);

	max8907c->i2c_rtc = i2c_new_dummy(i2c->adapter, RTC_I2C_ADDR);
	i2c_set_clientdata(max8907c->i2c_rtc, max8907c);

	mutex_init(&max8907c->io_lock);

	for (i = 0; i < ARRAY_SIZE(cells); i++) {
		cells[i].platform_data = max8907c;
		cells[i].pdata_size = sizeof(*max8907c);
	}
	ret = mfd_add_devices(max8907c->dev, -1, cells, ARRAY_SIZE(cells),
			      NULL, 0);
	if (ret != 0) {
	  	i2c_unregister_device(max8907c->i2c_rtc);
		kfree(max8907c);
		pr_debug("max8907c: failed to add MFD devices   %X\n", ret);
		return ret;
	}

	max8907c_client = i2c;

	max8907c_irq_init(max8907c, i2c->irq, pdata->irq_base);

	ret = max8097c_add_subdevs(max8907c, pdata);

	if (pdata->use_power_off && !pm_power_off)
		pm_power_off = max8907c_power_off;

	if (pdata->max8907c_setup)
		return pdata->max8907c_setup();

	return ret;
}
开发者ID:AndroidDeveloperAlliance,项目名称:ZenKernel_Grouper,代码行数:50,代码来源:max8907c.c

示例13: pm860x_probe

static int __devinit pm860x_probe(struct i2c_client *client,
				  const struct i2c_device_id *id)
{
	struct pm860x_platform_data *pdata = client->dev.platform_data;
	struct pm860x_chip *chip;

	if (!pdata) {
		pr_info("No platform data in %s!\n", __func__);
		return -EINVAL;
	}

	chip = kzalloc(sizeof(struct pm860x_chip), GFP_KERNEL);
	if (chip == NULL)
		return -ENOMEM;

	chip->id = verify_addr(client);
	chip->client = client;
	i2c_set_clientdata(client, chip);
	chip->dev = &client->dev;
	mutex_init(&chip->io_lock);
	dev_set_drvdata(chip->dev, chip);

	/*
	 * Both client and companion client shares same platform driver.
	 * Driver distinguishes them by pdata->companion_addr.
	 * pdata->companion_addr is only assigned if companion chip exists.
	 * At the same time, the companion_addr shouldn't equal to client
	 * address.
	 */
	if (pdata->companion_addr && (pdata->companion_addr != client->addr)) {
		chip->companion_addr = pdata->companion_addr;
		chip->companion = i2c_new_dummy(chip->client->adapter,
						chip->companion_addr);
		i2c_set_clientdata(chip->companion, chip);
	}

	pm860x_device_init(chip, pdata);
	return 0;
}
开发者ID:KaZoom,项目名称:buildroot-linux-kernel-m3,代码行数:39,代码来源:88pm860x-i2c.c

示例14: max77693_i2c_probe

static int max77693_i2c_probe(struct i2c_client *i2c,
			      const struct i2c_device_id *id)
{
	struct max77693_dev *max77693;
	unsigned int reg_data;
	int ret = 0;

	max77693 = devm_kzalloc(&i2c->dev,
			sizeof(struct max77693_dev), GFP_KERNEL);
	if (max77693 == NULL)
		return -ENOMEM;

	i2c_set_clientdata(i2c, max77693);
	max77693->dev = &i2c->dev;
	max77693->i2c = i2c;
	max77693->irq = i2c->irq;
	max77693->type = id->driver_data;

	max77693->regmap = devm_regmap_init_i2c(i2c, &max77693_regmap_config);
	if (IS_ERR(max77693->regmap)) {
		ret = PTR_ERR(max77693->regmap);
		dev_err(max77693->dev, "failed to allocate register map: %d\n",
				ret);
		return ret;
	}

	ret = regmap_read(max77693->regmap, MAX77693_PMIC_REG_PMIC_ID2,
				&reg_data);
	if (ret < 0) {
		dev_err(max77693->dev, "device not found on this channel\n");
		return ret;
	} else
		dev_info(max77693->dev, "device ID: 0x%x\n", reg_data);

	max77693->muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC);
	if (!max77693->muic) {
		dev_err(max77693->dev, "Failed to allocate I2C device for MUIC\n");
		return -ENODEV;
	}
	i2c_set_clientdata(max77693->muic, max77693);

	max77693->haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC);
	if (!max77693->haptic) {
		dev_err(max77693->dev, "Failed to allocate I2C device for Haptic\n");
		ret = -ENODEV;
		goto err_i2c_haptic;
	}
	i2c_set_clientdata(max77693->haptic, max77693);

	max77693->regmap_haptic = devm_regmap_init_i2c(max77693->haptic,
					&max77693_regmap_haptic_config);
	if (IS_ERR(max77693->regmap_haptic)) {
		ret = PTR_ERR(max77693->regmap_haptic);
		dev_err(max77693->dev,
			"failed to initialize haptic register map: %d\n", ret);
		goto err_regmap;
	}

	/*
	 * Initialize register map for MUIC device because use regmap-muic
	 * instance of MUIC device when irq of max77693 is initialized
	 * before call max77693-muic probe() function.
	 */
	max77693->regmap_muic = devm_regmap_init_i2c(max77693->muic,
					 &max77693_regmap_muic_config);
	if (IS_ERR(max77693->regmap_muic)) {
		ret = PTR_ERR(max77693->regmap_muic);
		dev_err(max77693->dev,
			"failed to allocate register map: %d\n", ret);
		goto err_regmap;
	}

	ret = regmap_add_irq_chip(max77693->regmap, max77693->irq,
				IRQF_ONESHOT | IRQF_SHARED |
				IRQF_TRIGGER_FALLING, 0,
				&max77693_led_irq_chip,
				&max77693->irq_data_led);
	if (ret) {
		dev_err(max77693->dev, "failed to add irq chip: %d\n", ret);
		goto err_regmap;
	}

	ret = regmap_add_irq_chip(max77693->regmap, max77693->irq,
				IRQF_ONESHOT | IRQF_SHARED |
				IRQF_TRIGGER_FALLING, 0,
				&max77693_topsys_irq_chip,
				&max77693->irq_data_topsys);
	if (ret) {
		dev_err(max77693->dev, "failed to add irq chip: %d\n", ret);
		goto err_irq_topsys;
	}

	ret = regmap_add_irq_chip(max77693->regmap, max77693->irq,
				IRQF_ONESHOT | IRQF_SHARED |
				IRQF_TRIGGER_FALLING, 0,
				&max77693_charger_irq_chip,
				&max77693->irq_data_charger);
	if (ret) {
		dev_err(max77693->dev, "failed to add irq chip: %d\n", ret);
		goto err_irq_charger;
//.........这里部分代码省略.........
开发者ID:383530895,项目名称:linux,代码行数:101,代码来源:max77693.c

示例15: bcmpmu_i2c_probe

static int bcmpmu_i2c_probe(struct i2c_client *i2c,
			    const struct i2c_device_id *id)
{
	struct bcmpmu *bcmpmu;
	int ret = 0;
	struct bcmpmu_platform_data *pdata;
	struct i2c_client *clt;
	struct i2c_adapter *adp;
	struct bcmpmu_i2c *bcmpmu_i2c;

	pdata = (struct bcmpmu_platform_data *)i2c->dev.platform_data;
	if(pdata == NULL){
		printk(KERN_INFO "%s: invalid platform_data. \n", __func__);
		return -ENODEV;
	}

	printk(KERN_INFO "%s called\n", __func__);

	bcmpmu = kzalloc(sizeof(struct bcmpmu), GFP_KERNEL);
	if (bcmpmu == NULL) {
		printk(KERN_ERR "%s: failed to alloc mem.\n", __func__);
		kfree(i2c);
		ret = -ENOMEM;
		goto err;
	}

	bcmpmu_i2c = kzalloc(sizeof(struct bcmpmu_i2c), GFP_KERNEL);
	if (bcmpmu_i2c == NULL) {
		printk(KERN_ERR "%s: failed to alloc mem.\n", __func__);
		ret = -ENOMEM;
		goto err1;
	}

	i2c_set_clientdata(i2c, bcmpmu);
	bcmpmu->dev = &i2c->dev;
	bcmpmu_i2c->i2c_client = i2c;

	adp = i2c_get_adapter(pdata->i2c_adapter_id);
	clt = i2c_new_dummy(adp, pdata->i2c_board_info_map1->addr);
	if (!clt) {
		printk(KERN_ERR "%s: add new device for map1 failed\n", __func__);
		ret = -ENOMEM;
		goto err2;
	}

	clt->dev.platform_data = pdata;
	bcmpmu_i2c->i2c_client1 = clt;
	mutex_init(&bcmpmu_i2c->i2c_mutex);
#ifdef CONFIG_HAS_WAKELOCK
	wake_lock_init(&bcmpmu_i2c->i2c_lock, WAKE_LOCK_SUSPEND,
		"bcmpmu_i2c");
	bcmpmu_i2c->ref_count = 0;
#endif

#if defined(CONFIG_MFD_BCM_PWRMGR_SW_SEQUENCER)
	bcmpmu->read_dev = bcmpmu_i2c_pwrmgr_read;
	bcmpmu->write_dev = bcmpmu_i2c_pwrmgr_write;
	bcmpmu->read_dev_drct = bcmpmu_i2c_pwrmgr_read_direct;
	bcmpmu->write_dev_drct = bcmpmu_i2c_pwrmgr_write_direct;
	bcmpmu->read_dev_bulk = bcmpmu_i2c_pwrmgr_read_direct_bulk;
	bcmpmu->write_dev_bulk = bcmpmu_i2c_pwrmgr_write_direct_bulk;
	pr_info("%s:PWRMGR I2C Sequencer\n", __func__);
#else
	bcmpmu->read_dev = bcmpmu_i2c_read_device;
	bcmpmu->write_dev = bcmpmu_i2c_write_device;
	bcmpmu->read_dev_drct = bcmpmu_i2c_read_device_direct;
	bcmpmu->write_dev_drct = bcmpmu_i2c_write_device_direct;
	bcmpmu->read_dev_bulk = bcmpmu_i2c_read_device_direct_bulk;
	bcmpmu->write_dev_bulk = bcmpmu_i2c_write_device_direct_bulk;
#endif
	bcmpmu->pdata = pdata;
	bcmpmu_i2c->pagesize = pdata->i2c_pagesize;

	bcmpmu->accinfo = bcmpmu_i2c;

	bcmpmu_core_device.dev.platform_data = bcmpmu;
	platform_device_register(&bcmpmu_core_device);

	return ret;

err2:
	kfree(bcmpmu_i2c);
err1:
	kfree(bcmpmu);
err:
	return ret;
}
开发者ID:emreharbutoglu,项目名称:i9105Sammy,代码行数:87,代码来源:bcmpmu-i2c.c


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