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


C++ platform_device_add_resources函数代码示例

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


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

示例1: platform_device_alloc

struct platform_device *tegra_usb_hsic_host_register(void)
{
	struct platform_device *pdev;
	int val;

	pdev = platform_device_alloc(tegra_ehci2_device.name,
		tegra_ehci2_device.id);
	if (!pdev)
		return NULL;

	val = platform_device_add_resources(pdev, tegra_ehci2_device.resource,
		tegra_ehci2_device.num_resources);
	if (val)
		goto error;

	pdev->dev.dma_mask =  tegra_ehci2_device.dev.dma_mask;
	pdev->dev.coherent_dma_mask = tegra_ehci2_device.dev.coherent_dma_mask;

	val = platform_device_add_data(pdev, &tegra_ehci_uhsic_pdata,
			sizeof(struct tegra_ehci_platform_data));
	if (val)
		goto error;

	val = platform_device_add(pdev);
	if (val)
		goto error;

	return pdev;

error:
	pr_err("%s: failed to add the host contoller device\n", __func__);
	platform_device_put(pdev);
	return NULL;
}
开发者ID:McSun,项目名称:HTC-One-X-3.1,代码行数:34,代码来源:board-enterprise.c

示例2: kempld_create_platform_device

static int kempld_create_platform_device(const struct dmi_system_id *id)
{
	struct kempld_platform_data *pdata = id->driver_data;
	int ret;

	kempld_pdev = platform_device_alloc("kempld", -1);
	if (!kempld_pdev)
		return -ENOMEM;

	ret = platform_device_add_data(kempld_pdev, pdata, sizeof(*pdata));
	if (ret)
		goto err;

	ret = platform_device_add_resources(kempld_pdev, pdata->ioresource, 1);
	if (ret)
		goto err;

	ret = platform_device_add(kempld_pdev);
	if (ret)
		goto err;

	return 0;
err:
	platform_device_put(kempld_pdev);
	return ret;
}
开发者ID:LuweiLight,项目名称:linux-3.14.35-vbal,代码行数:26,代码来源:kempld-core.c

示例3: omap_mcbsp_register_board_cfg

static void omap_mcbsp_register_board_cfg(struct resource *res, int res_count,
			struct omap_mcbsp_platform_data *config, int size)
{
	int i;

	omap_mcbsp_devices = kzalloc(size * sizeof(struct platform_device *),
				     GFP_KERNEL);
	if (!omap_mcbsp_devices) {
		printk(KERN_ERR "Could not register McBSP devices\n");
		return;
	}

	for (i = 0; i < size; i++) {
		struct platform_device *new_mcbsp;
		int ret;

		new_mcbsp = platform_device_alloc("omap-mcbsp", i + 1);
		if (!new_mcbsp)
			continue;
		platform_device_add_resources(new_mcbsp, &res[i * res_count],
					res_count);
		config[i].reg_size = 2;
		config[i].reg_step = 2;
		new_mcbsp->dev.platform_data = &config[i];
		ret = platform_device_add(new_mcbsp);
		if (ret) {
			platform_device_put(new_mcbsp);
			continue;
		}
		omap_mcbsp_devices[i] = new_mcbsp;
	}
}
开发者ID:Elamaran,项目名称:linux,代码行数:32,代码来源:mcbsp.c

示例4: mali_platform_device_register

int mali_platform_device_register(void)
{
	int err;

	MALI_DEBUG_PRINT(4, ("mali_platform_device_register() called\n"));

	/* Connect resources to the device */
	err = platform_device_add_resources(&exynos4_device_g3d, mali_gpu_resources, sizeof(mali_gpu_resources) / sizeof(mali_gpu_resources[0]));
	if (0 == err)
	{
		err = platform_device_add_data(&exynos4_device_g3d, &mali_gpu_data, sizeof(mali_gpu_data));
		if (0 == err)
		{
			mali_platform_init(&(exynos4_device_g3d.dev));

#ifdef CONFIG_PM_RUNTIME
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
			pm_runtime_set_autosuspend_delay(&(exynos4_device_g3d.dev), 1000);
			pm_runtime_use_autosuspend(&(exynos4_device_g3d.dev));
#endif
			pm_runtime_enable(&(exynos4_device_g3d.dev));
#endif
			return 0;
		}

	}
	return err;
}
开发者ID:cm-3470,项目名称:android_kernel_samsung_degaslte,代码行数:28,代码来源:exynos4.c

示例5: wcn36xx_msm_init

static int __init wcn36xx_msm_init(void)
{
	int ret;
	struct resource *wcnss_memory;
	struct resource *tx_irq;
	struct resource *rx_irq;
	struct resource res[3];
	wmsm.core = platform_device_alloc("wcn36xx", -1);

	memset(res, 0x00, sizeof(res));
	wmsm.ctrl_ops.open = wcn36xx_msm_smd_open;
	wmsm.ctrl_ops.close = wcn36xx_msm_smd_close;
	wmsm.ctrl_ops.tx = wcn36xx_msm_smd_send_and_wait;
	wmsm.ctrl_ops.get_hw_mac = wcn36xx_msm_get_hw_mac;
	wmsm.ctrl_ops.smsm_change_state = wcn36xx_msm_smsm_change_state;
	wcnss_memory =
		platform_get_resource_byname(wcnss_get_platform_device(),
					      IORESOURCE_MEM,
					      "wcnss_mmio");
	if (wcnss_memory == NULL) {
		dev_err(&wmsm.core->dev,
			"Failed to get wcnss wlan memory map.\n");
		ret = -ENOMEM;
		return ret;
	}
	memcpy(&res[0], wcnss_memory, sizeof(*wcnss_memory));

	tx_irq = platform_get_resource_byname(wcnss_get_platform_device(),
					      IORESOURCE_IRQ,
					      "wcnss_wlantx_irq");
	if (tx_irq == NULL) {
		dev_err(&wmsm.core->dev, "Failed to get wcnss tx_irq");
		ret = -ENOMEM;
		return ret;
	}
	memcpy(&res[1], tx_irq, sizeof(*tx_irq));

	rx_irq = platform_get_resource_byname(wcnss_get_platform_device(),
					      IORESOURCE_IRQ,
					      "wcnss_wlanrx_irq");
	if (rx_irq == NULL) {
		dev_err(&wmsm.core->dev, "Failed to get wcnss rx_irq");
		ret = -ENOMEM;
		return ret;
	}
	memcpy(&res[2], rx_irq, sizeof(*rx_irq));

	platform_device_add_resources(wmsm.core, res, ARRAY_SIZE(res));

	ret = platform_device_add_data(wmsm.core, &wmsm.ctrl_ops,
				       sizeof(wmsm.ctrl_ops));
	if (ret) {
		dev_err(&wmsm.core->dev, "Can't add platform data\n");
		ret = -ENOMEM;
		return ret;
	}

	platform_device_add(wmsm.core);
	return 0;
}
开发者ID:smihir,项目名称:wcn36xx,代码行数:60,代码来源:main.c

示例6: msm_sata_probe

static int __devinit msm_sata_probe(struct platform_device *pdev)
{
	struct platform_device *ahci;
	struct msm_sata_hba *hba;
	struct ahci_msm_platform_data *msm_ahci_data;
	int ret = 0;

	hba = devm_kzalloc(&pdev->dev, sizeof(struct msm_sata_hba), GFP_KERNEL);
	if (!hba) {
		dev_err(&pdev->dev, "no memory\n");
		ret = -ENOMEM;
		goto err;
	}

	platform_set_drvdata(pdev, hba);
	msm_ahci_data =
		(struct ahci_msm_platform_data *)pdev->dev.platform_data;
	hba->tx_preemph_gen3 = msm_ahci_data->tx_preemph_gen3;
	hba->rx_eq = msm_ahci_data->rx_eq;
	hba->mpll = msm_ahci_data->mpll;
	hba->term_off = msm_ahci_data->term_off;

	ahci = platform_device_alloc("ahci", pdev->id);
	if (!ahci) {
		dev_err(&pdev->dev, "couldn't allocate ahci device\n");
		ret = -ENOMEM;
		goto err_free;
	}

	dma_set_coherent_mask(&ahci->dev, pdev->dev.coherent_dma_mask);

	ahci->dev.parent = &pdev->dev;
	ahci->dev.dma_mask = pdev->dev.dma_mask;
	ahci->dev.dma_parms = pdev->dev.dma_parms;
	hba->ahci_pdev = ahci;

	ret = platform_device_add_resources(ahci, pdev->resource,
			pdev->num_resources);
	if (ret) {
		dev_err(&pdev->dev, "couldn't add resources to ahci device\n");
		goto err_put_device;
	}

	ahci->dev.platform_data = &msm_ahci_pdata;
	ret = platform_device_add(ahci);
	if (ret) {
		dev_err(&pdev->dev, "failed to register ahci device\n");
		goto err_put_device;
	}

	return 0;

err_put_device:
	platform_device_put(ahci);
err_free:
	devm_kfree(&pdev->dev, hba);
err:
	return ret;
}
开发者ID:darcyg,项目名称:ap_project_v2,代码行数:59,代码来源:ahci_msm.c

示例7: dwc3_pci_probe

static int dwc3_pci_probe(struct pci_dev *pci,
		const struct pci_device_id *id)
{
	struct resource		res[2];
	struct platform_device	*dwc3;
	int			ret;
	struct device		*dev = &pci->dev;

	ret = pcim_enable_device(pci);
	if (ret) {
		dev_err(dev, "failed to enable pci device\n");
		return -ENODEV;
	}

	pci_set_master(pci);

	dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO);
	if (!dwc3) {
		dev_err(dev, "couldn't allocate dwc3 device\n");
		return -ENOMEM;
	}

	memset(res, 0x00, sizeof(struct resource) * ARRAY_SIZE(res));

	res[0].start	= pci_resource_start(pci, 0);
	res[0].end	= pci_resource_end(pci, 0);
	res[0].name	= "dwc_usb3";
	res[0].flags	= IORESOURCE_MEM;

	res[1].start	= pci->irq;
	res[1].name	= "dwc_usb3";
	res[1].flags	= IORESOURCE_IRQ;

	ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res));
	if (ret) {
		dev_err(dev, "couldn't add resources to dwc3 device\n");
		return ret;
	}

	pci_set_drvdata(pci, dwc3);
	ret = dwc3_pci_quirks(pci);
	if (ret)
		goto err;

	dwc3->dev.parent = dev;
	ACPI_COMPANION_SET(&dwc3->dev, ACPI_COMPANION(dev));

	ret = platform_device_add(dwc3);
	if (ret) {
		dev_err(dev, "failed to register dwc3 device\n");
		goto err;
	}

	return 0;
err:
	platform_device_put(dwc3);
	return ret;
}
开发者ID:Chong-Li,项目名称:cse522,代码行数:58,代码来源:dwc3-pci.c

示例8: bcmgenet_mii_register

static int bcmgenet_mii_register(struct bcmgenet_priv *priv)
{
	struct platform_device *pdev = priv->pdev;
	struct bcmgenet_platform_data *pdata = pdev->dev.platform_data;
	struct device_node *dn = pdev->dev.of_node;
	struct unimac_mdio_pdata ppd;
	struct platform_device *ppdev;
	struct resource *pres, res;
	int id, ret;

	pres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	memset(&res, 0, sizeof(res));
	memset(&ppd, 0, sizeof(ppd));

	ppd.wait_func = bcmgenet_mii_wait;
	ppd.wait_func_data = priv;
	ppd.bus_name = "bcmgenet MII bus";

	/* Unimac MDIO bus controller starts at UniMAC offset + MDIO_CMD
	 * and is 2 * 32-bits word long, 8 bytes total.
	 */
	res.start = pres->start + GENET_UMAC_OFF + UMAC_MDIO_CMD;
	res.end = res.start + 8;
	res.flags = IORESOURCE_MEM;

	if (dn)
		id = of_alias_get_id(dn, "eth");
	else
		id = pdev->id;

	ppdev = platform_device_alloc(UNIMAC_MDIO_DRV_NAME, id);
	if (!ppdev)
		return -ENOMEM;

	/* Retain this platform_device pointer for later cleanup */
	priv->mii_pdev = ppdev;
	ppdev->dev.parent = &pdev->dev;
	ppdev->dev.of_node = bcmgenet_mii_of_find_mdio(priv);
	if (pdata)
		bcmgenet_mii_pdata_init(priv, &ppd);

	ret = platform_device_add_resources(ppdev, &res, 1);
	if (ret)
		goto out;

	ret = platform_device_add_data(ppdev, &ppd, sizeof(ppd));
	if (ret)
		goto out;

	ret = platform_device_add(ppdev);
	if (ret)
		goto out;

	return 0;
out:
	platform_device_put(ppdev);
	return ret;
}
开发者ID:Anjali05,项目名称:linux,代码行数:58,代码来源:bcmmii.c

示例9: platform_device_alloc

void __init *msic_gpio_platform_data(void *info)
{
	struct platform_device *pdev = NULL;
	struct sfi_device_table_entry *entry = info;
	static struct intel_msic_gpio_pdata msic_gpio_pdata;
	int ret;
	int gpio;
	struct resource res;

	pdev = platform_device_alloc(MSIC_GPIO_DEVICE_NAME, -1);

	if (!pdev) {
		pr_err("out of memory for SFI platform dev %s\n",
					MSIC_GPIO_DEVICE_NAME);
		return NULL;
	}

	gpio = get_gpio_by_name("msic_gpio_base");

	if (gpio < 0)
		return NULL;

	/* Basincove PMIC GPIO has total 8 GPIO pins,
	 * GPIO[5:2,0] support 1.8V, GPIO[7:6,1] support 1.8V and 3.3V,
	 * We group GPIO[5:2] to low voltage and GPIO[7:6] to
	 * high voltage. Because the CTL registers are contiguous,
	 * this grouping method doesn't affect the driver usage but
	 * easy for the driver sharing among multiple platforms.
	 */
	msic_gpio_pdata.ngpio_lv = 6;
	msic_gpio_pdata.ngpio_hv = 2;
	msic_gpio_pdata.gpio0_lv_ctlo = 0x7E;
	msic_gpio_pdata.gpio0_lv_ctli = 0x8E;
	msic_gpio_pdata.gpio0_hv_ctlo = 0x84;
	msic_gpio_pdata.gpio0_hv_ctli = 0x94;

	msic_gpio_pdata.can_sleep = 1;
	msic_gpio_pdata.gpio_base = gpio;

	pdev->dev.platform_data = &msic_gpio_pdata;

	ret = platform_device_add(pdev);
	if (ret) {
		pr_err("failed to add msic gpio platform device\n");
		platform_device_put(pdev);
		return NULL;
	}

	res.name = "IRQ",
	res.flags = IORESOURCE_IRQ,
	res.start = entry->irq;
	platform_device_add_resources(pdev, &res, 1);

	register_rpmsg_service("rpmsg_msic_gpio", RPROC_SCU, RP_MSIC_GPIO);

	return &msic_gpio_pdata;
}
开发者ID:0x000000FF,项目名称:Linux4Edison,代码行数:57,代码来源:platform_msic_gpio.c

示例10: pxa_register_device

int pxa_register_device(struct pxa_device_desc *desc,
				void *data, size_t size)
{
	struct platform_device *pdev;
	struct resource res[2 + MAX_RESOURCE_DMA];
	int i, ret = 0, nres = 0;

	if (desc == NULL)
		return -EINVAL;

	pdev = platform_device_alloc(desc->drv_name, desc->id);
	if (pdev == NULL)
		return -ENOMEM;

	pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);

	memset(res, 0, sizeof(res));

	if (desc->start != -1ul && desc->size > 0) {
		res[nres].start	= desc->start;
		res[nres].end	= desc->start + desc->size - 1;
		res[nres].flags	= IORESOURCE_MEM;
		nres++;
	}

	if (desc->irq != NO_IRQ) {
		res[nres].start	= desc->irq;
		res[nres].end	= desc->irq;
		res[nres].flags	= IORESOURCE_IRQ;
		nres++;
	}

	for (i = 0; i < MAX_RESOURCE_DMA; i++, nres++) {
		if (desc->dma[i] == 0)
			break;

		res[nres].start	= desc->dma[i];
		res[nres].end	= desc->dma[i];
		res[nres].flags	= IORESOURCE_DMA;
	}

	ret = platform_device_add_resources(pdev, res, nres);
	if (ret) {
		platform_device_put(pdev);
		return ret;
	}

	if (data && size) {
		ret = platform_device_add_data(pdev, data, size);
		if (ret) {
			platform_device_put(pdev);
			return ret;
		}
	}

	return platform_device_add(pdev);
}
开发者ID:coherentsolutions,项目名称:linux-2.6.29-ts4700,代码行数:57,代码来源:devices.c

示例11: gpu_init

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

#ifndef CONFIG_DOVE_GPU
    gpu_resources[0].start = gpu_resources[0].end = irqLine;

    gpu_resources[1].start = registerMemBase;
    gpu_resources[1].end   = registerMemBase + registerMemSize - 1;

    gpu_resources[2].start = contiguousBase;
    gpu_resources[2].end   = contiguousBase + contiguousSize - 1;

/*####modified for marvell-bg2*/
    /* Allocate device */
    gpu_device = platform_device_alloc(DRV_NAME, -1);
/*####end for marvell-bg2*/

    if (!gpu_device)
    {
        printk(KERN_ERR "galcore: platform_device_alloc failed.\n");
        ret = -ENOMEM;
        goto out;
    }

    /* Insert resource */
    ret = platform_device_add_resources(gpu_device, gpu_resources, 3);
    if (ret)
    {
        printk(KERN_ERR "galcore: platform_device_add_resources failed.\n");
        goto put_dev;
    }

    /* Add device */
    ret = platform_device_add(gpu_device);
    if (ret)
    {
        printk(KERN_ERR "galcore: platform_device_add failed.\n");
        goto put_dev;
    }
#endif

    ret = platform_driver_register(&gpu_driver);
    if (!ret)
    {
        goto out;
    }

#ifndef CONFIG_DOVE_GPU
    platform_device_del(gpu_device);
put_dev:
    platform_device_put(gpu_device);
#endif

out:
    return ret;
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.kernel,代码行数:57,代码来源:gc_hal_kernel_driver.c

示例12: mali_platform_device_register

int mali_platform_device_register(void)
{
    int err;

    MALI_DEBUG_PRINT(4, ("mali_platform_device_register() called\n"));

#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)
    exynos_pm_add_dev_to_genpd(&mali_gpu_device, &exynos4_pd_g3d);
#endif

    /* Connect resources to the device */
    err = platform_device_add_resources(&mali_gpu_device, mali_gpu_resources, sizeof(mali_gpu_resources) / sizeof(mali_gpu_resources[0]));
    if (0 == err)
    {
        err = platform_device_add_data(&mali_gpu_device, &mali_gpu_data, sizeof(mali_gpu_data));
        if (0 == err)
        {
#ifdef CONFIG_PM_RUNTIME
#if defined(USE_PM_NOTIFIER)
            err = register_pm_notifier(&mali_pwr_notif_block);
            if (err)
            {
                goto plat_init_err;
            }
#endif
#endif /* CONFIG_PM_RUNTIME */

            /* Register the platform device */
            err = platform_device_register(&mali_gpu_device);
            if (0 == err)
            {
                mali_platform_init(&(mali_gpu_device.dev));

#ifdef CONFIG_PM_RUNTIME
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
                pm_runtime_set_autosuspend_delay(&(mali_gpu_device.dev), 1000);
                pm_runtime_use_autosuspend(&(mali_gpu_device.dev));
#endif
                pm_runtime_enable(&(mali_gpu_device.dev));
#endif

                return 0;
            }
        }

#ifdef CONFIG_PM_RUNTIME
#if defined(USE_PM_NOTIFIER)
plat_init_err:
        unregister_pm_notifier(&mali_pwr_notif_block);
#endif
#endif /* CONFIG_PM_RUNTIME */
        platform_device_unregister(&mali_gpu_device);
    }

    return err;
}
开发者ID:Ricky310711,项目名称:RTL_KERNEL,代码行数:56,代码来源:exynos4.c

示例13: gpu_init

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

#ifndef CONFIG_DOVE_GPU
#if !MRVL_USE_GPU_RESERVE_MEM
    gpu_resources[0].start = gpu_resources[0].end = irqLine;

    gpu_resources[1].start = registerMemBase;
    gpu_resources[1].end   = registerMemBase + registerMemSize - 1;

    /* Allocate device */
    gpu_device = platform_device_alloc(DEVICE_NAME, -1);
    if (!gpu_device)
    {
        printk(KERN_ERR "galcore: platform_device_alloc failed.\n");
        ret = -ENOMEM;
        goto out;
    }

    /* Insert resource */
    ret = platform_device_add_resources(gpu_device, gpu_resources, 2);
    if (ret)
    {
        printk(KERN_ERR "galcore: platform_device_add_resources failed.\n");
        goto put_dev;
    }

    /* Add device */
    ret = platform_device_add(gpu_device);
    if (ret)
    {
        printk(KERN_ERR "galcore: platform_device_add failed.\n");
        goto put_dev;
    }
#endif
#endif

    ret = platform_driver_register(&gpu_driver);
    if (!ret)
    {
        goto out;
    }

#ifndef CONFIG_DOVE_GPU
#if !MRVL_USE_GPU_RESERVE_MEM
    platform_device_del(gpu_device);
put_dev:
    platform_device_put(gpu_device);
#endif
#endif

out:
    return ret;
}
开发者ID:Gabrius99,项目名称:kernel_goldenvess3g,代码行数:55,代码来源:gc_hal_kernel_driver.c

示例14: acpi_csrt_parse_shared_info

static int __init acpi_csrt_parse_shared_info(struct platform_device *pdev,
        const struct acpi_csrt_group *grp)
{
    const struct acpi_csrt_shared_info *si;
    struct resource res[3];
    size_t nres;
    int ret;

    memset(res, 0, sizeof(res));
    nres = 0;

    si = (const struct acpi_csrt_shared_info *)&grp[1];
    /*
     * The peripherals that are listed on CSRT typically support only
     * 32-bit addresses so we only use the low part of MMIO base for
     * now.
     */
    if (!si->mmio_base_high && si->mmio_base_low) {
        /*
         * There is no size of the memory resource in shared_info
         * so we assume that it is 4k here.
         */
        res[nres].start = si->mmio_base_low;
        res[nres].end = res[0].start + SZ_4K - 1;
        res[nres++].flags = IORESOURCE_MEM;
    }

    if (si->gsi_interrupt) {
        int irq = acpi_register_gsi(NULL, si->gsi_interrupt,
                                    si->interrupt_mode,
                                    si->interrupt_polarity);
        res[nres].start = irq;
        res[nres].end = irq;
        res[nres++].flags = IORESOURCE_IRQ;
    }

    if (si->base_request_line || si->num_handshake_signals) {
        /*
         * We pass the driver a DMA resource describing the range
         * of request lines the device supports.
         */
        res[nres].start = si->base_request_line;
        res[nres].end = res[nres].start + si->num_handshake_signals - 1;
        res[nres++].flags = IORESOURCE_DMA;
    }

    ret = platform_device_add_resources(pdev, res, nres);
    if (ret) {
        if (si->gsi_interrupt)
            acpi_unregister_gsi(si->gsi_interrupt);
        return ret;
    }

    return 0;
}
开发者ID:kjedruczyk,项目名称:parallella-linux-old,代码行数:55,代码来源:csrt.c

示例15: at32_add_device_psif

struct platform_device *__init at32_add_device_psif(unsigned int id)
{
	struct platform_device *pdev;
	u32 pin_mask;

	if (!(id == 0 || id == 1))
		return NULL;

	pdev = platform_device_alloc("atmel_psif", id);
	if (!pdev)
		return NULL;

	switch (id) {
	case 0:
		pin_mask  = (1 << 8) | (1 << 9); /* CLOCK & DATA */

		if (platform_device_add_resources(pdev, atmel_psif0_resource,
					ARRAY_SIZE(atmel_psif0_resource)))
			goto err_add_resources;
		atmel_psif0_pclk.dev = &pdev->dev;
		select_peripheral(PIOA, pin_mask, PERIPH_A, 0);
		break;
	case 1:
		pin_mask  = (1 << 11) | (1 << 12); /* CLOCK & DATA */

		if (platform_device_add_resources(pdev, atmel_psif1_resource,
					ARRAY_SIZE(atmel_psif1_resource)))
			goto err_add_resources;
		atmel_psif1_pclk.dev = &pdev->dev;
		select_peripheral(PIOB, pin_mask, PERIPH_A, 0);
		break;
	default:
		return NULL;
	}

	platform_device_add(pdev);
	return pdev;

err_add_resources:
	platform_device_put(pdev);
	return NULL;
}
开发者ID:LeonMagnus,项目名称:linux,代码行数:42,代码来源:at32ap700x.c


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