lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 25 Sep 2012 09:25:43 -0400
From:	Matthew Garrett <mjg@...hat.com>
To:	abelay@....edu
Cc:	bhelgaas@...gle.com, gregkh@...uxfoundation.org,
	linux-kernel@...r.kernel.org, Matthew Garrett <mjg@...hat.com>
Subject: [PATCH 1/2] PNP: Add a release method to system resource driver

This could conceivably be hotpluggable, and we may want to displace it
from devices under certain circustances, so add a release method to hand
back the resources.

Signed-off-by: Matthew Garrett <mjg@...hat.com>
---
 drivers/pnp/system.c | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/drivers/pnp/system.c b/drivers/pnp/system.c
index 49c1720..b0a50f2 100644
--- a/drivers/pnp/system.c
+++ b/drivers/pnp/system.c
@@ -52,7 +52,17 @@ static void reserve_range(struct pnp_dev *dev, struct resource *r, int port)
 		 res ? "has been" : "could not be");
 }
 
-static void reserve_resources_of_dev(struct pnp_dev *dev)
+static void free_range(struct pnp_dev *dev, struct resource *r, int port)
+{
+	resource_size_t start = r->start, end = r->end;
+
+	if (port)
+		release_region(start, end - start + 1);
+	else
+		release_mem_region(start, end - start + 1);
+}
+
+static void handle_resources_of_dev(struct pnp_dev *dev, bool free)
 {
 	struct resource *res;
 	int i;
@@ -75,29 +85,41 @@ static void reserve_resources_of_dev(struct pnp_dev *dev)
 		if (res->end < res->start)
 			continue;	/* invalid */
 
-		reserve_range(dev, res, 1);
+		if (free)
+			free_range(dev, res, 1);
+		else
+			reserve_range(dev, res, 1);
 	}
 
 	for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_MEM, i)); i++) {
 		if (res->flags & IORESOURCE_DISABLED)
 			continue;
 
-		reserve_range(dev, res, 0);
+		if (free)
+			free_range(dev, res, 0);
+		else
+			reserve_range(dev, res, 0);
 	}
 }
 
 static int system_pnp_probe(struct pnp_dev *dev,
 			    const struct pnp_device_id *dev_id)
 {
-	reserve_resources_of_dev(dev);
+	handle_resources_of_dev(dev, false);
 	return 0;
 }
 
+static void system_pnp_remove(struct pnp_dev *dev)
+{
+	handle_resources_of_dev(dev, true);
+}
+
 static struct pnp_driver system_pnp_driver = {
 	.name     = "system",
 	.id_table = pnp_dev_table,
 	.flags    = PNP_DRIVER_RES_DO_NOT_CHANGE,
 	.probe    = system_pnp_probe,
+	.remove   = system_pnp_remove,
 };
 
 static int __init pnp_system_init(void)
-- 
1.7.11.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ