2 * File...........: linux/drivers/s390/block/dasd_devmap.c
3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
4 * Horst Hummel <Horst.Hummel@de.ibm.com>
5 * Carsten Otte <Cotte@de.ibm.com>
6 * Martin Schwidefsky <schwidefsky@de.ibm.com>
7 * Bugreports.to..: <Linux390@de.ibm.com>
8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001
10 * Device mapping and dasd= parameter parsing functions. All devmap
11 * functions may not be called from interrupt context. In particular
12 * dasd_get_device is a no-no from interrupt context.
16 #include <linux/ctype.h>
17 #include <linux/init.h>
18 #include <linux/module.h>
20 #include <asm/debug.h>
21 #include <asm/uaccess.h>
25 #define PRINTK_HEADER "dasd_devmap:"
29 struct kmem_cache *dasd_page_cache;
30 EXPORT_SYMBOL_GPL(dasd_page_cache);
33 * dasd_devmap_t is used to store the features and the relation
34 * between device number and device index. To find a dasd_devmap_t
35 * that corresponds to a device number of a device index each
36 * dasd_devmap_t is added to two linked lists, one to search by
37 * the device number and one to search by the device index. As
38 * soon as big minor numbers are available the device index list
39 * can be removed since the device number will then be identical
40 * to the device index.
43 struct list_head list;
44 char bus_id[BUS_ID_SIZE];
45 unsigned int devindex;
46 unsigned short features;
47 struct dasd_device *device;
52 * dasd_server_ssid_map contains a globally unique storage server subsystem ID.
53 * dasd_server_ssid_list contains the list of all subsystem IDs accessed by
54 * the DASD device driver.
56 struct dasd_server_ssid_map {
57 struct list_head list;
65 static struct list_head dasd_server_ssid_list;
68 * Parameter parsing functions for dasd= parameter. The syntax is:
69 * <devno> : (0x)?[0-9a-fA-F]+
70 * <busid> : [0-0a-f]\.[0-9a-f]\.(0x)?[0-9a-fA-F]+
72 * <feature_list> : \(<feature>(:<feature>)*\)
73 * <devno-range> : <devno>(-<devno>)?<feature_list>?
74 * <busid-range> : <busid>(-<busid>)?<feature_list>?
75 * <devices> : <devno-range>|<busid-range>
76 * <dasd_module> : dasd_diag_mod|dasd_eckd_mod|dasd_fba_mod
78 * <dasd> : autodetect|probeonly|<devices>(,<devices>)*
81 int dasd_probeonly = 0; /* is true, when probeonly mode is active */
82 int dasd_autodetect = 0; /* is true, when autodetection is active */
83 int dasd_nopav = 0; /* is true, when PAV is disabled */
84 EXPORT_SYMBOL_GPL(dasd_nopav);
87 * char *dasd[] is intended to hold the ranges supplied by the dasd= statement
88 * it is named 'dasd' to directly be filled by insmod with the comma separated
89 * strings when running as a module.
91 static char *dasd[256];
92 module_param_array(dasd, charp, NULL, 0);
95 * Single spinlock to protect devmap and servermap structures and lists.
97 static DEFINE_SPINLOCK(dasd_devmap_lock);
100 * Hash lists for devmap structures.
102 static struct list_head dasd_hashlists[256];
103 int dasd_max_devindex;
105 static struct dasd_devmap *dasd_add_busid(char *, int);
108 dasd_hash_busid(char *bus_id)
113 for (i = 0; (i < BUS_ID_SIZE) && *bus_id; i++, bus_id++)
120 * The parameter parsing functions for builtin-drivers are called
121 * before kmalloc works. Store the pointers to the parameters strings
122 * into dasd[] for later processing.
125 dasd_call_setup(char *str)
127 static int count = 0;
134 __setup ("dasd=", dasd_call_setup);
135 #endif /* #ifndef MODULE */
137 #define DASD_IPLDEV "ipldev"
140 * Read a device busid/devno from a string.
143 dasd_busid(char **str, int *id0, int *id1, int *devno)
147 /* Interpret ipldev busid */
148 if (strncmp(DASD_IPLDEV, *str, strlen(DASD_IPLDEV)) == 0) {
149 if (ipl_info.type != IPL_TYPE_CCW) {
150 MESSAGE(KERN_ERR, "%s", "ipl device is not a ccw "
155 *id1 = ipl_info.data.ccw.dev_id.ssid;
156 *devno = ipl_info.data.ccw.dev_id.devno;
157 *str += strlen(DASD_IPLDEV);
161 /* check for leading '0x' */
163 if ((*str)[0] == '0' && (*str)[1] == 'x') {
167 if (!isxdigit((*str)[0])) /* We require at least one hex digit */
169 val = simple_strtoul(*str, str, 16);
170 if (old_style || (*str)[0] != '.') {
172 if (val < 0 || val > 0xffff)
177 /* New style x.y.z busid */
178 if (val < 0 || val > 0xff)
182 if (!isxdigit((*str)[0])) /* We require at least one hex digit */
184 val = simple_strtoul(*str, str, 16);
185 if (val < 0 || val > 0xff || (*str)++[0] != '.')
188 if (!isxdigit((*str)[0])) /* We require at least one hex digit */
190 val = simple_strtoul(*str, str, 16);
191 if (val < 0 || val > 0xffff)
198 * Read colon separated list of dasd features. Currently there is
199 * only one: "ro" for read-only devices. The default feature set
200 * is empty (value 0).
203 dasd_feature_list(char *str, char **endp)
205 int features, len, rc;
210 return DASD_FEATURE_DEFAULT;
217 str[len] && str[len] != ':' && str[len] != ')'; len++);
218 if (len == 2 && !strncmp(str, "ro", 2))
219 features |= DASD_FEATURE_READONLY;
220 else if (len == 4 && !strncmp(str, "diag", 4))
221 features |= DASD_FEATURE_USEDIAG;
222 else if (len == 6 && !strncmp(str, "erplog", 6))
223 features |= DASD_FEATURE_ERPLOG;
225 MESSAGE(KERN_WARNING,
226 "unsupported feature: %*s, "
227 "ignoring setting", len, str);
236 MESSAGE(KERN_WARNING, "%s",
237 "missing ')' in dasd parameter string\n");
248 * Try to match the first element on the comma separated parse string
249 * with one of the known keywords. If a keyword is found, take the approprate
250 * action and return a pointer to the residual string. If the first element
251 * could not be matched to any keyword then return an error code.
254 dasd_parse_keyword( char *parsestring ) {
256 char *nextcomma, *residual_str;
259 nextcomma = strchr(parsestring,',');
261 length = nextcomma - parsestring;
262 residual_str = nextcomma + 1;
264 length = strlen(parsestring);
265 residual_str = parsestring + length;
267 if (strncmp("autodetect", parsestring, length) == 0) {
269 MESSAGE (KERN_INFO, "%s",
270 "turning to autodetection mode");
273 if (strncmp("probeonly", parsestring, length) == 0) {
275 MESSAGE(KERN_INFO, "%s",
276 "turning to probeonly mode");
279 if (strncmp("nopav", parsestring, length) == 0) {
281 MESSAGE(KERN_INFO, "%s", "'nopav' not supported on VM");
284 MESSAGE(KERN_INFO, "%s", "disable PAV mode");
288 if (strncmp("fixedbuffers", parsestring, length) == 0) {
292 kmem_cache_create("dasd_page_cache", PAGE_SIZE,
293 PAGE_SIZE, SLAB_CACHE_DMA,
295 if (!dasd_page_cache)
296 MESSAGE(KERN_WARNING, "%s", "Failed to create slab, "
297 "fixed buffer mode disabled.");
299 MESSAGE (KERN_INFO, "%s",
300 "turning on fixed buffer mode");
303 return ERR_PTR(-EINVAL);
307 * Try to interprete the first element on the comma separated parse string
308 * as a device number or a range of devices. If the interpretation is
309 * successfull, create the matching dasd_devmap entries and return a pointer
310 * to the residual string.
311 * If interpretation fails or in case of an error, return an error code.
314 dasd_parse_range( char *parsestring ) {
316 struct dasd_devmap *devmap;
317 int from, from_id0, from_id1;
318 int to, to_id0, to_id1;
320 char bus_id[BUS_ID_SIZE+1], *str;
323 rc = dasd_busid(&str, &from_id0, &from_id1, &from);
330 rc = dasd_busid(&str, &to_id0, &to_id1, &to);
334 (from_id0 != to_id0 || from_id1 != to_id1 || from > to))
337 MESSAGE(KERN_ERR, "Invalid device range %s", parsestring);
340 features = dasd_feature_list(str, &str);
342 return ERR_PTR(-EINVAL);
343 /* each device in dasd= parameter should be set initially online */
344 features |= DASD_FEATURE_INITIAL_ONLINE;
346 sprintf(bus_id, "%01x.%01x.%04x",
347 from_id0, from_id1, from++);
348 devmap = dasd_add_busid(bus_id, features);
350 return (char *)devmap;
356 MESSAGE(KERN_WARNING,
357 "junk at end of dasd parameter string: %s\n", str);
358 return ERR_PTR(-EINVAL);
362 dasd_parse_next_element( char *parsestring ) {
364 residual_str = dasd_parse_keyword(parsestring);
365 if (!IS_ERR(residual_str))
367 residual_str = dasd_parse_range(parsestring);
372 * Parse parameters stored in dasd[]
373 * The 'dasd=...' parameter allows to specify a comma separated list of
374 * keywords and device ranges. When the dasd driver is build into the kernel,
375 * the complete list will be stored as one element of the dasd[] array.
376 * When the dasd driver is build as a module, then the list is broken into
377 * it's elements and each dasd[] entry contains one element.
386 for (i = 0; i < 256; i++) {
389 parsestring = dasd[i];
390 /* loop over the comma separated list in the parsestring */
391 while (*parsestring) {
392 parsestring = dasd_parse_next_element(parsestring);
393 if(IS_ERR(parsestring)) {
394 rc = PTR_ERR(parsestring);
399 DBF_EVENT(DBF_ALERT, "%s", "invalid range found");
407 * Add a devmap for the device specified by busid. It is possible that
408 * the devmap already exists (dasd= parameter). The order of the devices
409 * added through this function will define the kdevs for the individual
412 static struct dasd_devmap *
413 dasd_add_busid(char *bus_id, int features)
415 struct dasd_devmap *devmap, *new, *tmp;
418 new = (struct dasd_devmap *)
419 kzalloc(sizeof(struct dasd_devmap), GFP_KERNEL);
421 return ERR_PTR(-ENOMEM);
422 spin_lock(&dasd_devmap_lock);
424 hash = dasd_hash_busid(bus_id);
425 list_for_each_entry(tmp, &dasd_hashlists[hash], list)
426 if (strncmp(tmp->bus_id, bus_id, BUS_ID_SIZE) == 0) {
431 /* This bus_id is new. */
432 new->devindex = dasd_max_devindex++;
433 strncpy(new->bus_id, bus_id, BUS_ID_SIZE);
434 new->features = features;
436 list_add(&new->list, &dasd_hashlists[hash]);
440 spin_unlock(&dasd_devmap_lock);
446 * Find devmap for device with given bus_id.
448 static struct dasd_devmap *
449 dasd_find_busid(char *bus_id)
451 struct dasd_devmap *devmap, *tmp;
454 spin_lock(&dasd_devmap_lock);
455 devmap = ERR_PTR(-ENODEV);
456 hash = dasd_hash_busid(bus_id);
457 list_for_each_entry(tmp, &dasd_hashlists[hash], list) {
458 if (strncmp(tmp->bus_id, bus_id, BUS_ID_SIZE) == 0) {
463 spin_unlock(&dasd_devmap_lock);
468 * Check if busid has been added to the list of dasd ranges.
471 dasd_busid_known(char *bus_id)
473 return IS_ERR(dasd_find_busid(bus_id)) ? -ENOENT : 0;
477 * Forget all about the device numbers added so far.
478 * This may only be called at module unload or system shutdown.
481 dasd_forget_ranges(void)
483 struct dasd_devmap *devmap, *n;
486 spin_lock(&dasd_devmap_lock);
487 for (i = 0; i < 256; i++) {
488 list_for_each_entry_safe(devmap, n, &dasd_hashlists[i], list) {
489 BUG_ON(devmap->device != NULL);
490 list_del(&devmap->list);
494 spin_unlock(&dasd_devmap_lock);
498 * Find the device struct by its device index.
501 dasd_device_from_devindex(int devindex)
503 struct dasd_devmap *devmap, *tmp;
504 struct dasd_device *device;
507 spin_lock(&dasd_devmap_lock);
509 for (i = 0; (i < 256) && !devmap; i++)
510 list_for_each_entry(tmp, &dasd_hashlists[i], list)
511 if (tmp->devindex == devindex) {
512 /* Found the devmap for the device. */
516 if (devmap && devmap->device) {
517 device = devmap->device;
518 dasd_get_device(device);
520 device = ERR_PTR(-ENODEV);
521 spin_unlock(&dasd_devmap_lock);
526 * Return devmap for cdev. If no devmap exists yet, create one and
527 * connect it to the cdev.
529 static struct dasd_devmap *
530 dasd_devmap_from_cdev(struct ccw_device *cdev)
532 struct dasd_devmap *devmap;
534 devmap = dasd_find_busid(cdev->dev.bus_id);
536 devmap = dasd_add_busid(cdev->dev.bus_id,
537 DASD_FEATURE_DEFAULT);
542 * Create a dasd device structure for cdev.
545 dasd_create_device(struct ccw_device *cdev)
547 struct dasd_devmap *devmap;
548 struct dasd_device *device;
552 devmap = dasd_devmap_from_cdev(cdev);
554 return (void *) devmap;
556 device = dasd_alloc_device();
559 atomic_set(&device->ref_count, 3);
561 spin_lock(&dasd_devmap_lock);
562 if (!devmap->device) {
563 devmap->device = device;
564 device->devindex = devmap->devindex;
565 device->features = devmap->features;
566 get_device(&cdev->dev);
570 /* Someone else was faster. */
572 spin_unlock(&dasd_devmap_lock);
575 dasd_free_device(device);
579 spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
580 cdev->dev.driver_data = device;
581 spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
587 * Wait queue for dasd_delete_device waits.
589 static DECLARE_WAIT_QUEUE_HEAD(dasd_delete_wq);
592 * Remove a dasd device structure. The passed referenced
596 dasd_delete_device(struct dasd_device *device)
598 struct ccw_device *cdev;
599 struct dasd_devmap *devmap;
602 /* First remove device pointer from devmap. */
603 devmap = dasd_find_busid(device->cdev->dev.bus_id);
604 BUG_ON(IS_ERR(devmap));
605 spin_lock(&dasd_devmap_lock);
606 if (devmap->device != device) {
607 spin_unlock(&dasd_devmap_lock);
608 dasd_put_device(device);
611 devmap->device = NULL;
612 spin_unlock(&dasd_devmap_lock);
614 /* Disconnect dasd_device structure from ccw_device structure. */
615 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
616 device->cdev->dev.driver_data = NULL;
617 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
620 * Drop ref_count by 3, one for the devmap reference, one for
621 * the cdev reference and one for the passed reference.
623 atomic_sub(3, &device->ref_count);
625 /* Wait for reference counter to drop to zero. */
626 wait_event(dasd_delete_wq, atomic_read(&device->ref_count) == 0);
628 /* Disconnect dasd_device structure from ccw_device structure. */
632 /* Put ccw_device structure. */
633 put_device(&cdev->dev);
635 /* Now the device structure can be freed. */
636 dasd_free_device(device);
640 * Reference counter dropped to zero. Wake up waiter
641 * in dasd_delete_device.
644 dasd_put_device_wake(struct dasd_device *device)
646 wake_up(&dasd_delete_wq);
650 * Return dasd_device structure associated with cdev.
651 * This function needs to be called with the ccw device
652 * lock held. It can be used from interrupt context.
655 dasd_device_from_cdev_locked(struct ccw_device *cdev)
657 struct dasd_device *device = cdev->dev.driver_data;
660 return ERR_PTR(-ENODEV);
661 dasd_get_device(device);
666 * Return dasd_device structure associated with cdev.
669 dasd_device_from_cdev(struct ccw_device *cdev)
671 struct dasd_device *device;
674 spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
675 device = dasd_device_from_cdev_locked(cdev);
676 spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
681 * SECTION: files in sysfs
685 * readonly controls the readonly status of a dasd
688 dasd_ro_show(struct device *dev, struct device_attribute *attr, char *buf)
690 struct dasd_devmap *devmap;
693 devmap = dasd_find_busid(dev->bus_id);
695 ro_flag = (devmap->features & DASD_FEATURE_READONLY) != 0;
697 ro_flag = (DASD_FEATURE_DEFAULT & DASD_FEATURE_READONLY) != 0;
698 return snprintf(buf, PAGE_SIZE, ro_flag ? "1\n" : "0\n");
702 dasd_ro_store(struct device *dev, struct device_attribute *attr,
703 const char *buf, size_t count)
705 struct dasd_devmap *devmap;
709 devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
711 return PTR_ERR(devmap);
713 val = simple_strtoul(buf, &endp, 0);
714 if (((endp + 1) < (buf + count)) || (val > 1))
717 spin_lock(&dasd_devmap_lock);
719 devmap->features |= DASD_FEATURE_READONLY;
721 devmap->features &= ~DASD_FEATURE_READONLY;
723 devmap->device->features = devmap->features;
724 if (devmap->device && devmap->device->gdp)
725 set_disk_ro(devmap->device->gdp, val);
726 spin_unlock(&dasd_devmap_lock);
730 static DEVICE_ATTR(readonly, 0644, dasd_ro_show, dasd_ro_store);
732 * erplog controls the logging of ERP related data
733 * (e.g. failing channel programs).
736 dasd_erplog_show(struct device *dev, struct device_attribute *attr, char *buf)
738 struct dasd_devmap *devmap;
741 devmap = dasd_find_busid(dev->bus_id);
743 erplog = (devmap->features & DASD_FEATURE_ERPLOG) != 0;
745 erplog = (DASD_FEATURE_DEFAULT & DASD_FEATURE_ERPLOG) != 0;
746 return snprintf(buf, PAGE_SIZE, erplog ? "1\n" : "0\n");
750 dasd_erplog_store(struct device *dev, struct device_attribute *attr,
751 const char *buf, size_t count)
753 struct dasd_devmap *devmap;
757 devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
759 return PTR_ERR(devmap);
761 val = simple_strtoul(buf, &endp, 0);
762 if (((endp + 1) < (buf + count)) || (val > 1))
765 spin_lock(&dasd_devmap_lock);
767 devmap->features |= DASD_FEATURE_ERPLOG;
769 devmap->features &= ~DASD_FEATURE_ERPLOG;
771 devmap->device->features = devmap->features;
772 spin_unlock(&dasd_devmap_lock);
776 static DEVICE_ATTR(erplog, 0644, dasd_erplog_show, dasd_erplog_store);
779 * use_diag controls whether the driver should use diag rather than ssch
780 * to talk to the device
783 dasd_use_diag_show(struct device *dev, struct device_attribute *attr, char *buf)
785 struct dasd_devmap *devmap;
788 devmap = dasd_find_busid(dev->bus_id);
790 use_diag = (devmap->features & DASD_FEATURE_USEDIAG) != 0;
792 use_diag = (DASD_FEATURE_DEFAULT & DASD_FEATURE_USEDIAG) != 0;
793 return sprintf(buf, use_diag ? "1\n" : "0\n");
797 dasd_use_diag_store(struct device *dev, struct device_attribute *attr,
798 const char *buf, size_t count)
800 struct dasd_devmap *devmap;
805 devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
807 return PTR_ERR(devmap);
809 val = simple_strtoul(buf, &endp, 0);
810 if (((endp + 1) < (buf + count)) || (val > 1))
813 spin_lock(&dasd_devmap_lock);
814 /* Changing diag discipline flag is only allowed in offline state. */
816 if (!devmap->device) {
818 devmap->features |= DASD_FEATURE_USEDIAG;
820 devmap->features &= ~DASD_FEATURE_USEDIAG;
823 spin_unlock(&dasd_devmap_lock);
827 static DEVICE_ATTR(use_diag, 0644, dasd_use_diag_show, dasd_use_diag_store);
830 dasd_discipline_show(struct device *dev, struct device_attribute *attr,
833 struct dasd_device *device;
836 device = dasd_device_from_cdev(to_ccwdev(dev));
837 if (!IS_ERR(device) && device->discipline) {
838 len = snprintf(buf, PAGE_SIZE, "%s\n",
839 device->discipline->name);
840 dasd_put_device(device);
842 len = snprintf(buf, PAGE_SIZE, "none\n");
846 static DEVICE_ATTR(discipline, 0444, dasd_discipline_show, NULL);
849 dasd_device_status_show(struct device *dev, struct device_attribute *attr,
852 struct dasd_device *device;
855 device = dasd_device_from_cdev(to_ccwdev(dev));
856 if (!IS_ERR(device)) {
857 switch (device->state) {
859 len = snprintf(buf, PAGE_SIZE, "new\n");
861 case DASD_STATE_KNOWN:
862 len = snprintf(buf, PAGE_SIZE, "detected\n");
864 case DASD_STATE_BASIC:
865 len = snprintf(buf, PAGE_SIZE, "basic\n");
867 case DASD_STATE_UNFMT:
868 len = snprintf(buf, PAGE_SIZE, "unformatted\n");
870 case DASD_STATE_READY:
871 len = snprintf(buf, PAGE_SIZE, "ready\n");
873 case DASD_STATE_ONLINE:
874 len = snprintf(buf, PAGE_SIZE, "online\n");
877 len = snprintf(buf, PAGE_SIZE, "no stat\n");
880 dasd_put_device(device);
882 len = snprintf(buf, PAGE_SIZE, "unknown\n");
886 static DEVICE_ATTR(status, 0444, dasd_device_status_show, NULL);
889 dasd_alias_show(struct device *dev, struct device_attribute *attr, char *buf)
891 struct dasd_devmap *devmap;
894 devmap = dasd_find_busid(dev->bus_id);
895 spin_lock(&dasd_devmap_lock);
897 alias = devmap->uid.alias;
900 spin_unlock(&dasd_devmap_lock);
902 return sprintf(buf, alias ? "1\n" : "0\n");
905 static DEVICE_ATTR(alias, 0444, dasd_alias_show, NULL);
908 dasd_vendor_show(struct device *dev, struct device_attribute *attr, char *buf)
910 struct dasd_devmap *devmap;
913 devmap = dasd_find_busid(dev->bus_id);
914 spin_lock(&dasd_devmap_lock);
915 if (!IS_ERR(devmap) && strlen(devmap->uid.vendor) > 0)
916 vendor = devmap->uid.vendor;
919 spin_unlock(&dasd_devmap_lock);
921 return snprintf(buf, PAGE_SIZE, "%s\n", vendor);
924 static DEVICE_ATTR(vendor, 0444, dasd_vendor_show, NULL);
926 #define UID_STRLEN ( /* vendor */ 3 + 1 + /* serial */ 14 + 1 +\
927 /* SSID */ 4 + 1 + /* unit addr */ 2 + 1)
930 dasd_uid_show(struct device *dev, struct device_attribute *attr, char *buf)
932 struct dasd_devmap *devmap;
933 char uid[UID_STRLEN];
935 devmap = dasd_find_busid(dev->bus_id);
936 spin_lock(&dasd_devmap_lock);
937 if (!IS_ERR(devmap) && strlen(devmap->uid.vendor) > 0)
938 snprintf(uid, sizeof(uid), "%s.%s.%04x.%02x",
939 devmap->uid.vendor, devmap->uid.serial,
940 devmap->uid.ssid, devmap->uid.unit_addr);
943 spin_unlock(&dasd_devmap_lock);
945 return snprintf(buf, PAGE_SIZE, "%s\n", uid);
948 static DEVICE_ATTR(uid, 0444, dasd_uid_show, NULL);
951 * extended error-reporting
954 dasd_eer_show(struct device *dev, struct device_attribute *attr, char *buf)
956 struct dasd_devmap *devmap;
959 devmap = dasd_find_busid(dev->bus_id);
960 if (!IS_ERR(devmap) && devmap->device)
961 eer_flag = dasd_eer_enabled(devmap->device);
964 return snprintf(buf, PAGE_SIZE, eer_flag ? "1\n" : "0\n");
968 dasd_eer_store(struct device *dev, struct device_attribute *attr,
969 const char *buf, size_t count)
971 struct dasd_devmap *devmap;
975 devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
977 return PTR_ERR(devmap);
981 val = simple_strtoul(buf, &endp, 0);
982 if (((endp + 1) < (buf + count)) || (val > 1))
986 rc = dasd_eer_enable(devmap->device);
990 dasd_eer_disable(devmap->device);
994 static DEVICE_ATTR(eer_enabled, 0644, dasd_eer_show, dasd_eer_store);
996 static struct attribute * dasd_attrs[] = {
997 &dev_attr_readonly.attr,
998 &dev_attr_discipline.attr,
999 &dev_attr_status.attr,
1000 &dev_attr_alias.attr,
1001 &dev_attr_vendor.attr,
1003 &dev_attr_use_diag.attr,
1004 &dev_attr_eer_enabled.attr,
1005 &dev_attr_erplog.attr,
1009 static struct attribute_group dasd_attr_group = {
1010 .attrs = dasd_attrs,
1014 * Return copy of the device unique identifier.
1017 dasd_get_uid(struct ccw_device *cdev, struct dasd_uid *uid)
1019 struct dasd_devmap *devmap;
1021 devmap = dasd_find_busid(cdev->dev.bus_id);
1023 return PTR_ERR(devmap);
1024 spin_lock(&dasd_devmap_lock);
1026 spin_unlock(&dasd_devmap_lock);
1031 * Register the given device unique identifier into devmap struct.
1032 * In addition check if the related storage server subsystem ID is already
1033 * contained in the dasd_server_ssid_list. If subsystem ID is not contained,
1035 * Return 0 if server was already in serverlist,
1036 * 1 if the server was added successful
1037 * <0 in case of error.
1040 dasd_set_uid(struct ccw_device *cdev, struct dasd_uid *uid)
1042 struct dasd_devmap *devmap;
1043 struct dasd_server_ssid_map *srv, *tmp;
1045 devmap = dasd_find_busid(cdev->dev.bus_id);
1047 return PTR_ERR(devmap);
1049 /* generate entry for server_ssid_map */
1050 srv = (struct dasd_server_ssid_map *)
1051 kzalloc(sizeof(struct dasd_server_ssid_map), GFP_KERNEL);
1054 strncpy(srv->sid.vendor, uid->vendor, sizeof(srv->sid.vendor) - 1);
1055 strncpy(srv->sid.serial, uid->serial, sizeof(srv->sid.serial) - 1);
1056 srv->sid.ssid = uid->ssid;
1058 /* server is already contained ? */
1059 spin_lock(&dasd_devmap_lock);
1061 list_for_each_entry(tmp, &dasd_server_ssid_list, list) {
1062 if (!memcmp(&srv->sid, &tmp->sid,
1063 sizeof(struct system_id))) {
1070 /* add servermap to serverlist */
1072 list_add(&srv->list, &dasd_server_ssid_list);
1073 spin_unlock(&dasd_devmap_lock);
1075 return (srv ? 1 : 0);
1077 EXPORT_SYMBOL_GPL(dasd_set_uid);
1080 * Return value of the specified feature.
1083 dasd_get_feature(struct ccw_device *cdev, int feature)
1085 struct dasd_devmap *devmap;
1087 devmap = dasd_find_busid(cdev->dev.bus_id);
1089 return PTR_ERR(devmap);
1091 return ((devmap->features & feature) != 0);
1095 * Set / reset given feature.
1096 * Flag indicates wether to set (!=0) or the reset (=0) the feature.
1099 dasd_set_feature(struct ccw_device *cdev, int feature, int flag)
1101 struct dasd_devmap *devmap;
1103 devmap = dasd_find_busid(cdev->dev.bus_id);
1105 return PTR_ERR(devmap);
1107 spin_lock(&dasd_devmap_lock);
1109 devmap->features |= feature;
1111 devmap->features &= ~feature;
1113 devmap->device->features = devmap->features;
1114 spin_unlock(&dasd_devmap_lock);
1120 dasd_add_sysfs_files(struct ccw_device *cdev)
1122 return sysfs_create_group(&cdev->dev.kobj, &dasd_attr_group);
1126 dasd_remove_sysfs_files(struct ccw_device *cdev)
1128 sysfs_remove_group(&cdev->dev.kobj, &dasd_attr_group);
1133 dasd_devmap_init(void)
1137 /* Initialize devmap structures. */
1138 dasd_max_devindex = 0;
1139 for (i = 0; i < 256; i++)
1140 INIT_LIST_HEAD(&dasd_hashlists[i]);
1142 /* Initialize servermap structure. */
1143 INIT_LIST_HEAD(&dasd_server_ssid_list);
1148 dasd_devmap_exit(void)
1150 dasd_forget_ranges();