1/*
2 *  drivers/s390/s390_rdev.c
3 *  s390 root device
4 *
5 *    Copyright (C) 2002, 2005 IBM Deutschland Entwicklung GmbH,
6 *			 IBM Corporation
7 *    Author(s): Cornelia Huck (cornelia.huck@de.ibm.com)
8 *		  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);
30	dev = kzalloc(sizeof(struct device), GFP_KERNEL);
31	if (!dev)
32		return ERR_PTR(-ENOMEM);
33	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);
52