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 kmem_cache_t
*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_servermap is used to store the server_id of all storage servers
52 * accessed by DASD device driver.
54 struct dasd_servermap
{
55 struct list_head list
;
62 static struct list_head dasd_serverlist
;
65 * Parameter parsing functions for dasd= parameter. The syntax is:
66 * <devno> : (0x)?[0-9a-fA-F]+
67 * <busid> : [0-0a-f]\.[0-9a-f]\.(0x)?[0-9a-fA-F]+
69 * <feature_list> : \(<feature>(:<feature>)*\)
70 * <devno-range> : <devno>(-<devno>)?<feature_list>?
71 * <busid-range> : <busid>(-<busid>)?<feature_list>?
72 * <devices> : <devno-range>|<busid-range>
73 * <dasd_module> : dasd_diag_mod|dasd_eckd_mod|dasd_fba_mod
75 * <dasd> : autodetect|probeonly|<devices>(,<devices>)*
78 int dasd_probeonly
= 0; /* is true, when probeonly mode is active */
79 int dasd_autodetect
= 0; /* is true, when autodetection is active */
80 int dasd_nopav
= 0; /* is true, when PAV is disabled */
81 EXPORT_SYMBOL_GPL(dasd_nopav
);
84 * char *dasd[] is intended to hold the ranges supplied by the dasd= statement
85 * it is named 'dasd' to directly be filled by insmod with the comma separated
86 * strings when running as a module.
88 static char *dasd
[256];
89 module_param_array(dasd
, charp
, NULL
, 0);
92 * Single spinlock to protect devmap structures and lists.
94 static DEFINE_SPINLOCK(dasd_devmap_lock
);
97 * Hash lists for devmap structures.
99 static struct list_head dasd_hashlists
[256];
100 int dasd_max_devindex
;
102 static struct dasd_devmap
*dasd_add_busid(char *, int);
105 dasd_hash_busid(char *bus_id
)
110 for (i
= 0; (i
< BUS_ID_SIZE
) && *bus_id
; i
++, bus_id
++)
117 * The parameter parsing functions for builtin-drivers are called
118 * before kmalloc works. Store the pointers to the parameters strings
119 * into dasd[] for later processing.
122 dasd_call_setup(char *str
)
124 static int count
= 0;
131 __setup ("dasd=", dasd_call_setup
);
132 #endif /* #ifndef MODULE */
135 * Read a device busid/devno from a string.
138 dasd_busid(char **str
, int *id0
, int *id1
, int *devno
)
142 /* check for leading '0x' */
144 if ((*str
)[0] == '0' && (*str
)[1] == 'x') {
148 if (!isxdigit((*str
)[0])) /* We require at least one hex digit */
150 val
= simple_strtoul(*str
, str
, 16);
151 if (old_style
|| (*str
)[0] != '.') {
153 if (val
< 0 || val
> 0xffff)
158 /* New style x.y.z busid */
159 if (val
< 0 || val
> 0xff)
163 if (!isxdigit((*str
)[0])) /* We require at least one hex digit */
165 val
= simple_strtoul(*str
, str
, 16);
166 if (val
< 0 || val
> 0xff || (*str
)++[0] != '.')
169 if (!isxdigit((*str
)[0])) /* We require at least one hex digit */
171 val
= simple_strtoul(*str
, str
, 16);
172 if (val
< 0 || val
> 0xffff)
179 * Read colon separated list of dasd features. Currently there is
180 * only one: "ro" for read-only devices. The default feature set
181 * is empty (value 0).
184 dasd_feature_list(char *str
, char **endp
)
186 int features
, len
, rc
;
191 return DASD_FEATURE_DEFAULT
;
198 str
[len
] && str
[len
] != ':' && str
[len
] != ')'; len
++);
199 if (len
== 2 && !strncmp(str
, "ro", 2))
200 features
|= DASD_FEATURE_READONLY
;
201 else if (len
== 4 && !strncmp(str
, "diag", 4))
202 features
|= DASD_FEATURE_USEDIAG
;
204 MESSAGE(KERN_WARNING
,
205 "unsupported feature: %*s, "
206 "ignoring setting", len
, str
);
215 MESSAGE(KERN_WARNING
, "%s",
216 "missing ')' in dasd parameter string\n");
227 * Try to match the first element on the comma separated parse string
228 * with one of the known keywords. If a keyword is found, take the approprate
229 * action and return a pointer to the residual string. If the first element
230 * could not be matched to any keyword then return an error code.
233 dasd_parse_keyword( char *parsestring
) {
235 char *nextcomma
, *residual_str
;
238 nextcomma
= strchr(parsestring
,',');
240 length
= nextcomma
- parsestring
;
241 residual_str
= nextcomma
+ 1;
243 length
= strlen(parsestring
);
244 residual_str
= parsestring
+ length
;
246 if (strncmp("autodetect", parsestring
, length
) == 0) {
248 MESSAGE (KERN_INFO
, "%s",
249 "turning to autodetection mode");
252 if (strncmp("probeonly", parsestring
, length
) == 0) {
254 MESSAGE(KERN_INFO
, "%s",
255 "turning to probeonly mode");
258 if (strncmp("nopav", parsestring
, length
) == 0) {
260 MESSAGE(KERN_INFO
, "%s", "disable PAV mode");
263 if (strncmp("fixedbuffers", parsestring
, length
) == 0) {
267 kmem_cache_create("dasd_page_cache", PAGE_SIZE
, 0,
268 SLAB_CACHE_DMA
, NULL
, NULL
);
269 if (!dasd_page_cache
)
270 MESSAGE(KERN_WARNING
, "%s", "Failed to create slab, "
271 "fixed buffer mode disabled.");
273 MESSAGE (KERN_INFO
, "%s",
274 "turning on fixed buffer mode");
277 return ERR_PTR(-EINVAL
);
281 * Try to interprete the first element on the comma separated parse string
282 * as a device number or a range of devices. If the interpretation is
283 * successfull, create the matching dasd_devmap entries and return a pointer
284 * to the residual string.
285 * If interpretation fails or in case of an error, return an error code.
288 dasd_parse_range( char *parsestring
) {
290 struct dasd_devmap
*devmap
;
291 int from
, from_id0
, from_id1
;
292 int to
, to_id0
, to_id1
;
294 char bus_id
[BUS_ID_SIZE
+1], *str
;
297 rc
= dasd_busid(&str
, &from_id0
, &from_id1
, &from
);
304 rc
= dasd_busid(&str
, &to_id0
, &to_id1
, &to
);
308 (from_id0
!= to_id0
|| from_id1
!= to_id1
|| from
> to
))
311 MESSAGE(KERN_ERR
, "Invalid device range %s", parsestring
);
314 features
= dasd_feature_list(str
, &str
);
316 return ERR_PTR(-EINVAL
);
317 /* each device in dasd= parameter should be set initially online */
318 features
|= DASD_FEATURE_INITIAL_ONLINE
;
320 sprintf(bus_id
, "%01x.%01x.%04x",
321 from_id0
, from_id1
, from
++);
322 devmap
= dasd_add_busid(bus_id
, features
);
324 return (char *)devmap
;
330 MESSAGE(KERN_WARNING
,
331 "junk at end of dasd parameter string: %s\n", str
);
332 return ERR_PTR(-EINVAL
);
336 dasd_parse_next_element( char *parsestring
) {
338 residual_str
= dasd_parse_keyword(parsestring
);
339 if (!IS_ERR(residual_str
))
341 residual_str
= dasd_parse_range(parsestring
);
346 * Parse parameters stored in dasd[]
347 * The 'dasd=...' parameter allows to specify a comma separated list of
348 * keywords and device ranges. When the dasd driver is build into the kernel,
349 * the complete list will be stored as one element of the dasd[] array.
350 * When the dasd driver is build as a module, then the list is broken into
351 * it's elements and each dasd[] entry contains one element.
360 for (i
= 0; i
< 256; i
++) {
363 parsestring
= dasd
[i
];
364 /* loop over the comma separated list in the parsestring */
365 while (*parsestring
) {
366 parsestring
= dasd_parse_next_element(parsestring
);
367 if(IS_ERR(parsestring
)) {
368 rc
= PTR_ERR(parsestring
);
373 DBF_EVENT(DBF_ALERT
, "%s", "invalid range found");
381 * Add a devmap for the device specified by busid. It is possible that
382 * the devmap already exists (dasd= parameter). The order of the devices
383 * added through this function will define the kdevs for the individual
386 static struct dasd_devmap
*
387 dasd_add_busid(char *bus_id
, int features
)
389 struct dasd_devmap
*devmap
, *new, *tmp
;
392 new = (struct dasd_devmap
*)
393 kzalloc(sizeof(struct dasd_devmap
), GFP_KERNEL
);
395 return ERR_PTR(-ENOMEM
);
396 spin_lock(&dasd_devmap_lock
);
398 hash
= dasd_hash_busid(bus_id
);
399 list_for_each_entry(tmp
, &dasd_hashlists
[hash
], list
)
400 if (strncmp(tmp
->bus_id
, bus_id
, BUS_ID_SIZE
) == 0) {
405 /* This bus_id is new. */
406 new->devindex
= dasd_max_devindex
++;
407 strncpy(new->bus_id
, bus_id
, BUS_ID_SIZE
);
408 new->features
= features
;
410 list_add(&new->list
, &dasd_hashlists
[hash
]);
414 spin_unlock(&dasd_devmap_lock
);
420 * Find devmap for device with given bus_id.
422 static struct dasd_devmap
*
423 dasd_find_busid(char *bus_id
)
425 struct dasd_devmap
*devmap
, *tmp
;
428 spin_lock(&dasd_devmap_lock
);
429 devmap
= ERR_PTR(-ENODEV
);
430 hash
= dasd_hash_busid(bus_id
);
431 list_for_each_entry(tmp
, &dasd_hashlists
[hash
], list
) {
432 if (strncmp(tmp
->bus_id
, bus_id
, BUS_ID_SIZE
) == 0) {
437 spin_unlock(&dasd_devmap_lock
);
442 * Check if busid has been added to the list of dasd ranges.
445 dasd_busid_known(char *bus_id
)
447 return IS_ERR(dasd_find_busid(bus_id
)) ? -ENOENT
: 0;
451 * Forget all about the device numbers added so far.
452 * This may only be called at module unload or system shutdown.
455 dasd_forget_ranges(void)
457 struct dasd_devmap
*devmap
, *n
;
460 spin_lock(&dasd_devmap_lock
);
461 for (i
= 0; i
< 256; i
++) {
462 list_for_each_entry_safe(devmap
, n
, &dasd_hashlists
[i
], list
) {
463 BUG_ON(devmap
->device
!= NULL
);
464 list_del(&devmap
->list
);
468 spin_unlock(&dasd_devmap_lock
);
472 * Find the device struct by its device index.
475 dasd_device_from_devindex(int devindex
)
477 struct dasd_devmap
*devmap
, *tmp
;
478 struct dasd_device
*device
;
481 spin_lock(&dasd_devmap_lock
);
483 for (i
= 0; (i
< 256) && !devmap
; i
++)
484 list_for_each_entry(tmp
, &dasd_hashlists
[i
], list
)
485 if (tmp
->devindex
== devindex
) {
486 /* Found the devmap for the device. */
490 if (devmap
&& devmap
->device
) {
491 device
= devmap
->device
;
492 dasd_get_device(device
);
494 device
= ERR_PTR(-ENODEV
);
495 spin_unlock(&dasd_devmap_lock
);
500 * Return devmap for cdev. If no devmap exists yet, create one and
501 * connect it to the cdev.
503 static struct dasd_devmap
*
504 dasd_devmap_from_cdev(struct ccw_device
*cdev
)
506 struct dasd_devmap
*devmap
;
508 devmap
= dasd_find_busid(cdev
->dev
.bus_id
);
510 devmap
= dasd_add_busid(cdev
->dev
.bus_id
,
511 DASD_FEATURE_DEFAULT
);
516 * Create a dasd device structure for cdev.
519 dasd_create_device(struct ccw_device
*cdev
)
521 struct dasd_devmap
*devmap
;
522 struct dasd_device
*device
;
525 devmap
= dasd_devmap_from_cdev(cdev
);
527 return (void *) devmap
;
528 cdev
->dev
.driver_data
= devmap
;
530 device
= dasd_alloc_device();
533 atomic_set(&device
->ref_count
, 2);
535 spin_lock(&dasd_devmap_lock
);
536 if (!devmap
->device
) {
537 devmap
->device
= device
;
538 device
->devindex
= devmap
->devindex
;
539 device
->features
= devmap
->features
;
540 get_device(&cdev
->dev
);
544 /* Someone else was faster. */
546 spin_unlock(&dasd_devmap_lock
);
549 dasd_free_device(device
);
556 * Wait queue for dasd_delete_device waits.
558 static DECLARE_WAIT_QUEUE_HEAD(dasd_delete_wq
);
561 * Remove a dasd device structure. The passed referenced
565 dasd_delete_device(struct dasd_device
*device
)
567 struct ccw_device
*cdev
;
568 struct dasd_devmap
*devmap
;
570 /* First remove device pointer from devmap. */
571 devmap
= dasd_find_busid(device
->cdev
->dev
.bus_id
);
572 BUG_ON(IS_ERR(devmap
));
573 spin_lock(&dasd_devmap_lock
);
574 if (devmap
->device
!= device
) {
575 spin_unlock(&dasd_devmap_lock
);
576 dasd_put_device(device
);
579 devmap
->device
= NULL
;
580 spin_unlock(&dasd_devmap_lock
);
582 /* Drop ref_count by 2, one for the devmap reference and
583 * one for the passed reference. */
584 atomic_sub(2, &device
->ref_count
);
586 /* Wait for reference counter to drop to zero. */
587 wait_event(dasd_delete_wq
, atomic_read(&device
->ref_count
) == 0);
589 /* Disconnect dasd_device structure from ccw_device structure. */
593 /* Disconnect dasd_devmap structure from ccw_device structure. */
594 cdev
->dev
.driver_data
= NULL
;
596 /* Put ccw_device structure. */
597 put_device(&cdev
->dev
);
599 /* Now the device structure can be freed. */
600 dasd_free_device(device
);
604 * Reference counter dropped to zero. Wake up waiter
605 * in dasd_delete_device.
608 dasd_put_device_wake(struct dasd_device
*device
)
610 wake_up(&dasd_delete_wq
);
614 * Return dasd_device structure associated with cdev.
617 dasd_device_from_cdev(struct ccw_device
*cdev
)
619 struct dasd_devmap
*devmap
;
620 struct dasd_device
*device
;
622 device
= ERR_PTR(-ENODEV
);
623 spin_lock(&dasd_devmap_lock
);
624 devmap
= cdev
->dev
.driver_data
;
625 if (devmap
&& devmap
->device
) {
626 device
= devmap
->device
;
627 dasd_get_device(device
);
629 spin_unlock(&dasd_devmap_lock
);
634 * SECTION: files in sysfs
638 * readonly controls the readonly status of a dasd
641 dasd_ro_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
643 struct dasd_devmap
*devmap
;
646 devmap
= dasd_find_busid(dev
->bus_id
);
648 ro_flag
= (devmap
->features
& DASD_FEATURE_READONLY
) != 0;
650 ro_flag
= (DASD_FEATURE_DEFAULT
& DASD_FEATURE_READONLY
) != 0;
651 return snprintf(buf
, PAGE_SIZE
, ro_flag
? "1\n" : "0\n");
655 dasd_ro_store(struct device
*dev
, struct device_attribute
*attr
,
656 const char *buf
, size_t count
)
658 struct dasd_devmap
*devmap
;
661 devmap
= dasd_devmap_from_cdev(to_ccwdev(dev
));
663 return PTR_ERR(devmap
);
664 ro_flag
= buf
[0] == '1';
665 spin_lock(&dasd_devmap_lock
);
667 devmap
->features
|= DASD_FEATURE_READONLY
;
669 devmap
->features
&= ~DASD_FEATURE_READONLY
;
671 devmap
->device
->features
= devmap
->features
;
672 if (devmap
->device
&& devmap
->device
->gdp
)
673 set_disk_ro(devmap
->device
->gdp
, ro_flag
);
674 spin_unlock(&dasd_devmap_lock
);
678 static DEVICE_ATTR(readonly
, 0644, dasd_ro_show
, dasd_ro_store
);
681 * use_diag controls whether the driver should use diag rather than ssch
682 * to talk to the device
685 dasd_use_diag_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
687 struct dasd_devmap
*devmap
;
690 devmap
= dasd_find_busid(dev
->bus_id
);
692 use_diag
= (devmap
->features
& DASD_FEATURE_USEDIAG
) != 0;
694 use_diag
= (DASD_FEATURE_DEFAULT
& DASD_FEATURE_USEDIAG
) != 0;
695 return sprintf(buf
, use_diag
? "1\n" : "0\n");
699 dasd_use_diag_store(struct device
*dev
, struct device_attribute
*attr
,
700 const char *buf
, size_t count
)
702 struct dasd_devmap
*devmap
;
706 devmap
= dasd_devmap_from_cdev(to_ccwdev(dev
));
708 return PTR_ERR(devmap
);
709 use_diag
= buf
[0] == '1';
710 spin_lock(&dasd_devmap_lock
);
711 /* Changing diag discipline flag is only allowed in offline state. */
713 if (!devmap
->device
) {
715 devmap
->features
|= DASD_FEATURE_USEDIAG
;
717 devmap
->features
&= ~DASD_FEATURE_USEDIAG
;
720 spin_unlock(&dasd_devmap_lock
);
724 static DEVICE_ATTR(use_diag
, 0644, dasd_use_diag_show
, dasd_use_diag_store
);
727 dasd_discipline_show(struct device
*dev
, struct device_attribute
*attr
,
730 struct dasd_devmap
*devmap
;
733 spin_lock(&dasd_devmap_lock
);
735 devmap
= dev
->driver_data
;
736 if (devmap
&& devmap
->device
&& devmap
->device
->discipline
)
737 dname
= devmap
->device
->discipline
->name
;
738 spin_unlock(&dasd_devmap_lock
);
739 return snprintf(buf
, PAGE_SIZE
, "%s\n", dname
);
742 static DEVICE_ATTR(discipline
, 0444, dasd_discipline_show
, NULL
);
745 dasd_alias_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
747 struct dasd_devmap
*devmap
;
750 devmap
= dasd_find_busid(dev
->bus_id
);
751 spin_lock(&dasd_devmap_lock
);
753 alias
= devmap
->uid
.alias
;
756 spin_unlock(&dasd_devmap_lock
);
758 return sprintf(buf
, alias
? "1\n" : "0\n");
761 static DEVICE_ATTR(alias
, 0444, dasd_alias_show
, NULL
);
764 dasd_vendor_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
766 struct dasd_devmap
*devmap
;
769 devmap
= dasd_find_busid(dev
->bus_id
);
770 spin_lock(&dasd_devmap_lock
);
771 if (!IS_ERR(devmap
) && strlen(devmap
->uid
.vendor
) > 0)
772 vendor
= devmap
->uid
.vendor
;
775 spin_unlock(&dasd_devmap_lock
);
777 return snprintf(buf
, PAGE_SIZE
, "%s\n", vendor
);
780 static DEVICE_ATTR(vendor
, 0444, dasd_vendor_show
, NULL
);
782 #define UID_STRLEN ( /* vendor */ 3 + 1 + /* serial */ 14 + 1 +\
783 /* SSID */ 4 + 1 + /* unit addr */ 2 + 1)
786 dasd_uid_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
788 struct dasd_devmap
*devmap
;
789 char uid
[UID_STRLEN
];
791 devmap
= dasd_find_busid(dev
->bus_id
);
792 spin_lock(&dasd_devmap_lock
);
793 if (!IS_ERR(devmap
) && strlen(devmap
->uid
.vendor
) > 0)
794 snprintf(uid
, sizeof(uid
), "%s.%s.%04x.%02x",
795 devmap
->uid
.vendor
, devmap
->uid
.serial
,
796 devmap
->uid
.ssid
, devmap
->uid
.unit_addr
);
799 spin_unlock(&dasd_devmap_lock
);
801 return snprintf(buf
, PAGE_SIZE
, "%s\n", uid
);
804 static DEVICE_ATTR(uid
, 0444, dasd_uid_show
, NULL
);
807 * extended error-reporting
810 dasd_eer_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
812 struct dasd_devmap
*devmap
;
815 devmap
= dasd_find_busid(dev
->bus_id
);
816 if (!IS_ERR(devmap
) && devmap
->device
)
817 eer_flag
= dasd_eer_enabled(devmap
->device
);
820 return snprintf(buf
, PAGE_SIZE
, eer_flag
? "1\n" : "0\n");
824 dasd_eer_store(struct device
*dev
, struct device_attribute
*attr
,
825 const char *buf
, size_t count
)
827 struct dasd_devmap
*devmap
;
830 devmap
= dasd_devmap_from_cdev(to_ccwdev(dev
));
832 return PTR_ERR(devmap
);
836 rc
= dasd_eer_enable(devmap
->device
);
840 dasd_eer_disable(devmap
->device
);
844 static DEVICE_ATTR(eer_enabled
, 0644, dasd_eer_show
, dasd_eer_store
);
846 static struct attribute
* dasd_attrs
[] = {
847 &dev_attr_readonly
.attr
,
848 &dev_attr_discipline
.attr
,
849 &dev_attr_alias
.attr
,
850 &dev_attr_vendor
.attr
,
852 &dev_attr_use_diag
.attr
,
853 &dev_attr_eer_enabled
.attr
,
857 static struct attribute_group dasd_attr_group
= {
862 * Check if the related storage server is already contained in the
863 * dasd_serverlist. If server is not contained, create new entry.
864 * Return 0 if server was already in serverlist,
865 * 1 if the server was added successfully
866 * <0 in case of error.
869 dasd_add_server(struct dasd_uid
*uid
)
871 struct dasd_servermap
*new, *tmp
;
873 /* check if server is already contained */
874 list_for_each_entry(tmp
, &dasd_serverlist
, list
)
876 if (strncmp(tmp
->sid
.vendor
, uid
->vendor
,
877 sizeof(tmp
->sid
.vendor
)) == 0
878 && strncmp(tmp
->sid
.serial
, uid
->serial
,
879 sizeof(tmp
->sid
.serial
)) == 0)
882 new = (struct dasd_servermap
*)
883 kzalloc(sizeof(struct dasd_servermap
), GFP_KERNEL
);
887 strncpy(new->sid
.vendor
, uid
->vendor
, sizeof(new->sid
.vendor
));
888 strncpy(new->sid
.serial
, uid
->serial
, sizeof(new->sid
.serial
));
889 list_add(&new->list
, &dasd_serverlist
);
895 * Return copy of the device unique identifier.
898 dasd_get_uid(struct ccw_device
*cdev
, struct dasd_uid
*uid
)
900 struct dasd_devmap
*devmap
;
902 devmap
= dasd_find_busid(cdev
->dev
.bus_id
);
904 return PTR_ERR(devmap
);
905 spin_lock(&dasd_devmap_lock
);
907 spin_unlock(&dasd_devmap_lock
);
912 * Register the given device unique identifier into devmap struct.
913 * Return 0 if server was already in serverlist,
914 * 1 if the server was added successful
915 * <0 in case of error.
918 dasd_set_uid(struct ccw_device
*cdev
, struct dasd_uid
*uid
)
920 struct dasd_devmap
*devmap
;
923 devmap
= dasd_find_busid(cdev
->dev
.bus_id
);
925 return PTR_ERR(devmap
);
926 spin_lock(&dasd_devmap_lock
);
928 rc
= dasd_add_server(uid
);
929 spin_unlock(&dasd_devmap_lock
);
932 EXPORT_SYMBOL_GPL(dasd_set_uid
);
935 * Return value of the specified feature.
938 dasd_get_feature(struct ccw_device
*cdev
, int feature
)
940 struct dasd_devmap
*devmap
;
942 devmap
= dasd_find_busid(cdev
->dev
.bus_id
);
944 return PTR_ERR(devmap
);
946 return ((devmap
->features
& feature
) != 0);
950 * Set / reset given feature.
951 * Flag indicates wether to set (!=0) or the reset (=0) the feature.
954 dasd_set_feature(struct ccw_device
*cdev
, int feature
, int flag
)
956 struct dasd_devmap
*devmap
;
958 devmap
= dasd_find_busid(cdev
->dev
.bus_id
);
960 return PTR_ERR(devmap
);
962 spin_lock(&dasd_devmap_lock
);
964 devmap
->features
|= feature
;
966 devmap
->features
&= ~feature
;
968 devmap
->device
->features
= devmap
->features
;
969 spin_unlock(&dasd_devmap_lock
);
975 dasd_add_sysfs_files(struct ccw_device
*cdev
)
977 return sysfs_create_group(&cdev
->dev
.kobj
, &dasd_attr_group
);
981 dasd_remove_sysfs_files(struct ccw_device
*cdev
)
983 sysfs_remove_group(&cdev
->dev
.kobj
, &dasd_attr_group
);
988 dasd_devmap_init(void)
992 /* Initialize devmap structures. */
993 dasd_max_devindex
= 0;
994 for (i
= 0; i
< 256; i
++)
995 INIT_LIST_HEAD(&dasd_hashlists
[i
]);
997 /* Initialize servermap structure. */
998 INIT_LIST_HEAD(&dasd_serverlist
);
1003 dasd_devmap_exit(void)
1005 dasd_forget_ranges();