2 * dcssblk.c -- the S/390 block driver for dcss memory
4 * Authors: Carsten Otte, Stefan Weinhuber, Gerald Schaefer
7 #include <linux/module.h>
8 #include <linux/moduleparam.h>
9 #include <linux/ctype.h>
10 #include <linux/errno.h>
11 #include <linux/init.h>
12 #include <linux/slab.h>
13 #include <linux/blkdev.h>
14 #include <asm/extmem.h>
16 #include <linux/completion.h>
17 #include <linux/interrupt.h>
18 #include <asm/s390_rdev.h>
20 //#define DCSSBLK_DEBUG /* Debug messages on/off */
21 #define DCSSBLK_NAME "dcssblk"
22 #define DCSSBLK_MINORS_PER_DISK 1
23 #define DCSSBLK_PARM_LEN 400
24 #define DCSS_BUS_ID_SIZE 20
27 #define PRINT_DEBUG(x...) printk(KERN_DEBUG DCSSBLK_NAME " debug: " x)
29 #define PRINT_DEBUG(x...) do {} while (0)
31 #define PRINT_INFO(x...) printk(KERN_INFO DCSSBLK_NAME " info: " x)
32 #define PRINT_WARN(x...) printk(KERN_WARNING DCSSBLK_NAME " warning: " x)
33 #define PRINT_ERR(x...) printk(KERN_ERR DCSSBLK_NAME " error: " x)
35 static int dcssblk_open(struct block_device *bdev, fmode_t mode);
36 static int dcssblk_release(struct gendisk *disk, fmode_t mode);
37 static int dcssblk_make_request(struct request_queue *q, struct bio *bio);
38 static int dcssblk_direct_access(struct block_device *bdev, sector_t secnum,
39 void **kaddr, unsigned long *pfn);
41 static char dcssblk_segments[DCSSBLK_PARM_LEN] = "\0";
43 static int dcssblk_major;
44 static struct block_device_operations dcssblk_devops = {
47 .release = dcssblk_release,
48 .direct_access = dcssblk_direct_access,
51 struct dcssblk_dev_info {
54 char segment_name[DCSS_BUS_ID_SIZE];
60 unsigned char save_pending;
61 unsigned char is_shared;
62 struct request_queue *dcssblk_queue;
64 struct list_head seg_list;
69 char segment_name[DCSS_BUS_ID_SIZE];
75 static ssize_t dcssblk_add_store(struct device * dev, struct device_attribute *attr, const char * buf,
77 static ssize_t dcssblk_remove_store(struct device * dev, struct device_attribute *attr, const char * buf,
79 static ssize_t dcssblk_save_store(struct device * dev, struct device_attribute *attr, const char * buf,
81 static ssize_t dcssblk_save_show(struct device *dev, struct device_attribute *attr, char *buf);
82 static ssize_t dcssblk_shared_store(struct device * dev, struct device_attribute *attr, const char * buf,
84 static ssize_t dcssblk_shared_show(struct device *dev, struct device_attribute *attr, char *buf);
85 static ssize_t dcssblk_seglist_show(struct device *dev,
86 struct device_attribute *attr,
89 static DEVICE_ATTR(add, S_IWUSR, NULL, dcssblk_add_store);
90 static DEVICE_ATTR(remove, S_IWUSR, NULL, dcssblk_remove_store);
91 static DEVICE_ATTR(save, S_IWUSR | S_IRUSR, dcssblk_save_show,
93 static DEVICE_ATTR(shared, S_IWUSR | S_IRUSR, dcssblk_shared_show,
94 dcssblk_shared_store);
95 static DEVICE_ATTR(seglist, S_IRUSR, dcssblk_seglist_show, NULL);
97 static struct device *dcssblk_root_dev;
99 static LIST_HEAD(dcssblk_devices);
100 static struct rw_semaphore dcssblk_devices_sem;
103 * release function for segment device.
106 dcssblk_release_segment(struct device *dev)
108 struct dcssblk_dev_info *dev_info;
109 struct segment_info *entry, *temp;
111 dev_info = container_of(dev, struct dcssblk_dev_info, dev);
112 list_for_each_entry_safe(entry, temp, &dev_info->seg_list, lh) {
113 list_del(&entry->lh);
117 module_put(THIS_MODULE);
121 * get a minor number. needs to be called with
122 * down_write(&dcssblk_devices_sem) and the
123 * device needs to be enqueued before the semaphore is
127 dcssblk_assign_free_minor(struct dcssblk_dev_info *dev_info)
130 struct dcssblk_dev_info *entry;
132 if (dev_info == NULL)
134 for (minor = 0; minor < (1<<MINORBITS); minor++) {
136 // test if minor available
137 list_for_each_entry(entry, &dcssblk_devices, lh)
138 if (minor == MINOR(disk_devt(entry->gd)))
140 if (!found) break; // got unused minor
144 dev_info->gd->first_minor = minor;
149 * get the struct dcssblk_dev_info from dcssblk_devices
150 * for the given name.
151 * down_read(&dcssblk_devices_sem) must be held.
153 static struct dcssblk_dev_info *
154 dcssblk_get_device_by_name(char *name)
156 struct dcssblk_dev_info *entry;
158 list_for_each_entry(entry, &dcssblk_devices, lh) {
159 if (!strcmp(name, entry->segment_name)) {
167 * get the struct segment_info from seg_list
168 * for the given name.
169 * down_read(&dcssblk_devices_sem) must be held.
171 static struct segment_info *
172 dcssblk_get_segment_by_name(char *name)
174 struct dcssblk_dev_info *dev_info;
175 struct segment_info *entry;
177 list_for_each_entry(dev_info, &dcssblk_devices, lh) {
178 list_for_each_entry(entry, &dev_info->seg_list, lh) {
179 if (!strcmp(name, entry->segment_name))
187 * get the highest address of the multi-segment block.
190 dcssblk_find_highest_addr(struct dcssblk_dev_info *dev_info)
192 unsigned long highest_addr;
193 struct segment_info *entry;
196 list_for_each_entry(entry, &dev_info->seg_list, lh) {
197 if (highest_addr < entry->end)
198 highest_addr = entry->end;
204 * get the lowest address of the multi-segment block.
207 dcssblk_find_lowest_addr(struct dcssblk_dev_info *dev_info)
210 unsigned long lowest_addr;
211 struct segment_info *entry;
215 list_for_each_entry(entry, &dev_info->seg_list, lh) {
216 if (set_first == 0) {
217 lowest_addr = entry->start;
220 if (lowest_addr > entry->start)
221 lowest_addr = entry->start;
228 * Check continuity of segments.
231 dcssblk_is_continuous(struct dcssblk_dev_info *dev_info)
234 struct segment_info *sort_list, *entry, temp;
236 if (dev_info->num_of_segments <= 1)
240 sizeof(struct segment_info) * dev_info->num_of_segments,
242 if (sort_list == NULL)
245 list_for_each_entry(entry, &dev_info->seg_list, lh) {
246 memcpy(&sort_list[i], entry, sizeof(struct segment_info));
251 for (i = 0; i < dev_info->num_of_segments; i++)
252 for (j = 0; j < dev_info->num_of_segments; j++)
253 if (sort_list[j].start > sort_list[i].start) {
254 memcpy(&temp, &sort_list[i],
255 sizeof(struct segment_info));
256 memcpy(&sort_list[i], &sort_list[j],
257 sizeof(struct segment_info));
258 memcpy(&sort_list[j], &temp,
259 sizeof(struct segment_info));
262 /* check continuity */
263 for (i = 0; i < dev_info->num_of_segments - 1; i++) {
264 if ((sort_list[i].end + 1) != sort_list[i+1].start) {
265 PRINT_ERR("Segment %s is not contiguous with "
267 sort_list[i].segment_name,
268 sort_list[i+1].segment_name);
272 /* EN and EW are allowed in a block device */
273 if (sort_list[i].segment_type != sort_list[i+1].segment_type) {
274 if (!(sort_list[i].segment_type & SEGMENT_EXCLUSIVE) ||
275 (sort_list[i].segment_type == SEG_TYPE_ER) ||
276 !(sort_list[i+1].segment_type &
277 SEGMENT_EXCLUSIVE) ||
278 (sort_list[i+1].segment_type == SEG_TYPE_ER)) {
279 PRINT_ERR("Segment %s has different type from "
281 sort_list[i].segment_name,
282 sort_list[i+1].segment_name);
298 dcssblk_load_segment(char *name, struct segment_info **seg_info)
302 /* already loaded? */
303 down_read(&dcssblk_devices_sem);
304 *seg_info = dcssblk_get_segment_by_name(name);
305 up_read(&dcssblk_devices_sem);
306 if (*seg_info != NULL)
309 /* get a struct segment_info */
310 *seg_info = kzalloc(sizeof(struct segment_info), GFP_KERNEL);
311 if (*seg_info == NULL)
314 strcpy((*seg_info)->segment_name, name);
316 /* load the segment */
317 rc = segment_load(name, SEGMENT_SHARED,
318 &(*seg_info)->start, &(*seg_info)->end);
320 segment_warning(rc, (*seg_info)->segment_name);
323 INIT_LIST_HEAD(&(*seg_info)->lh);
324 (*seg_info)->segment_type = rc;
329 static void dcssblk_unregister_callback(struct device *dev)
331 device_unregister(dev);
336 * device attribute for switching shared/nonshared (exclusive)
337 * operation (show + store)
340 dcssblk_shared_show(struct device *dev, struct device_attribute *attr, char *buf)
342 struct dcssblk_dev_info *dev_info;
344 dev_info = container_of(dev, struct dcssblk_dev_info, dev);
345 return sprintf(buf, dev_info->is_shared ? "1\n" : "0\n");
349 dcssblk_shared_store(struct device *dev, struct device_attribute *attr, const char *inbuf, size_t count)
351 struct dcssblk_dev_info *dev_info;
352 struct segment_info *entry, *temp;
355 if ((count > 1) && (inbuf[1] != '\n') && (inbuf[1] != '\0'))
357 down_write(&dcssblk_devices_sem);
358 dev_info = container_of(dev, struct dcssblk_dev_info, dev);
359 if (atomic_read(&dev_info->use_count)) {
363 if (inbuf[0] == '1') {
364 /* reload segments in shared mode */
365 list_for_each_entry(entry, &dev_info->seg_list, lh) {
366 rc = segment_modify_shared(entry->segment_name,
369 BUG_ON(rc == -EINVAL);
374 dev_info->is_shared = 1;
375 switch (dev_info->segment_type) {
379 set_disk_ro(dev_info->gd, 1);
381 } else if (inbuf[0] == '0') {
382 /* reload segments in exclusive mode */
383 if (dev_info->segment_type == SEG_TYPE_SC) {
384 PRINT_ERR("Segment type SC (%s) cannot be loaded in "
385 "non-shared mode\n", dev_info->segment_name);
389 list_for_each_entry(entry, &dev_info->seg_list, lh) {
390 rc = segment_modify_shared(entry->segment_name,
393 BUG_ON(rc == -EINVAL);
398 dev_info->is_shared = 0;
399 set_disk_ro(dev_info->gd, 0);
408 PRINT_ERR("Could not reload segment(s) of the device %s, removing "
410 dev_info->segment_name);
412 list_for_each_entry(entry, &dev_info->seg_list, lh) {
414 segment_unload(entry->segment_name);
416 list_del(&dev_info->lh);
418 del_gendisk(dev_info->gd);
419 blk_cleanup_queue(dev_info->dcssblk_queue);
420 dev_info->gd->queue = NULL;
421 put_disk(dev_info->gd);
422 rc = device_schedule_callback(dev, dcssblk_unregister_callback);
424 up_write(&dcssblk_devices_sem);
429 * device attribute for save operation on current copy
430 * of the segment. If the segment is busy, saving will
431 * become pending until it gets released, which can be
432 * undone by storing a non-true value to this entry.
436 dcssblk_save_show(struct device *dev, struct device_attribute *attr, char *buf)
438 struct dcssblk_dev_info *dev_info;
440 dev_info = container_of(dev, struct dcssblk_dev_info, dev);
441 return sprintf(buf, dev_info->save_pending ? "1\n" : "0\n");
445 dcssblk_save_store(struct device *dev, struct device_attribute *attr, const char *inbuf, size_t count)
447 struct dcssblk_dev_info *dev_info;
448 struct segment_info *entry;
450 if ((count > 1) && (inbuf[1] != '\n') && (inbuf[1] != '\0'))
452 dev_info = container_of(dev, struct dcssblk_dev_info, dev);
454 down_write(&dcssblk_devices_sem);
455 if (inbuf[0] == '1') {
456 if (atomic_read(&dev_info->use_count) == 0) {
457 // device is idle => we save immediately
458 PRINT_INFO("Saving segment(s) of the device %s\n",
459 dev_info->segment_name);
460 list_for_each_entry(entry, &dev_info->seg_list, lh) {
461 segment_save(entry->segment_name);
464 // device is busy => we save it when it becomes
465 // idle in dcssblk_release
466 PRINT_INFO("Device %s is currently busy, segment(s) "
467 "will be saved when it becomes idle...\n",
468 dev_info->segment_name);
469 dev_info->save_pending = 1;
471 } else if (inbuf[0] == '0') {
472 if (dev_info->save_pending) {
473 // device is busy & the user wants to undo his save
475 dev_info->save_pending = 0;
476 PRINT_INFO("Pending save for segment(s) of the device "
478 dev_info->segment_name);
481 up_write(&dcssblk_devices_sem);
484 up_write(&dcssblk_devices_sem);
489 * device attribute for showing all segments in a device
492 dcssblk_seglist_show(struct device *dev, struct device_attribute *attr,
497 struct dcssblk_dev_info *dev_info;
498 struct segment_info *entry;
500 down_read(&dcssblk_devices_sem);
501 dev_info = container_of(dev, struct dcssblk_dev_info, dev);
504 list_for_each_entry(entry, &dev_info->seg_list, lh) {
505 strcpy(&buf[i], entry->segment_name);
506 i += strlen(entry->segment_name);
510 up_read(&dcssblk_devices_sem);
515 * device attribute for adding devices
518 dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
520 int rc, i, j, num_of_segments;
521 struct dcssblk_dev_info *dev_info;
522 struct segment_info *seg_info, *temp;
524 unsigned long seg_byte_size;
528 if (dev != dcssblk_root_dev) {
532 if ((count < 1) || (buf[0] == '\0') || (buf[0] == '\n')) {
537 local_buf = kmalloc(count + 1, GFP_KERNEL);
538 if (local_buf == NULL) {
547 for (i = 0; ((buf[i] != '\0') && (buf[i] != '\n') && i < count); i++) {
548 for (j = i; (buf[j] != ':') &&
552 local_buf[j-i] = toupper(buf[j]);
554 local_buf[j-i] = '\0';
555 if (((j - i) == 0) || ((j - i) > 8)) {
560 rc = dcssblk_load_segment(local_buf, &seg_info);
564 * get a struct dcssblk_dev_info
566 if (num_of_segments == 0) {
567 dev_info = kzalloc(sizeof(struct dcssblk_dev_info),
569 if (dev_info == NULL) {
573 strcpy(dev_info->segment_name, local_buf);
574 dev_info->segment_type = seg_info->segment_type;
575 INIT_LIST_HEAD(&dev_info->seg_list);
577 list_add_tail(&seg_info->lh, &dev_info->seg_list);
581 if ((buf[j] == '\0') || (buf[j] == '\n'))
585 /* no trailing colon at the end of the input */
586 if ((i > 0) && (buf[i-1] == ':')) {
590 strlcpy(local_buf, buf, i + 1);
591 dev_info->num_of_segments = num_of_segments;
592 rc = dcssblk_is_continuous(dev_info);
596 dev_info->start = dcssblk_find_lowest_addr(dev_info);
597 dev_info->end = dcssblk_find_highest_addr(dev_info);
599 dev_set_name(&dev_info->dev, dev_info->segment_name);
600 dev_info->dev.release = dcssblk_release_segment;
601 INIT_LIST_HEAD(&dev_info->lh);
602 dev_info->gd = alloc_disk(DCSSBLK_MINORS_PER_DISK);
603 if (dev_info->gd == NULL) {
607 dev_info->gd->major = dcssblk_major;
608 dev_info->gd->fops = &dcssblk_devops;
609 dev_info->dcssblk_queue = blk_alloc_queue(GFP_KERNEL);
610 dev_info->gd->queue = dev_info->dcssblk_queue;
611 dev_info->gd->private_data = dev_info;
612 dev_info->gd->driverfs_dev = &dev_info->dev;
613 blk_queue_make_request(dev_info->dcssblk_queue, dcssblk_make_request);
614 blk_queue_hardsect_size(dev_info->dcssblk_queue, 4096);
616 seg_byte_size = (dev_info->end - dev_info->start + 1);
617 set_capacity(dev_info->gd, seg_byte_size >> 9); // size in sectors
618 PRINT_INFO("Loaded segment(s) %s, size = %lu Byte, "
619 "capacity = %lu (512 Byte) sectors\n", local_buf,
620 seg_byte_size, seg_byte_size >> 9);
622 dev_info->save_pending = 0;
623 dev_info->is_shared = 1;
624 dev_info->dev.parent = dcssblk_root_dev;
627 *get minor, add to list
629 down_write(&dcssblk_devices_sem);
630 if (dcssblk_get_segment_by_name(local_buf)) {
634 rc = dcssblk_assign_free_minor(dev_info);
637 sprintf(dev_info->gd->disk_name, "dcssblk%d",
638 MINOR(disk_devt(dev_info->gd)));
639 list_add_tail(&dev_info->lh, &dcssblk_devices);
641 if (!try_module_get(THIS_MODULE)) {
646 * register the device
648 rc = device_register(&dev_info->dev);
650 module_put(THIS_MODULE);
653 get_device(&dev_info->dev);
654 rc = device_create_file(&dev_info->dev, &dev_attr_shared);
657 rc = device_create_file(&dev_info->dev, &dev_attr_save);
660 rc = device_create_file(&dev_info->dev, &dev_attr_seglist);
664 add_disk(dev_info->gd);
666 switch (dev_info->segment_type) {
670 set_disk_ro(dev_info->gd,1);
673 set_disk_ro(dev_info->gd,0);
676 up_write(&dcssblk_devices_sem);
681 list_del(&dev_info->lh);
682 blk_cleanup_queue(dev_info->dcssblk_queue);
683 dev_info->gd->queue = NULL;
684 put_disk(dev_info->gd);
685 device_unregister(&dev_info->dev);
686 list_for_each_entry(seg_info, &dev_info->seg_list, lh) {
687 segment_unload(seg_info->segment_name);
689 put_device(&dev_info->dev);
690 up_write(&dcssblk_devices_sem);
693 list_del(&dev_info->lh);
695 blk_cleanup_queue(dev_info->dcssblk_queue);
696 dev_info->gd->queue = NULL;
697 put_disk(dev_info->gd);
698 up_write(&dcssblk_devices_sem);
700 if (dev_info == NULL)
702 list_for_each_entry_safe(seg_info, temp, &dev_info->seg_list, lh) {
703 list_del(&seg_info->lh);
704 segment_unload(seg_info->segment_name);
715 * device attribute for removing devices
718 dcssblk_remove_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
720 struct dcssblk_dev_info *dev_info;
721 struct segment_info *entry;
725 if (dev != dcssblk_root_dev) {
728 local_buf = kmalloc(count + 1, GFP_KERNEL);
729 if (local_buf == NULL) {
735 for (i = 0; ((*(buf+i)!='\0') && (*(buf+i)!='\n') && i < count); i++) {
736 local_buf[i] = toupper(buf[i]);
739 if ((i == 0) || (i > 8)) {
744 down_write(&dcssblk_devices_sem);
745 dev_info = dcssblk_get_device_by_name(local_buf);
746 if (dev_info == NULL) {
747 up_write(&dcssblk_devices_sem);
748 PRINT_WARN("Device %s is not loaded!\n", local_buf);
752 if (atomic_read(&dev_info->use_count) != 0) {
753 up_write(&dcssblk_devices_sem);
754 PRINT_WARN("Device %s is in use!\n", local_buf);
759 list_del(&dev_info->lh);
760 del_gendisk(dev_info->gd);
761 blk_cleanup_queue(dev_info->dcssblk_queue);
762 dev_info->gd->queue = NULL;
763 put_disk(dev_info->gd);
764 device_unregister(&dev_info->dev);
766 /* unload all related segments */
767 list_for_each_entry(entry, &dev_info->seg_list, lh)
768 segment_unload(entry->segment_name);
770 put_device(&dev_info->dev);
771 up_write(&dcssblk_devices_sem);
780 dcssblk_open(struct block_device *bdev, fmode_t mode)
782 struct dcssblk_dev_info *dev_info;
785 dev_info = bdev->bd_disk->private_data;
786 if (NULL == dev_info) {
790 atomic_inc(&dev_info->use_count);
791 bdev->bd_block_size = 4096;
798 dcssblk_release(struct gendisk *disk, fmode_t mode)
800 struct dcssblk_dev_info *dev_info = disk->private_data;
801 struct segment_info *entry;
808 down_write(&dcssblk_devices_sem);
809 if (atomic_dec_and_test(&dev_info->use_count)
810 && (dev_info->save_pending)) {
811 PRINT_INFO("Device %s became idle and is being saved now\n",
812 dev_info->segment_name);
813 list_for_each_entry(entry, &dev_info->seg_list, lh) {
814 segment_save(entry->segment_name);
816 dev_info->save_pending = 0;
818 up_write(&dcssblk_devices_sem);
825 dcssblk_make_request(struct request_queue *q, struct bio *bio)
827 struct dcssblk_dev_info *dev_info;
828 struct bio_vec *bvec;
830 unsigned long page_addr;
831 unsigned long source_addr;
832 unsigned long bytes_done;
836 dev_info = bio->bi_bdev->bd_disk->private_data;
837 if (dev_info == NULL)
839 if ((bio->bi_sector & 7) != 0 || (bio->bi_size & 4095) != 0)
840 /* Request is not page-aligned. */
842 if (((bio->bi_size >> 9) + bio->bi_sector)
843 > get_capacity(bio->bi_bdev->bd_disk)) {
844 /* Request beyond end of DCSS segment. */
847 /* verify data transfer direction */
848 if (dev_info->is_shared) {
849 switch (dev_info->segment_type) {
853 /* cannot write to these segments */
854 if (bio_data_dir(bio) == WRITE) {
855 PRINT_WARN("rejecting write to ro device %s\n",
856 dev_name(&dev_info->dev));
862 index = (bio->bi_sector >> 3);
863 bio_for_each_segment(bvec, bio, i) {
864 page_addr = (unsigned long)
865 page_address(bvec->bv_page) + bvec->bv_offset;
866 source_addr = dev_info->start + (index<<12) + bytes_done;
867 if (unlikely((page_addr & 4095) != 0) || (bvec->bv_len & 4095) != 0)
870 if (bio_data_dir(bio) == READ) {
871 memcpy((void*)page_addr, (void*)source_addr,
874 memcpy((void*)source_addr, (void*)page_addr,
877 bytes_done += bvec->bv_len;
887 dcssblk_direct_access (struct block_device *bdev, sector_t secnum,
888 void **kaddr, unsigned long *pfn)
890 struct dcssblk_dev_info *dev_info;
893 dev_info = bdev->bd_disk->private_data;
896 if (secnum % (PAGE_SIZE/512))
898 pgoff = secnum / (PAGE_SIZE / 512);
899 if ((pgoff+1)*PAGE_SIZE-1 > dev_info->end - dev_info->start)
901 *kaddr = (void *) (dev_info->start+pgoff*PAGE_SIZE);
902 *pfn = virt_to_phys(*kaddr) >> PAGE_SHIFT;
908 dcssblk_check_params(void)
911 char buf[DCSSBLK_PARM_LEN + 1];
912 struct dcssblk_dev_info *dev_info;
914 for (i = 0; (i < DCSSBLK_PARM_LEN) && (dcssblk_segments[i] != '\0');
916 for (j = i; (dcssblk_segments[j] != ',') &&
917 (dcssblk_segments[j] != '\0') &&
918 (dcssblk_segments[j] != '(') &&
919 (j < DCSSBLK_PARM_LEN); j++)
921 buf[j-i] = dcssblk_segments[j];
924 rc = dcssblk_add_store(dcssblk_root_dev, NULL, buf, j-i);
925 if ((rc >= 0) && (dcssblk_segments[j] == '(')) {
926 for (k = 0; (buf[k] != ':') && (buf[k] != '\0'); k++)
927 buf[k] = toupper(buf[k]);
929 if (!strncmp(&dcssblk_segments[j], "(local)", 7)) {
930 down_read(&dcssblk_devices_sem);
931 dev_info = dcssblk_get_device_by_name(buf);
932 up_read(&dcssblk_devices_sem);
934 dcssblk_shared_store(&dev_info->dev,
938 while ((dcssblk_segments[j] != ',') &&
939 (dcssblk_segments[j] != '\0'))
943 if (dcssblk_segments[j] == '\0')
950 * The init/exit functions.
955 s390_root_dev_unregister(dcssblk_root_dev);
956 unregister_blkdev(dcssblk_major, DCSSBLK_NAME);
964 dcssblk_root_dev = s390_root_dev_register("dcssblk");
965 if (IS_ERR(dcssblk_root_dev))
966 return PTR_ERR(dcssblk_root_dev);
967 rc = device_create_file(dcssblk_root_dev, &dev_attr_add);
969 s390_root_dev_unregister(dcssblk_root_dev);
972 rc = device_create_file(dcssblk_root_dev, &dev_attr_remove);
974 s390_root_dev_unregister(dcssblk_root_dev);
977 rc = register_blkdev(0, DCSSBLK_NAME);
979 s390_root_dev_unregister(dcssblk_root_dev);
983 init_rwsem(&dcssblk_devices_sem);
985 dcssblk_check_params();
990 module_init(dcssblk_init);
991 module_exit(dcssblk_exit);
993 module_param_string(segments, dcssblk_segments, DCSSBLK_PARM_LEN, 0444);
994 MODULE_PARM_DESC(segments, "Name of DCSS segment(s) to be loaded, "
995 "comma-separated list, names in each set separated "
996 "by commas are separated by colons, each set contains "
997 "names of contiguous segments and each name max. 8 chars.\n"
998 "Adding \"(local)\" to the end of each set equals echoing 0 "
999 "to /sys/devices/dcssblk/<device name>/shared after loading "
1000 "the contiguous segments - \n"
1001 "e.g. segments=\"mydcss1,mydcss2:mydcss3,mydcss4(local)\"");
1003 MODULE_LICENSE("GPL");