blob: 3c7145d9f9a1f74189b655b54afbae05c8d22202 [file] [log] [blame]
Carsten Ottecfb1b552006-01-06 00:19:14 -08001/*
2 * drivers/s390/s390_rdev.c
3 * s390 root device
Carsten Ottecfb1b552006-01-06 00:19:14 -08004 *
5 * Copyright (C) 2002, 2005 IBM Deutschland Entwicklung GmbH,
6 * IBM Corporation
Cornelia Huck4ce3b302006-01-14 13:21:04 -08007 * Author(s): Cornelia Huck (cornelia.huck@de.ibm.com)
Carsten Ottecfb1b552006-01-06 00:19:14 -08008 * Carsten Otte (cotte@de.ibm.com)
9 */
10
11#include <linux/slab.h>
12#include <linux/err.h>
13#include <linux/device.h>
14#include <asm/s390_rdev.h>
15
16static void
17s390_root_dev_release(struct device *dev)
18{
19 kfree(dev);
20}
21
22struct device *
23s390_root_dev_register(const char *name)
24{
25 struct device *dev;
26 int ret;
27
28 if (!strlen(name))
29 return ERR_PTR(-EINVAL);
Eric Sesterhenn88abaab2006-03-24 03:15:31 -080030 dev = kzalloc(sizeof(struct device), GFP_KERNEL);
Carsten Ottecfb1b552006-01-06 00:19:14 -080031 if (!dev)
32 return ERR_PTR(-ENOMEM);
Carsten Ottecfb1b552006-01-06 00:19:14 -080033 strncpy(dev->bus_id, name, min(strlen(name), (size_t)BUS_ID_SIZE));
34 dev->release = s390_root_dev_release;
35 ret = device_register(dev);
36 if (ret) {
37 kfree(dev);
38 return ERR_PTR(ret);
39 }
40 return dev;
41}
42
43void
44s390_root_dev_unregister(struct device *dev)
45{
46 if (dev)
47 device_unregister(dev);
48}
49
50EXPORT_SYMBOL(s390_root_dev_register);
51EXPORT_SYMBOL(s390_root_dev_unregister);