| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 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 | 
|  | 9 | * | 
|  | 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. | 
|  | 13 | * | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | */ | 
|  | 15 |  | 
|  | 16 | #include <linux/config.h> | 
|  | 17 | #include <linux/ctype.h> | 
|  | 18 | #include <linux/init.h> | 
| Rusty Russell | 8d3b33f | 2006-03-25 03:07:05 -0800 | [diff] [blame] | 19 | #include <linux/module.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 |  | 
|  | 21 | #include <asm/debug.h> | 
|  | 22 | #include <asm/uaccess.h> | 
|  | 23 |  | 
|  | 24 | /* This is ugly... */ | 
|  | 25 | #define PRINTK_HEADER "dasd_devmap:" | 
|  | 26 |  | 
|  | 27 | #include "dasd_int.h" | 
|  | 28 |  | 
|  | 29 | kmem_cache_t *dasd_page_cache; | 
|  | 30 | EXPORT_SYMBOL(dasd_page_cache); | 
|  | 31 |  | 
|  | 32 | /* | 
|  | 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. | 
|  | 41 | */ | 
|  | 42 | struct dasd_devmap { | 
|  | 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; | 
| Horst Hummel | 3d05259 | 2006-04-27 18:40:28 -0700 | [diff] [blame^] | 48 | struct dasd_uid uid; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | }; | 
|  | 50 |  | 
|  | 51 | /* | 
|  | 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]+ | 
|  | 55 | *   <feature>		: ro | 
|  | 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 | 
|  | 61 | * | 
|  | 62 | *   <dasd>		: autodetect|probeonly|<devices>(,<devices>)* | 
|  | 63 | */ | 
|  | 64 |  | 
|  | 65 | int dasd_probeonly =  0;	/* is true, when probeonly mode is active */ | 
|  | 66 | int dasd_autodetect = 0;	/* is true, when autodetection is active */ | 
|  | 67 |  | 
|  | 68 | /* | 
|  | 69 | * char *dasd[] is intended to hold the ranges supplied by the dasd= statement | 
|  | 70 | * it is named 'dasd' to directly be filled by insmod with the comma separated | 
|  | 71 | * strings when running as a module. | 
|  | 72 | */ | 
|  | 73 | static char *dasd[256]; | 
| Rusty Russell | 8d3b33f | 2006-03-25 03:07:05 -0800 | [diff] [blame] | 74 | module_param_array(dasd, charp, NULL, 0); | 
|  | 75 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | /* | 
|  | 77 | * Single spinlock to protect devmap structures and lists. | 
|  | 78 | */ | 
|  | 79 | static DEFINE_SPINLOCK(dasd_devmap_lock); | 
|  | 80 |  | 
|  | 81 | /* | 
|  | 82 | * Hash lists for devmap structures. | 
|  | 83 | */ | 
|  | 84 | static struct list_head dasd_hashlists[256]; | 
|  | 85 | int dasd_max_devindex; | 
|  | 86 |  | 
|  | 87 | static struct dasd_devmap *dasd_add_busid(char *, int); | 
|  | 88 |  | 
|  | 89 | static inline int | 
|  | 90 | dasd_hash_busid(char *bus_id) | 
|  | 91 | { | 
|  | 92 | int hash, i; | 
|  | 93 |  | 
|  | 94 | hash = 0; | 
|  | 95 | for (i = 0; (i < BUS_ID_SIZE) && *bus_id; i++, bus_id++) | 
|  | 96 | hash += *bus_id; | 
|  | 97 | return hash & 0xff; | 
|  | 98 | } | 
|  | 99 |  | 
|  | 100 | #ifndef MODULE | 
|  | 101 | /* | 
|  | 102 | * The parameter parsing functions for builtin-drivers are called | 
|  | 103 | * before kmalloc works. Store the pointers to the parameters strings | 
|  | 104 | * into dasd[] for later processing. | 
|  | 105 | */ | 
|  | 106 | static int __init | 
|  | 107 | dasd_call_setup(char *str) | 
|  | 108 | { | 
|  | 109 | static int count = 0; | 
|  | 110 |  | 
|  | 111 | if (count < 256) | 
|  | 112 | dasd[count++] = str; | 
|  | 113 | return 1; | 
|  | 114 | } | 
|  | 115 |  | 
|  | 116 | __setup ("dasd=", dasd_call_setup); | 
|  | 117 | #endif	/* #ifndef MODULE */ | 
|  | 118 |  | 
|  | 119 | /* | 
|  | 120 | * Read a device busid/devno from a string. | 
|  | 121 | */ | 
|  | 122 | static inline int | 
|  | 123 | dasd_busid(char **str, int *id0, int *id1, int *devno) | 
|  | 124 | { | 
|  | 125 | int val, old_style; | 
|  | 126 |  | 
|  | 127 | /* check for leading '0x' */ | 
|  | 128 | old_style = 0; | 
|  | 129 | if ((*str)[0] == '0' && (*str)[1] == 'x') { | 
|  | 130 | *str += 2; | 
|  | 131 | old_style = 1; | 
|  | 132 | } | 
|  | 133 | if (!isxdigit((*str)[0]))	/* We require at least one hex digit */ | 
|  | 134 | return -EINVAL; | 
|  | 135 | val = simple_strtoul(*str, str, 16); | 
|  | 136 | if (old_style || (*str)[0] != '.') { | 
|  | 137 | *id0 = *id1 = 0; | 
|  | 138 | if (val < 0 || val > 0xffff) | 
|  | 139 | return -EINVAL; | 
|  | 140 | *devno = val; | 
|  | 141 | return 0; | 
|  | 142 | } | 
|  | 143 | /* New style x.y.z busid */ | 
|  | 144 | if (val < 0 || val > 0xff) | 
|  | 145 | return -EINVAL; | 
|  | 146 | *id0 = val; | 
|  | 147 | (*str)++; | 
|  | 148 | if (!isxdigit((*str)[0]))	/* We require at least one hex digit */ | 
|  | 149 | return -EINVAL; | 
|  | 150 | val = simple_strtoul(*str, str, 16); | 
|  | 151 | if (val < 0 || val > 0xff || (*str)++[0] != '.') | 
|  | 152 | return -EINVAL; | 
|  | 153 | *id1 = val; | 
|  | 154 | if (!isxdigit((*str)[0]))	/* We require at least one hex digit */ | 
|  | 155 | return -EINVAL; | 
|  | 156 | val = simple_strtoul(*str, str, 16); | 
|  | 157 | if (val < 0 || val > 0xffff) | 
|  | 158 | return -EINVAL; | 
|  | 159 | *devno = val; | 
|  | 160 | return 0; | 
|  | 161 | } | 
|  | 162 |  | 
|  | 163 | /* | 
|  | 164 | * Read colon separated list of dasd features. Currently there is | 
|  | 165 | * only one: "ro" for read-only devices. The default feature set | 
|  | 166 | * is empty (value 0). | 
|  | 167 | */ | 
|  | 168 | static inline int | 
|  | 169 | dasd_feature_list(char *str, char **endp) | 
|  | 170 | { | 
|  | 171 | int features, len, rc; | 
|  | 172 |  | 
|  | 173 | rc = 0; | 
|  | 174 | if (*str != '(') { | 
|  | 175 | *endp = str; | 
|  | 176 | return DASD_FEATURE_DEFAULT; | 
|  | 177 | } | 
|  | 178 | str++; | 
|  | 179 | features = 0; | 
|  | 180 |  | 
|  | 181 | while (1) { | 
|  | 182 | for (len = 0; | 
|  | 183 | str[len] && str[len] != ':' && str[len] != ')'; len++); | 
|  | 184 | if (len == 2 && !strncmp(str, "ro", 2)) | 
|  | 185 | features |= DASD_FEATURE_READONLY; | 
|  | 186 | else if (len == 4 && !strncmp(str, "diag", 4)) | 
|  | 187 | features |= DASD_FEATURE_USEDIAG; | 
|  | 188 | else { | 
|  | 189 | MESSAGE(KERN_WARNING, | 
|  | 190 | "unsupported feature: %*s, " | 
|  | 191 | "ignoring setting", len, str); | 
|  | 192 | rc = -EINVAL; | 
|  | 193 | } | 
|  | 194 | str += len; | 
|  | 195 | if (*str != ':') | 
|  | 196 | break; | 
|  | 197 | str++; | 
|  | 198 | } | 
|  | 199 | if (*str != ')') { | 
|  | 200 | MESSAGE(KERN_WARNING, "%s", | 
|  | 201 | "missing ')' in dasd parameter string\n"); | 
|  | 202 | rc = -EINVAL; | 
|  | 203 | } else | 
|  | 204 | str++; | 
|  | 205 | *endp = str; | 
|  | 206 | if (rc != 0) | 
|  | 207 | return rc; | 
|  | 208 | return features; | 
|  | 209 | } | 
|  | 210 |  | 
|  | 211 | /* | 
|  | 212 | * Try to match the first element on the comma separated parse string | 
|  | 213 | * with one of the known keywords. If a keyword is found, take the approprate | 
|  | 214 | * action and return a pointer to the residual string. If the first element | 
|  | 215 | * could not be matched to any keyword then return an error code. | 
|  | 216 | */ | 
|  | 217 | static char * | 
|  | 218 | dasd_parse_keyword( char *parsestring ) { | 
|  | 219 |  | 
|  | 220 | char *nextcomma, *residual_str; | 
|  | 221 | int length; | 
|  | 222 |  | 
|  | 223 | nextcomma = strchr(parsestring,','); | 
|  | 224 | if (nextcomma) { | 
|  | 225 | length = nextcomma - parsestring; | 
|  | 226 | residual_str = nextcomma + 1; | 
|  | 227 | } else { | 
|  | 228 | length = strlen(parsestring); | 
|  | 229 | residual_str = parsestring + length; | 
|  | 230 | } | 
|  | 231 | if (strncmp ("autodetect", parsestring, length) == 0) { | 
|  | 232 | dasd_autodetect = 1; | 
|  | 233 | MESSAGE (KERN_INFO, "%s", | 
|  | 234 | "turning to autodetection mode"); | 
|  | 235 | return residual_str; | 
|  | 236 | } | 
|  | 237 | if (strncmp ("probeonly", parsestring, length) == 0) { | 
|  | 238 | dasd_probeonly = 1; | 
|  | 239 | MESSAGE(KERN_INFO, "%s", | 
|  | 240 | "turning to probeonly mode"); | 
|  | 241 | return residual_str; | 
|  | 242 | } | 
|  | 243 | if (strncmp ("fixedbuffers", parsestring, length) == 0) { | 
|  | 244 | if (dasd_page_cache) | 
|  | 245 | return residual_str; | 
|  | 246 | dasd_page_cache = | 
|  | 247 | kmem_cache_create("dasd_page_cache", PAGE_SIZE, 0, | 
|  | 248 | SLAB_CACHE_DMA, NULL, NULL ); | 
|  | 249 | if (!dasd_page_cache) | 
|  | 250 | MESSAGE(KERN_WARNING, "%s", "Failed to create slab, " | 
|  | 251 | "fixed buffer mode disabled."); | 
|  | 252 | else | 
|  | 253 | MESSAGE (KERN_INFO, "%s", | 
|  | 254 | "turning on fixed buffer mode"); | 
|  | 255 | return residual_str; | 
|  | 256 | } | 
|  | 257 | return ERR_PTR(-EINVAL); | 
|  | 258 | } | 
|  | 259 |  | 
|  | 260 | /* | 
|  | 261 | * Try to interprete the first element on the comma separated parse string | 
|  | 262 | * as a device number or a range of devices. If the interpretation is | 
|  | 263 | * successfull, create the matching dasd_devmap entries and return a pointer | 
|  | 264 | * to the residual string. | 
|  | 265 | * If interpretation fails or in case of an error, return an error code. | 
|  | 266 | */ | 
|  | 267 | static char * | 
|  | 268 | dasd_parse_range( char *parsestring ) { | 
|  | 269 |  | 
|  | 270 | struct dasd_devmap *devmap; | 
|  | 271 | int from, from_id0, from_id1; | 
|  | 272 | int to, to_id0, to_id1; | 
|  | 273 | int features, rc; | 
|  | 274 | char bus_id[BUS_ID_SIZE+1], *str; | 
|  | 275 |  | 
|  | 276 | str = parsestring; | 
|  | 277 | rc = dasd_busid(&str, &from_id0, &from_id1, &from); | 
|  | 278 | if (rc == 0) { | 
|  | 279 | to = from; | 
|  | 280 | to_id0 = from_id0; | 
|  | 281 | to_id1 = from_id1; | 
|  | 282 | if (*str == '-') { | 
|  | 283 | str++; | 
|  | 284 | rc = dasd_busid(&str, &to_id0, &to_id1, &to); | 
|  | 285 | } | 
|  | 286 | } | 
|  | 287 | if (rc == 0 && | 
|  | 288 | (from_id0 != to_id0 || from_id1 != to_id1 || from > to)) | 
|  | 289 | rc = -EINVAL; | 
|  | 290 | if (rc) { | 
|  | 291 | MESSAGE(KERN_ERR, "Invalid device range %s", parsestring); | 
|  | 292 | return ERR_PTR(rc); | 
|  | 293 | } | 
|  | 294 | features = dasd_feature_list(str, &str); | 
|  | 295 | if (features < 0) | 
|  | 296 | return ERR_PTR(-EINVAL); | 
|  | 297 | while (from <= to) { | 
|  | 298 | sprintf(bus_id, "%01x.%01x.%04x", | 
|  | 299 | from_id0, from_id1, from++); | 
|  | 300 | devmap = dasd_add_busid(bus_id, features); | 
|  | 301 | if (IS_ERR(devmap)) | 
|  | 302 | return (char *)devmap; | 
|  | 303 | } | 
|  | 304 | if (*str == ',') | 
|  | 305 | return str + 1; | 
|  | 306 | if (*str == '\0') | 
|  | 307 | return str; | 
|  | 308 | MESSAGE(KERN_WARNING, | 
|  | 309 | "junk at end of dasd parameter string: %s\n", str); | 
|  | 310 | return ERR_PTR(-EINVAL); | 
|  | 311 | } | 
|  | 312 |  | 
|  | 313 | static inline char * | 
|  | 314 | dasd_parse_next_element( char *parsestring ) { | 
|  | 315 | char * residual_str; | 
|  | 316 | residual_str = dasd_parse_keyword(parsestring); | 
|  | 317 | if (!IS_ERR(residual_str)) | 
|  | 318 | return residual_str; | 
|  | 319 | residual_str = dasd_parse_range(parsestring); | 
|  | 320 | return residual_str; | 
|  | 321 | } | 
|  | 322 |  | 
|  | 323 | /* | 
|  | 324 | * Parse parameters stored in dasd[] | 
|  | 325 | * The 'dasd=...' parameter allows to specify a comma separated list of | 
|  | 326 | * keywords and device ranges. When the dasd driver is build into the kernel, | 
|  | 327 | * the complete list will be stored as one element of the dasd[] array. | 
|  | 328 | * When the dasd driver is build as a module, then the list is broken into | 
|  | 329 | * it's elements and each dasd[] entry contains one element. | 
|  | 330 | */ | 
|  | 331 | int | 
|  | 332 | dasd_parse(void) | 
|  | 333 | { | 
|  | 334 | int rc, i; | 
|  | 335 | char *parsestring; | 
|  | 336 |  | 
|  | 337 | rc = 0; | 
|  | 338 | for (i = 0; i < 256; i++) { | 
|  | 339 | if (dasd[i] == NULL) | 
|  | 340 | break; | 
|  | 341 | parsestring = dasd[i]; | 
|  | 342 | /* loop over the comma separated list in the parsestring */ | 
|  | 343 | while (*parsestring) { | 
|  | 344 | parsestring = dasd_parse_next_element(parsestring); | 
|  | 345 | if(IS_ERR(parsestring)) { | 
|  | 346 | rc = PTR_ERR(parsestring); | 
|  | 347 | break; | 
|  | 348 | } | 
|  | 349 | } | 
|  | 350 | if (rc) { | 
|  | 351 | DBF_EVENT(DBF_ALERT, "%s", "invalid range found"); | 
|  | 352 | break; | 
|  | 353 | } | 
|  | 354 | } | 
|  | 355 | return rc; | 
|  | 356 | } | 
|  | 357 |  | 
|  | 358 | /* | 
|  | 359 | * Add a devmap for the device specified by busid. It is possible that | 
|  | 360 | * the devmap already exists (dasd= parameter). The order of the devices | 
|  | 361 | * added through this function will define the kdevs for the individual | 
|  | 362 | * devices. | 
|  | 363 | */ | 
|  | 364 | static struct dasd_devmap * | 
|  | 365 | dasd_add_busid(char *bus_id, int features) | 
|  | 366 | { | 
|  | 367 | struct dasd_devmap *devmap, *new, *tmp; | 
|  | 368 | int hash; | 
|  | 369 |  | 
|  | 370 | new = (struct dasd_devmap *) | 
|  | 371 | kmalloc(sizeof(struct dasd_devmap), GFP_KERNEL); | 
|  | 372 | if (!new) | 
|  | 373 | return ERR_PTR(-ENOMEM); | 
|  | 374 | spin_lock(&dasd_devmap_lock); | 
|  | 375 | devmap = 0; | 
|  | 376 | hash = dasd_hash_busid(bus_id); | 
|  | 377 | list_for_each_entry(tmp, &dasd_hashlists[hash], list) | 
|  | 378 | if (strncmp(tmp->bus_id, bus_id, BUS_ID_SIZE) == 0) { | 
|  | 379 | devmap = tmp; | 
|  | 380 | break; | 
|  | 381 | } | 
|  | 382 | if (!devmap) { | 
|  | 383 | /* This bus_id is new. */ | 
|  | 384 | new->devindex = dasd_max_devindex++; | 
|  | 385 | strncpy(new->bus_id, bus_id, BUS_ID_SIZE); | 
|  | 386 | new->features = features; | 
|  | 387 | new->device = 0; | 
|  | 388 | list_add(&new->list, &dasd_hashlists[hash]); | 
|  | 389 | devmap = new; | 
|  | 390 | new = 0; | 
|  | 391 | } | 
|  | 392 | spin_unlock(&dasd_devmap_lock); | 
| Jesper Juhl | 17fd682 | 2005-11-07 01:01:30 -0800 | [diff] [blame] | 393 | kfree(new); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | return devmap; | 
|  | 395 | } | 
|  | 396 |  | 
|  | 397 | /* | 
|  | 398 | * Find devmap for device with given bus_id. | 
|  | 399 | */ | 
|  | 400 | static struct dasd_devmap * | 
|  | 401 | dasd_find_busid(char *bus_id) | 
|  | 402 | { | 
|  | 403 | struct dasd_devmap *devmap, *tmp; | 
|  | 404 | int hash; | 
|  | 405 |  | 
|  | 406 | spin_lock(&dasd_devmap_lock); | 
|  | 407 | devmap = ERR_PTR(-ENODEV); | 
|  | 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) { | 
|  | 411 | devmap = tmp; | 
|  | 412 | break; | 
|  | 413 | } | 
|  | 414 | } | 
|  | 415 | spin_unlock(&dasd_devmap_lock); | 
|  | 416 | return devmap; | 
|  | 417 | } | 
|  | 418 |  | 
|  | 419 | /* | 
|  | 420 | * Check if busid has been added to the list of dasd ranges. | 
|  | 421 | */ | 
|  | 422 | int | 
|  | 423 | dasd_busid_known(char *bus_id) | 
|  | 424 | { | 
|  | 425 | return IS_ERR(dasd_find_busid(bus_id)) ? -ENOENT : 0; | 
|  | 426 | } | 
|  | 427 |  | 
|  | 428 | /* | 
|  | 429 | * Forget all about the device numbers added so far. | 
|  | 430 | * This may only be called at module unload or system shutdown. | 
|  | 431 | */ | 
|  | 432 | static void | 
|  | 433 | dasd_forget_ranges(void) | 
|  | 434 | { | 
|  | 435 | struct dasd_devmap *devmap, *n; | 
|  | 436 | int i; | 
|  | 437 |  | 
|  | 438 | spin_lock(&dasd_devmap_lock); | 
|  | 439 | for (i = 0; i < 256; i++) { | 
|  | 440 | list_for_each_entry_safe(devmap, n, &dasd_hashlists[i], list) { | 
| Eric Sesterhenn | 606f442 | 2006-03-26 18:33:07 +0200 | [diff] [blame] | 441 | BUG_ON(devmap->device != NULL); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | list_del(&devmap->list); | 
|  | 443 | kfree(devmap); | 
|  | 444 | } | 
|  | 445 | } | 
|  | 446 | spin_unlock(&dasd_devmap_lock); | 
|  | 447 | } | 
|  | 448 |  | 
|  | 449 | /* | 
|  | 450 | * Find the device struct by its device index. | 
|  | 451 | */ | 
|  | 452 | struct dasd_device * | 
|  | 453 | dasd_device_from_devindex(int devindex) | 
|  | 454 | { | 
|  | 455 | struct dasd_devmap *devmap, *tmp; | 
|  | 456 | struct dasd_device *device; | 
|  | 457 | int i; | 
|  | 458 |  | 
|  | 459 | spin_lock(&dasd_devmap_lock); | 
|  | 460 | devmap = 0; | 
|  | 461 | for (i = 0; (i < 256) && !devmap; i++) | 
|  | 462 | list_for_each_entry(tmp, &dasd_hashlists[i], list) | 
|  | 463 | if (tmp->devindex == devindex) { | 
|  | 464 | /* Found the devmap for the device. */ | 
|  | 465 | devmap = tmp; | 
|  | 466 | break; | 
|  | 467 | } | 
|  | 468 | if (devmap && devmap->device) { | 
|  | 469 | device = devmap->device; | 
|  | 470 | dasd_get_device(device); | 
|  | 471 | } else | 
|  | 472 | device = ERR_PTR(-ENODEV); | 
|  | 473 | spin_unlock(&dasd_devmap_lock); | 
|  | 474 | return device; | 
|  | 475 | } | 
|  | 476 |  | 
|  | 477 | /* | 
|  | 478 | * Return devmap for cdev. If no devmap exists yet, create one and | 
|  | 479 | * connect it to the cdev. | 
|  | 480 | */ | 
|  | 481 | static struct dasd_devmap * | 
|  | 482 | dasd_devmap_from_cdev(struct ccw_device *cdev) | 
|  | 483 | { | 
|  | 484 | struct dasd_devmap *devmap; | 
|  | 485 |  | 
|  | 486 | devmap = dasd_find_busid(cdev->dev.bus_id); | 
|  | 487 | if (IS_ERR(devmap)) | 
|  | 488 | devmap = dasd_add_busid(cdev->dev.bus_id, | 
|  | 489 | DASD_FEATURE_DEFAULT); | 
|  | 490 | return devmap; | 
|  | 491 | } | 
|  | 492 |  | 
|  | 493 | /* | 
|  | 494 | * Create a dasd device structure for cdev. | 
|  | 495 | */ | 
|  | 496 | struct dasd_device * | 
|  | 497 | dasd_create_device(struct ccw_device *cdev) | 
|  | 498 | { | 
|  | 499 | struct dasd_devmap *devmap; | 
|  | 500 | struct dasd_device *device; | 
|  | 501 | int rc; | 
|  | 502 |  | 
|  | 503 | devmap = dasd_devmap_from_cdev(cdev); | 
|  | 504 | if (IS_ERR(devmap)) | 
|  | 505 | return (void *) devmap; | 
|  | 506 | cdev->dev.driver_data = devmap; | 
|  | 507 |  | 
|  | 508 | device = dasd_alloc_device(); | 
|  | 509 | if (IS_ERR(device)) | 
|  | 510 | return device; | 
|  | 511 | atomic_set(&device->ref_count, 2); | 
|  | 512 |  | 
|  | 513 | spin_lock(&dasd_devmap_lock); | 
|  | 514 | if (!devmap->device) { | 
|  | 515 | devmap->device = device; | 
|  | 516 | device->devindex = devmap->devindex; | 
| Horst Hummel | c6eb7b7 | 2005-09-03 15:57:58 -0700 | [diff] [blame] | 517 | device->features = devmap->features; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 518 | get_device(&cdev->dev); | 
|  | 519 | device->cdev = cdev; | 
|  | 520 | rc = 0; | 
|  | 521 | } else | 
|  | 522 | /* Someone else was faster. */ | 
|  | 523 | rc = -EBUSY; | 
|  | 524 | spin_unlock(&dasd_devmap_lock); | 
|  | 525 |  | 
|  | 526 | if (rc) { | 
|  | 527 | dasd_free_device(device); | 
|  | 528 | return ERR_PTR(rc); | 
|  | 529 | } | 
|  | 530 | return device; | 
|  | 531 | } | 
|  | 532 |  | 
|  | 533 | /* | 
|  | 534 | * Wait queue for dasd_delete_device waits. | 
|  | 535 | */ | 
|  | 536 | static DECLARE_WAIT_QUEUE_HEAD(dasd_delete_wq); | 
|  | 537 |  | 
|  | 538 | /* | 
|  | 539 | * Remove a dasd device structure. The passed referenced | 
|  | 540 | * is destroyed. | 
|  | 541 | */ | 
|  | 542 | void | 
|  | 543 | dasd_delete_device(struct dasd_device *device) | 
|  | 544 | { | 
|  | 545 | struct ccw_device *cdev; | 
|  | 546 | struct dasd_devmap *devmap; | 
|  | 547 |  | 
|  | 548 | /* First remove device pointer from devmap. */ | 
|  | 549 | devmap = dasd_find_busid(device->cdev->dev.bus_id); | 
| Eric Sesterhenn | 606f442 | 2006-03-26 18:33:07 +0200 | [diff] [blame] | 550 | BUG_ON(IS_ERR(devmap)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | spin_lock(&dasd_devmap_lock); | 
|  | 552 | if (devmap->device != device) { | 
|  | 553 | spin_unlock(&dasd_devmap_lock); | 
|  | 554 | dasd_put_device(device); | 
|  | 555 | return; | 
|  | 556 | } | 
|  | 557 | devmap->device = NULL; | 
|  | 558 | spin_unlock(&dasd_devmap_lock); | 
|  | 559 |  | 
|  | 560 | /* Drop ref_count by 2, one for the devmap reference and | 
|  | 561 | * one for the passed reference. */ | 
|  | 562 | atomic_sub(2, &device->ref_count); | 
|  | 563 |  | 
|  | 564 | /* Wait for reference counter to drop to zero. */ | 
|  | 565 | wait_event(dasd_delete_wq, atomic_read(&device->ref_count) == 0); | 
|  | 566 |  | 
|  | 567 | /* Disconnect dasd_device structure from ccw_device structure. */ | 
|  | 568 | cdev = device->cdev; | 
|  | 569 | device->cdev = NULL; | 
|  | 570 |  | 
|  | 571 | /* Disconnect dasd_devmap structure from ccw_device structure. */ | 
|  | 572 | cdev->dev.driver_data = NULL; | 
|  | 573 |  | 
|  | 574 | /* Put ccw_device structure. */ | 
|  | 575 | put_device(&cdev->dev); | 
|  | 576 |  | 
|  | 577 | /* Now the device structure can be freed. */ | 
|  | 578 | dasd_free_device(device); | 
|  | 579 | } | 
|  | 580 |  | 
|  | 581 | /* | 
|  | 582 | * Reference counter dropped to zero. Wake up waiter | 
|  | 583 | * in dasd_delete_device. | 
|  | 584 | */ | 
|  | 585 | void | 
|  | 586 | dasd_put_device_wake(struct dasd_device *device) | 
|  | 587 | { | 
|  | 588 | wake_up(&dasd_delete_wq); | 
|  | 589 | } | 
|  | 590 |  | 
|  | 591 | /* | 
|  | 592 | * Return dasd_device structure associated with cdev. | 
|  | 593 | */ | 
|  | 594 | struct dasd_device * | 
|  | 595 | dasd_device_from_cdev(struct ccw_device *cdev) | 
|  | 596 | { | 
|  | 597 | struct dasd_devmap *devmap; | 
|  | 598 | struct dasd_device *device; | 
|  | 599 |  | 
|  | 600 | device = ERR_PTR(-ENODEV); | 
|  | 601 | spin_lock(&dasd_devmap_lock); | 
|  | 602 | devmap = cdev->dev.driver_data; | 
|  | 603 | if (devmap && devmap->device) { | 
|  | 604 | device = devmap->device; | 
|  | 605 | dasd_get_device(device); | 
|  | 606 | } | 
|  | 607 | spin_unlock(&dasd_devmap_lock); | 
|  | 608 | return device; | 
|  | 609 | } | 
|  | 610 |  | 
|  | 611 | /* | 
|  | 612 | * SECTION: files in sysfs | 
|  | 613 | */ | 
|  | 614 |  | 
|  | 615 | /* | 
|  | 616 | * readonly controls the readonly status of a dasd | 
|  | 617 | */ | 
|  | 618 | static ssize_t | 
| Yani Ioannou | e404e27 | 2005-05-17 06:42:58 -0400 | [diff] [blame] | 619 | dasd_ro_show(struct device *dev, struct device_attribute *attr, char *buf) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | { | 
|  | 621 | struct dasd_devmap *devmap; | 
|  | 622 | int ro_flag; | 
|  | 623 |  | 
|  | 624 | devmap = dasd_find_busid(dev->bus_id); | 
|  | 625 | if (!IS_ERR(devmap)) | 
|  | 626 | ro_flag = (devmap->features & DASD_FEATURE_READONLY) != 0; | 
|  | 627 | else | 
|  | 628 | ro_flag = (DASD_FEATURE_DEFAULT & DASD_FEATURE_READONLY) != 0; | 
|  | 629 | return snprintf(buf, PAGE_SIZE, ro_flag ? "1\n" : "0\n"); | 
|  | 630 | } | 
|  | 631 |  | 
|  | 632 | static ssize_t | 
| Yani Ioannou | e404e27 | 2005-05-17 06:42:58 -0400 | [diff] [blame] | 633 | dasd_ro_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | { | 
|  | 635 | struct dasd_devmap *devmap; | 
|  | 636 | int ro_flag; | 
|  | 637 |  | 
|  | 638 | devmap = dasd_devmap_from_cdev(to_ccwdev(dev)); | 
|  | 639 | if (IS_ERR(devmap)) | 
|  | 640 | return PTR_ERR(devmap); | 
|  | 641 | ro_flag = buf[0] == '1'; | 
|  | 642 | spin_lock(&dasd_devmap_lock); | 
|  | 643 | if (ro_flag) | 
|  | 644 | devmap->features |= DASD_FEATURE_READONLY; | 
|  | 645 | else | 
|  | 646 | devmap->features &= ~DASD_FEATURE_READONLY; | 
| Horst Hummel | c6eb7b7 | 2005-09-03 15:57:58 -0700 | [diff] [blame] | 647 | if (devmap->device) | 
|  | 648 | devmap->device->features = devmap->features; | 
| Horst Hummel | f24acd4 | 2005-05-01 08:58:59 -0700 | [diff] [blame] | 649 | if (devmap->device && devmap->device->gdp) | 
|  | 650 | set_disk_ro(devmap->device->gdp, ro_flag); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 651 | spin_unlock(&dasd_devmap_lock); | 
|  | 652 | return count; | 
|  | 653 | } | 
|  | 654 |  | 
|  | 655 | static DEVICE_ATTR(readonly, 0644, dasd_ro_show, dasd_ro_store); | 
|  | 656 |  | 
|  | 657 | /* | 
|  | 658 | * use_diag controls whether the driver should use diag rather than ssch | 
|  | 659 | * to talk to the device | 
|  | 660 | */ | 
|  | 661 | static ssize_t | 
| Yani Ioannou | e404e27 | 2005-05-17 06:42:58 -0400 | [diff] [blame] | 662 | dasd_use_diag_show(struct device *dev, struct device_attribute *attr, char *buf) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | { | 
|  | 664 | struct dasd_devmap *devmap; | 
|  | 665 | int use_diag; | 
|  | 666 |  | 
|  | 667 | devmap = dasd_find_busid(dev->bus_id); | 
|  | 668 | if (!IS_ERR(devmap)) | 
|  | 669 | use_diag = (devmap->features & DASD_FEATURE_USEDIAG) != 0; | 
|  | 670 | else | 
|  | 671 | use_diag = (DASD_FEATURE_DEFAULT & DASD_FEATURE_USEDIAG) != 0; | 
|  | 672 | return sprintf(buf, use_diag ? "1\n" : "0\n"); | 
|  | 673 | } | 
|  | 674 |  | 
|  | 675 | static ssize_t | 
| Yani Ioannou | e404e27 | 2005-05-17 06:42:58 -0400 | [diff] [blame] | 676 | dasd_use_diag_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 677 | { | 
|  | 678 | struct dasd_devmap *devmap; | 
|  | 679 | ssize_t rc; | 
|  | 680 | int use_diag; | 
|  | 681 |  | 
|  | 682 | devmap = dasd_devmap_from_cdev(to_ccwdev(dev)); | 
|  | 683 | if (IS_ERR(devmap)) | 
|  | 684 | return PTR_ERR(devmap); | 
|  | 685 | use_diag = buf[0] == '1'; | 
|  | 686 | spin_lock(&dasd_devmap_lock); | 
|  | 687 | /* Changing diag discipline flag is only allowed in offline state. */ | 
|  | 688 | rc = count; | 
|  | 689 | if (!devmap->device) { | 
|  | 690 | if (use_diag) | 
|  | 691 | devmap->features |= DASD_FEATURE_USEDIAG; | 
|  | 692 | else | 
|  | 693 | devmap->features &= ~DASD_FEATURE_USEDIAG; | 
|  | 694 | } else | 
|  | 695 | rc = -EPERM; | 
|  | 696 | spin_unlock(&dasd_devmap_lock); | 
|  | 697 | return rc; | 
|  | 698 | } | 
|  | 699 |  | 
|  | 700 | static | 
|  | 701 | DEVICE_ATTR(use_diag, 0644, dasd_use_diag_show, dasd_use_diag_store); | 
|  | 702 |  | 
|  | 703 | static ssize_t | 
| Yani Ioannou | e404e27 | 2005-05-17 06:42:58 -0400 | [diff] [blame] | 704 | dasd_discipline_show(struct device *dev, struct device_attribute *attr, char *buf) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | { | 
|  | 706 | struct dasd_devmap *devmap; | 
|  | 707 | char *dname; | 
|  | 708 |  | 
|  | 709 | spin_lock(&dasd_devmap_lock); | 
|  | 710 | dname = "none"; | 
|  | 711 | devmap = dev->driver_data; | 
|  | 712 | if (devmap && devmap->device && devmap->device->discipline) | 
|  | 713 | dname = devmap->device->discipline->name; | 
|  | 714 | spin_unlock(&dasd_devmap_lock); | 
|  | 715 | return snprintf(buf, PAGE_SIZE, "%s\n", dname); | 
|  | 716 | } | 
|  | 717 |  | 
|  | 718 | static DEVICE_ATTR(discipline, 0444, dasd_discipline_show, NULL); | 
|  | 719 |  | 
| Horst Hummel | 3d05259 | 2006-04-27 18:40:28 -0700 | [diff] [blame^] | 720 | static ssize_t | 
|  | 721 | dasd_alias_show(struct device *dev, struct device_attribute *attr, char *buf) | 
|  | 722 | { | 
|  | 723 | struct dasd_devmap *devmap; | 
|  | 724 | int alias; | 
|  | 725 |  | 
|  | 726 | devmap = dasd_find_busid(dev->bus_id); | 
|  | 727 | spin_lock(&dasd_devmap_lock); | 
|  | 728 | if (!IS_ERR(devmap)) | 
|  | 729 | alias = devmap->uid.alias; | 
|  | 730 | else | 
|  | 731 | alias = 0; | 
|  | 732 | spin_unlock(&dasd_devmap_lock); | 
|  | 733 |  | 
|  | 734 | return sprintf(buf, alias ? "1\n" : "0\n"); | 
|  | 735 | } | 
|  | 736 |  | 
|  | 737 | static DEVICE_ATTR(alias, 0444, dasd_alias_show, NULL); | 
|  | 738 |  | 
|  | 739 | static ssize_t | 
|  | 740 | dasd_vendor_show(struct device *dev, struct device_attribute *attr, char *buf) | 
|  | 741 | { | 
|  | 742 | struct dasd_devmap *devmap; | 
|  | 743 | char *vendor; | 
|  | 744 |  | 
|  | 745 | devmap = dasd_find_busid(dev->bus_id); | 
|  | 746 | spin_lock(&dasd_devmap_lock); | 
|  | 747 | if (!IS_ERR(devmap) && strlen(devmap->uid.vendor) > 0) | 
|  | 748 | vendor = devmap->uid.vendor; | 
|  | 749 | else | 
|  | 750 | vendor = ""; | 
|  | 751 | spin_unlock(&dasd_devmap_lock); | 
|  | 752 |  | 
|  | 753 | return snprintf(buf, PAGE_SIZE, "%s\n", vendor); | 
|  | 754 | } | 
|  | 755 |  | 
|  | 756 | static DEVICE_ATTR(vendor, 0444, dasd_vendor_show, NULL); | 
|  | 757 |  | 
|  | 758 | #define UID_STRLEN ( /* vendor */ 3 + 1 + /* serial    */ 14 + 1 +\ | 
|  | 759 | /* SSID   */ 4 + 1 + /* unit addr */ 2 + 1) | 
|  | 760 |  | 
|  | 761 | static ssize_t | 
|  | 762 | dasd_uid_show(struct device *dev, struct device_attribute *attr, char *buf) | 
|  | 763 | { | 
|  | 764 | struct dasd_devmap *devmap; | 
|  | 765 | char uid[UID_STRLEN]; | 
|  | 766 |  | 
|  | 767 | devmap = dasd_find_busid(dev->bus_id); | 
|  | 768 | spin_lock(&dasd_devmap_lock); | 
|  | 769 | if (!IS_ERR(devmap) && strlen(devmap->uid.vendor) > 0) | 
|  | 770 | snprintf(uid, sizeof(uid), "%s.%s.%04x.%02x", | 
|  | 771 | devmap->uid.vendor, devmap->uid.serial, | 
|  | 772 | devmap->uid.ssid, devmap->uid.unit_addr); | 
|  | 773 | else | 
|  | 774 | uid[0] = 0; | 
|  | 775 | spin_unlock(&dasd_devmap_lock); | 
|  | 776 |  | 
|  | 777 | return snprintf(buf, PAGE_SIZE, "%s\n", uid); | 
|  | 778 | } | 
|  | 779 |  | 
|  | 780 | static DEVICE_ATTR(uid, 0444, dasd_uid_show, NULL); | 
|  | 781 |  | 
| Stefan Weinhuber | 20c6446 | 2006-03-24 03:15:25 -0800 | [diff] [blame] | 782 | /* | 
|  | 783 | * extended error-reporting | 
|  | 784 | */ | 
|  | 785 | static ssize_t | 
|  | 786 | dasd_eer_show(struct device *dev, struct device_attribute *attr, char *buf) | 
|  | 787 | { | 
|  | 788 | struct dasd_devmap *devmap; | 
|  | 789 | int eer_flag; | 
|  | 790 |  | 
|  | 791 | devmap = dasd_find_busid(dev->bus_id); | 
|  | 792 | if (!IS_ERR(devmap) && devmap->device) | 
|  | 793 | eer_flag = dasd_eer_enabled(devmap->device); | 
|  | 794 | else | 
|  | 795 | eer_flag = 0; | 
|  | 796 | return snprintf(buf, PAGE_SIZE, eer_flag ? "1\n" : "0\n"); | 
|  | 797 | } | 
|  | 798 |  | 
|  | 799 | static ssize_t | 
|  | 800 | dasd_eer_store(struct device *dev, struct device_attribute *attr, | 
|  | 801 | const char *buf, size_t count) | 
|  | 802 | { | 
|  | 803 | struct dasd_devmap *devmap; | 
|  | 804 | int rc; | 
|  | 805 |  | 
|  | 806 | devmap = dasd_devmap_from_cdev(to_ccwdev(dev)); | 
|  | 807 | if (IS_ERR(devmap)) | 
|  | 808 | return PTR_ERR(devmap); | 
|  | 809 | if (!devmap->device) | 
|  | 810 | return count; | 
|  | 811 | if (buf[0] == '1') { | 
|  | 812 | rc = dasd_eer_enable(devmap->device); | 
|  | 813 | if (rc) | 
|  | 814 | return rc; | 
|  | 815 | } else | 
|  | 816 | dasd_eer_disable(devmap->device); | 
|  | 817 | return count; | 
|  | 818 | } | 
|  | 819 |  | 
|  | 820 | static DEVICE_ATTR(eer_enabled, 0644, dasd_eer_show, dasd_eer_store); | 
|  | 821 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 822 | static struct attribute * dasd_attrs[] = { | 
|  | 823 | &dev_attr_readonly.attr, | 
|  | 824 | &dev_attr_discipline.attr, | 
| Horst Hummel | 3d05259 | 2006-04-27 18:40:28 -0700 | [diff] [blame^] | 825 | &dev_attr_alias.attr, | 
|  | 826 | &dev_attr_vendor.attr, | 
|  | 827 | &dev_attr_uid.attr, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 828 | &dev_attr_use_diag.attr, | 
| Stefan Weinhuber | 20c6446 | 2006-03-24 03:15:25 -0800 | [diff] [blame] | 829 | &dev_attr_eer_enabled.attr, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 830 | NULL, | 
|  | 831 | }; | 
|  | 832 |  | 
|  | 833 | static struct attribute_group dasd_attr_group = { | 
|  | 834 | .attrs = dasd_attrs, | 
|  | 835 | }; | 
|  | 836 |  | 
| Horst Hummel | 3d05259 | 2006-04-27 18:40:28 -0700 | [diff] [blame^] | 837 |  | 
|  | 838 | /* | 
|  | 839 | * Return copy of the device unique identifier. | 
|  | 840 | */ | 
|  | 841 | int | 
|  | 842 | dasd_get_uid(struct ccw_device *cdev, struct dasd_uid *uid) | 
|  | 843 | { | 
|  | 844 | struct dasd_devmap *devmap; | 
|  | 845 |  | 
|  | 846 | devmap = dasd_find_busid(cdev->dev.bus_id); | 
|  | 847 | if (IS_ERR(devmap)) | 
|  | 848 | return PTR_ERR(devmap); | 
|  | 849 | spin_lock(&dasd_devmap_lock); | 
|  | 850 | *uid = devmap->uid; | 
|  | 851 | spin_unlock(&dasd_devmap_lock); | 
|  | 852 | return 0; | 
|  | 853 | } | 
|  | 854 |  | 
|  | 855 | /* | 
|  | 856 | * Register the given device unique identifier into devmap struct. | 
|  | 857 | */ | 
|  | 858 | int | 
|  | 859 | dasd_set_uid(struct ccw_device *cdev, struct dasd_uid *uid) | 
|  | 860 | { | 
|  | 861 | struct dasd_devmap *devmap; | 
|  | 862 |  | 
|  | 863 | devmap = dasd_find_busid(cdev->dev.bus_id); | 
|  | 864 | if (IS_ERR(devmap)) | 
|  | 865 | return PTR_ERR(devmap); | 
|  | 866 | spin_lock(&dasd_devmap_lock); | 
|  | 867 | devmap->uid = *uid; | 
|  | 868 | spin_unlock(&dasd_devmap_lock); | 
|  | 869 | return 0; | 
|  | 870 | } | 
|  | 871 | EXPORT_SYMBOL(dasd_set_uid); | 
|  | 872 |  | 
| Horst Hummel | f24acd4 | 2005-05-01 08:58:59 -0700 | [diff] [blame] | 873 | /* | 
|  | 874 | * Return value of the specified feature. | 
|  | 875 | */ | 
|  | 876 | int | 
|  | 877 | dasd_get_feature(struct ccw_device *cdev, int feature) | 
|  | 878 | { | 
|  | 879 | struct dasd_devmap *devmap; | 
|  | 880 |  | 
|  | 881 | devmap = dasd_find_busid(cdev->dev.bus_id); | 
|  | 882 | if (IS_ERR(devmap)) | 
|  | 883 | return (int) PTR_ERR(devmap); | 
|  | 884 |  | 
|  | 885 | return ((devmap->features & feature) != 0); | 
|  | 886 | } | 
|  | 887 |  | 
|  | 888 | /* | 
|  | 889 | * Set / reset given feature. | 
|  | 890 | * Flag indicates wether to set (!=0) or the reset (=0) the feature. | 
|  | 891 | */ | 
|  | 892 | int | 
|  | 893 | dasd_set_feature(struct ccw_device *cdev, int feature, int flag) | 
|  | 894 | { | 
|  | 895 | struct dasd_devmap *devmap; | 
|  | 896 |  | 
|  | 897 | devmap = dasd_find_busid(cdev->dev.bus_id); | 
|  | 898 | if (IS_ERR(devmap)) | 
|  | 899 | return (int) PTR_ERR(devmap); | 
|  | 900 |  | 
|  | 901 | spin_lock(&dasd_devmap_lock); | 
|  | 902 | if (flag) | 
|  | 903 | devmap->features |= feature; | 
|  | 904 | else | 
|  | 905 | devmap->features &= ~feature; | 
| Horst Hummel | c6eb7b7 | 2005-09-03 15:57:58 -0700 | [diff] [blame] | 906 | if (devmap->device) | 
|  | 907 | devmap->device->features = devmap->features; | 
| Horst Hummel | f24acd4 | 2005-05-01 08:58:59 -0700 | [diff] [blame] | 908 | spin_unlock(&dasd_devmap_lock); | 
|  | 909 | return 0; | 
|  | 910 | } | 
|  | 911 |  | 
|  | 912 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 913 | int | 
|  | 914 | dasd_add_sysfs_files(struct ccw_device *cdev) | 
|  | 915 | { | 
|  | 916 | return sysfs_create_group(&cdev->dev.kobj, &dasd_attr_group); | 
|  | 917 | } | 
|  | 918 |  | 
|  | 919 | void | 
|  | 920 | dasd_remove_sysfs_files(struct ccw_device *cdev) | 
|  | 921 | { | 
|  | 922 | sysfs_remove_group(&cdev->dev.kobj, &dasd_attr_group); | 
|  | 923 | } | 
|  | 924 |  | 
|  | 925 |  | 
|  | 926 | int | 
|  | 927 | dasd_devmap_init(void) | 
|  | 928 | { | 
|  | 929 | int i; | 
|  | 930 |  | 
|  | 931 | /* Initialize devmap structures. */ | 
|  | 932 | dasd_max_devindex = 0; | 
|  | 933 | for (i = 0; i < 256; i++) | 
|  | 934 | INIT_LIST_HEAD(&dasd_hashlists[i]); | 
|  | 935 | return 0; | 
|  | 936 |  | 
|  | 937 | } | 
|  | 938 |  | 
|  | 939 | void | 
|  | 940 | dasd_devmap_exit(void) | 
|  | 941 | { | 
|  | 942 | dasd_forget_ranges(); | 
|  | 943 | } |