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>
24 #define PRINTK_HEADER "dasd_devmap:"
28 struct kmem_cache *dasd_page_cache;
29 EXPORT_SYMBOL_GPL(dasd_page_cache);
32 * dasd_devmap_t is used to store the features and the relation
33 * between device number and device index. To find a dasd_devmap_t
34 * that corresponds to a device number of a device index each
35 * dasd_devmap_t is added to two linked lists, one to search by
36 * the device number and one to search by the device index. As
37 * soon as big minor numbers are available the device index list
38 * can be removed since the device number will then be identical
39 * to the device index.
42 struct list_head list;
43 char bus_id[BUS_ID_SIZE];
44 unsigned int devindex;
45 unsigned short features;
46 struct dasd_device *device;
51 * dasd_server_ssid_map contains a globally unique storage server subsystem ID.
52 * dasd_server_ssid_list contains the list of all subsystem IDs accessed by
53 * the DASD device driver.
55 struct dasd_server_ssid_map {
56 struct list_head list;
64 static struct list_head dasd_server_ssid_list;
67 * Parameter parsing functions for dasd= parameter. The syntax is:
68 * <devno> : (0x)?[0-9a-fA-F]+
69 * <busid> : [0-0a-f]\.[0-9a-f]\.(0x)?[0-9a-fA-F]+
71 * <feature_list> : \(<feature>(:<feature>)*\)
72 * <devno-range> : <devno>(-<devno>)?<feature_list>?
73 * <busid-range> : <busid>(-<busid>)?<feature_list>?
74 * <devices> : <devno-range>|<busid-range>
75 * <dasd_module> : dasd_diag_mod|dasd_eckd_mod|dasd_fba_mod
77 * <dasd> : autodetect|probeonly|<devices>(,<devices>)*
80 int dasd_probeonly = 0; /* is true, when probeonly mode is active */
81 int dasd_autodetect = 0; /* is true, when autodetection is active */
82 int dasd_nopav = 0; /* is true, when PAV is disabled */
83 EXPORT_SYMBOL_GPL(dasd_nopav);
86 * char *dasd[] is intended to hold the ranges supplied by the dasd= statement
87 * it is named 'dasd' to directly be filled by insmod with the comma separated
88 * strings when running as a module.
90 static char *dasd[256];
91 module_param_array(dasd, charp, NULL, 0);
94 * Single spinlock to protect devmap and servermap structures and lists.
96 static DEFINE_SPINLOCK(dasd_devmap_lock);
99 * Hash lists for devmap structures.
101 static struct list_head dasd_hashlists[256];
102 int dasd_max_devindex;
104 static struct dasd_devmap *dasd_add_busid(char *, int);
107 dasd_hash_busid(char *bus_id)
112 for (i = 0; (i < BUS_ID_SIZE) && *bus_id; i++, bus_id++)
119 * The parameter parsing functions for builtin-drivers are called
120 * before kmalloc works. Store the pointers to the parameters strings
121 * into dasd[] for later processing.
124 dasd_call_setup(char *str)
126 static int count = 0;
133 __setup ("dasd=", dasd_call_setup);
134 #endif /* #ifndef MODULE */
137 * Read a device busid/devno from a string.
140 dasd_busid(char **str, int *id0, int *id1, int *devno)
144 /* check for leading '0x' */
146 if ((*str)[0] == '0' && (*str)[1] == 'x') {
150 if (!isxdigit((*str)[0])) /* We require at least one hex digit */
152 val = simple_strtoul(*str, str, 16);
153 if (old_style || (*str)[0] != '.') {
155 if (val < 0 || val > 0xffff)
160 /* New style x.y.z busid */
161 if (val < 0 || val > 0xff)
165 if (!isxdigit((*str)[0])) /* We require at least one hex digit */
167 val = simple_strtoul(*str, str, 16);
168 if (val < 0 || val > 0xff || (*str)++[0] != '.')
171 if (!isxdigit((*str)[0])) /* We require at least one hex digit */
173 val = simple_strtoul(*str, str, 16);
174 if (val < 0 || val > 0xffff)
181 * Read colon separated list of dasd features. Currently there is
182 * only one: "ro" for read-only devices. The default feature set
183 * is empty (value 0).
186 dasd_feature_list(char *str, char **endp)
188 int features, len, rc;
193 return DASD_FEATURE_DEFAULT;
200 str[len] && str[len] != ':' && str[len] != ')'; len++);
201 if (len == 2 && !strncmp(str, "ro", 2))
202 features |= DASD_FEATURE_READONLY;
203 else if (len == 4 && !strncmp(str, "diag", 4))
204 features |= DASD_FEATURE_USEDIAG;
205 else if (len == 6 && !strncmp(str, "erplog", 6))
206 features |= DASD_FEATURE_ERPLOG;
208 MESSAGE(KERN_WARNING,
209 "unsupported feature: %*s, "
210 "ignoring setting", len, str);
219 MESSAGE(KERN_WARNING, "%s",
220 "missing ')' in dasd parameter string\n");
231 * Try to match the first element on the comma separated parse string
232 * with one of the known keywords. If a keyword is found, take the approprate
233 * action and return a pointer to the residual string. If the first element
234 * could not be matched to any keyword then return an error code.
237 dasd_parse_keyword( char *parsestring ) {
239 char *nextcomma, *residual_str;
242 nextcomma = strchr(parsestring,',');
244 length = nextcomma - parsestring;
245 residual_str = nextcomma + 1;
247 length = strlen(parsestring);
248 residual_str = parsestring + length;
250 if (strncmp("autodetect", parsestring, length) == 0) {
252 MESSAGE (KERN_INFO, "%s",
253 "turning to autodetection mode");
256 if (strncmp("probeonly", parsestring, length) == 0) {
258 MESSAGE(KERN_INFO, "%s",
259 "turning to probeonly mode");
262 if (strncmp("nopav", parsestring, length) == 0) {
264 MESSAGE(KERN_INFO, "%s", "'nopav' not supported on VM");
267 MESSAGE(KERN_INFO, "%s", "disable PAV mode");
271 if (strncmp("fixedbuffers", parsestring, length) == 0) {
275 kmem_cache_create("dasd_page_cache", PAGE_SIZE,
276 PAGE_SIZE, SLAB_CACHE_DMA,
278 if (!dasd_page_cache)
279 MESSAGE(KERN_WARNING, "%s", "Failed to create slab, "
280 "fixed buffer mode disabled.");
282 MESSAGE (KERN_INFO, "%s",
283 "turning on fixed buffer mode");
286 return ERR_PTR(-EINVAL);
290 * Try to interprete the first element on the comma separated parse string
291 * as a device number or a range of devices. If the interpretation is
292 * successfull, create the matching dasd_devmap entries and return a pointer
293 * to the residual string.
294 * If interpretation fails or in case of an error, return an error code.
297 dasd_parse_range( char *parsestring ) {
299 struct dasd_devmap *devmap;
300 int from, from_id0, from_id1;
301 int to, to_id0, to_id1;
303 char bus_id[BUS_ID_SIZE+1], *str;
306 rc = dasd_busid(&str, &from_id0, &from_id1, &from);
313 rc = dasd_busid(&str, &to_id0, &to_id1, &to);
317 (from_id0 != to_id0 || from_id1 != to_id1 || from > to))
320 MESSAGE(KERN_ERR, "Invalid device range %s", parsestring);
323 features = dasd_feature_list(str, &str);
325 return ERR_PTR(-EINVAL);
326 /* each device in dasd= parameter should be set initially online */
327 features |= DASD_FEATURE_INITIAL_ONLINE;
329 sprintf(bus_id, "%01x.%01x.%04x",
330 from_id0, from_id1, from++);
331 devmap = dasd_add_busid(bus_id, features);
333 return (char *)devmap;
339 MESSAGE(KERN_WARNING,
340 "junk at end of dasd parameter string: %s\n", str);
341 return ERR_PTR(-EINVAL);
345 dasd_parse_next_element( char *parsestring ) {
347 residual_str = dasd_parse_keyword(parsestring);
348 if (!IS_ERR(residual_str))
350 residual_str = dasd_parse_range(parsestring);
355 * Parse parameters stored in dasd[]
356 * The 'dasd=...' parameter allows to specify a comma separated list of
357 * keywords and device ranges. When the dasd driver is build into the kernel,
358 * the complete list will be stored as one element of the dasd[] array.
359 * When the dasd driver is build as a module, then the list is broken into
360 * it's elements and each dasd[] entry contains one element.
369 for (i = 0; i < 256; i++) {
372 parsestring = dasd[i];
373 /* loop over the comma separated list in the parsestring */
374 while (*parsestring) {
375 parsestring = dasd_parse_next_element(parsestring);
376 if(IS_ERR(parsestring)) {
377 rc = PTR_ERR(parsestring);
382 DBF_EVENT(DBF_ALERT, "%s", "invalid range found");
390 * Add a devmap for the device specified by busid. It is possible that
391 * the devmap already exists (dasd= parameter). The order of the devices
392 * added through this function will define the kdevs for the individual
395 static struct dasd_devmap *
396 dasd_add_busid(char *bus_id, int features)
398 struct dasd_devmap *devmap, *new, *tmp;
401 new = (struct dasd_devmap *)
402 kzalloc(sizeof(struct dasd_devmap), GFP_KERNEL);
404 return ERR_PTR(-ENOMEM);
405 spin_lock(&dasd_devmap_lock);
407 hash = dasd_hash_busid(bus_id);
408 list_for_each_entry(tmp, &dasd_hashlists[hash], list)
409 if (strncmp(tmp->bus_id, bus_id, BUS_ID_SIZE) == 0) {
414 /* This bus_id is new. */
415 new->devindex = dasd_max_devindex++;
416 strncpy(new->bus_id, bus_id, BUS_ID_SIZE);
417 new->features = features;
419 list_add(&new->list, &dasd_hashlists[hash]);
423 spin_unlock(&dasd_devmap_lock);
429 * Find devmap for device with given bus_id.
431 static struct dasd_devmap *
432 dasd_find_busid(char *bus_id)
434 struct dasd_devmap *devmap, *tmp;
437 spin_lock(&dasd_devmap_lock);
438 devmap = ERR_PTR(-ENODEV);
439 hash = dasd_hash_busid(bus_id);
440 list_for_each_entry(tmp, &dasd_hashlists[hash], list) {
441 if (strncmp(tmp->bus_id, bus_id, BUS_ID_SIZE) == 0) {
446 spin_unlock(&dasd_devmap_lock);
451 * Check if busid has been added to the list of dasd ranges.
454 dasd_busid_known(char *bus_id)
456 return IS_ERR(dasd_find_busid(bus_id)) ? -ENOENT : 0;
460 * Forget all about the device numbers added so far.
461 * This may only be called at module unload or system shutdown.
464 dasd_forget_ranges(void)
466 struct dasd_devmap *devmap, *n;
469 spin_lock(&dasd_devmap_lock);
470 for (i = 0; i < 256; i++) {
471 list_for_each_entry_safe(devmap, n, &dasd_hashlists[i], list) {
472 BUG_ON(devmap->device != NULL);
473 list_del(&devmap->list);
477 spin_unlock(&dasd_devmap_lock);
481 * Find the device struct by its device index.
484 dasd_device_from_devindex(int devindex)
486 struct dasd_devmap *devmap, *tmp;
487 struct dasd_device *device;
490 spin_lock(&dasd_devmap_lock);
492 for (i = 0; (i < 256) && !devmap; i++)
493 list_for_each_entry(tmp, &dasd_hashlists[i], list)
494 if (tmp->devindex == devindex) {
495 /* Found the devmap for the device. */
499 if (devmap && devmap->device) {
500 device = devmap->device;
501 dasd_get_device(device);
503 device = ERR_PTR(-ENODEV);
504 spin_unlock(&dasd_devmap_lock);
509 * Return devmap for cdev. If no devmap exists yet, create one and
510 * connect it to the cdev.
512 static struct dasd_devmap *
513 dasd_devmap_from_cdev(struct ccw_device *cdev)
515 struct dasd_devmap *devmap;
517 devmap = dasd_find_busid(cdev->dev.bus_id);
519 devmap = dasd_add_busid(cdev->dev.bus_id,
520 DASD_FEATURE_DEFAULT);
525 * Create a dasd device structure for cdev.
528 dasd_create_device(struct ccw_device *cdev)
530 struct dasd_devmap *devmap;
531 struct dasd_device *device;
535 devmap = dasd_devmap_from_cdev(cdev);
537 return (void *) devmap;
539 device = dasd_alloc_device();
542 atomic_set(&device->ref_count, 3);
544 spin_lock(&dasd_devmap_lock);
545 if (!devmap->device) {
546 devmap->device = device;
547 device->devindex = devmap->devindex;
548 device->features = devmap->features;
549 get_device(&cdev->dev);
553 /* Someone else was faster. */
555 spin_unlock(&dasd_devmap_lock);
558 dasd_free_device(device);
562 spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
563 cdev->dev.driver_data = device;
564 spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
570 * Wait queue for dasd_delete_device waits.
572 static DECLARE_WAIT_QUEUE_HEAD(dasd_delete_wq);
575 * Remove a dasd device structure. The passed referenced
579 dasd_delete_device(struct dasd_device *device)
581 struct ccw_device *cdev;
582 struct dasd_devmap *devmap;
585 /* First remove device pointer from devmap. */
586 devmap = dasd_find_busid(device->cdev->dev.bus_id);
587 BUG_ON(IS_ERR(devmap));
588 spin_lock(&dasd_devmap_lock);
589 if (devmap->device != device) {
590 spin_unlock(&dasd_devmap_lock);
591 dasd_put_device(device);
594 devmap->device = NULL;
595 spin_unlock(&dasd_devmap_lock);
597 /* Disconnect dasd_device structure from ccw_device structure. */
598 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
599 device->cdev->dev.driver_data = NULL;
600 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
603 * Drop ref_count by 3, one for the devmap reference, one for
604 * the cdev reference and one for the passed reference.
606 atomic_sub(3, &device->ref_count);
608 /* Wait for reference counter to drop to zero. */
609 wait_event(dasd_delete_wq, atomic_read(&device->ref_count) == 0);
611 /* Disconnect dasd_device structure from ccw_device structure. */
615 /* Put ccw_device structure. */
616 put_device(&cdev->dev);
618 /* Now the device structure can be freed. */
619 dasd_free_device(device);
623 * Reference counter dropped to zero. Wake up waiter
624 * in dasd_delete_device.
627 dasd_put_device_wake(struct dasd_device *device)
629 wake_up(&dasd_delete_wq);
633 * Return dasd_device structure associated with cdev.
634 * This function needs to be called with the ccw device
635 * lock held. It can be used from interrupt context.
638 dasd_device_from_cdev_locked(struct ccw_device *cdev)
640 struct dasd_device *device = cdev->dev.driver_data;
643 return ERR_PTR(-ENODEV);
644 dasd_get_device(device);
649 * Return dasd_device structure associated with cdev.
652 dasd_device_from_cdev(struct ccw_device *cdev)
654 struct dasd_device *device;
657 spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
658 device = dasd_device_from_cdev_locked(cdev);
659 spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
664 * SECTION: files in sysfs
668 * readonly controls the readonly status of a dasd
671 dasd_ro_show(struct device *dev, struct device_attribute *attr, char *buf)
673 struct dasd_devmap *devmap;
676 devmap = dasd_find_busid(dev->bus_id);
678 ro_flag = (devmap->features & DASD_FEATURE_READONLY) != 0;
680 ro_flag = (DASD_FEATURE_DEFAULT & DASD_FEATURE_READONLY) != 0;
681 return snprintf(buf, PAGE_SIZE, ro_flag ? "1\n" : "0\n");
685 dasd_ro_store(struct device *dev, struct device_attribute *attr,
686 const char *buf, size_t count)
688 struct dasd_devmap *devmap;
692 devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
694 return PTR_ERR(devmap);
696 val = simple_strtoul(buf, &endp, 0);
697 if (((endp + 1) < (buf + count)) || (val > 1))
700 spin_lock(&dasd_devmap_lock);
702 devmap->features |= DASD_FEATURE_READONLY;
704 devmap->features &= ~DASD_FEATURE_READONLY;
706 devmap->device->features = devmap->features;
707 if (devmap->device && devmap->device->gdp)
708 set_disk_ro(devmap->device->gdp, val);
709 spin_unlock(&dasd_devmap_lock);
713 static DEVICE_ATTR(readonly, 0644, dasd_ro_show, dasd_ro_store);
715 * erplog controls the logging of ERP related data
716 * (e.g. failing channel programs).
719 dasd_erplog_show(struct device *dev, struct device_attribute *attr, char *buf)
721 struct dasd_devmap *devmap;
724 devmap = dasd_find_busid(dev->bus_id);
726 erplog = (devmap->features & DASD_FEATURE_ERPLOG) != 0;
728 erplog = (DASD_FEATURE_DEFAULT & DASD_FEATURE_ERPLOG) != 0;
729 return snprintf(buf, PAGE_SIZE, erplog ? "1\n" : "0\n");
733 dasd_erplog_store(struct device *dev, struct device_attribute *attr,
734 const char *buf, size_t count)
736 struct dasd_devmap *devmap;
740 devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
742 return PTR_ERR(devmap);
744 val = simple_strtoul(buf, &endp, 0);
745 if (((endp + 1) < (buf + count)) || (val > 1))
748 spin_lock(&dasd_devmap_lock);
750 devmap->features |= DASD_FEATURE_ERPLOG;
752 devmap->features &= ~DASD_FEATURE_ERPLOG;
754 devmap->device->features = devmap->features;
755 spin_unlock(&dasd_devmap_lock);
759 static DEVICE_ATTR(erplog, 0644, dasd_erplog_show, dasd_erplog_store);
762 * use_diag controls whether the driver should use diag rather than ssch
763 * to talk to the device
766 dasd_use_diag_show(struct device *dev, struct device_attribute *attr, char *buf)
768 struct dasd_devmap *devmap;
771 devmap = dasd_find_busid(dev->bus_id);
773 use_diag = (devmap->features & DASD_FEATURE_USEDIAG) != 0;
775 use_diag = (DASD_FEATURE_DEFAULT & DASD_FEATURE_USEDIAG) != 0;
776 return sprintf(buf, use_diag ? "1\n" : "0\n");
780 dasd_use_diag_store(struct device *dev, struct device_attribute *attr,
781 const char *buf, size_t count)
783 struct dasd_devmap *devmap;
788 devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
790 return PTR_ERR(devmap);
792 val = simple_strtoul(buf, &endp, 0);
793 if (((endp + 1) < (buf + count)) || (val > 1))
796 spin_lock(&dasd_devmap_lock);
797 /* Changing diag discipline flag is only allowed in offline state. */
799 if (!devmap->device) {
801 devmap->features |= DASD_FEATURE_USEDIAG;
803 devmap->features &= ~DASD_FEATURE_USEDIAG;
806 spin_unlock(&dasd_devmap_lock);
810 static DEVICE_ATTR(use_diag, 0644, dasd_use_diag_show, dasd_use_diag_store);
813 dasd_discipline_show(struct device *dev, struct device_attribute *attr,
816 struct dasd_device *device;
819 device = dasd_device_from_cdev(to_ccwdev(dev));
820 if (!IS_ERR(device) && device->discipline) {
821 len = snprintf(buf, PAGE_SIZE, "%s\n",
822 device->discipline->name);
823 dasd_put_device(device);
825 len = snprintf(buf, PAGE_SIZE, "none\n");
829 static DEVICE_ATTR(discipline, 0444, dasd_discipline_show, NULL);
832 dasd_alias_show(struct device *dev, struct device_attribute *attr, char *buf)
834 struct dasd_devmap *devmap;
837 devmap = dasd_find_busid(dev->bus_id);
838 spin_lock(&dasd_devmap_lock);
840 alias = devmap->uid.alias;
843 spin_unlock(&dasd_devmap_lock);
845 return sprintf(buf, alias ? "1\n" : "0\n");
848 static DEVICE_ATTR(alias, 0444, dasd_alias_show, NULL);
851 dasd_vendor_show(struct device *dev, struct device_attribute *attr, char *buf)
853 struct dasd_devmap *devmap;
856 devmap = dasd_find_busid(dev->bus_id);
857 spin_lock(&dasd_devmap_lock);
858 if (!IS_ERR(devmap) && strlen(devmap->uid.vendor) > 0)
859 vendor = devmap->uid.vendor;
862 spin_unlock(&dasd_devmap_lock);
864 return snprintf(buf, PAGE_SIZE, "%s\n", vendor);
867 static DEVICE_ATTR(vendor, 0444, dasd_vendor_show, NULL);
869 #define UID_STRLEN ( /* vendor */ 3 + 1 + /* serial */ 14 + 1 +\
870 /* SSID */ 4 + 1 + /* unit addr */ 2 + 1)
873 dasd_uid_show(struct device *dev, struct device_attribute *attr, char *buf)
875 struct dasd_devmap *devmap;
876 char uid[UID_STRLEN];
878 devmap = dasd_find_busid(dev->bus_id);
879 spin_lock(&dasd_devmap_lock);
880 if (!IS_ERR(devmap) && strlen(devmap->uid.vendor) > 0)
881 snprintf(uid, sizeof(uid), "%s.%s.%04x.%02x",
882 devmap->uid.vendor, devmap->uid.serial,
883 devmap->uid.ssid, devmap->uid.unit_addr);
886 spin_unlock(&dasd_devmap_lock);
888 return snprintf(buf, PAGE_SIZE, "%s\n", uid);
891 static DEVICE_ATTR(uid, 0444, dasd_uid_show, NULL);
894 * extended error-reporting
897 dasd_eer_show(struct device *dev, struct device_attribute *attr, char *buf)
899 struct dasd_devmap *devmap;
902 devmap = dasd_find_busid(dev->bus_id);
903 if (!IS_ERR(devmap) && devmap->device)
904 eer_flag = dasd_eer_enabled(devmap->device);
907 return snprintf(buf, PAGE_SIZE, eer_flag ? "1\n" : "0\n");
911 dasd_eer_store(struct device *dev, struct device_attribute *attr,
912 const char *buf, size_t count)
914 struct dasd_devmap *devmap;
918 devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
920 return PTR_ERR(devmap);
924 val = simple_strtoul(buf, &endp, 0);
925 if (((endp + 1) < (buf + count)) || (val > 1))
929 rc = dasd_eer_enable(devmap->device);
933 dasd_eer_disable(devmap->device);
937 static DEVICE_ATTR(eer_enabled, 0644, dasd_eer_show, dasd_eer_store);
939 static struct attribute * dasd_attrs[] = {
940 &dev_attr_readonly.attr,
941 &dev_attr_discipline.attr,
942 &dev_attr_alias.attr,
943 &dev_attr_vendor.attr,
945 &dev_attr_use_diag.attr,
946 &dev_attr_eer_enabled.attr,
947 &dev_attr_erplog.attr,
951 static struct attribute_group dasd_attr_group = {
956 * Return copy of the device unique identifier.
959 dasd_get_uid(struct ccw_device *cdev, struct dasd_uid *uid)
961 struct dasd_devmap *devmap;
963 devmap = dasd_find_busid(cdev->dev.bus_id);
965 return PTR_ERR(devmap);
966 spin_lock(&dasd_devmap_lock);
968 spin_unlock(&dasd_devmap_lock);
973 * Register the given device unique identifier into devmap struct.
974 * In addition check if the related storage server subsystem ID is already
975 * contained in the dasd_server_ssid_list. If subsystem ID is not contained,
977 * Return 0 if server was already in serverlist,
978 * 1 if the server was added successful
979 * <0 in case of error.
982 dasd_set_uid(struct ccw_device *cdev, struct dasd_uid *uid)
984 struct dasd_devmap *devmap;
985 struct dasd_server_ssid_map *srv, *tmp;
987 devmap = dasd_find_busid(cdev->dev.bus_id);
989 return PTR_ERR(devmap);
991 /* generate entry for server_ssid_map */
992 srv = (struct dasd_server_ssid_map *)
993 kzalloc(sizeof(struct dasd_server_ssid_map), GFP_KERNEL);
996 strncpy(srv->sid.vendor, uid->vendor, sizeof(srv->sid.vendor) - 1);
997 strncpy(srv->sid.serial, uid->serial, sizeof(srv->sid.serial) - 1);
998 srv->sid.ssid = uid->ssid;
1000 /* server is already contained ? */
1001 spin_lock(&dasd_devmap_lock);
1003 list_for_each_entry(tmp, &dasd_server_ssid_list, list) {
1004 if (!memcmp(&srv->sid, &tmp->sid,
1005 sizeof(struct system_id))) {
1012 /* add servermap to serverlist */
1014 list_add(&srv->list, &dasd_server_ssid_list);
1015 spin_unlock(&dasd_devmap_lock);
1017 return (srv ? 1 : 0);
1019 EXPORT_SYMBOL_GPL(dasd_set_uid);
1022 * Return value of the specified feature.
1025 dasd_get_feature(struct ccw_device *cdev, int feature)
1027 struct dasd_devmap *devmap;
1029 devmap = dasd_find_busid(cdev->dev.bus_id);
1031 return PTR_ERR(devmap);
1033 return ((devmap->features & feature) != 0);
1037 * Set / reset given feature.
1038 * Flag indicates wether to set (!=0) or the reset (=0) the feature.
1041 dasd_set_feature(struct ccw_device *cdev, int feature, int flag)
1043 struct dasd_devmap *devmap;
1045 devmap = dasd_find_busid(cdev->dev.bus_id);
1047 return PTR_ERR(devmap);
1049 spin_lock(&dasd_devmap_lock);
1051 devmap->features |= feature;
1053 devmap->features &= ~feature;
1055 devmap->device->features = devmap->features;
1056 spin_unlock(&dasd_devmap_lock);
1062 dasd_add_sysfs_files(struct ccw_device *cdev)
1064 return sysfs_create_group(&cdev->dev.kobj, &dasd_attr_group);
1068 dasd_remove_sysfs_files(struct ccw_device *cdev)
1070 sysfs_remove_group(&cdev->dev.kobj, &dasd_attr_group);
1075 dasd_devmap_init(void)
1079 /* Initialize devmap structures. */
1080 dasd_max_devindex = 0;
1081 for (i = 0; i < 256; i++)
1082 INIT_LIST_HEAD(&dasd_hashlists[i]);
1084 /* Initialize servermap structure. */
1085 INIT_LIST_HEAD(&dasd_server_ssid_list);
1090 dasd_devmap_exit(void)
1092 dasd_forget_ranges();