aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/s390_rdev.c
diff options
context:
space:
mode:
authorCarsten Otte <cotte@de.ibm.com>2006-01-06 03:19:14 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-06 11:33:49 -0500
commitcfb1b55595a0dfd87b5849e8d0216c029f34445f (patch)
tree86d73bda5e9c82e70a4bdbacfac6be5644c8a987 /drivers/s390/s390_rdev.c
parent6810a2bce3aa6573faa9920487274f166fe95c6e (diff)
[PATCH] s390: move s390_root_dev_* out of the cio layer
Extract the s390_root_dev_* functions from the common I/O layer as they are also used by non-ccw device drivers. Signed-off-by: Carsten Otte <cotte@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/s390/s390_rdev.c')
-rw-r--r--drivers/s390/s390_rdev.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/drivers/s390/s390_rdev.c b/drivers/s390/s390_rdev.c
new file mode 100644
index 000000000000..566cc3d185b6
--- /dev/null
+++ b/drivers/s390/s390_rdev.c
@@ -0,0 +1,53 @@
1/*
2 * drivers/s390/s390_rdev.c
3 * s390 root device
4 * $Revision: 1.2 $
5 *
6 * Copyright (C) 2002, 2005 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation
8 * Author(s): Cornelia Huck (cohuck@de.ibm.com)
9 * Carsten Otte (cotte@de.ibm.com)
10 */
11
12#include <linux/slab.h>
13#include <linux/err.h>
14#include <linux/device.h>
15#include <asm/s390_rdev.h>
16
17static void
18s390_root_dev_release(struct device *dev)
19{
20 kfree(dev);
21}
22
23struct device *
24s390_root_dev_register(const char *name)
25{
26 struct device *dev;
27 int ret;
28
29 if (!strlen(name))
30 return ERR_PTR(-EINVAL);
31 dev = kmalloc(sizeof(struct device), GFP_KERNEL);
32 if (!dev)
33 return ERR_PTR(-ENOMEM);
34 memset(dev, 0, sizeof(struct device));
35 strncpy(dev->bus_id, name, min(strlen(name), (size_t)BUS_ID_SIZE));
36 dev->release = s390_root_dev_release;
37 ret = device_register(dev);
38 if (ret) {
39 kfree(dev);
40 return ERR_PTR(ret);
41 }
42 return dev;
43}
44
45void
46s390_root_dev_unregister(struct device *dev)
47{
48 if (dev)
49 device_unregister(dev);
50}
51
52EXPORT_SYMBOL(s390_root_dev_register);
53EXPORT_SYMBOL(s390_root_dev_unregister);