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

C++ devm_gpio_request_one函数代码示例

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

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



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

示例1: lp8788_gpio_request_ldo_en

static int lp8788_gpio_request_ldo_en(struct platform_device *pdev,
				struct lp8788_ldo *ldo,
				enum lp8788_ext_ldo_en_id id)
{
	struct device *dev = &pdev->dev;
	struct lp8788_ldo_enable_pin *pin = ldo->en_pin;
	int ret, gpio, pinstate;
	char *name[] = {
		[EN_ALDO1]   = "LP8788_EN_ALDO1",
		[EN_ALDO234] = "LP8788_EN_ALDO234",
		[EN_ALDO5]   = "LP8788_EN_ALDO5",
		[EN_ALDO7]   = "LP8788_EN_ALDO7",
		[EN_DLDO7]   = "LP8788_EN_DLDO7",
		[EN_DLDO911] = "LP8788_EN_DLDO911",
	};

	gpio = pin->gpio;
	if (!gpio_is_valid(gpio)) {
		dev_err(dev, "invalid gpio: %d\n", gpio);
		return -EINVAL;
	}

	pinstate = pin->init_state;
	ret = devm_gpio_request_one(dev, gpio, pinstate, name[id]);
	if (ret == -EBUSY) {
		dev_warn(dev, "gpio%d already used\n", gpio);
		return 0;
	}

	return ret;
}
开发者ID:AiWinters,项目名称:linux,代码行数:31,代码来源:lp8788-ldo.c


示例2: lp872x_init_dvs

static int lp872x_init_dvs(struct lp872x *lp)
{
	int ret, gpio;
	struct lp872x_dvs *dvs = lp->pdata ? lp->pdata->dvs : NULL;
	enum lp872x_dvs_state pinstate;
	u8 mask[] = { LP8720_EXT_DVS_M, LP8725_DVS1_M | LP8725_DVS2_M };
	u8 default_dvs_mode[] = { LP8720_DEFAULT_DVS, LP8725_DEFAULT_DVS };

	if (!dvs)
		goto set_default_dvs_mode;

	gpio = dvs->gpio;
	if (!gpio_is_valid(gpio)) {
		dev_warn(lp->dev, "invalid gpio: %d\n", gpio);
		goto set_default_dvs_mode;
	}

	pinstate = dvs->init_state;
	ret = devm_gpio_request_one(lp->dev, gpio, pinstate, "LP872X DVS");
	if (ret) {
		dev_err(lp->dev, "gpio request err: %d\n", ret);
		return ret;
	}

	lp->dvs_pin = pinstate;
	lp->dvs_gpio = gpio;

	return 0;

set_default_dvs_mode:
	return lp872x_update_bits(lp, LP872X_GENERAL_CFG, mask[lp->chipid],
				default_dvs_mode[lp->chipid]);
}
开发者ID:mikuhatsune001,项目名称:linux2.6.32,代码行数:33,代码来源:lp872x.c


示例3: ak4104_spi_probe

static int ak4104_spi_probe(struct spi_device *spi)
{
	struct device_node *np = spi->dev.of_node;
	struct ak4104_private *ak4104;
	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;
	}

	if (np) {
		enum of_gpio_flags flags;
		int gpio = of_get_named_gpio_flags(np, "reset-gpio", 0, &flags);

		if (gpio_is_valid(gpio)) {
			ret = devm_gpio_request_one(&spi->dev, gpio,
				     flags & OF_GPIO_ACTIVE_LOW ?
					GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH,
				     "ak4104 reset");
			if (ret < 0)
				return ret;
		}
	}

	/* 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 = snd_soc_register_codec(&spi->dev,
			&soc_codec_device_ak4104, &ak4104_dai, 1);
	return ret;
}
开发者ID:AshishNamdev,项目名称:linux,代码行数:60,代码来源:ak4104.c


示例4: aic31xx_device_init

static int aic31xx_device_init(struct aic31xx_priv *aic31xx)
{
	int ret, i;

	dev_set_drvdata(aic31xx->dev, aic31xx);

	if (dev_get_platdata(aic31xx->dev))
		memcpy(&aic31xx->pdata, dev_get_platdata(aic31xx->dev),
		       sizeof(aic31xx->pdata));
	else if (aic31xx->dev->of_node)
		aic31xx_pdata_from_of(aic31xx);

	if (aic31xx->pdata.gpio_reset) {
		ret = devm_gpio_request_one(aic31xx->dev,
					    aic31xx->pdata.gpio_reset,
					    GPIOF_OUT_INIT_HIGH,
					    "aic31xx-reset-pin");
		if (ret < 0) {
			dev_err(aic31xx->dev, "not able to acquire gpio\n");
			return ret;
		}
	}

	for (i = 0; i < ARRAY_SIZE(aic31xx->supplies); i++)
		aic31xx->supplies[i].supply = aic31xx_supply_names[i];

	ret = devm_regulator_bulk_get(aic31xx->dev,
				      ARRAY_SIZE(aic31xx->supplies),
				      aic31xx->supplies);
	if (ret != 0)
		dev_err(aic31xx->dev, "Failed to request supplies: %d\n", ret);

	return ret;
}
开发者ID:imcek,项目名称:BEAGLEBONE_BSP,代码行数:34,代码来源:tlv320aic31xx.c


示例5: lp872x_hw_enable

static int lp872x_hw_enable(struct lp872x *lp)
{
	int ret, gpio;

	if (!lp->pdata)
		return -EINVAL;

	gpio = lp->pdata->enable_gpio;
	if (!gpio_is_valid(gpio))
		return 0;

	/* Always set enable GPIO high. */
	ret = devm_gpio_request_one(lp->dev, gpio, GPIOF_OUT_INIT_HIGH, "LP872X EN");
	if (ret) {
		dev_err(lp->dev, "gpio request err: %d\n", ret);
		return ret;
	}

	/* Each chip has a different enable delay. */
	if (lp->chipid == LP8720)
		usleep_range(LP8720_ENABLE_DELAY, 1.5 * LP8720_ENABLE_DELAY);
	else
		usleep_range(LP8725_ENABLE_DELAY, 1.5 * LP8725_ENABLE_DELAY);

	return 0;
}
开发者ID:020gzh,项目名称:linux,代码行数:26,代码来源:lp872x.c


示例6: tpm_stm_i2c_request_resources

static int tpm_stm_i2c_request_resources(struct i2c_client *client,
					 struct tpm_chip *chip)
{
	struct st33zp24_platform_data *pdata;
	struct tpm_stm_dev *tpm_dev = (struct tpm_stm_dev *)TPM_VPRIV(chip);
	int ret;

	pdata = client->dev.platform_data;
	if (!pdata) {
		dev_err(chip->pdev, "No platform data\n");
		return -ENODEV;
	}

	/* store for late use */
	tpm_dev->io_lpcpd = pdata->io_lpcpd;

	if (gpio_is_valid(pdata->io_lpcpd)) {
		ret = devm_gpio_request_one(&client->dev,
				pdata->io_lpcpd, GPIOF_OUT_INIT_HIGH,
				"TPM IO_LPCPD");
		if (ret) {
			dev_err(chip->pdev, "%s : reset gpio_request failed\n",
				__FILE__);
			return ret;
		}
	}

	return 0;
}
开发者ID:168519,项目名称:linux,代码行数:29,代码来源:tpm_i2c_stm_st33.c


示例7: st_nci_i2c_of_request_resources

static int st_nci_i2c_of_request_resources(struct i2c_client *client)
{
	struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
	struct device_node *pp;
	int gpio;
	int r;

	pp = client->dev.of_node;
	if (!pp)
		return -ENODEV;

	/* Get GPIO from device tree */
	gpio = of_get_named_gpio(pp, "reset-gpios", 0);
	if (gpio < 0) {
		nfc_err(&client->dev,
			"Failed to retrieve reset-gpios from device tree\n");
		return gpio;
	}

	/* GPIO request and configuration */
	r = devm_gpio_request_one(&client->dev, gpio,
				GPIOF_OUT_INIT_HIGH, "clf_reset");
	if (r) {
		nfc_err(&client->dev, "Failed to request reset pin\n");
		return r;
	}
	phy->gpio_reset = gpio;

	phy->irq_polarity = irq_get_trigger_type(client->irq);

	return 0;
}
开发者ID:DenisLug,项目名称:mptcp,代码行数:32,代码来源:i2c.c


示例8: st_nci_i2c_request_resources

static int st_nci_i2c_request_resources(struct i2c_client *client)
{
	struct st_nci_nfc_platform_data *pdata;
	struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
	int r;

	pdata = client->dev.platform_data;
	if (pdata == NULL) {
		nfc_err(&client->dev, "No platform data\n");
		return -EINVAL;
	}

	/* store for later use */
	phy->gpio_reset = pdata->gpio_reset;
	phy->irq_polarity = pdata->irq_polarity;

	r = devm_gpio_request_one(&client->dev,
			phy->gpio_reset, GPIOF_OUT_INIT_HIGH,
			ST_NCI_GPIO_NAME_RESET);
	if (r) {
		pr_err("%s : reset gpio_request failed\n", __FILE__);
		return r;
	}

	phy->se_status.is_ese_present = pdata->is_ese_present;
	phy->se_status.is_uicc_present = pdata->is_uicc_present;

	return 0;
}
开发者ID:513855417,项目名称:linux,代码行数:29,代码来源:i2c.c


示例9: lp872x_init_dvs

static int lp872x_init_dvs(struct lp872x *lp)
{
	int ret, gpio;
	struct lp872x_dvs *dvs = lp->pdata->dvs;
	enum lp872x_dvs_state pinstate;

	ret = lp872x_check_dvs_validity(lp);
	if (ret) {
		dev_warn(lp->dev, "invalid dvs data: %d\n", ret);
		return ret;
	}

	gpio = dvs->gpio;
	if (!gpio_is_valid(gpio)) {
		dev_err(lp->dev, "invalid gpio: %d\n", gpio);
		return -EINVAL;
	}

	pinstate = dvs->init_state;
	ret = devm_gpio_request_one(lp->dev, gpio, pinstate, "LP872X DVS");
	if (ret) {
		dev_err(lp->dev, "gpio request err: %d\n", ret);
		return ret;
	}

	lp->dvs_pin = pinstate;
	lp->dvs_gpio = gpio;

	return 0;
}
开发者ID:ARMWorks,项目名称:FA_2451_Linux_Kernel,代码行数:30,代码来源:lp872x.c


示例10: sdhci_acpi_add_own_cd

static int sdhci_acpi_add_own_cd(struct device *dev, int gpio,
				 struct mmc_host *mmc)
{
	unsigned long flags;
	int err, irq;

	if (gpio < 0) {
		err = gpio;
		goto out;
	}

	err = devm_gpio_request_one(dev, gpio, GPIOF_DIR_IN, "sd_cd");
	if (err)
		goto out;

	irq = gpio_to_irq(gpio);
	if (irq < 0) {
		err = irq;
		goto out_free;
	}

	flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;
	err = devm_request_irq(dev, irq, sdhci_acpi_sd_cd, flags, "sd_cd", mmc);
	if (err)
		goto out_free;

	return 0;

out_free:
	devm_gpio_free(dev, gpio);
out:
	dev_warn(dev, "failed to setup card detect wake up\n");
	return err;
}
开发者ID:neominds,项目名称:wrfx227819,代码行数:34,代码来源:sdhci-acpi.c


示例11: ak5386_probe

static int ak5386_probe(struct platform_device *pdev)
{
	struct device *dev = &pdev->dev;
	struct ak5386_priv *priv;

	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
	if (!priv)
		return -ENOMEM;

	priv->reset_gpio = -EINVAL;
	dev_set_drvdata(dev, priv);

	if (of_match_device(of_match_ptr(ak5386_dt_ids), dev))
		priv->reset_gpio = of_get_named_gpio(dev->of_node,
						      "reset-gpio", 0);

	if (gpio_is_valid(priv->reset_gpio))
		if (devm_gpio_request_one(dev, priv->reset_gpio,
					  GPIOF_OUT_INIT_LOW,
					  "AK5386 Reset"))
			priv->reset_gpio = -EINVAL;

	return snd_soc_register_codec(dev, &soc_codec_ak5386,
				      &ak5386_dai, 1);
}
开发者ID:AD5GB,项目名称:kernel_n5_3.10-experimental,代码行数:25,代码来源:ak5386.c


示例12: sharp_ls_panel_probe

static int sharp_ls_panel_probe(struct omap_dss_device *dssdev)
{
	struct panel_sharp_ls037v7dw01_data *pd = get_panel_data(dssdev);
	int r;

	if (!pd)
		return -EINVAL;

	dssdev->panel.timings = sharp_ls_timings;

	if (gpio_is_valid(pd->mo_gpio)) {
		r = devm_gpio_request_one(&dssdev->dev, pd->mo_gpio,
				GPIOF_OUT_INIT_LOW, "lcd MO");
		if (r)
			return r;
	}

	if (gpio_is_valid(pd->lr_gpio)) {
		r = devm_gpio_request_one(&dssdev->dev, pd->lr_gpio,
				GPIOF_OUT_INIT_HIGH, "lcd LR");
		if (r)
			return r;
	}

	if (gpio_is_valid(pd->ud_gpio)) {
		r = devm_gpio_request_one(&dssdev->dev, pd->ud_gpio,
				GPIOF_OUT_INIT_HIGH, "lcd UD");
		if (r)
			return r;
	}

	if (gpio_is_valid(pd->resb_gpio)) {
		r = devm_gpio_request_one(&dssdev->dev, pd->resb_gpio,
				GPIOF_OUT_INIT_LOW, "lcd RESB");
		if (r)
			return r;
	}

	if (gpio_is_valid(pd->ini_gpio)) {
		r = devm_gpio_request_one(&dssdev->dev, pd->ini_gpio,
				GPIOF_OUT_INIT_LOW, "lcd INI");
		if (r)
			return r;
	}

	return 0;
}
开发者ID:AD5GB,项目名称:kernel_n5_3.10-experimental,代码行数:47,代码来源:panel-sharp-ls037v7dw01.c


示例13: exynos_pcie_assert_reset

static void exynos_pcie_assert_reset(struct pcie_port *pp)
{
	struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);

	if (exynos_pcie->reset_gpio >= 0)
		devm_gpio_request_one(pp->dev, exynos_pcie->reset_gpio,
				GPIOF_OUT_INIT_HIGH, "RESET");
}
开发者ID:DenisLug,项目名称:mptcp,代码行数:8,代码来源:pci-exynos.c


示例14: lp55xx_init_device

int lp55xx_init_device(struct lp55xx_chip *chip)
{
	struct lp55xx_platform_data *pdata;
	struct lp55xx_device_config *cfg;
	struct device *dev = &chip->cl->dev;
	int ret = 0;

	WARN_ON(!chip);

	pdata = chip->pdata;
	cfg = chip->cfg;

	if (!pdata || !cfg)
		return -EINVAL;

	if (gpio_is_valid(pdata->enable_gpio)) {
		ret = devm_gpio_request_one(dev, pdata->enable_gpio,
					    GPIOF_DIR_OUT, "lp5523_enable");
		if (ret < 0) {
			dev_err(dev, "could not acquire enable gpio (err=%d)\n",
				ret);
			goto err;
		}

		gpio_set_value(pdata->enable_gpio, 0);
		usleep_range(1000, 2000); /* Keep enable down at least 1ms */
		gpio_set_value(pdata->enable_gpio, 1);
		usleep_range(1000, 2000); /* 500us abs min. */
	}

	lp55xx_reset_device(chip);

	/*
	 * Exact value is not available. 10 - 20ms
	 * appears to be enough for reset.
	 */
	usleep_range(10000, 20000);

	ret = lp55xx_detect_device(chip);
	if (ret) {
		dev_err(dev, "device detection err: %d\n", ret);
		goto err;
	}

	/* chip specific initialization */
	ret = lp55xx_post_init_device(chip);
	if (ret) {
		dev_err(dev, "post init device err: %d\n", ret);
		goto err_post_init;
	}

	return 0;

err_post_init:
	lp55xx_deinit_device(chip);
err:
	return ret;
}
开发者ID:BORETS24,项目名称:common.git-android-4.4,代码行数:58,代码来源:leds-lp55xx-common.c


示例15: de1soc_audio_probe

static int de1soc_audio_probe(struct platform_device *pdev)
{
	struct device_node *np = pdev->dev.of_node;
	struct device_node *codec_np, *cpu_np;
	struct snd_soc_card *card = &snd_soc_de1soc;
	int ret;

	if (!np) {
		return -ENODEV;
	}

	card->dev = &pdev->dev;

	/* I2C bus is muxed between HPS and FPGA. Set mux to HPS */
	i2c_mux_gpio = of_get_named_gpio(np, "i2c-mux-gpio", 0);
	if (gpio_is_valid(i2c_mux_gpio)) {
		ret = devm_gpio_request_one(&pdev->dev,
			i2c_mux_gpio, GPIOF_OUT_INIT_LOW, "I2C_MUX");
		if (ret) {
			dev_err(&pdev->dev,
				"Failed to request GPIO_%d for i2c_mux: %d\n",
				i2c_mux_gpio, ret);
			return ret;
		}
		gpio_set_value(i2c_mux_gpio, 1);
	}

	/* Parse codec info */
	de1soc_dai.codec_name = NULL;
	codec_np = of_parse_phandle(np, "audio-codec", 0);
	if (!codec_np) {
		dev_err(&pdev->dev, "codec info missing\n");
		return -EINVAL;
	}
	de1soc_dai.codec_of_node = codec_np;

	/* Parse dai and platform info */
	de1soc_dai.cpu_dai_name = NULL;
	de1soc_dai.platform_name = NULL;
	cpu_np = of_parse_phandle(np, "i2s-controller", 0);
	if (!cpu_np) {
		dev_err(&pdev->dev, "dai and pcm info missing\n");
		return -EINVAL;
	}
	de1soc_dai.cpu_of_node = cpu_np;
	de1soc_dai.platform_of_node = cpu_np;

	of_node_put(codec_np);
	of_node_put(cpu_np);

	ret = snd_soc_register_card(card);
	if (ret) {
		dev_err(&pdev->dev, "snd_soc_register_card() failed\n");
	}

	return ret;
}
开发者ID:bsteinsbo,项目名称:DE1-SoC-Sound,代码行数:57,代码来源:de1-soc-wm8731.c


示例16: exynos_pcie_assert_reset

static void exynos_pcie_assert_reset(struct exynos_pcie *exynos_pcie)
{
	struct pcie_port *pp = &exynos_pcie->pp;
	struct device *dev = pp->dev;

	if (exynos_pcie->reset_gpio >= 0)
		devm_gpio_request_one(dev, exynos_pcie->reset_gpio,
				GPIOF_OUT_INIT_HIGH, "RESET");
}
开发者ID:acton393,项目名称:linux,代码行数:9,代码来源:pci-exynos.c


示例17: exynos_pcie_assert_reset

static void exynos_pcie_assert_reset(struct exynos_pcie *ep)
{
	struct dw_pcie *pci = ep->pci;
	struct device *dev = pci->dev;

	if (ep->reset_gpio >= 0)
		devm_gpio_request_one(dev, ep->reset_gpio,
				GPIOF_OUT_INIT_HIGH, "RESET");
}
开发者ID:ReneNyffenegger,项目名称:linux,代码行数:9,代码来源:pci-exynos.c


示例18: st21nfcb_nci_i2c_request_resources

static int st21nfcb_nci_i2c_request_resources(struct i2c_client *client)
{
	struct st21nfcb_nfc_platform_data *pdata;
	struct st21nfcb_i2c_phy *phy = i2c_get_clientdata(client);
	int r;
	int irq;

	pdata = client->dev.platform_data;
	if (pdata == NULL) {
		nfc_err(&client->dev, "No platform data\n");
		return -EINVAL;
	}

	/* store for later use */
	phy->gpio_irq = pdata->gpio_irq;
	phy->gpio_reset = pdata->gpio_reset;
	phy->irq_polarity = pdata->irq_polarity;

	r = devm_gpio_request_one(&client->dev, phy->gpio_irq,
				GPIOF_IN, "clf_irq");
	if (r) {
		pr_err("%s : gpio_request failed\n", __FILE__);
		return -ENODEV;
	}

	r = devm_gpio_request_one(&client->dev,
			phy->gpio_reset, GPIOF_OUT_INIT_HIGH, "clf_reset");
	if (r) {
		pr_err("%s : reset gpio_request failed\n", __FILE__);
		return -ENODEV;
	}

	/* IRQ */
	irq = gpio_to_irq(phy->gpio_irq);
	if (irq < 0) {
		nfc_err(&client->dev,
			"Unable to get irq number for GPIO %d error %d\n",
			phy->gpio_irq, r);
		return -ENODEV;
	}
	client->irq = irq;

	return 0;
}
开发者ID:royceniu,项目名称:RP2_MPTCP,代码行数:44,代码来源:i2c.c


示例19: s3fwrn5_i2c_probe

static int s3fwrn5_i2c_probe(struct i2c_client *client,
				  const struct i2c_device_id *id)
{
	struct s3fwrn5_i2c_phy *phy;
	int ret;

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

	mutex_init(&phy->mutex);
	phy->mode = S3FWRN5_MODE_COLD;
	phy->irq_skip = true;

	phy->i2c_dev = client;
	i2c_set_clientdata(client, phy);

	ret = s3fwrn5_i2c_parse_dt(client);
	if (ret < 0)
		return ret;

	ret = devm_gpio_request_one(&phy->i2c_dev->dev, phy->gpio_en,
		GPIOF_OUT_INIT_HIGH, "s3fwrn5_en");
	if (ret < 0)
		return ret;

	ret = devm_gpio_request_one(&phy->i2c_dev->dev, phy->gpio_fw_wake,
		GPIOF_OUT_INIT_LOW, "s3fwrn5_fw_wake");
	if (ret < 0)
		return ret;

	ret = s3fwrn5_probe(&phy->ndev, phy, &phy->i2c_dev->dev, &i2c_phy_ops,
		S3FWRN5_I2C_MAX_PAYLOAD);
	if (ret < 0)
		return ret;

	ret = request_threaded_irq(phy->i2c_dev->irq, NULL,
		s3fwrn5_i2c_irq_thread_fn, IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
		S3FWRN5_I2C_DRIVER_NAME, phy);
	if (ret)
		s3fwrn5_remove(phy->ndev);

	return ret;
}
开发者ID:DenisLug,项目名称:mptcp,代码行数:44,代码来源:i2c.c


示例20: mmc_gpio_request_cd

/**
 * mmc_gpio_request_cd - request a gpio for card-detection
 * @host: mmc host
 * @gpio: gpio number requested
 *
 * As devm_* managed functions are used in mmc_gpio_request_cd(), client
 * drivers do not need to explicitly call mmc_gpio_free_cd() for freeing up,
 * if the requesting and freeing are only needed at probing and unbinding time
 * for once.  However, if client drivers do something special like runtime
 * switching for card-detection, they are responsible for calling
 * mmc_gpio_request_cd() and mmc_gpio_free_cd() as a pair on their own.
 *
 * Returns zero on success, else an error.
 */
int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio)
{
	struct mmc_gpio *ctx;
	int irq = gpio_to_irq(gpio);
	int ret;

	ret = mmc_gpio_alloc(host);
	if (ret < 0)
		return ret;

	ctx = host->slot.handler_priv;

	ret = devm_gpio_request_one(&host->class_dev, gpio, GPIOF_DIR_IN,
				    ctx->cd_label);
	if (ret < 0)
		/*
		 * don't bother freeing memory. It might still get used by other
		 * slot functions, in any case it will be freed, when the device
		 * is destroyed.
		 */
		return ret;

	/*
	 * Even if gpio_to_irq() returns a valid IRQ number, the platform might
	 * still prefer to poll, e.g., because that IRQ number is already used
	 * by another unit and cannot be shared.
	 */
	if (irq >= 0 && host->caps & MMC_CAP_NEEDS_POLL)
		irq = -EINVAL;

	ctx->cd_gpio = gpio;
	host->slot.cd_irq = irq;

	ret = mmc_gpio_get_status(host);
	if (ret < 0)
		return ret;

	ctx->status = ret;
	if (irq >= 0) {
		ret = devm_request_threaded_irq(&host->class_dev, irq,
			NULL, mmc_gpio_cd_irqt,
			IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
			ctx->cd_label, host);
		if (ret < 0)
			irq = ret;
#ifndef VENDOR_EDIT
//Lycan.Wa[email protected], 2014-07-10 Add for retry 5 times when new sdcard init error
    	enable_irq_wake(irq);
#endif /* VENDOR_EDIT */
	}

	if (irq < 0)
		host->caps |= MMC_CAP_NEEDS_POLL;

	return 0;
}
开发者ID:NamelessRom,项目名称:android_kernel_oppo_r7,代码行数:70,代码来源:slot-gpio.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ devm_iio_device_alloc函数代码示例发布时间:2022-05-30
下一篇:
C++ devm_clk_get函数代码示例发布时间: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