aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/lib/devres.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-05-05 15:48:53 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2008-05-05 15:48:53 -0700
commit2e83fc4df5f27dfc1b53044c4f142b2f9d1db08c (patch)
tree6afd0fe3aba28ed7137a9b2916a8a6d517ff9c04 /arch/powerpc/lib/devres.c
parent17aa7e034416e3080bc57a786d09ba0a4a044561 (diff)
parent9185ef6787f1c8f1c06aa0cb3c7746fb4f101f50 (diff)
downloadkernel_samsung_smdk4412-2e83fc4df5f27dfc1b53044c4f142b2f9d1db08c.zip
kernel_samsung_smdk4412-2e83fc4df5f27dfc1b53044c4f142b2f9d1db08c.tar.gz
kernel_samsung_smdk4412-2e83fc4df5f27dfc1b53044c4f142b2f9d1db08c.tar.bz2
Merge branch 'powerpc-next' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
* 'powerpc-next' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc: [POWERPC] Assign PDE->data before gluing PDE into /proc tree [POWERPC] devres: Add devm_ioremap_prot() [POWERPC] macintosh: ADB driver: adb_handler_sem semaphore to mutex [POWERPC] macintosh: windfarm_smu_sat: semaphore to mutex [POWERPC] macintosh: therm_pm72: driver_lock semaphore to mutex
Diffstat (limited to 'arch/powerpc/lib/devres.c')
-rw-r--r--arch/powerpc/lib/devres.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/arch/powerpc/lib/devres.c b/arch/powerpc/lib/devres.c
new file mode 100644
index 0000000..292115d
--- /dev/null
+++ b/arch/powerpc/lib/devres.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2008 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include <linux/device.h> /* devres_*(), devm_ioremap_release() */
+#include <linux/io.h> /* ioremap_flags() */
+#include <linux/module.h> /* EXPORT_SYMBOL() */
+
+/**
+ * devm_ioremap_prot - Managed ioremap_flags()
+ * @dev: Generic device to remap IO address for
+ * @offset: BUS offset to map
+ * @size: Size of map
+ * @flags: Page flags
+ *
+ * Managed ioremap_prot(). Map is automatically unmapped on driver
+ * detach.
+ */
+void __iomem *devm_ioremap_prot(struct device *dev, resource_size_t offset,
+ size_t size, unsigned long flags)
+{
+ void __iomem **ptr, *addr;
+
+ ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL);
+ if (!ptr)
+ return NULL;
+
+ addr = ioremap_flags(offset, size, flags);
+ if (addr) {
+ *ptr = addr;
+ devres_add(dev, ptr);
+ } else
+ devres_free(ptr);
+
+ return addr;
+}
+EXPORT_SYMBOL(devm_ioremap_prot);