From: Randy Dunlap [EMAIL PROTECTED]
Move RAID class configuration to the BLOCK menu since it is not
SCSI-specific.
Signed-off-by: Randy Dunlap [EMAIL PROTECTED]
---
block/Kconfig |5
block/Makefile|2
block/raid_class.c| 313 +
drivers/scsi/Kconfig |7 -
drivers/scsi/Makefile |2
drivers/scsi/raid_class.c | 314 --
6 files changed, 320 insertions(+), 323 deletions(-)
--- linux-2.6.24-rc1-git13.orig/block/Kconfig
+++ linux-2.6.24-rc1-git13/block/Kconfig
@@ -62,6 +62,11 @@ config BLK_DEV_BSG
protocols (e.g. Task Management Functions and SMP in Serial
Attached SCSI).
+config RAID_ATTRS
+ tristate RAID Transport Class
+ ---help---
+ Provides RAID class information in sysfs.
+
endif # BLOCK
config BLOCK_COMPAT
--- linux-2.6.24-rc1-git13.orig/drivers/scsi/Kconfig
+++ linux-2.6.24-rc1-git13/drivers/scsi/Kconfig
@@ -1,12 +1,5 @@
menu SCSI device support
-config RAID_ATTRS
- tristate RAID Transport Class
- default n
- depends on BLOCK
- ---help---
- Provides RAID
-
config SCSI
tristate SCSI device support
depends on BLOCK
--- /dev/null
+++ linux-2.6.24-rc1-git13/block/raid_class.c
@@ -0,0 +1,313 @@
+/*
+ * raid_class.c - implementation of a simple raid visualisation class
+ *
+ * Copyright (c) 2005 - James Bottomley [EMAIL PROTECTED]
+ *
+ * This file is licensed under GPLv2
+ *
+ * This class is designed to allow raid attributes to be visualised and
+ * manipulated in a form independent of the underlying raid. Ultimately this
+ * should work for both hardware and software raids.
+ */
+#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
+
+#define RAID_NUM_ATTRS 3
+
+struct raid_internal {
+ struct raid_template r;
+ struct raid_function_template *f;
+ /* The actual attributes */
+ struct class_device_attribute private_attrs[RAID_NUM_ATTRS];
+ /* The array of null terminated pointers to attributes
+* needed by scsi_sysfs.c */
+ struct class_device_attribute *attrs[RAID_NUM_ATTRS + 1];
+};
+
+struct raid_component {
+ struct list_head node;
+ struct class_device cdev;
+ int num;
+};
+
+#define to_raid_internal(tmpl) container_of(tmpl, struct raid_internal, r)
+
+#define tc_to_raid_internal(tcont) ({ \
+ struct raid_template *r = \
+ container_of(tcont, struct raid_template, raid_attrs); \
+ to_raid_internal(r);\
+})
+
+#define ac_to_raid_internal(acont) ({ \
+ struct transport_container *tc =\
+ container_of(acont, struct transport_container, ac);\
+ tc_to_raid_internal(tc);\
+})
+
+#define class_device_to_raid_internal(cdev) ({ \
+ struct attribute_container *ac =\
+ attribute_container_classdev_to_container(cdev);\
+ ac_to_raid_internal(ac);\
+})
+
+
+static int raid_match(struct attribute_container *cont, struct device *dev)
+{
+ /* We have to look for every subsystem that could house
+* emulated RAID devices, so start with SCSI */
+ struct raid_internal *i = ac_to_raid_internal(cont);
+
+ if (scsi_is_sdev_device(dev)) {
+ struct scsi_device *sdev = to_scsi_device(dev);
+
+ if (i-f-cookie != sdev-host-hostt)
+ return 0;
+
+ return i-f-is_raid(dev);
+ }
+ /* FIXME: look at other subsystems too */
+ return 0;
+}
+
+static int raid_setup(struct transport_container *tc, struct device *dev,
+ struct class_device *cdev)
+{
+ struct raid_data *rd;
+
+ BUG_ON(class_get_devdata(cdev));
+
+ rd = kzalloc(sizeof(*rd), GFP_KERNEL);
+ if (!rd)
+ return -ENOMEM;
+
+ INIT_LIST_HEAD(rd-component_list);
+ class_set_devdata(cdev, rd);
+
+ return 0;
+}
+
+static int raid_remove(struct transport_container *tc, struct device *dev,
+ struct class_device *cdev)
+{
+ struct raid_data *rd = class_get_devdata(cdev);
+ struct raid_component *rc, *next;
+ dev_printk(KERN_ERR, dev, RAID REMOVE\n);
+ class_set_devdata(cdev, NULL);
+ list_for_each_entry_safe(rc, next, rd-component_list, node) {
+ list_del(rc-node);
+ dev_printk(KERN_ERR, rc-cdev.dev, RAID COMPONENT REMOVE\n);
+ class_device_unregister(rc-cdev);
+