Carsten Otte | cfb1b55 | 2006-01-06 00:19:14 -0800 | [diff] [blame] | 1 | /* |
| 2 | * drivers/s390/s390_rdev.c |
| 3 | * s390 root device |
Carsten Otte | cfb1b55 | 2006-01-06 00:19:14 -0800 | [diff] [blame] | 4 | * |
| 5 | * Copyright (C) 2002, 2005 IBM Deutschland Entwicklung GmbH, |
| 6 | * IBM Corporation |
Cornelia Huck | 4ce3b30 | 2006-01-14 13:21:04 -0800 | [diff] [blame] | 7 | * Author(s): Cornelia Huck (cornelia.huck@de.ibm.com) |
Carsten Otte | cfb1b55 | 2006-01-06 00:19:14 -0800 | [diff] [blame] | 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 | |
| 16 | static void |
| 17 | s390_root_dev_release(struct device *dev) |
| 18 | { |
| 19 | kfree(dev); |
| 20 | } |
| 21 | |
| 22 | struct device * |
| 23 | s390_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 Sesterhenn | 88abaab | 2006-03-24 03:15:31 -0800 | [diff] [blame] | 30 | dev = kzalloc(sizeof(struct device), GFP_KERNEL); |
Carsten Otte | cfb1b55 | 2006-01-06 00:19:14 -0800 | [diff] [blame] | 31 | if (!dev) |
| 32 | return ERR_PTR(-ENOMEM); |
Carsten Otte | cfb1b55 | 2006-01-06 00:19:14 -0800 | [diff] [blame] | 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 | |
| 43 | void |
| 44 | s390_root_dev_unregister(struct device *dev) |
| 45 | { |
| 46 | if (dev) |
| 47 | device_unregister(dev); |
| 48 | } |
| 49 | |
| 50 | EXPORT_SYMBOL(s390_root_dev_register); |
| 51 | EXPORT_SYMBOL(s390_root_dev_unregister); |