git://ftp.safe.ca
/
safe
/
jmp
/
linux-2.6
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sh: Kill off the remaining ST40 cruft.
[safe/jmp/linux-2.6]
/
drivers
/
scsi
/
raid_class.c
diff --git
a/drivers/scsi/raid_class.c
b/drivers/scsi/raid_class.c
index
a9f99c6
..
86e1318
100644
(file)
--- a/
drivers/scsi/raid_class.c
+++ b/
drivers/scsi/raid_class.c
@@
-12,6
+12,8
@@
#include <linux/init.h>
#include <linux/module.h>
#include <linux/list.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/list.h>
+#include <linux/slab.h>
+#include <linux/string.h>
#include <linux/raid_class.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_host.h>
#include <linux/raid_class.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_host.h>
@@
-113,7
+115,7
@@
static DECLARE_TRANSPORT_CLASS(raid_class,
raid_remove,
NULL);
raid_remove,
NULL);
-static struct {
+static
const
struct {
enum raid_state value;
char *name;
} raid_states[] = {
enum raid_state value;
char *name;
} raid_states[] = {
@@
-129,7
+131,7
@@
static const char *raid_state_name(enum raid_state state)
int i;
char *name = NULL;
int i;
char *name = NULL;
- for (i = 0; i <
sizeof(raid_states)/sizeof(raid_states[0]
); i++) {
+ for (i = 0; i <
ARRAY_SIZE(raid_states
); i++) {
if (raid_states[i].value == state) {
name = raid_states[i].name;
break;
if (raid_states[i].value == state) {
name = raid_states[i].name;
break;
@@
-146,9
+148,11
@@
static struct {
{ RAID_LEVEL_LINEAR, "linear" },
{ RAID_LEVEL_0, "raid0" },
{ RAID_LEVEL_1, "raid1" },
{ RAID_LEVEL_LINEAR, "linear" },
{ RAID_LEVEL_0, "raid0" },
{ RAID_LEVEL_1, "raid1" },
+ { RAID_LEVEL_10, "raid10" },
{ RAID_LEVEL_3, "raid3" },
{ RAID_LEVEL_4, "raid4" },
{ RAID_LEVEL_5, "raid5" },
{ RAID_LEVEL_3, "raid3" },
{ RAID_LEVEL_4, "raid4" },
{ RAID_LEVEL_5, "raid5" },
+ { RAID_LEVEL_50, "raid50" },
{ RAID_LEVEL_6, "raid6" },
};
{ RAID_LEVEL_6, "raid6" },
};
@@
-157,7
+161,7
@@
static const char *raid_level_name(enum raid_level level)
int i;
char *name = NULL;
int i;
char *name = NULL;
- for (i = 0; i <
sizeof(raid_levels)/sizeof(raid_levels[0]
); i++) {
+ for (i = 0; i <
ARRAY_SIZE(raid_levels
); i++) {
if (raid_levels[i].value == level) {
name = raid_levels[i].name;
break;
if (raid_levels[i].value == level) {
name = raid_levels[i].name;
break;
@@
-211,18
+215,19
@@
static void raid_component_release(struct class_device *cdev)
kfree(rc);
}
kfree(rc);
}
-
void
raid_component_add(struct raid_template *r,struct device *raid_dev,
-
struct device *component_dev)
+
int
raid_component_add(struct raid_template *r,struct device *raid_dev,
+ struct device *component_dev)
{
struct class_device *cdev =
attribute_container_find_class_device(&r->raid_attrs.ac,
raid_dev);
struct raid_component *rc;
struct raid_data *rd = class_get_devdata(cdev);
{
struct class_device *cdev =
attribute_container_find_class_device(&r->raid_attrs.ac,
raid_dev);
struct raid_component *rc;
struct raid_data *rd = class_get_devdata(cdev);
+ int err;
rc = kzalloc(sizeof(*rc), GFP_KERNEL);
if (!rc)
rc = kzalloc(sizeof(*rc), GFP_KERNEL);
if (!rc)
- return;
+ return
-ENOMEM
;
INIT_LIST_HEAD(&rc->node);
class_device_initialize(&rc->cdev);
INIT_LIST_HEAD(&rc->node);
class_device_initialize(&rc->cdev);
@@
-235,7
+240,18
@@
void raid_component_add(struct raid_template *r,struct device *raid_dev,
list_add_tail(&rc->node, &rd->component_list);
rc->cdev.parent = cdev;
rc->cdev.class = &raid_class.class;
list_add_tail(&rc->node, &rd->component_list);
rc->cdev.parent = cdev;
rc->cdev.class = &raid_class.class;
- class_device_add(&rc->cdev);
+ err = class_device_add(&rc->cdev);
+ if (err)
+ goto err_out;
+
+ return 0;
+
+err_out:
+ list_del(&rc->node);
+ rd->component_count--;
+ put_device(component_dev);
+ kfree(rc);
+ return err;
}
EXPORT_SYMBOL(raid_component_add);
}
EXPORT_SYMBOL(raid_component_add);