public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <bjorn.helgaas@hp.com>
To: Len Brown <lenb@kernel.org>
To: Andi Kleen <andi@firstfloor.org>
Cc: linux-acpi@vger.kernel.org, Rene Herman <rene.herman@gmail.com>
Cc: linux-kernel@vger.kernel.org
Cc: Adam Belay <ambx1@neo.rr.com>
Cc: Adam M Belay <abelay@mit.edu>
Cc: Li Shaohua <shaohua.li@intel.com>
Cc: Matthieu Castet <castet.matthieu@free.fr>
Cc: Thomas Renninger <trenn@suse.de>
Cc: Rene Herman <rene.herman@keyaccess.nl>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Jiri Slaby <jirislaby@gmail.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [patch 10/28] PNP: add pnp_possible_config() -- can a device could be configured this way?
Date: Fri, 27 Jun 2008 16:57:01 -0600	[thread overview]
Message-ID: <20080627225800.310058020@ldl.fc.hp.com> (raw)
In-Reply-To: 20080627225651.663174474@ldl.fc.hp.com

[-- Attachment #1: pnp-new-option-interface-for-serial-pnp --]
[-- Type: text/plain, Size: 5032 bytes --]

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>
Acked-by: Rene Herman <rene.herman@gmail.com>

---
 drivers/pnp/resource.c    |   61 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/serial/8250_pnp.c |   24 +++++-------------
 include/linux/pnp.h       |    3 ++
 3 files changed, 71 insertions(+), 17 deletions(-)

Index: work14/drivers/pnp/resource.c
===================================================================
--- work14.orig/drivers/pnp/resource.c	2008-06-24 17:06:49.000000000 -0600
+++ work14/drivers/pnp/resource.c	2008-06-24 17:06:49.000000000 -0600
@@ -624,6 +624,68 @@ struct pnp_resource *pnp_add_mem_resourc
 	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)
 {
Index: work14/drivers/serial/8250_pnp.c
===================================================================
--- work14.orig/drivers/serial/8250_pnp.c	2008-06-24 16:53:06.000000000 -0600
+++ work14/drivers/serial/8250_pnp.c	2008-06-24 17:06:49.000000000 -0600
@@ -383,21 +383,14 @@ static int __devinit check_name(char *na
 	return 0;
 }
 
-static int __devinit check_resources(struct pnp_option *option)
+static int __devinit check_resources(struct pnp_dev *dev)
 {
-	struct pnp_option *tmp;
-	if (!option)
-		return 0;
+	resource_size_t base[] = {0x2f8, 0x3f8, 0x2e8, 0x3e8};
+	int i;
 
-	for (tmp = option; tmp; tmp = tmp->next) {
-		struct pnp_port *port;
-		for (port = tmp->port; port; port = port->next)
-			if ((port->size == 8) &&
-			    ((port->min == 0x2f8) ||
-			     (port->min == 0x3f8) ||
-			     (port->min == 0x2e8) ||
-			     (port->min == 0x3e8)))
-				return 1;
+	for (i = 0; i < ARRAY_SIZE(base); i++) {
+		if (pnp_possible_config(dev, IORESOURCE_IO, base[i], 8))
+			return 1;
 	}
 
 	return 0;
@@ -420,10 +413,7 @@ static int __devinit serial_pnp_guess_bo
 		(dev->card && check_name(dev->card->name))))
 			return -ENODEV;
 
-	if (check_resources(dev->independent))
-		return 0;
-
-	if (check_resources(dev->dependent))
+	if (check_resources(dev))
 		return 0;
 
 	return -ENODEV;
Index: work14/include/linux/pnp.h
===================================================================
--- work14.orig/include/linux/pnp.h	2008-06-24 16:53:06.000000000 -0600
+++ work14/include/linux/pnp.h	2008-06-24 17:07:27.000000000 -0600
@@ -479,6 +479,8 @@ void pnp_unregister_card_driver(struct p
 extern struct list_head pnp_cards;
 
 /* resource management */
+int pnp_possible_config(struct pnp_dev *dev, int type, resource_size_t base,
+			resource_size_t size);
 int pnp_auto_config_dev(struct pnp_dev *dev);
 int pnp_start_dev(struct pnp_dev *dev);
 int pnp_stop_dev(struct pnp_dev *dev);
@@ -506,6 +508,9 @@ static inline int pnp_register_card_driv
 static inline void pnp_unregister_card_driver(struct pnp_card_driver *drv) { }
 
 /* resource management */
+static inline int pnp_possible_config(struct pnp_dev *dev, int type,
+				      resource_size_t base,
+				      resource_size_t size) { return 0; }
 static inline int pnp_auto_config_dev(struct pnp_dev *dev) { return -ENODEV; }
 static inline int pnp_start_dev(struct pnp_dev *dev) { return -ENODEV; }
 static inline int pnp_stop_dev(struct pnp_dev *dev) { return -ENODEV; }

-- 

  parent reply	other threads:[~2008-06-27 23:06 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-27 22:56 [patch 00/28] PNP: convert fixed tables to lists, v4 Bjorn Helgaas
2008-06-27 22:56 ` [patch 01/28] PNP: add detail to debug resource dump Bjorn Helgaas
2008-06-27 22:56 ` [patch 02/28] PNP: remove pnp_resource.index Bjorn Helgaas
2008-06-27 22:56 ` [patch 03/28] PNP: add pnp_resource_type() internal interface Bjorn Helgaas
2008-06-27 22:56 ` [patch 04/28] PNP: add pnp_resource_type_name() helper function Bjorn Helgaas
2008-06-27 22:56 ` [patch 05/28] PNP: make pnp_{port,mem,etc}_start(), et al work for invalid resources Bjorn Helgaas
2008-06-27 22:56 ` [patch 06/28] PNP: replace pnp_resource_table with dynamically allocated resources Bjorn Helgaas
2008-06-27 22:56 ` [patch 07/28] PNPACPI: keep disabled resources when parsing current config Bjorn Helgaas
2008-06-27 22:56 ` [patch 08/28] PNP: remove ratelimit on add resource failures Bjorn Helgaas
2008-06-27 22:57 ` [patch 09/28] PNP: dont sort by type in /sys/.../resources Bjorn Helgaas
2008-06-27 22:57 ` Bjorn Helgaas [this message]
2008-06-27 22:57 ` [patch 11/28] PNP: whitespace/coding style fixes Bjorn Helgaas
2008-06-28 19:56   ` Joe Perches
2008-06-28 20:02     ` Rene Herman
2008-06-27 22:57 ` [patch 12/28] PNP: define PNP-specific IORESOURCE_IO_* flags alongside IRQ, DMA, MEM Bjorn Helgaas
2008-06-27 22:57 ` [patch 13/28] PNP: make resource option structures private to PNP subsystem Bjorn Helgaas
2008-06-27 22:57 ` [patch 14/28] PNP: introduce pnp_irq_mask_t typedef Bjorn Helgaas
2008-06-27 22:57 ` [patch 15/28] PNP: increase I/O port & memory option address sizes Bjorn Helgaas
2008-06-27 22:57 ` [patch 16/28] PNP: improve resource assignment debug Bjorn Helgaas
2008-06-27 22:57 ` [patch 17/28] PNP: in debug resource dump, make empty list obvious Bjorn Helgaas
2008-06-27 22:57 ` [patch 18/28] PNP: make resource assignment functions return 0 (success) or -EBUSY (failure) Bjorn Helgaas
2008-06-27 22:57 ` [patch 19/28] PNP: remove redundant pnp_can_configure() check Bjorn Helgaas
2008-06-27 22:57 ` [patch 20/28] PNP: centralize resource option allocations Bjorn Helgaas
2008-06-27 22:57 ` [patch 21/28] PNPACPI: ignore _PRS interrupt numbers larger than PNP_IRQ_NR Bjorn Helgaas
2008-06-27 22:57 ` [patch 22/28] PNP: rename pnp_register_*_resource() local variables Bjorn Helgaas
2008-06-27 22:57 ` [patch 23/28] PNP: support optional IRQ resources Bjorn Helgaas
2008-06-27 22:57 ` [patch 24/28] PNP: remove extra 0x100 bit from option priority Bjorn Helgaas
2008-06-27 22:57 ` [patch 25/28] ISAPNP: handle independent options following dependent ones Bjorn Helgaas
2008-06-27 22:57 ` [patch 26/28] PNP: convert resource options to single linked list Bjorn Helgaas
2008-06-27 22:57 ` [patch 27/28] PNP: avoid legacy IDE IRQs Bjorn Helgaas
2008-06-27 22:57 ` [patch 28/28] PNPACPI: add support for HP vendor-specific CCSR descriptors Bjorn Helgaas
2008-06-28  4:36 ` [patch 00/28] PNP: convert fixed tables to lists, v4 Len Brown
  -- strict thread matches above, loose matches on Subject: below --
2008-06-17 22:58 [patch 00/28] PNP: convert fixed tables to lists, v3 Bjorn Helgaas
2008-06-17 22:58 ` [patch 10/28] PNP: add pnp_possible_config() -- can a device could be configured this way? Bjorn Helgaas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080627225800.310058020@ldl.fc.hp.com \
    --to=bjorn.helgaas@hp.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=rene.herman@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox