コード例 #1
0
ファイル: ltp_tpci.c プロジェクト: 1587/ltp
/*
 * test_match_device
 *	make call to pci_match_device, returns a
 *	pci_device_id pointer
 */
static int test_match_device(void)
{
	struct pci_dev *dev = ltp_pci.dev;
	struct pci_driver *drv;
	const struct pci_device_id *id;

	prk_info("test pci_device_id()");

	drv = pci_dev_driver(dev);

	if (!drv) {
		prk_err("driver pointer not allocated for pci_dev");
		return TFAIL;
	}

	id = pci_match_id(drv->id_table, dev);

	if (id) {
		prk_info("match device success");
		return TPASS;
	}

	prk_err("failed return pci_device_id");
	return TFAIL;
}
コード例 #2
0
ファイル: drm_drv.c プロジェクト: Ionic/nx-libs
/**
 * Module initialization. Called via init_module at module load time, or via
 * linux/init/main.c (this is not currently supported).
 *
 * \return zero on success or a negative number on failure.
 *
 * Initializes an array of drm_device structures, and attempts to
 * initialize all available devices, using consecutive minors, registering the
 * stubs and initializing the AGP device.
 *
 * Expands the \c DRIVER_PREINIT and \c DRIVER_POST_INIT macros before and
 * after the initialization for driver customization.
 */
int drm_init(struct drm_driver *driver,
		       struct pci_device_id *pciidlist)
{
	struct pci_dev *pdev;
	struct pci_device_id *pid;
	int rc, i;

	DRM_DEBUG("\n");

	for (i = 0; (pciidlist[i].vendor != 0) && !drm_fb_loaded; i++) {
		pid = &pciidlist[i];

		pdev = NULL;
		/* pass back in pdev to account for multiple identical cards */
		while ((pdev =
			pci_get_subsys(pid->vendor, pid->device, pid->subvendor,
				       pid->subdevice, pdev))) {
			/* is there already a driver loaded, or (short circuit saves work) */
			/* does something like VesaFB have control of the memory region? */
			if (pci_dev_driver(pdev)
			    || pci_request_regions(pdev, "DRM scan")) {
				/* go into stealth mode */
				drm_fb_loaded = 1;
				pci_dev_put(pdev);
				break;
			}
			/* no fbdev or vesadev, put things back and wait for normal probe */
			pci_release_regions(pdev);
		}
	}

	if (!drm_fb_loaded)
		pci_register_driver(&driver->pci_driver);
	else {
		for (i = 0; pciidlist[i].vendor != 0; i++) {
			pid = &pciidlist[i];

			pdev = NULL;
			/* pass back in pdev to account for multiple identical cards */
			while ((pdev =
				pci_get_subsys(pid->vendor, pid->device,
					       pid->subvendor, pid->subdevice,
					       pdev))) {
				/* stealth mode requires a manual probe */
				pci_dev_get(pdev);
				if ((rc = drm_get_dev(pdev, &pciidlist[i], driver))) {
					pci_dev_put(pdev);
					return rc;
				}
			}
		}
		DRM_INFO("Used old pci detect: framebuffer loaded\n");
	}
	return 0;
}
コード例 #3
0
ファイル: gcu_main.c プロジェクト: janfj/dd-wrt
static int
gcu_notify_reboot(struct notifier_block *nb, unsigned long event, void *p)
{
    struct pci_dev *pdev = NULL;

    GCU_DBG("%s\n", __func__);

    switch(event) {
    case SYS_DOWN:
    case SYS_HALT:
    case SYS_POWER_OFF:
        while((pdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pdev))) {
            if(pci_dev_driver(pdev) == &gcu_driver){
                gcu_suspend(pdev, 0x3);
            }
        }
    }
    return NOTIFY_DONE;
}
コード例 #4
0
ファイル: proc.c プロジェクト: ricardoanguiano/linux-xlnx
static int show_device(struct seq_file *m, void *v)
{
    const struct pci_dev *dev = v;
    const struct pci_driver *drv;
    int i;

    if (dev == NULL)
        return 0;

    drv = pci_dev_driver(dev);
    seq_printf(m, "%02x%02x\t%04x%04x\t%x",
               dev->bus->number,
               dev->devfn,
               dev->vendor,
               dev->device,
               dev->irq);

    /* only print standard and ROM resources to preserve compatibility */
    for (i = 0; i <= PCI_ROM_RESOURCE; i++) {
        resource_size_t start, end;
        pci_resource_to_user(dev, i, &dev->resource[i], &start, &end);
        seq_printf(m, "\t%16llx",
                   (unsigned long long)(start |
                                        (dev->resource[i].flags & PCI_REGION_FLAG_MASK)));
    }
    for (i = 0; i <= PCI_ROM_RESOURCE; i++) {
        resource_size_t start, end;
        pci_resource_to_user(dev, i, &dev->resource[i], &start, &end);
        seq_printf(m, "\t%16llx",
                   dev->resource[i].start < dev->resource[i].end ?
                   (unsigned long long)(end - start) + 1 : 0);
    }
    seq_putc(m, '\t');
    if (drv)
        seq_printf(m, "%s", drv->name);
    seq_putc(m, '\n');
    return 0;
}