Beispiel #1
0
int pnp_check_dma(struct pnp_dev * dev, int idx)
{
	int tmp;
	struct pnp_dev *tdev;
	unsigned long * dma = &dev->res.dma_resource[idx].start;

	/* if the resource doesn't exist, don't complain about it */
	if (dev->res.dma_resource[idx].flags & IORESOURCE_UNSET)
		return 1;

	/* check if the resource is valid */
	if (*dma < 0 || *dma == 4 || *dma > 7)
		return 0;

	/* check if the resource is reserved */
	for (tmp = 0; tmp < 8; tmp++) {
		if (pnp_reserve_dma[tmp] == *dma)
			return 0;
	}

	/* check for internal conflicts */
	for (tmp = 0; tmp < PNP_MAX_DMA && tmp != idx; tmp++) {
		if (dev->res.dma_resource[tmp].flags & IORESOURCE_DMA) {
			if (dev->res.dma_resource[tmp].start == *dma)
				return 0;
		}
	}

	/* check if the resource is already in use, skip if the
	 * device is active because it itself may be in use */
	if(!dev->active) {
		if (request_dma(*dma, "pnp"))
			return 0;
		free_dma(*dma);
	}

	/* check for conflicts with other pnp devices */
	pnp_for_each_dev(tdev) {
		if (tdev == dev)
			continue;
		for (tmp = 0; tmp < PNP_MAX_DMA; tmp++) {
			if (tdev->res.dma_resource[tmp].flags & IORESOURCE_DMA) {
				if (pnp_dma_flags(dev, tmp) & IORESOURCE_DISABLED)
					continue;
				if ((tdev->res.dma_resource[tmp].start == *dma))
					return 0;
			}
		}
	}

	return 1;
}
Beispiel #2
0
static int parport_pc_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *id)
{
    struct parport *pdata;
    unsigned long io_lo, io_hi;
    int dma, irq;

    if (pnp_port_valid(dev, 0) && !(pnp_port_flags(dev, 0) & IORESOURCE_DISABLED))
    {
        io_lo = pnp_port_start(dev, 0);
    }
    else
        return -EINVAL;

#if 0
        if (pnp_port_valid(dev,1) &&
                !(pnp_port_flags(dev,1) & IORESOURCE_DISABLED)) {
                io_hi = pnp_port_start(dev,1);
        } else
                io_hi = 0;
#endif

#if 0
        if (pnp_irq_valid(dev,0) &&
                !(pnp_irq_flags(dev,0) & IORESOURCE_DISABLED)) {
                irq = pnp_irq(dev,0);
        } else
                irq = PARPORT_IRQ_NONE;
#endif

#if 0
        if (pnp_dma_valid(dev,0) &&
                !(pnp_dma_flags(dev,0) & IORESOURCE_DISABLED)) {
                dma = pnp_dma(dev,0);
        } else
                dma = PARPORT_DMA_NONE;
#endif

#if 0
        printk(KERN_INFO "parport: PnPBIOS parport detected.\n");
        if (!(pdata = parport_pc_probe_port (io_lo, io_hi, irq, dma, NULL)))
                return -ENODEV;

        pnp_set_drvdata(dev,pdata);
#endif
    return 0;
}
Beispiel #3
0
static ssize_t pnp_show_current_resources(struct device *dmdev, struct device_attribute *attr, char *buf)
{
	struct pnp_dev *dev = to_pnp_dev(dmdev);
	int i, ret;
	pnp_info_buffer_t *buffer;

	if (!dev)
		return -EINVAL;

	buffer = (pnp_info_buffer_t *) pnp_alloc(sizeof(pnp_info_buffer_t));
	if (!buffer)
		return -ENOMEM;
	buffer->len = PAGE_SIZE;
	buffer->buffer = buf;
	buffer->curr = buffer->buffer;

	pnp_printf(buffer,"state = ");
	if (dev->active)
		pnp_printf(buffer,"active\n");
	else
		pnp_printf(buffer,"disabled\n");

	for (i = 0; i < PNP_MAX_PORT; i++) {
		if (pnp_port_valid(dev, i)) {
			pnp_printf(buffer,"io");
			if (pnp_port_flags(dev, i) & IORESOURCE_DISABLED)
				pnp_printf(buffer," disabled\n");
			else
				pnp_printf(buffer," 0x%llx-0x%llx\n",
					(unsigned long long)pnp_port_start(dev, i),
					(unsigned long long)pnp_port_end(dev, i));
		}
	}
	for (i = 0; i < PNP_MAX_MEM; i++) {
		if (pnp_mem_valid(dev, i)) {
			pnp_printf(buffer,"mem");
			if (pnp_mem_flags(dev, i) & IORESOURCE_DISABLED)
				pnp_printf(buffer," disabled\n");
			else
				pnp_printf(buffer," 0x%llx-0x%llx\n",
					(unsigned long long)pnp_mem_start(dev, i),
					(unsigned long long)pnp_mem_end(dev, i));
		}
	}
	for (i = 0; i < PNP_MAX_IRQ; i++) {
		if (pnp_irq_valid(dev, i)) {
			pnp_printf(buffer,"irq");
			if (pnp_irq_flags(dev, i) & IORESOURCE_DISABLED)
				pnp_printf(buffer," disabled\n");
			else
				pnp_printf(buffer," %lld\n",
					(unsigned long long)pnp_irq(dev, i));
		}
	}
	for (i = 0; i < PNP_MAX_DMA; i++) {
		if (pnp_dma_valid(dev, i)) {
			pnp_printf(buffer,"dma");
			if (pnp_dma_flags(dev, i) & IORESOURCE_DISABLED)
				pnp_printf(buffer," disabled\n");
			else
				pnp_printf(buffer," %lld\n",
					(unsigned long long)pnp_dma(dev, i));
		}
	}
	ret = (buffer->curr - buf);
	kfree(buffer);
	return ret;
}