summaryrefslogtreecommitdiff
path: root/drivers/pnp
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2008-06-27 16:57:01 -0600
committerAndi Kleen <andi@basil.nowhere.org>2008-07-16 23:27:06 +0200
commit57fd51a8be26921b56747ddd09d1d9e01c11c9e0 (patch)
tree8b34c3d57867a217cfabf09a73a1af19242bdc7b /drivers/pnp
parentf61ed7e32d2d6a0a8c3c101da513ccedd542e14d (diff)
downloadkernel-common-57fd51a8be26921b56747ddd09d1d9e01c11c9e0.tar.gz
kernel-common-57fd51a8be26921b56747ddd09d1d9e01c11c9e0.tar.bz2
kernel-common-57fd51a8be26921b56747ddd09d1d9e01c11c9e0.zip
PNP: add pnp_possible_config() -- can a device could be configured this way?
As part of a heuristic to identify modem devices, 8250_pnp.c checks to see whether a device can be configured at any of the legacy COM port addresses. This patch moves the code that traverses the PNP "possible resource options" from 8250_pnp.c to the PNP subsystem. This encapsulation is important because a future patch will change the implementation of those resource options. Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Signed-off-by: Andi Kleen <ak@linux.intel.com> Acked-by: Rene Herman <rene.herman@gmail.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/pnp')
-rw-r--r--drivers/pnp/resource.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
index ff79aa6168cf..786fd356916d 100644
--- a/drivers/pnp/resource.c
+++ b/drivers/pnp/resource.c
@@ -624,6 +624,68 @@ struct pnp_resource *pnp_add_mem_resource(struct pnp_dev *dev,
return pnp_res;
}
+static int pnp_possible_option(struct pnp_option *option, int type,
+ resource_size_t start, resource_size_t size)
+{
+ struct pnp_option *tmp;
+ struct pnp_port *port;
+ struct pnp_mem *mem;
+ struct pnp_irq *irq;
+ struct pnp_dma *dma;
+
+ if (!option)
+ return 0;
+
+ for (tmp = option; tmp; tmp = tmp->next) {
+ switch (type) {
+ case IORESOURCE_IO:
+ for (port = tmp->port; port; port = port->next) {
+ if (port->min == start && port->size == size)
+ return 1;
+ }
+ break;
+ case IORESOURCE_MEM:
+ for (mem = tmp->mem; mem; mem = mem->next) {
+ if (mem->min == start && mem->size == size)
+ return 1;
+ }
+ break;
+ case IORESOURCE_IRQ:
+ for (irq = tmp->irq; irq; irq = irq->next) {
+ if (start < PNP_IRQ_NR &&
+ test_bit(start, irq->map))
+ return 1;
+ }
+ break;
+ case IORESOURCE_DMA:
+ for (dma = tmp->dma; dma; dma = dma->next) {
+ if (dma->map & (1 << start))
+ return 1;
+ }
+ break;
+ }
+ }
+
+ return 0;
+}
+
+/*
+ * Determine whether the specified resource is a possible configuration
+ * for this device.
+ */
+int pnp_possible_config(struct pnp_dev *dev, int type, resource_size_t start,
+ resource_size_t size)
+{
+ if (pnp_possible_option(dev->independent, type, start, size))
+ return 1;
+
+ if (pnp_possible_option(dev->dependent, type, start, size))
+ return 1;
+
+ return 0;
+}
+EXPORT_SYMBOL(pnp_possible_config);
+
/* format is: pnp_reserve_irq=irq1[,irq2] .... */
static int __init pnp_setup_reserve_irq(char *str)
{