aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-05-05 18:48:53 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-05-05 18:48:53 -0400
commit2e83fc4df5f27dfc1b53044c4f142b2f9d1db08c (patch)
tree6afd0fe3aba28ed7137a9b2916a8a6d517ff9c04 /arch
parent17aa7e034416e3080bc57a786d09ba0a4a044561 (diff)
parent9185ef6787f1c8f1c06aa0cb3c7746fb4f101f50 (diff)
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')
-rw-r--r--arch/powerpc/lib/Makefile1
-rw-r--r--arch/powerpc/lib/devres.c42
-rw-r--r--arch/powerpc/platforms/pseries/scanlog.c19
3 files changed, 45 insertions, 17 deletions
diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
index 4bb023f4c869..f1d2cdc5331b 100644
--- a/arch/powerpc/lib/Makefile
+++ b/arch/powerpc/lib/Makefile
@@ -23,3 +23,4 @@ obj-$(CONFIG_SMP) += locks.o
23endif 23endif
24 24
25obj-$(CONFIG_PPC_LIB_RHEAP) += rheap.o 25obj-$(CONFIG_PPC_LIB_RHEAP) += rheap.o
26obj-$(CONFIG_HAS_IOMEM) += devres.o
diff --git a/arch/powerpc/lib/devres.c b/arch/powerpc/lib/devres.c
new file mode 100644
index 000000000000..292115d98ea9
--- /dev/null
+++ b/arch/powerpc/lib/devres.c
@@ -0,0 +1,42 @@
1/*
2 * Copyright (C) 2008 Freescale Semiconductor, Inc.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
9
10#include <linux/device.h> /* devres_*(), devm_ioremap_release() */
11#include <linux/io.h> /* ioremap_flags() */
12#include <linux/module.h> /* EXPORT_SYMBOL() */
13
14/**
15 * devm_ioremap_prot - Managed ioremap_flags()
16 * @dev: Generic device to remap IO address for
17 * @offset: BUS offset to map
18 * @size: Size of map
19 * @flags: Page flags
20 *
21 * Managed ioremap_prot(). Map is automatically unmapped on driver
22 * detach.
23 */
24void __iomem *devm_ioremap_prot(struct device *dev, resource_size_t offset,
25 size_t size, unsigned long flags)
26{
27 void __iomem **ptr, *addr;
28
29 ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL);
30 if (!ptr)
31 return NULL;
32
33 addr = ioremap_flags(offset, size, flags);
34 if (addr) {
35 *ptr = addr;
36 devres_add(dev, ptr);
37 } else
38 devres_free(ptr);
39
40 return addr;
41}
42EXPORT_SYMBOL(devm_ioremap_prot);
diff --git a/arch/powerpc/platforms/pseries/scanlog.c b/arch/powerpc/platforms/pseries/scanlog.c
index bec3803f0618..417eca79df69 100644
--- a/arch/powerpc/platforms/pseries/scanlog.c
+++ b/arch/powerpc/platforms/pseries/scanlog.c
@@ -55,11 +55,6 @@ static ssize_t scanlog_read(struct file *file, char __user *buf,
55 dp = PDE(inode); 55 dp = PDE(inode);
56 data = (unsigned int *)dp->data; 56 data = (unsigned int *)dp->data;
57 57
58 if (!data) {
59 printk(KERN_ERR "scanlog: read failed no data\n");
60 return -EIO;
61 }
62
63 if (count > RTAS_DATA_BUF_SIZE) 58 if (count > RTAS_DATA_BUF_SIZE)
64 count = RTAS_DATA_BUF_SIZE; 59 count = RTAS_DATA_BUF_SIZE;
65 60
@@ -146,11 +141,6 @@ static int scanlog_open(struct inode * inode, struct file * file)
146 struct proc_dir_entry *dp = PDE(inode); 141 struct proc_dir_entry *dp = PDE(inode);
147 unsigned int *data = (unsigned int *)dp->data; 142 unsigned int *data = (unsigned int *)dp->data;
148 143
149 if (!data) {
150 printk(KERN_ERR "scanlog: open failed no data\n");
151 return -EIO;
152 }
153
154 if (data[0] != 0) { 144 if (data[0] != 0) {
155 /* This imperfect test stops a second copy of the 145 /* This imperfect test stops a second copy of the
156 * data (or a reset while data is being copied) 146 * data (or a reset while data is being copied)
@@ -168,10 +158,6 @@ static int scanlog_release(struct inode * inode, struct file * file)
168 struct proc_dir_entry *dp = PDE(inode); 158 struct proc_dir_entry *dp = PDE(inode);
169 unsigned int *data = (unsigned int *)dp->data; 159 unsigned int *data = (unsigned int *)dp->data;
170 160
171 if (!data) {
172 printk(KERN_ERR "scanlog: release failed no data\n");
173 return -EIO;
174 }
175 data[0] = 0; 161 data[0] = 0;
176 162
177 return 0; 163 return 0;
@@ -200,12 +186,11 @@ static int __init scanlog_init(void)
200 if (!data) 186 if (!data)
201 goto err; 187 goto err;
202 188
203 ent = proc_create("ppc64/rtas/scan-log-dump", S_IRUSR, NULL, 189 ent = proc_create_data("ppc64/rtas/scan-log-dump", S_IRUSR, NULL,
204 &scanlog_fops); 190 &scanlog_fops, data);
205 if (!ent) 191 if (!ent)
206 goto err; 192 goto err;
207 193
208 ent->data = data;
209 proc_ppc64_scan_log_dump = ent; 194 proc_ppc64_scan_log_dump = ent;
210 195
211 return 0; 196 return 0;