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 * Parameter parsing functions for dasd= parameter. The syntax is:
53 * <devno> : (0x)?[0-9a-fA-F]+
54 * <busid> : [0-0a-f]\.[0-9a-f]\.(0x)?[0-9a-fA-F]+
56 * <feature_list> : \(<feature>(:<feature>)*\)
57 * <devno-range> : <devno>(-<devno>)?<feature_list>?
58 * <busid-range> : <busid>(-<busid>)?<feature_list>?
59 * <devices> : <devno-range>|<busid-range>
60 * <dasd_module> : dasd_diag_mod|dasd_eckd_mod|dasd_fba_mod
62 * <dasd> : autodetect|probeonly|<devices>(,<devices>)*
65 int dasd_probeonly = 0; /* is true, when probeonly mode is active */
66 int dasd_autodetect = 0; /* is true, when autodetection is active */
67 int dasd_nopav = 0; /* is true, when PAV is disabled */
68 EXPORT_SYMBOL_GPL(dasd_nopav);
71 * char *dasd[] is intended to hold the ranges supplied by the dasd= statement
72 * it is named 'dasd' to directly be filled by insmod with the comma separated
73 * strings when running as a module.
75 static char *dasd[256];
76 module_param_array(dasd, charp, NULL, 0);
79 * Single spinlock to protect devmap and servermap structures and lists.
81 static DEFINE_SPINLOCK(dasd_devmap_lock);
84 * Hash lists for devmap structures.
86 static struct list_head dasd_hashlists[256];
87 int dasd_max_devindex;
89 static struct dasd_devmap *dasd_add_busid(char *, int);
92 dasd_hash_busid(char *bus_id)
97 for (i = 0; (i < BUS_ID_SIZE) && *bus_id; i++, bus_id++)
104 * The parameter parsing functions for builtin-drivers are called
105 * before kmalloc works. Store the pointers to the parameters strings
106 * into dasd[] for later processing.
109 dasd_call_setup(char *str)
111 static int count = 0;
118 __setup ("dasd=", dasd_call_setup);
119 #endif /* #ifndef MODULE */
121 #define DASD_IPLDEV "ipldev"
124 * Read a device busid/devno from a string.
127 dasd_busid(char **str, int *id0, int *id1, int *devno)
131 /* Interpret ipldev busid */
132 if (strncmp(DASD_IPLDEV, *str, strlen(DASD_IPLDEV)) == 0) {
133 if (ipl_info.type != IPL_TYPE_CCW) {
134 MESSAGE(KERN_ERR, "%s", "ipl device is not a ccw "
139 *id1 = ipl_info.data.ccw.dev_id.ssid;
140 *devno = ipl_info.data.ccw.dev_id.devno;
141 *str += strlen(DASD_IPLDEV);
145 /* check for leading '0x' */
147 if ((*str)[0] == '0' && (*str)[1] == 'x') {
151 if (!isxdigit((*str)[0])) /* We require at least one hex digit */
153 val = simple_strtoul(*str, str, 16);
154 if (old_style || (*str)[0] != '.') {
156 if (val < 0 || val > 0xffff)
161 /* New style x.y.z busid */
162 if (val < 0 || val > 0xff)
166 if (!isxdigit((*str)[0])) /* We require at least one hex digit */
168 val = simple_strtoul(*str, str, 16);
169 if (val < 0 || val > 0xff || (*str)++[0] != '.')
172 if (!isxdigit((*str)[0])) /* We require at least one hex digit */
174 val = simple_strtoul(*str, str, 16);
175 if (val < 0 || val > 0xffff)
182 * Read colon separated list of dasd features. Currently there is
183 * only one: "ro" for read-only devices. The default feature set
184 * is empty (value 0).
187 dasd_feature_list(char *str, char **endp)
189 int features, len, rc;
194 return DASD_FEATURE_DEFAULT;
201 str[len] && str[len] != ':' && str[len] != ')'; len++);
202 if (len == 2 && !strncmp(str, "ro", 2))
203 features |= DASD_FEATURE_READONLY;
204 else if (len == 4 && !strncmp(str, "diag", 4))
205 features |= DASD_FEATURE_USEDIAG;
206 else if (len == 6 && !strncmp(str, "erplog", 6))
207 features |= DASD_FEATURE_ERPLOG;
209 MESSAGE(KERN_WARNING,
210 "unsupported feature: %*s, "
211 "ignoring setting", len, str);
220 MESSAGE(KERN_WARNING, "%s",
221 "missing ')' in dasd parameter string\n");
232 * Try to match the first element on the comma separated parse string
233 * with one of the known keywords. If a keyword is found, take the approprate
234 * action and return a pointer to the residual string. If the first element
235 * could not be matched to any keyword then return an error code.
238 dasd_parse_keyword( char *parsestring ) {
240 char *nextcomma, *residual_str;
243 nextcomma = strchr(parsestring,',');
245 length = nextcomma - parsestring;
246 residual_str = nextcomma + 1;
248 length = strlen(parsestring);
249 residual_str = parsestring + length;
251 if (strncmp("autodetect", parsestring, length) == 0) {
253 MESSAGE (KERN_INFO, "%s",
254 "turning to autodetection mode");
257 if (strncmp("probeonly", parsestring, length) == 0) {
259 MESSAGE(KERN_INFO, "%s",
260 "turning to probeonly mode");
263 if (strncmp("nopav", parsestring, length) == 0) {
265 MESSAGE(KERN_INFO, "%s", "'nopav' not supported on VM");
268 MESSAGE(KERN_INFO, "%s", "disable PAV mode");
272 if (strncmp("fixedbuffers", parsestring, length) == 0) {
276 kmem_cache_create("dasd_page_cache", PAGE_SIZE,
277 PAGE_SIZE, SLAB_CACHE_DMA,
279 if (!dasd_page_cache)
280 MESSAGE(KERN_WARNING, "%s", "Failed to create slab, "
281 "fixed buffer mode disabled.");
283 MESSAGE (KERN_INFO, "%s",
284 "turning on fixed buffer mode");
287 return ERR_PTR(-EINVAL);
291 * Try to interprete the first element on the comma separated parse string
292 * as a device number or a range of devices. If the interpretation is
293 * successfull, create the matching dasd_devmap entries and return a pointer
294 * to the residual string.
295 * If interpretation fails or in case of an error, return an error code.
298 dasd_parse_range( char *parsestring ) {
300 struct dasd_devmap *devmap;
301 int from, from_id0, from_id1;
302 int to, to_id0, to_id1;
304 char bus_id[BUS_ID_SIZE+1], *str;
307 rc = dasd_busid(&str, &from_id0, &from_id1, &from);
314 rc = dasd_busid(&str, &to_id0, &to_id1, &to);
318 (from_id0 != to_id0 || from_id1 != to_id1 || from > to))
321 MESSAGE(KERN_ERR, "Invalid device range %s", parsestring);
324 features = dasd_feature_list(str, &str);
326 return ERR_PTR(-EINVAL);
327 /* each device in dasd= parameter should be set initially online */
328 features |= DASD_FEATURE_INITIAL_ONLINE;
330 sprintf(bus_id, "%01x.%01x.%04x",
331 from_id0, from_id1, from++);
332 devmap = dasd_add_busid(bus_id, features);
334 return (char *)devmap;
340 MESSAGE(KERN_WARNING,
341 "junk at end of dasd parameter string: %s\n", str);
342 return ERR_PTR(-EINVAL);
346 dasd_parse_next_element( char *parsestring ) {
348 residual_str = dasd_parse_keyword(parsestring);
349 if (!IS_ERR(residual_str))
351 residual_str = dasd_parse_range(parsestring);
356 * Parse parameters stored in dasd[]
357 * The 'dasd=...' parameter allows to specify a comma separated list of
358 * keywords and device ranges. When the dasd driver is build into the kernel,
359 * the complete list will be stored as one element of the dasd[] array.
360 * When the dasd driver is build as a module, then the list is broken into
361 * it's elements and each dasd[] entry contains one element.
370 for (i = 0; i < 256; i++) {
373 parsestring = dasd[i];
374 /* loop over the comma separated list in the parsestring */
375 while (*parsestring) {
376 parsestring = dasd_parse_next_element(parsestring);
377 if(IS_ERR(parsestring)) {
378 rc = PTR_ERR(parsestring);
383 DBF_EVENT(DBF_ALERT, "%s", "invalid range found");
391 * Add a devmap for the device specified by busid. It is possible that
392 * the devmap already exists (dasd= parameter). The order of the devices
393 * added through this function will define the kdevs for the individual
396 static struct dasd_devmap *
397 dasd_add_busid(char *bus_id, int features)
399 struct dasd_devmap *devmap, *new, *tmp;
402 new = (struct dasd_devmap *)
403 kzalloc(sizeof(struct dasd_devmap), GFP_KERNEL);
405 return ERR_PTR(-ENOMEM);
406 spin_lock(&dasd_devmap_lock);
408 hash = dasd_hash_busid(bus_id);
409 list_for_each_entry(tmp, &dasd_hashlists[hash], list)
410 if (strncmp(tmp->bus_id, bus_id, BUS_ID_SIZE) == 0) {
415 /* This bus_id is new. */
416 new->devindex = dasd_max_devindex++;
417 strncpy(new->bus_id, bus_id, BUS_ID_SIZE);
418 new->features = features;
420 list_add(&new->list, &dasd_hashlists[hash]);
424 spin_unlock(&dasd_devmap_lock);
430 * Find devmap for device with given bus_id.
432 static struct dasd_devmap *
433 dasd_find_busid(char *bus_id)
435 struct dasd_devmap *devmap, *tmp;
438 spin_lock(&dasd_devmap_lock);
439 devmap = ERR_PTR(-ENODEV);
440 hash = dasd_hash_busid(bus_id);
441 list_for_each_entry(tmp, &dasd_hashlists[hash], list) {
442 if (strncmp(tmp->bus_id, bus_id, BUS_ID_SIZE) == 0) {
447 spin_unlock(&dasd_devmap_lock);
452 * Check if busid has been added to the list of dasd ranges.
455 dasd_busid_known(char *bus_id)
457 return IS_ERR(dasd_find_busid(bus_id)) ? -ENOENT : 0;
461 * Forget all about the device numbers added so far.
462 * This may only be called at module unload or system shutdown.
465 dasd_forget_ranges(void)
467 struct dasd_devmap *devmap, *n;
470 spin_lock(&dasd_devmap_lock);
471 for (i = 0; i < 256; i++) {
472 list_for_each_entry_safe(devmap, n, &dasd_hashlists[i], list) {
473 BUG_ON(devmap->device != NULL);
474 list_del(&devmap->list);
478 spin_unlock(&dasd_devmap_lock);
482 * Find the device struct by its device index.
485 dasd_device_from_devindex(int devindex)
487 struct dasd_devmap *devmap, *tmp;
488 struct dasd_device *device;
491 spin_lock(&dasd_devmap_lock);
493 for (i = 0; (i < 256) && !devmap; i++)
494 list_for_each_entry(tmp, &dasd_hashlists[i], list)
495 if (tmp->devindex == devindex) {
496 /* Found the devmap for the device. */
500 if (devmap && devmap->device) {
501 device = devmap->device;
502 dasd_get_device(device);
504 device = ERR_PTR(-ENODEV);
505 spin_unlock(&dasd_devmap_lock);
510 * Return devmap for cdev. If no devmap exists yet, create one and
511 * connect it to the cdev.
513 static struct dasd_devmap *
514 dasd_devmap_from_cdev(struct ccw_device *cdev)
516 struct dasd_devmap *devmap;
518 devmap = dasd_find_busid(cdev->dev.bus_id);
520 devmap = dasd_add_busid(cdev->dev.bus_id,
521 DASD_FEATURE_DEFAULT);
526 * Create a dasd device structure for cdev.
529 dasd_create_device(struct ccw_device *cdev)
531 struct dasd_devmap *devmap;
532 struct dasd_device *device;
536 devmap = dasd_devmap_from_cdev(cdev);
538 return (void *) devmap;
540 device = dasd_alloc_device();
543 atomic_set(&device->ref_count, 3);
545 spin_lock(&dasd_devmap_lock);
546 if (!devmap->device) {
547 devmap->device = device;
548 device->devindex = devmap->devindex;
549 device->features = devmap->features;
550 get_device(&cdev->dev);
554 /* Someone else was faster. */
556 spin_unlock(&dasd_devmap_lock);
559 dasd_free_device(device);
563 spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
564 cdev->dev.driver_data = device;
565 spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
571 * Wait queue for dasd_delete_device waits.
573 static DECLARE_WAIT_QUEUE_HEAD(dasd_delete_wq);
576 * Remove a dasd device structure. The passed referenced
580 dasd_delete_device(struct dasd_device *device)
582 struct ccw_device *cdev;
583 struct dasd_devmap *devmap;
586 /* First remove device pointer from devmap. */
587 devmap = dasd_find_busid(device->cdev->dev.bus_id);
588 BUG_ON(IS_ERR(devmap));
589 spin_lock(&dasd_devmap_lock);
590 if (devmap->device != device) {
591 spin_unlock(&dasd_devmap_lock);
592 dasd_put_device(device);
595 devmap->device = NULL;
596 spin_unlock(&dasd_devmap_lock);
598 /* Disconnect dasd_device structure from ccw_device structure. */
599 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
600 device->cdev->dev.driver_data = NULL;
601 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
604 * Drop ref_count by 3, one for the devmap reference, one for
605 * the cdev reference and one for the passed reference.
607 atomic_sub(3, &device->ref_count);
609 /* Wait for reference counter to drop to zero. */
610 wait_event(dasd_delete_wq, atomic_read(&device->ref_count) == 0);
612 /* Disconnect dasd_device structure from ccw_device structure. */
616 /* Put ccw_device structure. */
617 put_device(&cdev->dev);
619 /* Now the device structure can be freed. */
620 dasd_free_device(device);
624 * Reference counter dropped to zero. Wake up waiter
625 * in dasd_delete_device.
628 dasd_put_device_wake(struct dasd_device *device)
630 wake_up(&dasd_delete_wq);
634 * Return dasd_device structure associated with cdev.
635 * This function needs to be called with the ccw device
636 * lock held. It can be used from interrupt context.
639 dasd_device_from_cdev_locked(struct ccw_device *cdev)
641 struct dasd_device *device = cdev->dev.driver_data;
644 return ERR_PTR(-ENODEV);
645 dasd_get_device(device);
650 * Return dasd_device structure associated with cdev.
653 dasd_device_from_cdev(struct ccw_device *cdev)
655 struct dasd_device *device;
658 spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
659 device = dasd_device_from_cdev_locked(cdev);
660 spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
665 * SECTION: files in sysfs
669 * readonly controls the readonly status of a dasd
672 dasd_ro_show(struct device *dev, struct device_attribute *attr, char *buf)
674 struct dasd_devmap *devmap;
677 devmap = dasd_find_busid(dev->bus_id);
679 ro_flag = (devmap->features & DASD_FEATURE_READONLY) != 0;
681 ro_flag = (DASD_FEATURE_DEFAULT & DASD_FEATURE_READONLY) != 0;
682 return snprintf(buf, PAGE_SIZE, ro_flag ? "1\n" : "0\n");
686 dasd_ro_store(struct device *dev, struct device_attribute *attr,
687 const char *buf, size_t count)
689 struct dasd_devmap *devmap;
693 devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
695 return PTR_ERR(devmap);
697 val = simple_strtoul(buf, &endp, 0);
698 if (((endp + 1) < (buf + count)) || (val > 1))
701 spin_lock(&dasd_devmap_lock);
703 devmap->features |= DASD_FEATURE_READONLY;
705 devmap->features &= ~DASD_FEATURE_READONLY;
707 devmap->device->features = devmap->features;
708 if (devmap->device && devmap->device->block
709 && devmap->device->block->gdp)
710 set_disk_ro(devmap->device->block->gdp, val);
711 spin_unlock(&dasd_devmap_lock);
715 static DEVICE_ATTR(readonly, 0644, dasd_ro_show, dasd_ro_store);
717 * erplog controls the logging of ERP related data
718 * (e.g. failing channel programs).
721 dasd_erplog_show(struct device *dev, struct device_attribute *attr, char *buf)
723 struct dasd_devmap *devmap;
726 devmap = dasd_find_busid(dev->bus_id);
728 erplog = (devmap->features & DASD_FEATURE_ERPLOG) != 0;
730 erplog = (DASD_FEATURE_DEFAULT & DASD_FEATURE_ERPLOG) != 0;
731 return snprintf(buf, PAGE_SIZE, erplog ? "1\n" : "0\n");
735 dasd_erplog_store(struct device *dev, struct device_attribute *attr,
736 const char *buf, size_t count)
738 struct dasd_devmap *devmap;
742 devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
744 return PTR_ERR(devmap);
746 val = simple_strtoul(buf, &endp, 0);
747 if (((endp + 1) < (buf + count)) || (val > 1))
750 spin_lock(&dasd_devmap_lock);
752 devmap->features |= DASD_FEATURE_ERPLOG;
754 devmap->features &= ~DASD_FEATURE_ERPLOG;
756 devmap->device->features = devmap->features;
757 spin_unlock(&dasd_devmap_lock);
761 static DEVICE_ATTR(erplog, 0644, dasd_erplog_show, dasd_erplog_store);
764 * use_diag controls whether the driver should use diag rather than ssch
765 * to talk to the device
768 dasd_use_diag_show(struct device *dev, struct device_attribute *attr, char *buf)
770 struct dasd_devmap *devmap;
773 devmap = dasd_find_busid(dev->bus_id);
775 use_diag = (devmap->features & DASD_FEATURE_USEDIAG) != 0;
777 use_diag = (DASD_FEATURE_DEFAULT & DASD_FEATURE_USEDIAG) != 0;
778 return sprintf(buf, use_diag ? "1\n" : "0\n");
782 dasd_use_diag_store(struct device *dev, struct device_attribute *attr,
783 const char *buf, size_t count)
785 struct dasd_devmap *devmap;
790 devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
792 return PTR_ERR(devmap);
794 val = simple_strtoul(buf, &endp, 0);
795 if (((endp + 1) < (buf + count)) || (val > 1))
798 spin_lock(&dasd_devmap_lock);
799 /* Changing diag discipline flag is only allowed in offline state. */
801 if (!devmap->device) {
803 devmap->features |= DASD_FEATURE_USEDIAG;
805 devmap->features &= ~DASD_FEATURE_USEDIAG;
808 spin_unlock(&dasd_devmap_lock);
812 static DEVICE_ATTR(use_diag, 0644, dasd_use_diag_show, dasd_use_diag_store);
815 dasd_discipline_show(struct device *dev, struct device_attribute *attr,
818 struct dasd_device *device;
821 device = dasd_device_from_cdev(to_ccwdev(dev));
822 if (!IS_ERR(device) && device->discipline) {
823 len = snprintf(buf, PAGE_SIZE, "%s\n",
824 device->discipline->name);
825 dasd_put_device(device);
827 len = snprintf(buf, PAGE_SIZE, "none\n");
831 static DEVICE_ATTR(discipline, 0444, dasd_discipline_show, NULL);
834 dasd_device_status_show(struct device *dev, struct device_attribute *attr,
837 struct dasd_device *device;
840 device = dasd_device_from_cdev(to_ccwdev(dev));
841 if (!IS_ERR(device)) {
842 switch (device->state) {
844 len = snprintf(buf, PAGE_SIZE, "new\n");
846 case DASD_STATE_KNOWN:
847 len = snprintf(buf, PAGE_SIZE, "detected\n");
849 case DASD_STATE_BASIC:
850 len = snprintf(buf, PAGE_SIZE, "basic\n");
852 case DASD_STATE_UNFMT:
853 len = snprintf(buf, PAGE_SIZE, "unformatted\n");
855 case DASD_STATE_READY:
856 len = snprintf(buf, PAGE_SIZE, "ready\n");
858 case DASD_STATE_ONLINE:
859 len = snprintf(buf, PAGE_SIZE, "online\n");
862 len = snprintf(buf, PAGE_SIZE, "no stat\n");
865 dasd_put_device(device);
867 len = snprintf(buf, PAGE_SIZE, "unknown\n");
871 static DEVICE_ATTR(status, 0444, dasd_device_status_show, NULL);
874 dasd_alias_show(struct device *dev, struct device_attribute *attr, char *buf)
876 struct dasd_devmap *devmap;
879 devmap = dasd_find_busid(dev->bus_id);
880 spin_lock(&dasd_devmap_lock);
881 if (IS_ERR(devmap) || strlen(devmap->uid.vendor) == 0) {
882 spin_unlock(&dasd_devmap_lock);
883 return sprintf(buf, "0\n");
885 if (devmap->uid.type == UA_BASE_PAV_ALIAS ||
886 devmap->uid.type == UA_HYPER_PAV_ALIAS)
890 spin_unlock(&dasd_devmap_lock);
891 return sprintf(buf, alias ? "1\n" : "0\n");
894 static DEVICE_ATTR(alias, 0444, dasd_alias_show, NULL);
897 dasd_vendor_show(struct device *dev, struct device_attribute *attr, char *buf)
899 struct dasd_devmap *devmap;
902 devmap = dasd_find_busid(dev->bus_id);
903 spin_lock(&dasd_devmap_lock);
904 if (!IS_ERR(devmap) && strlen(devmap->uid.vendor) > 0)
905 vendor = devmap->uid.vendor;
908 spin_unlock(&dasd_devmap_lock);
910 return snprintf(buf, PAGE_SIZE, "%s\n", vendor);
913 static DEVICE_ATTR(vendor, 0444, dasd_vendor_show, NULL);
915 #define UID_STRLEN ( /* vendor */ 3 + 1 + /* serial */ 14 + 1 +\
916 /* SSID */ 4 + 1 + /* unit addr */ 2 + 1)
919 dasd_uid_show(struct device *dev, struct device_attribute *attr, char *buf)
921 struct dasd_devmap *devmap;
922 char uid_string[UID_STRLEN];
924 struct dasd_uid *uid;
926 devmap = dasd_find_busid(dev->bus_id);
927 spin_lock(&dasd_devmap_lock);
928 if (IS_ERR(devmap) || strlen(devmap->uid.vendor) == 0) {
929 spin_unlock(&dasd_devmap_lock);
930 return sprintf(buf, "\n");
935 sprintf(ua_string, "%02x", uid->real_unit_addr);
937 case UA_BASE_PAV_ALIAS:
938 sprintf(ua_string, "%02x", uid->base_unit_addr);
940 case UA_HYPER_PAV_ALIAS:
941 sprintf(ua_string, "xx");
944 /* should not happen, treat like base device */
945 sprintf(ua_string, "%02x", uid->real_unit_addr);
948 snprintf(uid_string, sizeof(uid_string), "%s.%s.%04x.%s",
949 uid->vendor, uid->serial, uid->ssid, ua_string);
950 spin_unlock(&dasd_devmap_lock);
951 return snprintf(buf, PAGE_SIZE, "%s\n", uid_string);
954 static DEVICE_ATTR(uid, 0444, dasd_uid_show, NULL);
957 * extended error-reporting
960 dasd_eer_show(struct device *dev, struct device_attribute *attr, char *buf)
962 struct dasd_devmap *devmap;
965 devmap = dasd_find_busid(dev->bus_id);
966 if (!IS_ERR(devmap) && devmap->device)
967 eer_flag = dasd_eer_enabled(devmap->device);
970 return snprintf(buf, PAGE_SIZE, eer_flag ? "1\n" : "0\n");
974 dasd_eer_store(struct device *dev, struct device_attribute *attr,
975 const char *buf, size_t count)
977 struct dasd_devmap *devmap;
981 devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
983 return PTR_ERR(devmap);
987 val = simple_strtoul(buf, &endp, 0);
988 if (((endp + 1) < (buf + count)) || (val > 1))
992 rc = dasd_eer_enable(devmap->device);
996 dasd_eer_disable(devmap->device);
1000 static DEVICE_ATTR(eer_enabled, 0644, dasd_eer_show, dasd_eer_store);
1002 static struct attribute * dasd_attrs[] = {
1003 &dev_attr_readonly.attr,
1004 &dev_attr_discipline.attr,
1005 &dev_attr_status.attr,
1006 &dev_attr_alias.attr,
1007 &dev_attr_vendor.attr,
1009 &dev_attr_use_diag.attr,
1010 &dev_attr_eer_enabled.attr,
1011 &dev_attr_erplog.attr,
1015 static struct attribute_group dasd_attr_group = {
1016 .attrs = dasd_attrs,
1020 * Return copy of the device unique identifier.
1023 dasd_get_uid(struct ccw_device *cdev, struct dasd_uid *uid)
1025 struct dasd_devmap *devmap;
1027 devmap = dasd_find_busid(cdev->dev.bus_id);
1029 return PTR_ERR(devmap);
1030 spin_lock(&dasd_devmap_lock);
1032 spin_unlock(&dasd_devmap_lock);
1037 * Register the given device unique identifier into devmap struct.
1038 * In addition check if the related storage server subsystem ID is already
1039 * contained in the dasd_server_ssid_list. If subsystem ID is not contained,
1041 * Return 0 if server was already in serverlist,
1042 * 1 if the server was added successful
1043 * <0 in case of error.
1046 dasd_set_uid(struct ccw_device *cdev, struct dasd_uid *uid)
1048 struct dasd_devmap *devmap;
1050 devmap = dasd_find_busid(cdev->dev.bus_id);
1052 return PTR_ERR(devmap);
1054 spin_lock(&dasd_devmap_lock);
1056 spin_unlock(&dasd_devmap_lock);
1060 EXPORT_SYMBOL_GPL(dasd_set_uid);
1063 * Return value of the specified feature.
1066 dasd_get_feature(struct ccw_device *cdev, int feature)
1068 struct dasd_devmap *devmap;
1070 devmap = dasd_find_busid(cdev->dev.bus_id);
1072 return PTR_ERR(devmap);
1074 return ((devmap->features & feature) != 0);
1078 * Set / reset given feature.
1079 * Flag indicates wether to set (!=0) or the reset (=0) the feature.
1082 dasd_set_feature(struct ccw_device *cdev, int feature, int flag)
1084 struct dasd_devmap *devmap;
1086 devmap = dasd_find_busid(cdev->dev.bus_id);
1088 return PTR_ERR(devmap);
1090 spin_lock(&dasd_devmap_lock);
1092 devmap->features |= feature;
1094 devmap->features &= ~feature;
1096 devmap->device->features = devmap->features;
1097 spin_unlock(&dasd_devmap_lock);
1103 dasd_add_sysfs_files(struct ccw_device *cdev)
1105 return sysfs_create_group(&cdev->dev.kobj, &dasd_attr_group);
1109 dasd_remove_sysfs_files(struct ccw_device *cdev)
1111 sysfs_remove_group(&cdev->dev.kobj, &dasd_attr_group);
1116 dasd_devmap_init(void)
1120 /* Initialize devmap structures. */
1121 dasd_max_devindex = 0;
1122 for (i = 0; i < 256; i++)
1123 INIT_LIST_HEAD(&dasd_hashlists[i]);
1128 dasd_devmap_exit(void)
1130 dasd_forget_ranges();