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


C++ spi_set_drvdata函数代码示例

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


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

示例1: adis16400_probe

static int adis16400_probe(struct spi_device *spi)
{
	struct adis16400_state *st;
	struct iio_dev *indio_dev;
	int ret;

	indio_dev = iio_device_alloc(sizeof(*st));
	if (indio_dev == NULL)
		return -ENOMEM;

	st = iio_priv(indio_dev);
	/* this is only used for removal purposes */
	spi_set_drvdata(spi, indio_dev);

	/* setup the industrialio driver allocated elements */
	st->variant = &adis16400_chips[spi_get_device_id(spi)->driver_data];
	indio_dev->dev.parent = &spi->dev;
	indio_dev->name = spi_get_device_id(spi)->name;
	indio_dev->channels = st->variant->channels;
	indio_dev->num_channels = st->variant->num_channels;
	indio_dev->info = &adis16400_info;
	indio_dev->modes = INDIO_DIRECT_MODE;

	if (!(st->variant->flags & ADIS16400_NO_BURST))
		indio_dev->available_scan_masks = adis16400_burst_scan_mask;

	ret = adis_init(&st->adis, indio_dev, spi, &adis16400_data);
	if (ret)
		goto error_free_dev;

	ret = adis_setup_buffer_and_trigger(&st->adis, indio_dev,
			adis16400_trigger_handler);
	if (ret)
		goto error_free_dev;

	/* Get the device into a sane initial state */
	ret = adis16400_initial_setup(indio_dev);
	if (ret)
		goto error_cleanup_buffer;
	ret = iio_device_register(indio_dev);
	if (ret)
		goto error_cleanup_buffer;

	adis16400_debugfs_init(indio_dev);
	return 0;

error_cleanup_buffer:
	adis_cleanup_buffer_and_trigger(&st->adis, indio_dev);
error_free_dev:
	iio_device_free(indio_dev);
	return ret;
}
开发者ID:nahuelange,项目名称:yoda-kernel-H7-PLK-L01-MM,代码行数:52,代码来源:adis16400_core.c

示例2: ak4104_spi_probe

static int ak4104_spi_probe(struct spi_device *spi)
{
	struct ak4104_private *ak4104;
	struct gpio_desc *reset_gpiod;
	unsigned int val;
	int ret;

	spi->bits_per_word = 8;
	spi->mode = SPI_MODE_0;
	ret = spi_setup(spi);
	if (ret < 0)
		return ret;

	ak4104 = devm_kzalloc(&spi->dev, sizeof(struct ak4104_private),
			      GFP_KERNEL);
	if (ak4104 == NULL)
		return -ENOMEM;

	ak4104->regulator = devm_regulator_get(&spi->dev, "vdd");
	if (IS_ERR(ak4104->regulator)) {
		ret = PTR_ERR(ak4104->regulator);
		dev_err(&spi->dev, "Unable to get Vdd regulator: %d\n", ret);
		return ret;
	}

	ak4104->regmap = devm_regmap_init_spi(spi, &ak4104_regmap);
	if (IS_ERR(ak4104->regmap)) {
		ret = PTR_ERR(ak4104->regmap);
		return ret;
	}

	reset_gpiod = devm_gpiod_get_optional(&spi->dev, "reset",
					      GPIOD_OUT_HIGH);
	if (IS_ERR(reset_gpiod) &&
	    PTR_ERR(reset_gpiod) == -EPROBE_DEFER)
		return -EPROBE_DEFER;

	/* read the 'reserved' register - according to the datasheet, it
	 * should contain 0x5b. Not a good way to verify the presence of
	 * the device, but there is no hardware ID register. */
	ret = regmap_read(ak4104->regmap, AK4104_REG_RESERVED, &val);
	if (ret != 0)
		return ret;
	if (val != AK4104_RESERVED_VAL)
		return -ENODEV;

	spi_set_drvdata(spi, ak4104);

	ret = devm_snd_soc_register_component(&spi->dev,
			&soc_component_device_ak4104, &ak4104_dai, 1);
	return ret;
}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:52,代码来源:ak4104.c

示例3: corgi_lcd_probe

static int corgi_lcd_probe(struct spi_device *spi)
{
	struct backlight_properties props;
	struct corgi_lcd_platform_data *pdata = dev_get_platdata(&spi->dev);
	struct corgi_lcd *lcd;
	int ret = 0;

	if (pdata == NULL) {
		dev_err(&spi->dev, "platform data not available\n");
		return -EINVAL;
	}

	lcd = devm_kzalloc(&spi->dev, sizeof(struct corgi_lcd), GFP_KERNEL);
	if (!lcd)
		return -ENOMEM;

	lcd->spi_dev = spi;

	lcd->lcd_dev = devm_lcd_device_register(&spi->dev, "corgi_lcd",
						&spi->dev, lcd, &corgi_lcd_ops);
	if (IS_ERR(lcd->lcd_dev))
		return PTR_ERR(lcd->lcd_dev);

	lcd->power = FB_BLANK_POWERDOWN;
	lcd->mode = (pdata) ? pdata->init_mode : CORGI_LCD_MODE_VGA;

	memset(&props, 0, sizeof(struct backlight_properties));
	props.type = BACKLIGHT_RAW;
	props.max_brightness = pdata->max_intensity;
	lcd->bl_dev = devm_backlight_device_register(&spi->dev, "corgi_bl",
						&spi->dev, lcd, &corgi_bl_ops,
						&props);
	if (IS_ERR(lcd->bl_dev))
		return PTR_ERR(lcd->bl_dev);

	lcd->bl_dev->props.brightness = pdata->default_intensity;
	lcd->bl_dev->props.power = FB_BLANK_UNBLANK;

	ret = setup_gpio_backlight(lcd, pdata);
	if (ret)
		return ret;

	lcd->kick_battery = pdata->kick_battery;

	spi_set_drvdata(spi, lcd);
	corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_UNBLANK);
	backlight_update_status(lcd->bl_dev);

	lcd->limit_mask = pdata->limit_mask;
	the_corgi_lcd = lcd;
	return 0;
}
开发者ID:020gzh,项目名称:linux,代码行数:52,代码来源:corgi_lcd.c

示例4: pmic_probe

static int __devinit pmic_probe(struct spi_device *spi)
{
	struct tps6524x *hw;
	struct device *dev = &spi->dev;
	const struct supply_info *info = supply_info;
	struct regulator_init_data *init_data;
	int ret = 0, i;

	init_data = dev->platform_data;
	if (!init_data) {
		dev_err(dev, "could not find regulator platform data\n");
		return -EINVAL;
	}

	hw = kzalloc(sizeof(struct tps6524x), GFP_KERNEL);
	if (!hw) {
		dev_err(dev, "cannot allocate regulator private data\n");
		return -ENOMEM;
	}
	spi_set_drvdata(spi, hw);

	memset(hw, 0, sizeof(struct tps6524x));
	hw->dev = dev;
	hw->spi = spi_dev_get(spi);
	mutex_init(&hw->lock);

	for (i = 0; i < N_REGULATORS; i++, info++, init_data++) {
		hw->desc[i].name	= info->name;
		hw->desc[i].id		= i;
		hw->desc[i].n_voltages	= info->n_voltages;
		hw->desc[i].ops		= &regulator_ops;
		hw->desc[i].type	= REGULATOR_VOLTAGE;
		hw->desc[i].owner	= THIS_MODULE;

		if (info->flags & FIXED_VOLTAGE)
			hw->desc[i].n_voltages = 1;

		hw->rdev[i] = regulator_register(&hw->desc[i], dev,
						 init_data, hw);
		if (IS_ERR(hw->rdev[i])) {
			ret = PTR_ERR(hw->rdev[i]);
			hw->rdev[i] = NULL;
			goto fail;
		}
	}

	return 0;

fail:
	pmic_remove(spi);
	return ret;
}
开发者ID:119-org,项目名称:hi3518-osdrv,代码行数:52,代码来源:tps6524x-regulator.c

示例5: v4l2_spi_subdev_init

void v4l2_spi_subdev_init(struct v4l2_subdev *sd, struct spi_device *spi,
		const struct v4l2_subdev_ops *ops)
{
	v4l2_subdev_init(sd, ops);
	sd->flags |= V4L2_SUBDEV_FL_IS_SPI;
	/* the owner is the same as the spi_device's driver owner */
	sd->owner = spi->dev.driver->owner;
	/* spi_device and v4l2_subdev point to one another */
	v4l2_set_subdevdata(sd, spi);
	spi_set_drvdata(spi, sd);
	/* initialize name */
	strlcpy(sd->name, spi->dev.driver->name, sizeof(sd->name));
}
开发者ID:ArthySundaram,项目名称:chromeos-kvm,代码行数:13,代码来源:v4l2-common.c

示例6: v4l2_spi_subdev_init

void v4l2_spi_subdev_init(struct v4l2_subdev *sd, struct spi_device *spi,
		const struct v4l2_subdev_ops *ops)
{
	v4l2_subdev_init(sd, ops);
	sd->flags |= V4L2_SUBDEV_FL_IS_SPI;
	
	sd->owner = spi->dev.driver->owner;
	
	v4l2_set_subdevdata(sd, spi);
	spi_set_drvdata(spi, sd);
	
	strlcpy(sd->name, spi->dev.driver->name, sizeof(sd->name));
}
开发者ID:DirtyDroidX,项目名称:android_kernel_htc_m8ul,代码行数:13,代码来源:v4l2-common.c

示例7: ds3234_probe

static int ds3234_probe(struct spi_device *spi)
{
	struct rtc_device *rtc;
	unsigned char tmp;
	int res;

	spi->mode = SPI_MODE_3;
	spi->bits_per_word = 8;
	spi_setup(spi);

	res = ds3234_get_reg(&spi->dev, DS3234_REG_SECONDS, &tmp);
	if (res != 0)
		return res;

	/* Control settings
	 *
	 * CONTROL_REG
	 * BIT 7	6	5	4	3	2	1	0
	 *     EOSC	BBSQW	CONV	RS2	RS1	INTCN	A2IE	A1IE
	 *
	 *     0	0	0	1	1	1	0	0
	 *
	 * CONTROL_STAT_REG
	 * BIT 7	6	5	4	3	2	1	0
	 *     OSF	BB32kHz	CRATE1	CRATE0	EN32kHz	BSY	A2F	A1F
	 *
	 *     1	0	0	0	1	0	0	0
	 */
	ds3234_get_reg(&spi->dev, DS3234_REG_CONTROL, &tmp);
	ds3234_set_reg(&spi->dev, DS3234_REG_CONTROL, tmp & 0x1c);

	ds3234_get_reg(&spi->dev, DS3234_REG_CONT_STAT, &tmp);
	ds3234_set_reg(&spi->dev, DS3234_REG_CONT_STAT, tmp & 0x88);

	/* Print our settings */
	ds3234_get_reg(&spi->dev, DS3234_REG_CONTROL, &tmp);
	dev_info(&spi->dev, "Control Reg: 0x%02x\n", tmp);

	ds3234_get_reg(&spi->dev, DS3234_REG_CONT_STAT, &tmp);
	dev_info(&spi->dev, "Ctrl/Stat Reg: 0x%02x\n", tmp);

	rtc = devm_rtc_device_register(&spi->dev, "ds3234",
				&ds3234_rtc_ops, THIS_MODULE);
	if (IS_ERR(rtc))
		return PTR_ERR(rtc);

	spi_set_drvdata(spi, rtc);

	return 0;
}
开发者ID:AD5GB,项目名称:kernel_n5_3.10-experimental,代码行数:50,代码来源:rtc-ds3234.c

示例8: cs4271_spi_probe

static int __devinit cs4271_spi_probe(struct spi_device *spi)
{
	struct cs4271_private *cs4271;

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

	spi_set_drvdata(spi, cs4271);
	cs4271->bus_type = SND_SOC_SPI;

	return snd_soc_register_codec(&spi->dev, &soc_codec_dev_cs4271,
		&cs4271_dai, 1);
}
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:14,代码来源:cs4271.c

示例9: pmic_remove

static int pmic_remove(struct spi_device *spi)
{
	struct tps6524x *hw = spi_get_drvdata(spi);
	int i;

	if (!hw)
		return 0;
	for (i = 0; i < N_REGULATORS; i++) {
		regulator_unregister(hw->rdev[i]);
		hw->rdev[i] = NULL;
	}
	spi_set_drvdata(spi, NULL);
	return 0;
}
开发者ID:AD5GB,项目名称:kernel_n5_3.10-experimental,代码行数:14,代码来源:tps6524x-regulator.c

示例10: gspi_dvobj_deinit

static void gspi_dvobj_deinit(struct spi_device *spi)
{
	struct dvobj_priv *dvobj = spi_get_drvdata(spi);

_func_enter_;

	spi_set_drvdata(spi, NULL);
	if (dvobj) {
		gspi_deinit(dvobj);
		rtw_mfree((u8*)dvobj, sizeof(*dvobj));
	}

_func_exit_;
}
开发者ID:32743069,项目名称:amlogic_common_3050,代码行数:14,代码来源:gspi_intf.c

示例11: adis16136_probe

static int adis16136_probe(struct spi_device *spi)
{
	const struct spi_device_id *id = spi_get_device_id(spi);
	struct adis16136 *adis16136;
	struct iio_dev *indio_dev;
	int ret;

	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adis16136));
	if (indio_dev == NULL)
		return -ENOMEM;

	spi_set_drvdata(spi, indio_dev);

	adis16136 = iio_priv(indio_dev);

	adis16136->chip_info = &adis16136_chip_info[id->driver_data];
	indio_dev->dev.parent = &spi->dev;
	indio_dev->name = spi_get_device_id(spi)->name;
	indio_dev->channels = adis16136_channels;
	indio_dev->num_channels = ARRAY_SIZE(adis16136_channels);
	indio_dev->info = &adis16136_info;
	indio_dev->modes = INDIO_DIRECT_MODE;

	ret = adis_init(&adis16136->adis, indio_dev, spi, &adis16136_data);
	if (ret)
		return ret;

	ret = adis_setup_buffer_and_trigger(&adis16136->adis, indio_dev, NULL);
	if (ret)
		return ret;

	ret = adis16136_initial_setup(indio_dev);
	if (ret)
		goto error_cleanup_buffer;

	ret = iio_device_register(indio_dev);
	if (ret)
		goto error_stop_device;

	adis16136_debugfs_init(indio_dev);

	return 0;

error_stop_device:
	adis16136_stop_device(indio_dev);
error_cleanup_buffer:
	adis_cleanup_buffer_and_trigger(&adis16136->adis, indio_dev);
	return ret;
}
开发者ID:03199618,项目名称:linux,代码行数:49,代码来源:adis16136.c

示例12: ad7606_spi_probe

static int ad7606_spi_probe(struct spi_device *spi)
{
	struct iio_dev *indio_dev;

	indio_dev = ad7606_probe(&spi->dev, spi->irq, NULL,
			   spi_get_device_id(spi)->driver_data,
			   &ad7606_spi_bops);

	if (IS_ERR(indio_dev))
		return PTR_ERR(indio_dev);

	spi_set_drvdata(spi, indio_dev);

	return 0;
}
开发者ID:3null,项目名称:linux,代码行数:15,代码来源:ad7606_spi.c

示例13: dit4192_spi_probe

static int __devinit dit4192_spi_probe(struct spi_device *spi)
{
	int ret;
	struct dit4192 *chip;
	struct dit4192_platform_data *pdata;

	if (spi->dev.platform_data == NULL) {
		pr_err("%s: platform data is missing\n", __func__);
		return -EINVAL;
	}
	pdata = (struct dit4192_platform_data *)spi->dev.platform_data;
        gl_chip = chip = devm_kzalloc(&spi->dev, sizeof(struct dit4192), GFP_KERNEL);
        if (!chip)
                return -ENOMEM;

	pr_info("%s(): \n" , __func__);

	chip->spi	= spi;
	chip->buf_int	= pdata->gpio_buf_flip_int;
	chip->ubit_pin	= pdata->gpio_u_bits;
	chip->bls_pin	= pdata->gpio_bls;
	chip->reset_pin	= pdata->gpio_reset;

        spi_set_drvdata(spi, chip);

	ret = dit4192_gpio_init(chip);
	if( ret < 0 ) {
		return ret;
	}

	dit4192_poweron(chip);

	ret = dit4192_check_device(chip);
	if (ret < 0) {
		dit4192_gpio_free(chip);
		return ret;
	}
		
	/* send initial values */
	dit4192_init(chip);

	ret = snd_soc_register_codec(	&spi->dev,
					&soc_codec_dev_dit4192, 
					dit4192_dai, 
					ARRAY_SIZE(dit4192_dai));

	return 0;
}
开发者ID:danielcbit,项目名称:android_kernel_amazon_bueller,代码行数:48,代码来源:dit4192.c

示例14: ab4500_probe

static int __init ab4500_probe(struct spi_device *spi)
{
	struct ab4500	*ab4500;
	unsigned char revision;
	int err = 0;
	int i;

	ab4500 = kzalloc(sizeof *ab4500, GFP_KERNEL);
	if (!ab4500) {
		dev_err(&spi->dev, "could not allocate AB4500\n");
		err = -ENOMEM;
		goto not_detect;
	}

	ab4500->spi = spi;
	spi_set_drvdata(spi, ab4500);

	mutex_init(&ab4500->lock);

	/* read the revision register */
	revision = ab4500_read(ab4500, AB4500_MISC, AB4500_REV_REG);

	/* revision id 0x0 is for early drop, 0x10 is for cut1.0 */
	if (revision == 0x0 || revision == 0x10)
		dev_info(&spi->dev, "Detected chip: %s, revision = %x\n",
			ab4500_driver.driver.name, revision);
	else	{
		dev_err(&spi->dev, "unknown chip: 0x%x\n", revision);
		goto not_detect;
	}

	for (i = 0; i < ARRAY_SIZE(ab4500_platform_devs); i++)	{
		ab4500_platform_devs[i]->dev.parent =
			&spi->dev;
		platform_set_drvdata(ab4500_platform_devs[i], ab4500);
	}

	/* register the ab4500 platform devices */
	platform_add_devices(ab4500_platform_devs,
			ARRAY_SIZE(ab4500_platform_devs));

	return err;

 not_detect:
	spi_unregister_driver(&ab4500_driver);
	kfree(ab4500);
	return err;
}
开发者ID:A2109devs,项目名称:lenovo_a2109a_kernel,代码行数:48,代码来源:ab4500-core.c

示例15: nrf905_probe

static int nrf905_probe(struct spi_device *spi)
{
	int retval = 0;

	dev_info(&spi->dev, "probe\n");

	retval = spi_setup(spi);
	if (retval < 0) {
		dev_err(&spi->dev, "Can not setup spi device\n");
		retval = -ENODEV;
		goto err;
	}

	spi_set_drvdata(spi, nrf905_dev);

	nrf905_dev->spi_dev = spi;

	retval = nrf905_gpio_config(nrf905_dev);
	if (retval < 0)
		goto err;

	retval = devm_request_irq(
			nrf905_dev->char_dev,
			nrf905_dev->chip.dataready_irq,
			nrf905_dr_irq,
			IRQF_TRIGGER_RISING,
			"nrf905",
			nrf905_dev);
	if (retval < 0) {
		dev_err(&spi->dev, "Irq request failed\n");
		goto err_irq;
	}

	retval = nrf905_init_chip(nrf905_dev);
	if (retval < 0)
		goto err_init_chip;

	return retval;

err_init_chip:
	devm_free_irq(nrf905_dev->char_dev,
		nrf905_dev->chip.dataready_irq,
		nrf905_dev);
err_irq:
	nrf905_gpio_release(nrf905_dev);
err:
	return retval;
}
开发者ID:ts37140,项目名称:nrf905,代码行数:48,代码来源:nrf905_driver.c


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