blob: 206518c7d3322dba7d723ada73df1d3b48dca6f8 [file] [log] [blame]
Carsten Ottecfb1b552006-01-06 00:19:14 -08001/*
2 * drivers/s390/s390_rdev.c
3 * s390 root device
Cornelia Huck4ce3b302006-01-14 13:21:04 -08004 * $Revision: 1.4 $
Carsten Ottecfb1b552006-01-06 00:19:14 -08005 *
6 * Copyright (C) 2002, 2005 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation
Cornelia Huck4ce3b302006-01-14 13:21:04 -08008 * Author(s): Cornelia Huck (cornelia.huck@de.ibm.com)
Carsten Ottecfb1b552006-01-06 00:19:14 -08009 * 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);