1 // SPDX-License-Identifier: GPL-2.0
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 * Copyright IBM Corp. 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 #define KMSG_COMPONENT "dasd"
18 #include <linux/ctype.h>
19 #include <linux/init.h>
20 #include <linux/module.h>
21 #include <linux/slab.h>
23 #include <asm/debug.h>
24 #include <linux/uaccess.h>
28 #define PRINTK_HEADER "dasd_devmap:"
29 #define DASD_BUS_ID_SIZE 20
30 #define DASD_MAX_PARAMS 256
34 struct kmem_cache *dasd_page_cache;
35 EXPORT_SYMBOL_GPL(dasd_page_cache);
38 * dasd_devmap_t is used to store the features and the relation
39 * between device number and device index. To find a dasd_devmap_t
40 * that corresponds to a device number of a device index each
41 * dasd_devmap_t is added to two linked lists, one to search by
42 * the device number and one to search by the device index. As
43 * soon as big minor numbers are available the device index list
44 * can be removed since the device number will then be identical
45 * to the device index.
48 struct list_head list;
49 char bus_id[DASD_BUS_ID_SIZE];
50 unsigned int devindex;
51 unsigned short features;
52 struct dasd_device *device;
56 * Parameter parsing functions for dasd= parameter. The syntax is:
57 * <devno> : (0x)?[0-9a-fA-F]+
58 * <busid> : [0-0a-f]\.[0-9a-f]\.(0x)?[0-9a-fA-F]+
60 * <feature_list> : \(<feature>(:<feature>)*\)
61 * <devno-range> : <devno>(-<devno>)?<feature_list>?
62 * <busid-range> : <busid>(-<busid>)?<feature_list>?
63 * <devices> : <devno-range>|<busid-range>
64 * <dasd_module> : dasd_diag_mod|dasd_eckd_mod|dasd_fba_mod
66 * <dasd> : autodetect|probeonly|<devices>(,<devices>)*
69 int dasd_probeonly = 0; /* is true, when probeonly mode is active */
70 int dasd_autodetect = 0; /* is true, when autodetection is active */
71 int dasd_nopav = 0; /* is true, when PAV is disabled */
72 EXPORT_SYMBOL_GPL(dasd_nopav);
73 int dasd_nofcx; /* disable High Performance Ficon */
74 EXPORT_SYMBOL_GPL(dasd_nofcx);
77 * char *dasd[] is intended to hold the ranges supplied by the dasd= statement
78 * it is named 'dasd' to directly be filled by insmod with the comma separated
79 * strings when running as a module.
81 static char *dasd[DASD_MAX_PARAMS];
82 module_param_array(dasd, charp, NULL, S_IRUGO);
85 * Single spinlock to protect devmap and servermap structures and lists.
87 static DEFINE_SPINLOCK(dasd_devmap_lock);
90 * Hash lists for devmap structures.
92 static struct list_head dasd_hashlists[256];
93 int dasd_max_devindex;
95 static struct dasd_devmap *dasd_add_busid(const char *, int);
98 dasd_hash_busid(const char *bus_id)
103 for (i = 0; (i < DASD_BUS_ID_SIZE) && *bus_id; i++, bus_id++)
109 static int __init dasd_call_setup(char *opt)
111 static int i __initdata;
114 while (i < DASD_MAX_PARAMS) {
115 tmp = strsep(&opt, ",");
125 __setup ("dasd=", dasd_call_setup);
126 #endif /* #ifndef MODULE */
128 #define DASD_IPLDEV "ipldev"
131 * Read a device busid/devno from a string.
133 static int __init dasd_busid(char *str, int *id0, int *id1, int *devno)
138 /* Interpret ipldev busid */
139 if (strncmp(DASD_IPLDEV, str, strlen(DASD_IPLDEV)) == 0) {
140 if (ipl_info.type != IPL_TYPE_CCW) {
141 pr_err("The IPL device is not a CCW device\n");
145 *id1 = ipl_info.data.ccw.dev_id.ssid;
146 *devno = ipl_info.data.ccw.dev_id.devno;
151 /* Old style 0xXXXX or XXXX */
152 if (!kstrtouint(str, 16, &val)) {
160 /* New style x.y.z busid */
161 tok = strsep(&str, ".");
162 if (kstrtouint(tok, 16, &val) || val > 0xff)
166 tok = strsep(&str, ".");
167 if (kstrtouint(tok, 16, &val) || val > 0xff)
171 tok = strsep(&str, ".");
172 if (kstrtouint(tok, 16, &val) || val > 0xffff)
180 * Read colon separated list of dasd features.
182 static int __init dasd_feature_list(char *str)
184 int features, len, rc;
190 return DASD_FEATURE_DEFAULT;
194 str[len] && str[len] != ':' && str[len] != ')'; len++);
195 if (len == 2 && !strncmp(str, "ro", 2))
196 features |= DASD_FEATURE_READONLY;
197 else if (len == 4 && !strncmp(str, "diag", 4))
198 features |= DASD_FEATURE_USEDIAG;
199 else if (len == 3 && !strncmp(str, "raw", 3))
200 features |= DASD_FEATURE_USERAW;
201 else if (len == 6 && !strncmp(str, "erplog", 6))
202 features |= DASD_FEATURE_ERPLOG;
203 else if (len == 8 && !strncmp(str, "failfast", 8))
204 features |= DASD_FEATURE_FAILFAST;
206 pr_warn("%.*s is not a supported device option\n",
216 return rc ? : features;
220 * Try to match the first element on the comma separated parse string
221 * with one of the known keywords. If a keyword is found, take the approprate
222 * action and return a pointer to the residual string. If the first element
223 * could not be matched to any keyword then return an error code.
225 static int __init dasd_parse_keyword(char *keyword)
227 int length = strlen(keyword);
229 if (strncmp("autodetect", keyword, length) == 0) {
231 pr_info("The autodetection mode has been activated\n");
234 if (strncmp("probeonly", keyword, length) == 0) {
236 pr_info("The probeonly mode has been activated\n");
239 if (strncmp("nopav", keyword, length) == 0) {
241 pr_info("'nopav' is not supported on z/VM\n");
244 pr_info("PAV support has be deactivated\n");
248 if (strncmp("nofcx", keyword, length) == 0) {
250 pr_info("High Performance FICON support has been "
254 if (strncmp("fixedbuffers", keyword, length) == 0) {
258 kmem_cache_create("dasd_page_cache", PAGE_SIZE,
259 PAGE_SIZE, SLAB_CACHE_DMA,
261 if (!dasd_page_cache)
262 DBF_EVENT(DBF_WARNING, "%s", "Failed to create slab, "
263 "fixed buffer mode disabled.");
265 DBF_EVENT(DBF_INFO, "%s",
266 "turning on fixed buffer mode");
274 * Split a string of a device range into its pieces and return the from, to, and
275 * feature parts separately.
277 * 0.0.1234-0.0.5678(ro:erplog) -> from: 0.0.1234 to: 0.0.5678 features: ro:erplog
278 * 0.0.8765(raw) -> from: 0.0.8765 to: null features: raw
279 * 0x4321 -> from: 0x4321 to: null features: null
281 static int __init dasd_evaluate_range_param(char *range, char **from_str,
282 char **to_str, char **features_str)
286 /* Do we have a range or a single device? */
287 if (strchr(range, '-')) {
288 *from_str = strsep(&range, "-");
289 *to_str = strsep(&range, "(");
290 *features_str = strsep(&range, ")");
292 *from_str = strsep(&range, "(");
293 *features_str = strsep(&range, ")");
296 if (*features_str && !range) {
297 pr_warn("A closing parenthesis ')' is missing in the dasd= parameter\n");
305 * Try to interprete the range string as a device number or a range of devices.
306 * If the interpretation is successful, create the matching dasd_devmap entries.
307 * If interpretation fails or in case of an error, return an error code.
309 static int __init dasd_parse_range(const char *range)
311 struct dasd_devmap *devmap;
312 int from, from_id0, from_id1;
313 int to, to_id0, to_id1;
315 char bus_id[DASD_BUS_ID_SIZE + 1];
316 char *features_str = NULL;
317 char *from_str = NULL;
322 tmp = kstrdup(range, GFP_KERNEL);
326 if (dasd_evaluate_range_param(tmp, &from_str, &to_str, &features_str)) {
331 if (dasd_busid(from_str, &from_id0, &from_id1, &from)) {
340 if (dasd_busid(to_str, &to_id0, &to_id1, &to)) {
344 if (from_id0 != to_id0 || from_id1 != to_id1 || from > to) {
345 pr_err("%s is not a valid device range\n", range);
351 features = dasd_feature_list(features_str);
356 /* each device in dasd= parameter should be set initially online */
357 features |= DASD_FEATURE_INITIAL_ONLINE;
359 sprintf(bus_id, "%01x.%01x.%04x", from_id0, from_id1, from++);
360 devmap = dasd_add_busid(bus_id, features);
361 if (IS_ERR(devmap)) {
362 rc = PTR_ERR(devmap);
374 * Parse parameters stored in dasd[]
375 * The 'dasd=...' parameter allows to specify a comma separated list of
376 * keywords and device ranges. The parameters in that list will be stored as
377 * separate elementes in dasd[].
379 int __init dasd_parse(void)
385 for (i = 0; i < DASD_MAX_PARAMS; i++) {
392 rc = dasd_parse_keyword(cur);
394 rc = dasd_parse_range(cur);
404 * Add a devmap for the device specified by busid. It is possible that
405 * the devmap already exists (dasd= parameter). The order of the devices
406 * added through this function will define the kdevs for the individual
409 static struct dasd_devmap *
410 dasd_add_busid(const char *bus_id, int features)
412 struct dasd_devmap *devmap, *new, *tmp;
415 new = kzalloc(sizeof(struct dasd_devmap), GFP_KERNEL);
417 return ERR_PTR(-ENOMEM);
418 spin_lock(&dasd_devmap_lock);
420 hash = dasd_hash_busid(bus_id);
421 list_for_each_entry(tmp, &dasd_hashlists[hash], list)
422 if (strncmp(tmp->bus_id, bus_id, DASD_BUS_ID_SIZE) == 0) {
427 /* This bus_id is new. */
428 new->devindex = dasd_max_devindex++;
429 strlcpy(new->bus_id, bus_id, DASD_BUS_ID_SIZE);
430 new->features = features;
432 list_add(&new->list, &dasd_hashlists[hash]);
436 spin_unlock(&dasd_devmap_lock);
442 * Find devmap for device with given bus_id.
444 static struct dasd_devmap *
445 dasd_find_busid(const char *bus_id)
447 struct dasd_devmap *devmap, *tmp;
450 spin_lock(&dasd_devmap_lock);
451 devmap = ERR_PTR(-ENODEV);
452 hash = dasd_hash_busid(bus_id);
453 list_for_each_entry(tmp, &dasd_hashlists[hash], list) {
454 if (strncmp(tmp->bus_id, bus_id, DASD_BUS_ID_SIZE) == 0) {
459 spin_unlock(&dasd_devmap_lock);
464 * Check if busid has been added to the list of dasd ranges.
467 dasd_busid_known(const char *bus_id)
469 return IS_ERR(dasd_find_busid(bus_id)) ? -ENOENT : 0;
473 * Forget all about the device numbers added so far.
474 * This may only be called at module unload or system shutdown.
477 dasd_forget_ranges(void)
479 struct dasd_devmap *devmap, *n;
482 spin_lock(&dasd_devmap_lock);
483 for (i = 0; i < 256; i++) {
484 list_for_each_entry_safe(devmap, n, &dasd_hashlists[i], list) {
485 BUG_ON(devmap->device != NULL);
486 list_del(&devmap->list);
490 spin_unlock(&dasd_devmap_lock);
494 * Find the device struct by its device index.
497 dasd_device_from_devindex(int devindex)
499 struct dasd_devmap *devmap, *tmp;
500 struct dasd_device *device;
503 spin_lock(&dasd_devmap_lock);
505 for (i = 0; (i < 256) && !devmap; i++)
506 list_for_each_entry(tmp, &dasd_hashlists[i], list)
507 if (tmp->devindex == devindex) {
508 /* Found the devmap for the device. */
512 if (devmap && devmap->device) {
513 device = devmap->device;
514 dasd_get_device(device);
516 device = ERR_PTR(-ENODEV);
517 spin_unlock(&dasd_devmap_lock);
522 * Return devmap for cdev. If no devmap exists yet, create one and
523 * connect it to the cdev.
525 static struct dasd_devmap *
526 dasd_devmap_from_cdev(struct ccw_device *cdev)
528 struct dasd_devmap *devmap;
530 devmap = dasd_find_busid(dev_name(&cdev->dev));
532 devmap = dasd_add_busid(dev_name(&cdev->dev),
533 DASD_FEATURE_DEFAULT);
538 * Create a dasd device structure for cdev.
541 dasd_create_device(struct ccw_device *cdev)
543 struct dasd_devmap *devmap;
544 struct dasd_device *device;
548 devmap = dasd_devmap_from_cdev(cdev);
550 return (void *) devmap;
552 device = dasd_alloc_device();
555 atomic_set(&device->ref_count, 3);
557 spin_lock(&dasd_devmap_lock);
558 if (!devmap->device) {
559 devmap->device = device;
560 device->devindex = devmap->devindex;
561 device->features = devmap->features;
562 get_device(&cdev->dev);
566 /* Someone else was faster. */
568 spin_unlock(&dasd_devmap_lock);
571 dasd_free_device(device);
575 spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
576 dev_set_drvdata(&cdev->dev, device);
577 spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
579 device->paths_info = kset_create_and_add("paths_info", NULL,
580 &device->cdev->dev.kobj);
581 if (!device->paths_info)
582 dev_warn(&cdev->dev, "Could not create paths_info kset\n");
588 * Wait queue for dasd_delete_device waits.
590 static DECLARE_WAIT_QUEUE_HEAD(dasd_delete_wq);
593 * Remove a dasd device structure. The passed referenced
597 dasd_delete_device(struct dasd_device *device)
599 struct ccw_device *cdev;
600 struct dasd_devmap *devmap;
603 /* First remove device pointer from devmap. */
604 devmap = dasd_find_busid(dev_name(&device->cdev->dev));
605 BUG_ON(IS_ERR(devmap));
606 spin_lock(&dasd_devmap_lock);
607 if (devmap->device != device) {
608 spin_unlock(&dasd_devmap_lock);
609 dasd_put_device(device);
612 devmap->device = NULL;
613 spin_unlock(&dasd_devmap_lock);
615 /* Disconnect dasd_device structure from ccw_device structure. */
616 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
617 dev_set_drvdata(&device->cdev->dev, NULL);
618 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
621 * Drop ref_count by 3, one for the devmap reference, one for
622 * the cdev reference and one for the passed reference.
624 atomic_sub(3, &device->ref_count);
626 /* Wait for reference counter to drop to zero. */
627 wait_event(dasd_delete_wq, atomic_read(&device->ref_count) == 0);
629 dasd_generic_free_discipline(device);
631 kset_unregister(device->paths_info);
633 /* Disconnect dasd_device structure from ccw_device structure. */
637 /* Put ccw_device structure. */
638 put_device(&cdev->dev);
640 /* Now the device structure can be freed. */
641 dasd_free_device(device);
645 * Reference counter dropped to zero. Wake up waiter
646 * in dasd_delete_device.
649 dasd_put_device_wake(struct dasd_device *device)
651 wake_up(&dasd_delete_wq);
653 EXPORT_SYMBOL_GPL(dasd_put_device_wake);
656 * Return dasd_device structure associated with cdev.
657 * This function needs to be called with the ccw device
658 * lock held. It can be used from interrupt context.
661 dasd_device_from_cdev_locked(struct ccw_device *cdev)
663 struct dasd_device *device = dev_get_drvdata(&cdev->dev);
666 return ERR_PTR(-ENODEV);
667 dasd_get_device(device);
672 * Return dasd_device structure associated with cdev.
675 dasd_device_from_cdev(struct ccw_device *cdev)
677 struct dasd_device *device;
680 spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
681 device = dasd_device_from_cdev_locked(cdev);
682 spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
686 void dasd_add_link_to_gendisk(struct gendisk *gdp, struct dasd_device *device)
688 struct dasd_devmap *devmap;
690 devmap = dasd_find_busid(dev_name(&device->cdev->dev));
693 spin_lock(&dasd_devmap_lock);
694 gdp->private_data = devmap;
695 spin_unlock(&dasd_devmap_lock);
698 struct dasd_device *dasd_device_from_gendisk(struct gendisk *gdp)
700 struct dasd_device *device;
701 struct dasd_devmap *devmap;
703 if (!gdp->private_data)
706 spin_lock(&dasd_devmap_lock);
707 devmap = gdp->private_data;
708 if (devmap && devmap->device) {
709 device = devmap->device;
710 dasd_get_device(device);
712 spin_unlock(&dasd_devmap_lock);
717 * SECTION: files in sysfs
721 * failfast controls the behaviour, if no path is available
723 static ssize_t dasd_ff_show(struct device *dev, struct device_attribute *attr,
726 struct dasd_devmap *devmap;
729 devmap = dasd_find_busid(dev_name(dev));
731 ff_flag = (devmap->features & DASD_FEATURE_FAILFAST) != 0;
733 ff_flag = (DASD_FEATURE_DEFAULT & DASD_FEATURE_FAILFAST) != 0;
734 return snprintf(buf, PAGE_SIZE, ff_flag ? "1\n" : "0\n");
737 static ssize_t dasd_ff_store(struct device *dev, struct device_attribute *attr,
738 const char *buf, size_t count)
743 if (kstrtouint(buf, 0, &val) || val > 1)
746 rc = dasd_set_feature(to_ccwdev(dev), DASD_FEATURE_FAILFAST, val);
751 static DEVICE_ATTR(failfast, 0644, dasd_ff_show, dasd_ff_store);
754 * readonly controls the readonly status of a dasd
757 dasd_ro_show(struct device *dev, struct device_attribute *attr, char *buf)
759 struct dasd_devmap *devmap;
760 struct dasd_device *device;
763 devmap = dasd_find_busid(dev_name(dev));
767 ro_flag = !!(devmap->features & DASD_FEATURE_READONLY);
769 spin_lock(&dasd_devmap_lock);
770 device = devmap->device;
772 ro_flag |= test_bit(DASD_FLAG_DEVICE_RO, &device->flags);
773 spin_unlock(&dasd_devmap_lock);
776 return snprintf(buf, PAGE_SIZE, ro_flag ? "1\n" : "0\n");
780 dasd_ro_store(struct device *dev, struct device_attribute *attr,
781 const char *buf, size_t count)
783 struct ccw_device *cdev = to_ccwdev(dev);
784 struct dasd_device *device;
789 if (kstrtouint(buf, 0, &val) || val > 1)
792 rc = dasd_set_feature(cdev, DASD_FEATURE_READONLY, val);
796 device = dasd_device_from_cdev(cdev);
800 spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
801 val = val || test_bit(DASD_FLAG_DEVICE_RO, &device->flags);
803 if (!device->block || !device->block->gdp ||
804 test_bit(DASD_FLAG_OFFLINE, &device->flags)) {
805 spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
808 /* Increase open_count to avoid losing the block device */
809 atomic_inc(&device->block->open_count);
810 spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
812 set_disk_ro(device->block->gdp, val);
813 atomic_dec(&device->block->open_count);
816 dasd_put_device(device);
821 static DEVICE_ATTR(readonly, 0644, dasd_ro_show, dasd_ro_store);
823 * erplog controls the logging of ERP related data
824 * (e.g. failing channel programs).
827 dasd_erplog_show(struct device *dev, struct device_attribute *attr, char *buf)
829 struct dasd_devmap *devmap;
832 devmap = dasd_find_busid(dev_name(dev));
834 erplog = (devmap->features & DASD_FEATURE_ERPLOG) != 0;
836 erplog = (DASD_FEATURE_DEFAULT & DASD_FEATURE_ERPLOG) != 0;
837 return snprintf(buf, PAGE_SIZE, erplog ? "1\n" : "0\n");
841 dasd_erplog_store(struct device *dev, struct device_attribute *attr,
842 const char *buf, size_t count)
847 if (kstrtouint(buf, 0, &val) || val > 1)
850 rc = dasd_set_feature(to_ccwdev(dev), DASD_FEATURE_ERPLOG, val);
855 static DEVICE_ATTR(erplog, 0644, dasd_erplog_show, dasd_erplog_store);
858 * use_diag controls whether the driver should use diag rather than ssch
859 * to talk to the device
862 dasd_use_diag_show(struct device *dev, struct device_attribute *attr, char *buf)
864 struct dasd_devmap *devmap;
867 devmap = dasd_find_busid(dev_name(dev));
869 use_diag = (devmap->features & DASD_FEATURE_USEDIAG) != 0;
871 use_diag = (DASD_FEATURE_DEFAULT & DASD_FEATURE_USEDIAG) != 0;
872 return sprintf(buf, use_diag ? "1\n" : "0\n");
876 dasd_use_diag_store(struct device *dev, struct device_attribute *attr,
877 const char *buf, size_t count)
879 struct dasd_devmap *devmap;
883 devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
885 return PTR_ERR(devmap);
887 if (kstrtouint(buf, 0, &val) || val > 1)
890 spin_lock(&dasd_devmap_lock);
891 /* Changing diag discipline flag is only allowed in offline state. */
893 if (!devmap->device && !(devmap->features & DASD_FEATURE_USERAW)) {
895 devmap->features |= DASD_FEATURE_USEDIAG;
897 devmap->features &= ~DASD_FEATURE_USEDIAG;
900 spin_unlock(&dasd_devmap_lock);
904 static DEVICE_ATTR(use_diag, 0644, dasd_use_diag_show, dasd_use_diag_store);
907 * use_raw controls whether the driver should give access to raw eckd data or
908 * operate in standard mode
911 dasd_use_raw_show(struct device *dev, struct device_attribute *attr, char *buf)
913 struct dasd_devmap *devmap;
916 devmap = dasd_find_busid(dev_name(dev));
918 use_raw = (devmap->features & DASD_FEATURE_USERAW) != 0;
920 use_raw = (DASD_FEATURE_DEFAULT & DASD_FEATURE_USERAW) != 0;
921 return sprintf(buf, use_raw ? "1\n" : "0\n");
925 dasd_use_raw_store(struct device *dev, struct device_attribute *attr,
926 const char *buf, size_t count)
928 struct dasd_devmap *devmap;
932 devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
934 return PTR_ERR(devmap);
936 if ((kstrtoul(buf, 10, &val) != 0) || val > 1)
939 spin_lock(&dasd_devmap_lock);
940 /* Changing diag discipline flag is only allowed in offline state. */
942 if (!devmap->device && !(devmap->features & DASD_FEATURE_USEDIAG)) {
944 devmap->features |= DASD_FEATURE_USERAW;
946 devmap->features &= ~DASD_FEATURE_USERAW;
949 spin_unlock(&dasd_devmap_lock);
953 static DEVICE_ATTR(raw_track_access, 0644, dasd_use_raw_show,
957 dasd_safe_offline_store(struct device *dev, struct device_attribute *attr,
958 const char *buf, size_t count)
960 struct ccw_device *cdev = to_ccwdev(dev);
961 struct dasd_device *device;
965 spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
966 device = dasd_device_from_cdev_locked(cdev);
967 if (IS_ERR(device)) {
968 rc = PTR_ERR(device);
969 spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
973 if (test_bit(DASD_FLAG_OFFLINE, &device->flags) ||
974 test_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags)) {
975 /* Already doing offline processing */
976 dasd_put_device(device);
977 spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
982 set_bit(DASD_FLAG_SAFE_OFFLINE, &device->flags);
983 dasd_put_device(device);
984 spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
986 rc = ccw_device_set_offline(cdev);
989 return rc ? rc : count;
992 static DEVICE_ATTR(safe_offline, 0200, NULL, dasd_safe_offline_store);
995 dasd_access_show(struct device *dev, struct device_attribute *attr,
998 struct ccw_device *cdev = to_ccwdev(dev);
999 struct dasd_device *device;
1002 device = dasd_device_from_cdev(cdev);
1004 return PTR_ERR(device);
1006 if (!device->discipline)
1008 else if (!device->discipline->host_access_count)
1009 count = -EOPNOTSUPP;
1011 count = device->discipline->host_access_count(device);
1013 dasd_put_device(device);
1017 return sprintf(buf, "%d\n", count);
1020 static DEVICE_ATTR(host_access_count, 0444, dasd_access_show, NULL);
1023 dasd_discipline_show(struct device *dev, struct device_attribute *attr,
1026 struct dasd_device *device;
1029 device = dasd_device_from_cdev(to_ccwdev(dev));
1032 else if (!device->discipline) {
1033 dasd_put_device(device);
1036 len = snprintf(buf, PAGE_SIZE, "%s\n",
1037 device->discipline->name);
1038 dasd_put_device(device);
1042 len = snprintf(buf, PAGE_SIZE, "none\n");
1046 static DEVICE_ATTR(discipline, 0444, dasd_discipline_show, NULL);
1049 dasd_device_status_show(struct device *dev, struct device_attribute *attr,
1052 struct dasd_device *device;
1055 device = dasd_device_from_cdev(to_ccwdev(dev));
1056 if (!IS_ERR(device)) {
1057 switch (device->state) {
1058 case DASD_STATE_NEW:
1059 len = snprintf(buf, PAGE_SIZE, "new\n");
1061 case DASD_STATE_KNOWN:
1062 len = snprintf(buf, PAGE_SIZE, "detected\n");
1064 case DASD_STATE_BASIC:
1065 len = snprintf(buf, PAGE_SIZE, "basic\n");
1067 case DASD_STATE_UNFMT:
1068 len = snprintf(buf, PAGE_SIZE, "unformatted\n");
1070 case DASD_STATE_READY:
1071 len = snprintf(buf, PAGE_SIZE, "ready\n");
1073 case DASD_STATE_ONLINE:
1074 len = snprintf(buf, PAGE_SIZE, "online\n");
1077 len = snprintf(buf, PAGE_SIZE, "no stat\n");
1080 dasd_put_device(device);
1082 len = snprintf(buf, PAGE_SIZE, "unknown\n");
1086 static DEVICE_ATTR(status, 0444, dasd_device_status_show, NULL);
1088 static ssize_t dasd_alias_show(struct device *dev,
1089 struct device_attribute *attr, char *buf)
1091 struct dasd_device *device;
1092 struct dasd_uid uid;
1094 device = dasd_device_from_cdev(to_ccwdev(dev));
1096 return sprintf(buf, "0\n");
1098 if (device->discipline && device->discipline->get_uid &&
1099 !device->discipline->get_uid(device, &uid)) {
1100 if (uid.type == UA_BASE_PAV_ALIAS ||
1101 uid.type == UA_HYPER_PAV_ALIAS) {
1102 dasd_put_device(device);
1103 return sprintf(buf, "1\n");
1106 dasd_put_device(device);
1108 return sprintf(buf, "0\n");
1111 static DEVICE_ATTR(alias, 0444, dasd_alias_show, NULL);
1113 static ssize_t dasd_vendor_show(struct device *dev,
1114 struct device_attribute *attr, char *buf)
1116 struct dasd_device *device;
1117 struct dasd_uid uid;
1120 device = dasd_device_from_cdev(to_ccwdev(dev));
1123 return snprintf(buf, PAGE_SIZE, "%s\n", vendor);
1125 if (device->discipline && device->discipline->get_uid &&
1126 !device->discipline->get_uid(device, &uid))
1127 vendor = uid.vendor;
1129 dasd_put_device(device);
1131 return snprintf(buf, PAGE_SIZE, "%s\n", vendor);
1134 static DEVICE_ATTR(vendor, 0444, dasd_vendor_show, NULL);
1136 #define UID_STRLEN ( /* vendor */ 3 + 1 + /* serial */ 14 + 1 +\
1137 /* SSID */ 4 + 1 + /* unit addr */ 2 + 1 +\
1141 dasd_uid_show(struct device *dev, struct device_attribute *attr, char *buf)
1143 struct dasd_device *device;
1144 struct dasd_uid uid;
1145 char uid_string[UID_STRLEN];
1148 device = dasd_device_from_cdev(to_ccwdev(dev));
1151 return snprintf(buf, PAGE_SIZE, "%s\n", uid_string);
1153 if (device->discipline && device->discipline->get_uid &&
1154 !device->discipline->get_uid(device, &uid)) {
1156 case UA_BASE_DEVICE:
1157 snprintf(ua_string, sizeof(ua_string), "%02x",
1158 uid.real_unit_addr);
1160 case UA_BASE_PAV_ALIAS:
1161 snprintf(ua_string, sizeof(ua_string), "%02x",
1162 uid.base_unit_addr);
1164 case UA_HYPER_PAV_ALIAS:
1165 snprintf(ua_string, sizeof(ua_string), "xx");
1168 /* should not happen, treat like base device */
1169 snprintf(ua_string, sizeof(ua_string), "%02x",
1170 uid.real_unit_addr);
1174 if (strlen(uid.vduit) > 0)
1175 snprintf(uid_string, sizeof(uid_string),
1177 uid.vendor, uid.serial, uid.ssid, ua_string,
1180 snprintf(uid_string, sizeof(uid_string),
1182 uid.vendor, uid.serial, uid.ssid, ua_string);
1184 dasd_put_device(device);
1186 return snprintf(buf, PAGE_SIZE, "%s\n", uid_string);
1188 static DEVICE_ATTR(uid, 0444, dasd_uid_show, NULL);
1191 * extended error-reporting
1194 dasd_eer_show(struct device *dev, struct device_attribute *attr, char *buf)
1196 struct dasd_devmap *devmap;
1199 devmap = dasd_find_busid(dev_name(dev));
1200 if (!IS_ERR(devmap) && devmap->device)
1201 eer_flag = dasd_eer_enabled(devmap->device);
1204 return snprintf(buf, PAGE_SIZE, eer_flag ? "1\n" : "0\n");
1208 dasd_eer_store(struct device *dev, struct device_attribute *attr,
1209 const char *buf, size_t count)
1211 struct dasd_device *device;
1215 device = dasd_device_from_cdev(to_ccwdev(dev));
1217 return PTR_ERR(device);
1219 if (kstrtouint(buf, 0, &val) || val > 1)
1223 rc = dasd_eer_enable(device);
1225 dasd_eer_disable(device);
1227 dasd_put_device(device);
1229 return rc ? : count;
1232 static DEVICE_ATTR(eer_enabled, 0644, dasd_eer_show, dasd_eer_store);
1235 * expiration time for default requests
1238 dasd_expires_show(struct device *dev, struct device_attribute *attr, char *buf)
1240 struct dasd_device *device;
1243 device = dasd_device_from_cdev(to_ccwdev(dev));
1246 len = snprintf(buf, PAGE_SIZE, "%lu\n", device->default_expires);
1247 dasd_put_device(device);
1252 dasd_expires_store(struct device *dev, struct device_attribute *attr,
1253 const char *buf, size_t count)
1255 struct dasd_device *device;
1258 device = dasd_device_from_cdev(to_ccwdev(dev));
1262 if ((kstrtoul(buf, 10, &val) != 0) ||
1263 (val > DASD_EXPIRES_MAX) || val == 0) {
1264 dasd_put_device(device);
1269 device->default_expires = val;
1271 dasd_put_device(device);
1275 static DEVICE_ATTR(expires, 0644, dasd_expires_show, dasd_expires_store);
1278 dasd_retries_show(struct device *dev, struct device_attribute *attr, char *buf)
1280 struct dasd_device *device;
1283 device = dasd_device_from_cdev(to_ccwdev(dev));
1286 len = snprintf(buf, PAGE_SIZE, "%lu\n", device->default_retries);
1287 dasd_put_device(device);
1292 dasd_retries_store(struct device *dev, struct device_attribute *attr,
1293 const char *buf, size_t count)
1295 struct dasd_device *device;
1298 device = dasd_device_from_cdev(to_ccwdev(dev));
1302 if ((kstrtoul(buf, 10, &val) != 0) ||
1303 (val > DASD_RETRIES_MAX)) {
1304 dasd_put_device(device);
1309 device->default_retries = val;
1311 dasd_put_device(device);
1315 static DEVICE_ATTR(retries, 0644, dasd_retries_show, dasd_retries_store);
1318 dasd_timeout_show(struct device *dev, struct device_attribute *attr,
1321 struct dasd_device *device;
1324 device = dasd_device_from_cdev(to_ccwdev(dev));
1327 len = snprintf(buf, PAGE_SIZE, "%lu\n", device->blk_timeout);
1328 dasd_put_device(device);
1333 dasd_timeout_store(struct device *dev, struct device_attribute *attr,
1334 const char *buf, size_t count)
1336 struct dasd_device *device;
1337 struct request_queue *q;
1340 device = dasd_device_from_cdev(to_ccwdev(dev));
1341 if (IS_ERR(device) || !device->block)
1344 if ((kstrtoul(buf, 10, &val) != 0) ||
1345 val > UINT_MAX / HZ) {
1346 dasd_put_device(device);
1349 q = device->block->request_queue;
1351 dasd_put_device(device);
1355 device->blk_timeout = val;
1357 blk_queue_rq_timeout(q, device->blk_timeout * HZ);
1359 dasd_put_device(device);
1363 static DEVICE_ATTR(timeout, 0644,
1364 dasd_timeout_show, dasd_timeout_store);
1368 dasd_path_reset_store(struct device *dev, struct device_attribute *attr,
1369 const char *buf, size_t count)
1371 struct dasd_device *device;
1374 device = dasd_device_from_cdev(to_ccwdev(dev));
1378 if ((kstrtouint(buf, 16, &val) != 0) || val > 0xff)
1381 if (device->discipline && device->discipline->reset_path)
1382 device->discipline->reset_path(device, (__u8) val);
1384 dasd_put_device(device);
1388 static DEVICE_ATTR(path_reset, 0200, NULL, dasd_path_reset_store);
1390 static ssize_t dasd_hpf_show(struct device *dev, struct device_attribute *attr,
1393 struct dasd_device *device;
1396 device = dasd_device_from_cdev(to_ccwdev(dev));
1399 if (!device->discipline || !device->discipline->hpf_enabled) {
1400 dasd_put_device(device);
1401 return snprintf(buf, PAGE_SIZE, "%d\n", dasd_nofcx);
1403 hpf = device->discipline->hpf_enabled(device);
1404 dasd_put_device(device);
1405 return snprintf(buf, PAGE_SIZE, "%d\n", hpf);
1408 static DEVICE_ATTR(hpf, 0444, dasd_hpf_show, NULL);
1410 static ssize_t dasd_reservation_policy_show(struct device *dev,
1411 struct device_attribute *attr,
1414 struct dasd_devmap *devmap;
1417 devmap = dasd_find_busid(dev_name(dev));
1418 if (IS_ERR(devmap)) {
1419 rc = snprintf(buf, PAGE_SIZE, "ignore\n");
1421 spin_lock(&dasd_devmap_lock);
1422 if (devmap->features & DASD_FEATURE_FAILONSLCK)
1423 rc = snprintf(buf, PAGE_SIZE, "fail\n");
1425 rc = snprintf(buf, PAGE_SIZE, "ignore\n");
1426 spin_unlock(&dasd_devmap_lock);
1431 static ssize_t dasd_reservation_policy_store(struct device *dev,
1432 struct device_attribute *attr,
1433 const char *buf, size_t count)
1435 struct ccw_device *cdev = to_ccwdev(dev);
1438 if (sysfs_streq("ignore", buf))
1439 rc = dasd_set_feature(cdev, DASD_FEATURE_FAILONSLCK, 0);
1440 else if (sysfs_streq("fail", buf))
1441 rc = dasd_set_feature(cdev, DASD_FEATURE_FAILONSLCK, 1);
1445 return rc ? : count;
1448 static DEVICE_ATTR(reservation_policy, 0644,
1449 dasd_reservation_policy_show, dasd_reservation_policy_store);
1451 static ssize_t dasd_reservation_state_show(struct device *dev,
1452 struct device_attribute *attr,
1455 struct dasd_device *device;
1458 device = dasd_device_from_cdev(to_ccwdev(dev));
1460 return snprintf(buf, PAGE_SIZE, "none\n");
1462 if (test_bit(DASD_FLAG_IS_RESERVED, &device->flags))
1463 rc = snprintf(buf, PAGE_SIZE, "reserved\n");
1464 else if (test_bit(DASD_FLAG_LOCK_STOLEN, &device->flags))
1465 rc = snprintf(buf, PAGE_SIZE, "lost\n");
1467 rc = snprintf(buf, PAGE_SIZE, "none\n");
1468 dasd_put_device(device);
1472 static ssize_t dasd_reservation_state_store(struct device *dev,
1473 struct device_attribute *attr,
1474 const char *buf, size_t count)
1476 struct dasd_device *device;
1479 device = dasd_device_from_cdev(to_ccwdev(dev));
1482 if (sysfs_streq("reset", buf))
1483 clear_bit(DASD_FLAG_LOCK_STOLEN, &device->flags);
1486 dasd_put_device(device);
1494 static DEVICE_ATTR(last_known_reservation_state, 0644,
1495 dasd_reservation_state_show, dasd_reservation_state_store);
1497 static ssize_t dasd_pm_show(struct device *dev,
1498 struct device_attribute *attr, char *buf)
1500 struct dasd_device *device;
1501 u8 opm, nppm, cablepm, cuirpm, hpfpm, ifccpm;
1503 device = dasd_device_from_cdev(to_ccwdev(dev));
1505 return sprintf(buf, "0\n");
1507 opm = dasd_path_get_opm(device);
1508 nppm = dasd_path_get_nppm(device);
1509 cablepm = dasd_path_get_cablepm(device);
1510 cuirpm = dasd_path_get_cuirpm(device);
1511 hpfpm = dasd_path_get_hpfpm(device);
1512 ifccpm = dasd_path_get_ifccpm(device);
1513 dasd_put_device(device);
1515 return sprintf(buf, "%02x %02x %02x %02x %02x %02x\n", opm, nppm,
1516 cablepm, cuirpm, hpfpm, ifccpm);
1519 static DEVICE_ATTR(path_masks, 0444, dasd_pm_show, NULL);
1522 * threshold value for IFCC/CCC errors
1525 dasd_path_threshold_show(struct device *dev,
1526 struct device_attribute *attr, char *buf)
1528 struct dasd_device *device;
1531 device = dasd_device_from_cdev(to_ccwdev(dev));
1534 len = snprintf(buf, PAGE_SIZE, "%lu\n", device->path_thrhld);
1535 dasd_put_device(device);
1540 dasd_path_threshold_store(struct device *dev, struct device_attribute *attr,
1541 const char *buf, size_t count)
1543 struct dasd_device *device;
1544 unsigned long flags;
1547 device = dasd_device_from_cdev(to_ccwdev(dev));
1551 if (kstrtoul(buf, 10, &val) != 0 || val > DASD_THRHLD_MAX) {
1552 dasd_put_device(device);
1555 spin_lock_irqsave(get_ccwdev_lock(to_ccwdev(dev)), flags);
1556 device->path_thrhld = val;
1557 spin_unlock_irqrestore(get_ccwdev_lock(to_ccwdev(dev)), flags);
1558 dasd_put_device(device);
1561 static DEVICE_ATTR(path_threshold, 0644, dasd_path_threshold_show,
1562 dasd_path_threshold_store);
1565 * configure if path is disabled after IFCC/CCC error threshold is
1569 dasd_path_autodisable_show(struct device *dev,
1570 struct device_attribute *attr, char *buf)
1572 struct dasd_devmap *devmap;
1575 devmap = dasd_find_busid(dev_name(dev));
1576 if (!IS_ERR(devmap))
1577 flag = (devmap->features & DASD_FEATURE_PATH_AUTODISABLE) != 0;
1579 flag = (DASD_FEATURE_DEFAULT &
1580 DASD_FEATURE_PATH_AUTODISABLE) != 0;
1581 return snprintf(buf, PAGE_SIZE, flag ? "1\n" : "0\n");
1585 dasd_path_autodisable_store(struct device *dev,
1586 struct device_attribute *attr,
1587 const char *buf, size_t count)
1592 if (kstrtouint(buf, 0, &val) || val > 1)
1595 rc = dasd_set_feature(to_ccwdev(dev),
1596 DASD_FEATURE_PATH_AUTODISABLE, val);
1598 return rc ? : count;
1601 static DEVICE_ATTR(path_autodisable, 0644,
1602 dasd_path_autodisable_show,
1603 dasd_path_autodisable_store);
1605 * interval for IFCC/CCC checks
1606 * meaning time with no IFCC/CCC error before the error counter
1610 dasd_path_interval_show(struct device *dev,
1611 struct device_attribute *attr, char *buf)
1613 struct dasd_device *device;
1616 device = dasd_device_from_cdev(to_ccwdev(dev));
1619 len = snprintf(buf, PAGE_SIZE, "%lu\n", device->path_interval);
1620 dasd_put_device(device);
1625 dasd_path_interval_store(struct device *dev, struct device_attribute *attr,
1626 const char *buf, size_t count)
1628 struct dasd_device *device;
1629 unsigned long flags;
1632 device = dasd_device_from_cdev(to_ccwdev(dev));
1636 if ((kstrtoul(buf, 10, &val) != 0) ||
1637 (val > DASD_INTERVAL_MAX) || val == 0) {
1638 dasd_put_device(device);
1641 spin_lock_irqsave(get_ccwdev_lock(to_ccwdev(dev)), flags);
1643 device->path_interval = val;
1644 spin_unlock_irqrestore(get_ccwdev_lock(to_ccwdev(dev)), flags);
1645 dasd_put_device(device);
1649 static DEVICE_ATTR(path_interval, 0644, dasd_path_interval_show,
1650 dasd_path_interval_store);
1653 dasd_device_fcs_show(struct device *dev, struct device_attribute *attr,
1656 struct dasd_device *device;
1660 device = dasd_device_from_cdev(to_ccwdev(dev));
1663 fc_sec = dasd_path_get_fcs_device(device);
1664 if (fc_sec == -EINVAL)
1665 rc = snprintf(buf, PAGE_SIZE, "Inconsistent\n");
1667 rc = snprintf(buf, PAGE_SIZE, "%s\n", dasd_path_get_fcs_str(fc_sec));
1668 dasd_put_device(device);
1672 static DEVICE_ATTR(fc_security, 0444, dasd_device_fcs_show, NULL);
1675 dasd_path_fcs_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
1677 struct dasd_path *path = to_dasd_path(kobj);
1678 unsigned int fc_sec = path->fc_security;
1680 return snprintf(buf, PAGE_SIZE, "%s\n", dasd_path_get_fcs_str(fc_sec));
1683 static struct kobj_attribute path_fcs_attribute =
1684 __ATTR(fc_security, 0444, dasd_path_fcs_show, NULL);
1686 #define DASD_DEFINE_ATTR(_name, _func) \
1687 static ssize_t dasd_##_name##_show(struct device *dev, \
1688 struct device_attribute *attr, \
1691 struct ccw_device *cdev = to_ccwdev(dev); \
1692 struct dasd_device *device = dasd_device_from_cdev(cdev); \
1695 if (IS_ERR(device)) \
1697 if (device->discipline && _func) \
1698 val = _func(device); \
1699 dasd_put_device(device); \
1701 return snprintf(buf, PAGE_SIZE, "%d\n", val); \
1703 static DEVICE_ATTR(_name, 0444, dasd_##_name##_show, NULL); \
1705 DASD_DEFINE_ATTR(ese, device->discipline->is_ese);
1706 DASD_DEFINE_ATTR(extent_size, device->discipline->ext_size);
1707 DASD_DEFINE_ATTR(pool_id, device->discipline->ext_pool_id);
1708 DASD_DEFINE_ATTR(space_configured, device->discipline->space_configured);
1709 DASD_DEFINE_ATTR(space_allocated, device->discipline->space_allocated);
1710 DASD_DEFINE_ATTR(logical_capacity, device->discipline->logical_capacity);
1711 DASD_DEFINE_ATTR(warn_threshold, device->discipline->ext_pool_warn_thrshld);
1712 DASD_DEFINE_ATTR(cap_at_warnlevel, device->discipline->ext_pool_cap_at_warnlevel);
1713 DASD_DEFINE_ATTR(pool_oos, device->discipline->ext_pool_oos);
1715 static struct attribute * dasd_attrs[] = {
1716 &dev_attr_readonly.attr,
1717 &dev_attr_discipline.attr,
1718 &dev_attr_status.attr,
1719 &dev_attr_alias.attr,
1720 &dev_attr_vendor.attr,
1722 &dev_attr_use_diag.attr,
1723 &dev_attr_raw_track_access.attr,
1724 &dev_attr_eer_enabled.attr,
1725 &dev_attr_erplog.attr,
1726 &dev_attr_failfast.attr,
1727 &dev_attr_expires.attr,
1728 &dev_attr_retries.attr,
1729 &dev_attr_timeout.attr,
1730 &dev_attr_reservation_policy.attr,
1731 &dev_attr_last_known_reservation_state.attr,
1732 &dev_attr_safe_offline.attr,
1733 &dev_attr_host_access_count.attr,
1734 &dev_attr_path_masks.attr,
1735 &dev_attr_path_threshold.attr,
1736 &dev_attr_path_autodisable.attr,
1737 &dev_attr_path_interval.attr,
1738 &dev_attr_path_reset.attr,
1741 &dev_attr_fc_security.attr,
1745 static const struct attribute_group dasd_attr_group = {
1746 .attrs = dasd_attrs,
1749 static struct attribute *capacity_attrs[] = {
1750 &dev_attr_space_configured.attr,
1751 &dev_attr_space_allocated.attr,
1752 &dev_attr_logical_capacity.attr,
1756 static const struct attribute_group capacity_attr_group = {
1758 .attrs = capacity_attrs,
1761 static struct attribute *ext_pool_attrs[] = {
1762 &dev_attr_pool_id.attr,
1763 &dev_attr_extent_size.attr,
1764 &dev_attr_warn_threshold.attr,
1765 &dev_attr_cap_at_warnlevel.attr,
1766 &dev_attr_pool_oos.attr,
1770 static const struct attribute_group ext_pool_attr_group = {
1771 .name = "extent_pool",
1772 .attrs = ext_pool_attrs,
1775 static const struct attribute_group *dasd_attr_groups[] = {
1777 &capacity_attr_group,
1778 &ext_pool_attr_group,
1783 * Return value of the specified feature.
1786 dasd_get_feature(struct ccw_device *cdev, int feature)
1788 struct dasd_devmap *devmap;
1790 devmap = dasd_find_busid(dev_name(&cdev->dev));
1792 return PTR_ERR(devmap);
1794 return ((devmap->features & feature) != 0);
1798 * Set / reset given feature.
1799 * Flag indicates whether to set (!=0) or the reset (=0) the feature.
1802 dasd_set_feature(struct ccw_device *cdev, int feature, int flag)
1804 struct dasd_devmap *devmap;
1806 devmap = dasd_devmap_from_cdev(cdev);
1808 return PTR_ERR(devmap);
1810 spin_lock(&dasd_devmap_lock);
1812 devmap->features |= feature;
1814 devmap->features &= ~feature;
1816 devmap->device->features = devmap->features;
1817 spin_unlock(&dasd_devmap_lock);
1820 EXPORT_SYMBOL(dasd_set_feature);
1822 static struct attribute *paths_info_attrs[] = {
1823 &path_fcs_attribute.attr,
1827 static struct kobj_type path_attr_type = {
1828 .release = dasd_path_release,
1829 .default_attrs = paths_info_attrs,
1830 .sysfs_ops = &kobj_sysfs_ops,
1833 static void dasd_path_init_kobj(struct dasd_device *device, int chp)
1835 device->path[chp].kobj.kset = device->paths_info;
1836 kobject_init(&device->path[chp].kobj, &path_attr_type);
1839 void dasd_path_create_kobj(struct dasd_device *device, int chp)
1843 if (test_bit(DASD_FLAG_OFFLINE, &device->flags))
1845 if (!device->paths_info) {
1846 dev_warn(&device->cdev->dev, "Unable to create paths objects\n");
1849 if (device->path[chp].in_sysfs)
1851 if (!device->path[chp].conf_data)
1854 dasd_path_init_kobj(device, chp);
1856 rc = kobject_add(&device->path[chp].kobj, NULL, "%x.%02x",
1857 device->path[chp].cssid, device->path[chp].chpid);
1859 kobject_put(&device->path[chp].kobj);
1860 device->path[chp].in_sysfs = true;
1862 EXPORT_SYMBOL(dasd_path_create_kobj);
1864 void dasd_path_create_kobjects(struct dasd_device *device)
1868 opm = dasd_path_get_opm(device);
1869 for (lpm = 0x80; lpm; lpm >>= 1) {
1872 dasd_path_create_kobj(device, pathmask_to_pos(lpm));
1875 EXPORT_SYMBOL(dasd_path_create_kobjects);
1877 static void dasd_path_remove_kobj(struct dasd_device *device, int chp)
1879 if (device->path[chp].in_sysfs) {
1880 kobject_put(&device->path[chp].kobj);
1881 device->path[chp].in_sysfs = false;
1886 * As we keep kobjects for the lifetime of a device, this function must not be
1887 * called anywhere but in the context of offlining a device.
1889 void dasd_path_remove_kobjects(struct dasd_device *device)
1893 for (i = 0; i < 8; i++)
1894 dasd_path_remove_kobj(device, i);
1896 EXPORT_SYMBOL(dasd_path_remove_kobjects);
1898 int dasd_add_sysfs_files(struct ccw_device *cdev)
1900 return sysfs_create_groups(&cdev->dev.kobj, dasd_attr_groups);
1904 dasd_remove_sysfs_files(struct ccw_device *cdev)
1906 sysfs_remove_groups(&cdev->dev.kobj, dasd_attr_groups);
1911 dasd_devmap_init(void)
1915 /* Initialize devmap structures. */
1916 dasd_max_devindex = 0;
1917 for (i = 0; i < 256; i++)
1918 INIT_LIST_HEAD(&dasd_hashlists[i]);
1923 dasd_devmap_exit(void)
1925 dasd_forget_ranges();