dasd_devmap.c 45.7 KB
Newer Older
1
// SPDX-License-Identifier: GPL-2.0
L
Linus Torvalds 已提交
2 3 4 5 6 7
/*
 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
 *		    Horst Hummel <Horst.Hummel@de.ibm.com>
 *		    Carsten Otte <Cotte@de.ibm.com>
 *		    Martin Schwidefsky <schwidefsky@de.ibm.com>
 * Bugreports.to..: <Linux390@de.ibm.com>
8
 * Copyright IBM Corp. 1999,2001
L
Linus Torvalds 已提交
9 10 11 12 13 14 15
 *
 * Device mapping and dasd= parameter parsing functions. All devmap
 * functions may not be called from interrupt context. In particular
 * dasd_get_device is a no-no from interrupt context.
 *
 */

S
Stefan Haberland 已提交
16 17
#define KMSG_COMPONENT "dasd"

L
Linus Torvalds 已提交
18 19
#include <linux/ctype.h>
#include <linux/init.h>
R
Rusty Russell 已提交
20
#include <linux/module.h>
21
#include <linux/slab.h>
L
Linus Torvalds 已提交
22 23

#include <asm/debug.h>
24
#include <linux/uaccess.h>
25
#include <asm/ipl.h>
L
Linus Torvalds 已提交
26 27 28

/* This is ugly... */
#define PRINTK_HEADER "dasd_devmap:"
29
#define DASD_BUS_ID_SIZE 20
30
#define DASD_MAX_PARAMS 256
L
Linus Torvalds 已提交
31 32 33

#include "dasd_int.h"

34
struct kmem_cache *dasd_page_cache;
35
EXPORT_SYMBOL_GPL(dasd_page_cache);
L
Linus Torvalds 已提交
36 37 38 39 40 41 42 43 44 45 46 47 48

/*
 * dasd_devmap_t is used to store the features and the relation
 * between device number and device index. To find a dasd_devmap_t
 * that corresponds to a device number of a device index each
 * dasd_devmap_t is added to two linked lists, one to search by
 * the device number and one to search by the device index. As
 * soon as big minor numbers are available the device index list
 * can be removed since the device number will then be identical
 * to the device index.
 */
struct dasd_devmap {
	struct list_head list;
49
	char bus_id[DASD_BUS_ID_SIZE];
L
Linus Torvalds 已提交
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
        unsigned int devindex;
        unsigned short features;
	struct dasd_device *device;
};

/*
 * Parameter parsing functions for dasd= parameter. The syntax is:
 *   <devno>		: (0x)?[0-9a-fA-F]+
 *   <busid>		: [0-0a-f]\.[0-9a-f]\.(0x)?[0-9a-fA-F]+
 *   <feature>		: ro
 *   <feature_list>	: \(<feature>(:<feature>)*\)
 *   <devno-range>	: <devno>(-<devno>)?<feature_list>?
 *   <busid-range>	: <busid>(-<busid>)?<feature_list>?
 *   <devices>		: <devno-range>|<busid-range>
 *   <dasd_module>	: dasd_diag_mod|dasd_eckd_mod|dasd_fba_mod
 *
 *   <dasd>		: autodetect|probeonly|<devices>(,<devices>)*
 */

int dasd_probeonly =  0;	/* is true, when probeonly mode is active */
int dasd_autodetect = 0;	/* is true, when autodetection is active */
71 72
int dasd_nopav = 0;		/* is true, when PAV is disabled */
EXPORT_SYMBOL_GPL(dasd_nopav);
73 74
int dasd_nofcx;			/* disable High Performance Ficon */
EXPORT_SYMBOL_GPL(dasd_nofcx);
L
Linus Torvalds 已提交
75 76 77 78 79 80

/*
 * char *dasd[] is intended to hold the ranges supplied by the dasd= statement
 * it is named 'dasd' to directly be filled by insmod with the comma separated
 * strings when running as a module.
 */
81
static char *dasd[DASD_MAX_PARAMS];
82
module_param_array(dasd, charp, NULL, S_IRUGO);
R
Rusty Russell 已提交
83

L
Linus Torvalds 已提交
84
/*
85
 * Single spinlock to protect devmap and servermap structures and lists.
L
Linus Torvalds 已提交
86 87 88 89 90 91 92 93 94
 */
static DEFINE_SPINLOCK(dasd_devmap_lock);

/*
 * Hash lists for devmap structures.
 */
static struct list_head dasd_hashlists[256];
int dasd_max_devindex;

95
static struct dasd_devmap *dasd_add_busid(const char *, int);
L
Linus Torvalds 已提交
96 97

static inline int
98
dasd_hash_busid(const char *bus_id)
L
Linus Torvalds 已提交
99 100 101 102
{
	int hash, i;

	hash = 0;
103
	for (i = 0; (i < DASD_BUS_ID_SIZE) && *bus_id; i++, bus_id++)
L
Linus Torvalds 已提交
104 105 106 107 108
		hash += *bus_id;
	return hash & 0xff;
}

#ifndef MODULE
109
static int __init dasd_call_setup(char *opt)
L
Linus Torvalds 已提交
110
{
111
	static int i __initdata;
112 113 114 115 116 117 118 119 120
	char *tmp;

	while (i < DASD_MAX_PARAMS) {
		tmp = strsep(&opt, ",");
		if (!tmp)
			break;

		dasd[i++] = tmp;
	}
L
Linus Torvalds 已提交
121 122 123 124 125 126 127

	return 1;
}

__setup ("dasd=", dasd_call_setup);
#endif	/* #ifndef MODULE */

128 129
#define	DASD_IPLDEV	"ipldev"

L
Linus Torvalds 已提交
130 131 132
/*
 * Read a device busid/devno from a string.
 */
133
static int __init dasd_busid(char *str, int *id0, int *id1, int *devno)
L
Linus Torvalds 已提交
134
{
135 136
	unsigned int val;
	char *tok;
137

138
	/* Interpret ipldev busid */
139
	if (strncmp(DASD_IPLDEV, str, strlen(DASD_IPLDEV)) == 0) {
140
		if (ipl_info.type != IPL_TYPE_CCW) {
S
Stefan Haberland 已提交
141
			pr_err("The IPL device is not a CCW device\n");
142 143 144 145 146 147 148 149
			return -EINVAL;
		}
		*id0 = 0;
		*id1 = ipl_info.data.ccw.dev_id.ssid;
		*devno = ipl_info.data.ccw.dev_id.devno;

		return 0;
	}
150 151 152

	/* Old style 0xXXXX or XXXX */
	if (!kstrtouint(str, 16, &val)) {
L
Linus Torvalds 已提交
153
		*id0 = *id1 = 0;
S
Sebastian Ott 已提交
154
		if (val > 0xffff)
L
Linus Torvalds 已提交
155 156 157 158
			return -EINVAL;
		*devno = val;
		return 0;
	}
159

L
Linus Torvalds 已提交
160
	/* New style x.y.z busid */
161 162
	tok = strsep(&str, ".");
	if (kstrtouint(tok, 16, &val) || val > 0xff)
L
Linus Torvalds 已提交
163 164
		return -EINVAL;
	*id0 = val;
165 166 167

	tok = strsep(&str, ".");
	if (kstrtouint(tok, 16, &val) || val > 0xff)
L
Linus Torvalds 已提交
168 169
		return -EINVAL;
	*id1 = val;
170 171 172

	tok = strsep(&str, ".");
	if (kstrtouint(tok, 16, &val) || val > 0xffff)
L
Linus Torvalds 已提交
173 174
		return -EINVAL;
	*devno = val;
175

L
Linus Torvalds 已提交
176 177 178 179
	return 0;
}

/*
180
 * Read colon separated list of dasd features.
L
Linus Torvalds 已提交
181
 */
182
static int __init dasd_feature_list(char *str)
L
Linus Torvalds 已提交
183 184 185
{
	int features, len, rc;

186
	features = 0;
L
Linus Torvalds 已提交
187
	rc = 0;
188 189

	if (!str)
L
Linus Torvalds 已提交
190 191 192
		return DASD_FEATURE_DEFAULT;

	while (1) {
193
		for (len = 0;
L
Linus Torvalds 已提交
194 195 196 197 198
		     str[len] && str[len] != ':' && str[len] != ')'; len++);
		if (len == 2 && !strncmp(str, "ro", 2))
			features |= DASD_FEATURE_READONLY;
		else if (len == 4 && !strncmp(str, "diag", 4))
			features |= DASD_FEATURE_USEDIAG;
199 200
		else if (len == 3 && !strncmp(str, "raw", 3))
			features |= DASD_FEATURE_USERAW;
201 202
		else if (len == 6 && !strncmp(str, "erplog", 6))
			features |= DASD_FEATURE_ERPLOG;
203 204
		else if (len == 8 && !strncmp(str, "failfast", 8))
			features |= DASD_FEATURE_FAILFAST;
L
Linus Torvalds 已提交
205
		else {
206
			pr_warn("%.*s is not a supported device option\n",
207
				len, str);
L
Linus Torvalds 已提交
208 209 210 211 212 213 214
			rc = -EINVAL;
		}
		str += len;
		if (*str != ':')
			break;
		str++;
	}
215 216

	return rc ? : features;
L
Linus Torvalds 已提交
217 218 219 220 221 222 223 224
}

/*
 * Try to match the first element on the comma separated parse string
 * with one of the known keywords. If a keyword is found, take the approprate
 * action and return a pointer to the residual string. If the first element
 * could not be matched to any keyword then return an error code.
 */
225 226 227
static int __init dasd_parse_keyword(char *keyword)
{
	int length = strlen(keyword);
L
Linus Torvalds 已提交
228

229
	if (strncmp("autodetect", keyword, length) == 0) {
L
Linus Torvalds 已提交
230
		dasd_autodetect = 1;
S
Stefan Haberland 已提交
231
		pr_info("The autodetection mode has been activated\n");
232
		return 0;
L
Linus Torvalds 已提交
233
        }
234
	if (strncmp("probeonly", keyword, length) == 0) {
L
Linus Torvalds 已提交
235
		dasd_probeonly = 1;
S
Stefan Haberland 已提交
236
		pr_info("The probeonly mode has been activated\n");
237
		return 0;
L
Linus Torvalds 已提交
238
        }
239
	if (strncmp("nopav", keyword, length) == 0) {
240
		if (MACHINE_IS_VM)
S
Stefan Haberland 已提交
241
			pr_info("'nopav' is not supported on z/VM\n");
242 243
		else {
			dasd_nopav = 1;
S
Stefan Haberland 已提交
244
			pr_info("PAV support has be deactivated\n");
245
		}
246
		return 0;
247
	}
248
	if (strncmp("nofcx", keyword, length) == 0) {
249
		dasd_nofcx = 1;
S
Stefan Haberland 已提交
250 251
		pr_info("High Performance FICON support has been "
			"deactivated\n");
252
		return 0;
253
	}
254
	if (strncmp("fixedbuffers", keyword, length) == 0) {
L
Linus Torvalds 已提交
255
		if (dasd_page_cache)
256
			return 0;
L
Linus Torvalds 已提交
257
		dasd_page_cache =
258 259
			kmem_cache_create("dasd_page_cache", PAGE_SIZE,
					  PAGE_SIZE, SLAB_CACHE_DMA,
260
					  NULL);
L
Linus Torvalds 已提交
261
		if (!dasd_page_cache)
S
Stefan Haberland 已提交
262
			DBF_EVENT(DBF_WARNING, "%s", "Failed to create slab, "
L
Linus Torvalds 已提交
263 264
				"fixed buffer mode disabled.");
		else
S
Stefan Haberland 已提交
265
			DBF_EVENT(DBF_INFO, "%s",
L
Linus Torvalds 已提交
266
				 "turning on fixed buffer mode");
267 268 269 270
		return 0;
	}

	return -EINVAL;
L
Linus Torvalds 已提交
271 272 273
}

/*
274 275 276 277 278 279
 * Split a string of a device range into its pieces and return the from, to, and
 * feature parts separately.
 * e.g.:
 * 0.0.1234-0.0.5678(ro:erplog) -> from: 0.0.1234 to: 0.0.5678 features: ro:erplog
 * 0.0.8765(raw) -> from: 0.0.8765 to: null features: raw
 * 0x4321 -> from: 0x4321 to: null features: null
L
Linus Torvalds 已提交
280
 */
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
static int __init dasd_evaluate_range_param(char *range, char **from_str,
					    char **to_str, char **features_str)
{
	int rc = 0;

	/* Do we have a range or a single device? */
	if (strchr(range, '-')) {
		*from_str = strsep(&range, "-");
		*to_str = strsep(&range, "(");
		*features_str = strsep(&range, ")");
	} else {
		*from_str = strsep(&range, "(");
		*features_str = strsep(&range, ")");
	}

	if (*features_str && !range) {
		pr_warn("A closing parenthesis ')' is missing in the dasd= parameter\n");
		rc = -EINVAL;
	}
L
Linus Torvalds 已提交
300

301 302 303 304 305 306 307 308 309 310
	return rc;
}

/*
 * Try to interprete the range string as a device number or a range of devices.
 * If the interpretation is successful, create the matching dasd_devmap entries.
 * If interpretation fails or in case of an error, return an error code.
 */
static int __init dasd_parse_range(const char *range)
{
L
Linus Torvalds 已提交
311 312 313
	struct dasd_devmap *devmap;
	int from, from_id0, from_id1;
	int to, to_id0, to_id1;
314 315 316 317 318
	int features;
	char bus_id[DASD_BUS_ID_SIZE + 1];
	char *features_str = NULL;
	char *from_str = NULL;
	char *to_str = NULL;
319 320
	int rc = 0;
	char *tmp;
321

322 323 324
	tmp = kstrdup(range, GFP_KERNEL);
	if (!tmp)
		return -ENOMEM;
325

326 327 328 329
	if (dasd_evaluate_range_param(tmp, &from_str, &to_str, &features_str)) {
		rc = -EINVAL;
		goto out;
	}
330

331 332 333 334
	if (dasd_busid(from_str, &from_id0, &from_id1, &from)) {
		rc = -EINVAL;
		goto out;
	}
335 336 337 338 339

	to = from;
	to_id0 = from_id0;
	to_id1 = from_id1;
	if (to_str) {
340 341 342 343
		if (dasd_busid(to_str, &to_id0, &to_id1, &to)) {
			rc = -EINVAL;
			goto out;
		}
344 345
		if (from_id0 != to_id0 || from_id1 != to_id1 || from > to) {
			pr_err("%s is not a valid device range\n", range);
346 347
			rc = -EINVAL;
			goto out;
L
Linus Torvalds 已提交
348 349
		}
	}
350 351

	features = dasd_feature_list(features_str);
352 353 354 355
	if (features < 0) {
		rc = -EINVAL;
		goto out;
	}
356 357
	/* each device in dasd= parameter should be set initially online */
	features |= DASD_FEATURE_INITIAL_ONLINE;
L
Linus Torvalds 已提交
358
	while (from <= to) {
359
		sprintf(bus_id, "%01x.%01x.%04x", from_id0, from_id1, from++);
L
Linus Torvalds 已提交
360
		devmap = dasd_add_busid(bus_id, features);
361 362 363 364
		if (IS_ERR(devmap)) {
			rc = PTR_ERR(devmap);
			goto out;
		}
L
Linus Torvalds 已提交
365 366
	}

367 368
out:
	kfree(tmp);
369

370
	return rc;
L
Linus Torvalds 已提交
371 372 373 374 375
}

/*
 * Parse parameters stored in dasd[]
 * The 'dasd=...' parameter allows to specify a comma separated list of
376 377
 * keywords and device ranges. The parameters in that list will be stored as
 * separate elementes in dasd[].
L
Linus Torvalds 已提交
378
 */
379
int __init dasd_parse(void)
L
Linus Torvalds 已提交
380 381
{
	int rc, i;
382
	char *cur;
L
Linus Torvalds 已提交
383 384

	rc = 0;
385
	for (i = 0; i < DASD_MAX_PARAMS; i++) {
386 387
		cur = dasd[i];
		if (!cur)
L
Linus Torvalds 已提交
388
			break;
389 390 391 392 393 394 395 396
		if (*cur == '\0')
			continue;

		rc = dasd_parse_keyword(cur);
		if (rc)
			rc = dasd_parse_range(cur);

		if (rc)
L
Linus Torvalds 已提交
397 398
			break;
	}
399

L
Linus Torvalds 已提交
400 401 402 403 404 405 406
	return rc;
}

/*
 * Add a devmap for the device specified by busid. It is possible that
 * the devmap already exists (dasd= parameter). The order of the devices
 * added through this function will define the kdevs for the individual
407
 * devices.
L
Linus Torvalds 已提交
408 409
 */
static struct dasd_devmap *
410
dasd_add_busid(const char *bus_id, int features)
L
Linus Torvalds 已提交
411 412 413 414
{
	struct dasd_devmap *devmap, *new, *tmp;
	int hash;

415
	new = kzalloc(sizeof(struct dasd_devmap), GFP_KERNEL);
L
Linus Torvalds 已提交
416 417 418
	if (!new)
		return ERR_PTR(-ENOMEM);
	spin_lock(&dasd_devmap_lock);
H
Heiko Carstens 已提交
419
	devmap = NULL;
L
Linus Torvalds 已提交
420 421
	hash = dasd_hash_busid(bus_id);
	list_for_each_entry(tmp, &dasd_hashlists[hash], list)
422
		if (strncmp(tmp->bus_id, bus_id, DASD_BUS_ID_SIZE) == 0) {
L
Linus Torvalds 已提交
423 424 425 426 427 428
			devmap = tmp;
			break;
		}
	if (!devmap) {
		/* This bus_id is new. */
		new->devindex = dasd_max_devindex++;
429
		strlcpy(new->bus_id, bus_id, DASD_BUS_ID_SIZE);
L
Linus Torvalds 已提交
430
		new->features = features;
H
Heiko Carstens 已提交
431
		new->device = NULL;
L
Linus Torvalds 已提交
432 433
		list_add(&new->list, &dasd_hashlists[hash]);
		devmap = new;
H
Heiko Carstens 已提交
434
		new = NULL;
L
Linus Torvalds 已提交
435 436
	}
	spin_unlock(&dasd_devmap_lock);
J
Jesper Juhl 已提交
437
	kfree(new);
L
Linus Torvalds 已提交
438 439 440 441 442 443 444
	return devmap;
}

/*
 * Find devmap for device with given bus_id.
 */
static struct dasd_devmap *
445
dasd_find_busid(const char *bus_id)
L
Linus Torvalds 已提交
446 447 448 449 450 451 452 453
{
	struct dasd_devmap *devmap, *tmp;
	int hash;

	spin_lock(&dasd_devmap_lock);
	devmap = ERR_PTR(-ENODEV);
	hash = dasd_hash_busid(bus_id);
	list_for_each_entry(tmp, &dasd_hashlists[hash], list) {
454
		if (strncmp(tmp->bus_id, bus_id, DASD_BUS_ID_SIZE) == 0) {
L
Linus Torvalds 已提交
455 456 457 458 459 460 461 462 463 464 465 466
			devmap = tmp;
			break;
		}
	}
	spin_unlock(&dasd_devmap_lock);
	return devmap;
}

/*
 * Check if busid has been added to the list of dasd ranges.
 */
int
467
dasd_busid_known(const char *bus_id)
L
Linus Torvalds 已提交
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
{
	return IS_ERR(dasd_find_busid(bus_id)) ? -ENOENT : 0;
}

/*
 * Forget all about the device numbers added so far.
 * This may only be called at module unload or system shutdown.
 */
static void
dasd_forget_ranges(void)
{
	struct dasd_devmap *devmap, *n;
	int i;

	spin_lock(&dasd_devmap_lock);
	for (i = 0; i < 256; i++) {
		list_for_each_entry_safe(devmap, n, &dasd_hashlists[i], list) {
485
			BUG_ON(devmap->device != NULL);
L
Linus Torvalds 已提交
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503
			list_del(&devmap->list);
			kfree(devmap);
		}
	}
	spin_unlock(&dasd_devmap_lock);
}

/*
 * Find the device struct by its device index.
 */
struct dasd_device *
dasd_device_from_devindex(int devindex)
{
	struct dasd_devmap *devmap, *tmp;
	struct dasd_device *device;
	int i;

	spin_lock(&dasd_devmap_lock);
H
Heiko Carstens 已提交
504
	devmap = NULL;
L
Linus Torvalds 已提交
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529
	for (i = 0; (i < 256) && !devmap; i++)
		list_for_each_entry(tmp, &dasd_hashlists[i], list)
			if (tmp->devindex == devindex) {
				/* Found the devmap for the device. */
				devmap = tmp;
				break;
			}
	if (devmap && devmap->device) {
		device = devmap->device;
		dasd_get_device(device);
	} else
		device = ERR_PTR(-ENODEV);
	spin_unlock(&dasd_devmap_lock);
	return device;
}

/*
 * Return devmap for cdev. If no devmap exists yet, create one and
 * connect it to the cdev.
 */
static struct dasd_devmap *
dasd_devmap_from_cdev(struct ccw_device *cdev)
{
	struct dasd_devmap *devmap;

530
	devmap = dasd_find_busid(dev_name(&cdev->dev));
L
Linus Torvalds 已提交
531
	if (IS_ERR(devmap))
532
		devmap = dasd_add_busid(dev_name(&cdev->dev),
L
Linus Torvalds 已提交
533 534 535 536 537 538 539 540 541 542 543 544
					DASD_FEATURE_DEFAULT);
	return devmap;
}

/*
 * Create a dasd device structure for cdev.
 */
struct dasd_device *
dasd_create_device(struct ccw_device *cdev)
{
	struct dasd_devmap *devmap;
	struct dasd_device *device;
545
	unsigned long flags;
L
Linus Torvalds 已提交
546 547 548 549 550 551 552 553 554
	int rc;

	devmap = dasd_devmap_from_cdev(cdev);
	if (IS_ERR(devmap))
		return (void *) devmap;

	device = dasd_alloc_device();
	if (IS_ERR(device))
		return device;
555
	atomic_set(&device->ref_count, 3);
L
Linus Torvalds 已提交
556 557 558 559 560

	spin_lock(&dasd_devmap_lock);
	if (!devmap->device) {
		devmap->device = device;
		device->devindex = devmap->devindex;
561
		device->features = devmap->features;
L
Linus Torvalds 已提交
562 563 564 565 566 567 568 569 570 571 572 573
		get_device(&cdev->dev);
		device->cdev = cdev;
		rc = 0;
	} else
		/* Someone else was faster. */
		rc = -EBUSY;
	spin_unlock(&dasd_devmap_lock);

	if (rc) {
		dasd_free_device(device);
		return ERR_PTR(rc);
	}
574 575

	spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
576
	dev_set_drvdata(&cdev->dev, device);
577 578
	spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);

579 580 581 582 583
	device->paths_info = kset_create_and_add("paths_info", NULL,
						 &device->cdev->dev.kobj);
	if (!device->paths_info)
		dev_warn(&cdev->dev, "Could not create paths_info kset\n");

L
Linus Torvalds 已提交
584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600
	return device;
}

/*
 * Wait queue for dasd_delete_device waits.
 */
static DECLARE_WAIT_QUEUE_HEAD(dasd_delete_wq);

/*
 * Remove a dasd device structure. The passed referenced
 * is destroyed.
 */
void
dasd_delete_device(struct dasd_device *device)
{
	struct ccw_device *cdev;
	struct dasd_devmap *devmap;
601
	unsigned long flags;
L
Linus Torvalds 已提交
602 603

	/* First remove device pointer from devmap. */
604
	devmap = dasd_find_busid(dev_name(&device->cdev->dev));
605
	BUG_ON(IS_ERR(devmap));
L
Linus Torvalds 已提交
606 607 608 609 610 611 612 613 614
	spin_lock(&dasd_devmap_lock);
	if (devmap->device != device) {
		spin_unlock(&dasd_devmap_lock);
		dasd_put_device(device);
		return;
	}
	devmap->device = NULL;
	spin_unlock(&dasd_devmap_lock);

615 616
	/* Disconnect dasd_device structure from ccw_device structure. */
	spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
617
	dev_set_drvdata(&device->cdev->dev, NULL);
618 619 620 621 622 623 624
	spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);

	/*
	 * Drop ref_count by 3, one for the devmap reference, one for
	 * the cdev reference and one for the passed reference.
	 */
	atomic_sub(3, &device->ref_count);
L
Linus Torvalds 已提交
625 626 627 628

	/* Wait for reference counter to drop to zero. */
	wait_event(dasd_delete_wq, atomic_read(&device->ref_count) == 0);

629
	dasd_generic_free_discipline(device);
630 631 632

	kset_unregister(device->paths_info);

L
Linus Torvalds 已提交
633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652
	/* Disconnect dasd_device structure from ccw_device structure. */
	cdev = device->cdev;
	device->cdev = NULL;

	/* Put ccw_device structure. */
	put_device(&cdev->dev);

	/* Now the device structure can be freed. */
	dasd_free_device(device);
}

/*
 * Reference counter dropped to zero. Wake up waiter
 * in dasd_delete_device.
 */
void
dasd_put_device_wake(struct dasd_device *device)
{
	wake_up(&dasd_delete_wq);
}
653
EXPORT_SYMBOL_GPL(dasd_put_device_wake);
L
Linus Torvalds 已提交
654

655 656 657 658 659 660 661 662
/*
 * Return dasd_device structure associated with cdev.
 * This function needs to be called with the ccw device
 * lock held. It can be used from interrupt context.
 */
struct dasd_device *
dasd_device_from_cdev_locked(struct ccw_device *cdev)
{
663
	struct dasd_device *device = dev_get_drvdata(&cdev->dev);
664 665 666 667 668 669 670

	if (!device)
		return ERR_PTR(-ENODEV);
	dasd_get_device(device);
	return device;
}

L
Linus Torvalds 已提交
671 672 673 674 675 676 677
/*
 * Return dasd_device structure associated with cdev.
 */
struct dasd_device *
dasd_device_from_cdev(struct ccw_device *cdev)
{
	struct dasd_device *device;
678
	unsigned long flags;
L
Linus Torvalds 已提交
679

680 681 682
	spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
	device = dasd_device_from_cdev_locked(cdev);
	spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
L
Linus Torvalds 已提交
683 684 685
	return device;
}

686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715
void dasd_add_link_to_gendisk(struct gendisk *gdp, struct dasd_device *device)
{
	struct dasd_devmap *devmap;

	devmap = dasd_find_busid(dev_name(&device->cdev->dev));
	if (IS_ERR(devmap))
		return;
	spin_lock(&dasd_devmap_lock);
	gdp->private_data = devmap;
	spin_unlock(&dasd_devmap_lock);
}

struct dasd_device *dasd_device_from_gendisk(struct gendisk *gdp)
{
	struct dasd_device *device;
	struct dasd_devmap *devmap;

	if (!gdp->private_data)
		return NULL;
	device = NULL;
	spin_lock(&dasd_devmap_lock);
	devmap = gdp->private_data;
	if (devmap && devmap->device) {
		device = devmap->device;
		dasd_get_device(device);
	}
	spin_unlock(&dasd_devmap_lock);
	return device;
}

L
Linus Torvalds 已提交
716 717 718 719
/*
 * SECTION: files in sysfs
 */

720 721 722 723 724 725 726 727 728
/*
 * failfast controls the behaviour, if no path is available
 */
static ssize_t dasd_ff_show(struct device *dev, struct device_attribute *attr,
			    char *buf)
{
	struct dasd_devmap *devmap;
	int ff_flag;

729
	devmap = dasd_find_busid(dev_name(dev));
730 731 732 733 734 735 736 737 738 739
	if (!IS_ERR(devmap))
		ff_flag = (devmap->features & DASD_FEATURE_FAILFAST) != 0;
	else
		ff_flag = (DASD_FEATURE_DEFAULT & DASD_FEATURE_FAILFAST) != 0;
	return snprintf(buf, PAGE_SIZE, ff_flag ? "1\n" : "0\n");
}

static ssize_t dasd_ff_store(struct device *dev, struct device_attribute *attr,
	      const char *buf, size_t count)
{
740
	unsigned int val;
741
	int rc;
742

743
	if (kstrtouint(buf, 0, &val) || val > 1)
744 745
		return -EINVAL;

746 747 748
	rc = dasd_set_feature(to_ccwdev(dev), DASD_FEATURE_FAILFAST, val);

	return rc ? : count;
749 750 751 752
}

static DEVICE_ATTR(failfast, 0644, dasd_ff_show, dasd_ff_store);

L
Linus Torvalds 已提交
753 754 755 756
/*
 * readonly controls the readonly status of a dasd
 */
static ssize_t
757
dasd_ro_show(struct device *dev, struct device_attribute *attr, char *buf)
L
Linus Torvalds 已提交
758 759
{
	struct dasd_devmap *devmap;
760 761
	struct dasd_device *device;
	int ro_flag = 0;
L
Linus Torvalds 已提交
762

763
	devmap = dasd_find_busid(dev_name(dev));
764 765 766 767 768 769 770 771 772 773 774 775
	if (IS_ERR(devmap))
		goto out;

	ro_flag = !!(devmap->features & DASD_FEATURE_READONLY);

	spin_lock(&dasd_devmap_lock);
	device = devmap->device;
	if (device)
		ro_flag |= test_bit(DASD_FLAG_DEVICE_RO, &device->flags);
	spin_unlock(&dasd_devmap_lock);

out:
L
Linus Torvalds 已提交
776 777 778 779
	return snprintf(buf, PAGE_SIZE, ro_flag ? "1\n" : "0\n");
}

static ssize_t
780 781
dasd_ro_store(struct device *dev, struct device_attribute *attr,
	      const char *buf, size_t count)
L
Linus Torvalds 已提交
782
{
783
	struct ccw_device *cdev = to_ccwdev(dev);
784
	struct dasd_device *device;
785
	unsigned long flags;
786
	unsigned int val;
787
	int rc;
788

789
	if (kstrtouint(buf, 0, &val) || val > 1)
790 791
		return -EINVAL;

792 793 794 795 796 797
	rc = dasd_set_feature(cdev, DASD_FEATURE_READONLY, val);
	if (rc)
		return rc;

	device = dasd_device_from_cdev(cdev);
	if (IS_ERR(device))
798
		return count;
799

800
	spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
801 802
	val = val || test_bit(DASD_FLAG_DEVICE_RO, &device->flags);

803 804 805 806 807 808 809 810 811 812 813 814 815
	if (!device->block || !device->block->gdp ||
	    test_bit(DASD_FLAG_OFFLINE, &device->flags)) {
		spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
		goto out;
	}
	/* Increase open_count to avoid losing the block device */
	atomic_inc(&device->block->open_count);
	spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);

	set_disk_ro(device->block->gdp, val);
	atomic_dec(&device->block->open_count);

out:
816 817
	dasd_put_device(device);

L
Linus Torvalds 已提交
818 819 820 821
	return count;
}

static DEVICE_ATTR(readonly, 0644, dasd_ro_show, dasd_ro_store);
822 823 824 825 826 827 828 829 830 831
/*
 * erplog controls the logging of ERP related data
 * (e.g. failing channel programs).
 */
static ssize_t
dasd_erplog_show(struct device *dev, struct device_attribute *attr, char *buf)
{
	struct dasd_devmap *devmap;
	int erplog;

832
	devmap = dasd_find_busid(dev_name(dev));
833 834 835 836 837 838 839 840 841 842 843
	if (!IS_ERR(devmap))
		erplog = (devmap->features & DASD_FEATURE_ERPLOG) != 0;
	else
		erplog = (DASD_FEATURE_DEFAULT & DASD_FEATURE_ERPLOG) != 0;
	return snprintf(buf, PAGE_SIZE, erplog ? "1\n" : "0\n");
}

static ssize_t
dasd_erplog_store(struct device *dev, struct device_attribute *attr,
	      const char *buf, size_t count)
{
844
	unsigned int val;
845
	int rc;
846

847
	if (kstrtouint(buf, 0, &val) || val > 1)
848 849
		return -EINVAL;

850 851 852
	rc = dasd_set_feature(to_ccwdev(dev), DASD_FEATURE_ERPLOG, val);

	return rc ? : count;
853 854 855
}

static DEVICE_ATTR(erplog, 0644, dasd_erplog_show, dasd_erplog_store);
L
Linus Torvalds 已提交
856 857 858 859 860

/*
 * use_diag controls whether the driver should use diag rather than ssch
 * to talk to the device
 */
861
static ssize_t
862
dasd_use_diag_show(struct device *dev, struct device_attribute *attr, char *buf)
L
Linus Torvalds 已提交
863 864 865 866
{
	struct dasd_devmap *devmap;
	int use_diag;

867
	devmap = dasd_find_busid(dev_name(dev));
L
Linus Torvalds 已提交
868 869 870 871 872 873 874 875
	if (!IS_ERR(devmap))
		use_diag = (devmap->features & DASD_FEATURE_USEDIAG) != 0;
	else
		use_diag = (DASD_FEATURE_DEFAULT & DASD_FEATURE_USEDIAG) != 0;
	return sprintf(buf, use_diag ? "1\n" : "0\n");
}

static ssize_t
876 877
dasd_use_diag_store(struct device *dev, struct device_attribute *attr,
		    const char *buf, size_t count)
L
Linus Torvalds 已提交
878 879
{
	struct dasd_devmap *devmap;
880
	unsigned int val;
L
Linus Torvalds 已提交
881 882 883 884 885
	ssize_t rc;

	devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
	if (IS_ERR(devmap))
		return PTR_ERR(devmap);
886

887
	if (kstrtouint(buf, 0, &val) || val > 1)
888 889
		return -EINVAL;

L
Linus Torvalds 已提交
890 891 892
	spin_lock(&dasd_devmap_lock);
	/* Changing diag discipline flag is only allowed in offline state. */
	rc = count;
893
	if (!devmap->device && !(devmap->features & DASD_FEATURE_USERAW)) {
894
		if (val)
L
Linus Torvalds 已提交
895 896 897 898 899 900 901 902 903
			devmap->features |= DASD_FEATURE_USEDIAG;
		else
			devmap->features &= ~DASD_FEATURE_USEDIAG;
	} else
		rc = -EPERM;
	spin_unlock(&dasd_devmap_lock);
	return rc;
}

904
static DEVICE_ATTR(use_diag, 0644, dasd_use_diag_show, dasd_use_diag_store);
L
Linus Torvalds 已提交
905

906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935
/*
 * use_raw controls whether the driver should give access to raw eckd data or
 * operate in standard mode
 */
static ssize_t
dasd_use_raw_show(struct device *dev, struct device_attribute *attr, char *buf)
{
	struct dasd_devmap *devmap;
	int use_raw;

	devmap = dasd_find_busid(dev_name(dev));
	if (!IS_ERR(devmap))
		use_raw = (devmap->features & DASD_FEATURE_USERAW) != 0;
	else
		use_raw = (DASD_FEATURE_DEFAULT & DASD_FEATURE_USERAW) != 0;
	return sprintf(buf, use_raw ? "1\n" : "0\n");
}

static ssize_t
dasd_use_raw_store(struct device *dev, struct device_attribute *attr,
		    const char *buf, size_t count)
{
	struct dasd_devmap *devmap;
	ssize_t rc;
	unsigned long val;

	devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
	if (IS_ERR(devmap))
		return PTR_ERR(devmap);

936
	if ((kstrtoul(buf, 10, &val) != 0) || val > 1)
937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955
		return -EINVAL;

	spin_lock(&dasd_devmap_lock);
	/* Changing diag discipline flag is only allowed in offline state. */
	rc = count;
	if (!devmap->device && !(devmap->features & DASD_FEATURE_USEDIAG)) {
		if (val)
			devmap->features |= DASD_FEATURE_USERAW;
		else
			devmap->features &= ~DASD_FEATURE_USERAW;
	} else
		rc = -EPERM;
	spin_unlock(&dasd_devmap_lock);
	return rc;
}

static DEVICE_ATTR(raw_track_access, 0644, dasd_use_raw_show,
		   dasd_use_raw_store);

956 957 958 959 960 961
static ssize_t
dasd_safe_offline_store(struct device *dev, struct device_attribute *attr,
			const char *buf, size_t count)
{
	struct ccw_device *cdev = to_ccwdev(dev);
	struct dasd_device *device;
962
	unsigned long flags;
963 964
	int rc;

965 966
	spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
	device = dasd_device_from_cdev_locked(cdev);
967 968
	if (IS_ERR(device)) {
		rc = PTR_ERR(device);
969
		spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
970 971 972 973 974 975 976
		goto out;
	}

	if (test_bit(DASD_FLAG_OFFLINE, &device->flags) ||
	    test_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags)) {
		/* Already doing offline processing */
		dasd_put_device(device);
977
		spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
978 979 980 981 982 983
		rc = -EBUSY;
		goto out;
	}

	set_bit(DASD_FLAG_SAFE_OFFLINE, &device->flags);
	dasd_put_device(device);
984
	spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
985 986 987 988 989 990 991 992 993

	rc = ccw_device_set_offline(cdev);

out:
	return rc ? rc : count;
}

static DEVICE_ATTR(safe_offline, 0200, NULL, dasd_safe_offline_store);

994 995 996 997 998 999 1000 1001 1002 1003 1004 1005
static ssize_t
dasd_access_show(struct device *dev, struct device_attribute *attr,
		 char *buf)
{
	struct ccw_device *cdev = to_ccwdev(dev);
	struct dasd_device *device;
	int count;

	device = dasd_device_from_cdev(cdev);
	if (IS_ERR(device))
		return PTR_ERR(device);

1006 1007 1008
	if (!device->discipline)
		count = -ENODEV;
	else if (!device->discipline->host_access_count)
1009
		count = -EOPNOTSUPP;
1010 1011
	else
		count = device->discipline->host_access_count(device);
1012 1013 1014 1015 1016 1017 1018 1019 1020 1021

	dasd_put_device(device);
	if (count < 0)
		return count;

	return sprintf(buf, "%d\n", count);
}

static DEVICE_ATTR(host_access_count, 0444, dasd_access_show, NULL);

L
Linus Torvalds 已提交
1022
static ssize_t
1023 1024
dasd_discipline_show(struct device *dev, struct device_attribute *attr,
		     char *buf)
L
Linus Torvalds 已提交
1025
{
1026 1027
	struct dasd_device *device;
	ssize_t len;
L
Linus Torvalds 已提交
1028

1029
	device = dasd_device_from_cdev(to_ccwdev(dev));
S
Stefan Haberland 已提交
1030 1031 1032 1033 1034 1035
	if (IS_ERR(device))
		goto out;
	else if (!device->discipline) {
		dasd_put_device(device);
		goto out;
	} else {
1036 1037 1038
		len = snprintf(buf, PAGE_SIZE, "%s\n",
			       device->discipline->name);
		dasd_put_device(device);
S
Stefan Haberland 已提交
1039 1040 1041 1042
		return len;
	}
out:
	len = snprintf(buf, PAGE_SIZE, "none\n");
1043
	return len;
L
Linus Torvalds 已提交
1044 1045 1046 1047
}

static DEVICE_ATTR(discipline, 0444, dasd_discipline_show, NULL);

1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087
static ssize_t
dasd_device_status_show(struct device *dev, struct device_attribute *attr,
		     char *buf)
{
	struct dasd_device *device;
	ssize_t len;

	device = dasd_device_from_cdev(to_ccwdev(dev));
	if (!IS_ERR(device)) {
		switch (device->state) {
		case DASD_STATE_NEW:
			len = snprintf(buf, PAGE_SIZE, "new\n");
			break;
		case DASD_STATE_KNOWN:
			len = snprintf(buf, PAGE_SIZE, "detected\n");
			break;
		case DASD_STATE_BASIC:
			len = snprintf(buf, PAGE_SIZE, "basic\n");
			break;
		case DASD_STATE_UNFMT:
			len = snprintf(buf, PAGE_SIZE, "unformatted\n");
			break;
		case DASD_STATE_READY:
			len = snprintf(buf, PAGE_SIZE, "ready\n");
			break;
		case DASD_STATE_ONLINE:
			len = snprintf(buf, PAGE_SIZE, "online\n");
			break;
		default:
			len = snprintf(buf, PAGE_SIZE, "no stat\n");
			break;
		}
		dasd_put_device(device);
	} else
		len = snprintf(buf, PAGE_SIZE, "unknown\n");
	return len;
}

static DEVICE_ATTR(status, 0444, dasd_device_status_show, NULL);

1088 1089
static ssize_t dasd_alias_show(struct device *dev,
			       struct device_attribute *attr, char *buf)
1090
{
1091 1092
	struct dasd_device *device;
	struct dasd_uid uid;
1093

1094 1095
	device = dasd_device_from_cdev(to_ccwdev(dev));
	if (IS_ERR(device))
1096
		return sprintf(buf, "0\n");
1097 1098 1099 1100

	if (device->discipline && device->discipline->get_uid &&
	    !device->discipline->get_uid(device, &uid)) {
		if (uid.type == UA_BASE_PAV_ALIAS ||
S
Stefan Haberland 已提交
1101 1102
		    uid.type == UA_HYPER_PAV_ALIAS) {
			dasd_put_device(device);
1103
			return sprintf(buf, "1\n");
S
Stefan Haberland 已提交
1104
		}
1105
	}
1106 1107 1108
	dasd_put_device(device);

	return sprintf(buf, "0\n");
1109 1110 1111 1112
}

static DEVICE_ATTR(alias, 0444, dasd_alias_show, NULL);

1113 1114
static ssize_t dasd_vendor_show(struct device *dev,
				struct device_attribute *attr, char *buf)
1115
{
1116 1117
	struct dasd_device *device;
	struct dasd_uid uid;
1118 1119
	char *vendor;

1120 1121 1122 1123 1124 1125 1126 1127 1128 1129
	device = dasd_device_from_cdev(to_ccwdev(dev));
	vendor = "";
	if (IS_ERR(device))
		return snprintf(buf, PAGE_SIZE, "%s\n", vendor);

	if (device->discipline && device->discipline->get_uid &&
	    !device->discipline->get_uid(device, &uid))
			vendor = uid.vendor;

	dasd_put_device(device);
1130 1131 1132 1133 1134 1135 1136

	return snprintf(buf, PAGE_SIZE, "%s\n", vendor);
}

static DEVICE_ATTR(vendor, 0444, dasd_vendor_show, NULL);

#define UID_STRLEN ( /* vendor */ 3 + 1 + /* serial    */ 14 + 1 +\
1137 1138
		     /* SSID   */ 4 + 1 + /* unit addr */ 2 + 1 +\
		     /* vduit */ 32 + 1)
1139 1140 1141 1142

static ssize_t
dasd_uid_show(struct device *dev, struct device_attribute *attr, char *buf)
{
1143 1144
	struct dasd_device *device;
	struct dasd_uid uid;
1145 1146
	char uid_string[UID_STRLEN];
	char ua_string[3];
1147

1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182
	device = dasd_device_from_cdev(to_ccwdev(dev));
	uid_string[0] = 0;
	if (IS_ERR(device))
		return snprintf(buf, PAGE_SIZE, "%s\n", uid_string);

	if (device->discipline && device->discipline->get_uid &&
	    !device->discipline->get_uid(device, &uid)) {
		switch (uid.type) {
		case UA_BASE_DEVICE:
			snprintf(ua_string, sizeof(ua_string), "%02x",
				 uid.real_unit_addr);
			break;
		case UA_BASE_PAV_ALIAS:
			snprintf(ua_string, sizeof(ua_string), "%02x",
				 uid.base_unit_addr);
			break;
		case UA_HYPER_PAV_ALIAS:
			snprintf(ua_string, sizeof(ua_string), "xx");
			break;
		default:
			/* should not happen, treat like base device */
			snprintf(ua_string, sizeof(ua_string), "%02x",
				 uid.real_unit_addr);
			break;
		}

		if (strlen(uid.vduit) > 0)
			snprintf(uid_string, sizeof(uid_string),
				 "%s.%s.%04x.%s.%s",
				 uid.vendor, uid.serial, uid.ssid, ua_string,
				 uid.vduit);
		else
			snprintf(uid_string, sizeof(uid_string),
				 "%s.%s.%04x.%s",
				 uid.vendor, uid.serial, uid.ssid, ua_string);
1183
	}
1184 1185
	dasd_put_device(device);

1186
	return snprintf(buf, PAGE_SIZE, "%s\n", uid_string);
1187 1188 1189
}
static DEVICE_ATTR(uid, 0444, dasd_uid_show, NULL);

1190 1191 1192 1193 1194 1195 1196 1197 1198
/*
 * extended error-reporting
 */
static ssize_t
dasd_eer_show(struct device *dev, struct device_attribute *attr, char *buf)
{
	struct dasd_devmap *devmap;
	int eer_flag;

1199
	devmap = dasd_find_busid(dev_name(dev));
1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210
	if (!IS_ERR(devmap) && devmap->device)
		eer_flag = dasd_eer_enabled(devmap->device);
	else
		eer_flag = 0;
	return snprintf(buf, PAGE_SIZE, eer_flag ? "1\n" : "0\n");
}

static ssize_t
dasd_eer_store(struct device *dev, struct device_attribute *attr,
	       const char *buf, size_t count)
{
1211
	struct dasd_device *device;
1212
	unsigned int val;
1213
	int rc = 0;
1214

1215 1216 1217
	device = dasd_device_from_cdev(to_ccwdev(dev));
	if (IS_ERR(device))
		return PTR_ERR(device);
1218

1219
	if (kstrtouint(buf, 0, &val) || val > 1)
1220 1221
		return -EINVAL;

1222 1223 1224 1225 1226 1227 1228 1229
	if (val)
		rc = dasd_eer_enable(device);
	else
		dasd_eer_disable(device);

	dasd_put_device(device);

	return rc ? : count;
1230 1231 1232 1233
}

static DEVICE_ATTR(eer_enabled, 0644, dasd_eer_show, dasd_eer_store);

1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261
/*
 * expiration time for default requests
 */
static ssize_t
dasd_expires_show(struct device *dev, struct device_attribute *attr, char *buf)
{
	struct dasd_device *device;
	int len;

	device = dasd_device_from_cdev(to_ccwdev(dev));
	if (IS_ERR(device))
		return -ENODEV;
	len = snprintf(buf, PAGE_SIZE, "%lu\n", device->default_expires);
	dasd_put_device(device);
	return len;
}

static ssize_t
dasd_expires_store(struct device *dev, struct device_attribute *attr,
	       const char *buf, size_t count)
{
	struct dasd_device *device;
	unsigned long val;

	device = dasd_device_from_cdev(to_ccwdev(dev));
	if (IS_ERR(device))
		return -ENODEV;

1262
	if ((kstrtoul(buf, 10, &val) != 0) ||
1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276
	    (val > DASD_EXPIRES_MAX) || val == 0) {
		dasd_put_device(device);
		return -EINVAL;
	}

	if (val)
		device->default_expires = val;

	dasd_put_device(device);
	return count;
}

static DEVICE_ATTR(expires, 0644, dasd_expires_show, dasd_expires_store);

1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301
static ssize_t
dasd_retries_show(struct device *dev, struct device_attribute *attr, char *buf)
{
	struct dasd_device *device;
	int len;

	device = dasd_device_from_cdev(to_ccwdev(dev));
	if (IS_ERR(device))
		return -ENODEV;
	len = snprintf(buf, PAGE_SIZE, "%lu\n", device->default_retries);
	dasd_put_device(device);
	return len;
}

static ssize_t
dasd_retries_store(struct device *dev, struct device_attribute *attr,
		   const char *buf, size_t count)
{
	struct dasd_device *device;
	unsigned long val;

	device = dasd_device_from_cdev(to_ccwdev(dev));
	if (IS_ERR(device))
		return -ENODEV;

1302
	if ((kstrtoul(buf, 10, &val) != 0) ||
1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316
	    (val > DASD_RETRIES_MAX)) {
		dasd_put_device(device);
		return -EINVAL;
	}

	if (val)
		device->default_retries = val;

	dasd_put_device(device);
	return count;
}

static DEVICE_ATTR(retries, 0644, dasd_retries_show, dasd_retries_store);

1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337
static ssize_t
dasd_timeout_show(struct device *dev, struct device_attribute *attr,
		  char *buf)
{
	struct dasd_device *device;
	int len;

	device = dasd_device_from_cdev(to_ccwdev(dev));
	if (IS_ERR(device))
		return -ENODEV;
	len = snprintf(buf, PAGE_SIZE, "%lu\n", device->blk_timeout);
	dasd_put_device(device);
	return len;
}

static ssize_t
dasd_timeout_store(struct device *dev, struct device_attribute *attr,
		   const char *buf, size_t count)
{
	struct dasd_device *device;
	struct request_queue *q;
S
Stefan Haberland 已提交
1338
	unsigned long val;
1339 1340 1341 1342 1343

	device = dasd_device_from_cdev(to_ccwdev(dev));
	if (IS_ERR(device) || !device->block)
		return -ENODEV;

1344
	if ((kstrtoul(buf, 10, &val) != 0) ||
1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365
	    val > UINT_MAX / HZ) {
		dasd_put_device(device);
		return -EINVAL;
	}
	q = device->block->request_queue;
	if (!q) {
		dasd_put_device(device);
		return -ENODEV;
	}

	device->blk_timeout = val;

	blk_queue_rq_timeout(q, device->blk_timeout * HZ);

	dasd_put_device(device);
	return count;
}

static DEVICE_ATTR(timeout, 0644,
		   dasd_timeout_show, dasd_timeout_store);

1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409

static ssize_t
dasd_path_reset_store(struct device *dev, struct device_attribute *attr,
		      const char *buf, size_t count)
{
	struct dasd_device *device;
	unsigned int val;

	device = dasd_device_from_cdev(to_ccwdev(dev));
	if (IS_ERR(device))
		return -ENODEV;

	if ((kstrtouint(buf, 16, &val) != 0) || val > 0xff)
		val = 0;

	if (device->discipline && device->discipline->reset_path)
		device->discipline->reset_path(device, (__u8) val);

	dasd_put_device(device);
	return count;
}

static DEVICE_ATTR(path_reset, 0200, NULL, dasd_path_reset_store);

static ssize_t dasd_hpf_show(struct device *dev, struct device_attribute *attr,
			     char *buf)
{
	struct dasd_device *device;
	int hpf;

	device = dasd_device_from_cdev(to_ccwdev(dev));
	if (IS_ERR(device))
		return -ENODEV;
	if (!device->discipline || !device->discipline->hpf_enabled) {
		dasd_put_device(device);
		return snprintf(buf, PAGE_SIZE, "%d\n", dasd_nofcx);
	}
	hpf = device->discipline->hpf_enabled(device);
	dasd_put_device(device);
	return snprintf(buf, PAGE_SIZE, "%d\n", hpf);
}

static DEVICE_ATTR(hpf, 0444, dasd_hpf_show, NULL);

1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434
static ssize_t dasd_reservation_policy_show(struct device *dev,
					    struct device_attribute *attr,
					    char *buf)
{
	struct dasd_devmap *devmap;
	int rc = 0;

	devmap = dasd_find_busid(dev_name(dev));
	if (IS_ERR(devmap)) {
		rc = snprintf(buf, PAGE_SIZE, "ignore\n");
	} else {
		spin_lock(&dasd_devmap_lock);
		if (devmap->features & DASD_FEATURE_FAILONSLCK)
			rc = snprintf(buf, PAGE_SIZE, "fail\n");
		else
			rc = snprintf(buf, PAGE_SIZE, "ignore\n");
		spin_unlock(&dasd_devmap_lock);
	}
	return rc;
}

static ssize_t dasd_reservation_policy_store(struct device *dev,
					     struct device_attribute *attr,
					     const char *buf, size_t count)
{
1435
	struct ccw_device *cdev = to_ccwdev(dev);
1436 1437 1438
	int rc;

	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);
1442 1443
	else
		rc = -EINVAL;
1444 1445

	return rc ? : count;
1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496
}

static DEVICE_ATTR(reservation_policy, 0644,
		   dasd_reservation_policy_show, dasd_reservation_policy_store);

static ssize_t dasd_reservation_state_show(struct device *dev,
					   struct device_attribute *attr,
					   char *buf)
{
	struct dasd_device *device;
	int rc = 0;

	device = dasd_device_from_cdev(to_ccwdev(dev));
	if (IS_ERR(device))
		return snprintf(buf, PAGE_SIZE, "none\n");

	if (test_bit(DASD_FLAG_IS_RESERVED, &device->flags))
		rc = snprintf(buf, PAGE_SIZE, "reserved\n");
	else if (test_bit(DASD_FLAG_LOCK_STOLEN, &device->flags))
		rc = snprintf(buf, PAGE_SIZE, "lost\n");
	else
		rc = snprintf(buf, PAGE_SIZE, "none\n");
	dasd_put_device(device);
	return rc;
}

static ssize_t dasd_reservation_state_store(struct device *dev,
					    struct device_attribute *attr,
					    const char *buf, size_t count)
{
	struct dasd_device *device;
	int rc = 0;

	device = dasd_device_from_cdev(to_ccwdev(dev));
	if (IS_ERR(device))
		return -ENODEV;
	if (sysfs_streq("reset", buf))
		clear_bit(DASD_FLAG_LOCK_STOLEN, &device->flags);
	else
		rc = -EINVAL;
	dasd_put_device(device);

	if (rc)
		return rc;
	else
		return count;
}

static DEVICE_ATTR(last_known_reservation_state, 0644,
		   dasd_reservation_state_show, dasd_reservation_state_store);

1497 1498 1499 1500
static ssize_t dasd_pm_show(struct device *dev,
			      struct device_attribute *attr, char *buf)
{
	struct dasd_device *device;
1501
	u8 opm, nppm, cablepm, cuirpm, hpfpm, ifccpm;
1502 1503 1504 1505 1506

	device = dasd_device_from_cdev(to_ccwdev(dev));
	if (IS_ERR(device))
		return sprintf(buf, "0\n");

1507 1508 1509 1510 1511
	opm = dasd_path_get_opm(device);
	nppm = dasd_path_get_nppm(device);
	cablepm = dasd_path_get_cablepm(device);
	cuirpm = dasd_path_get_cuirpm(device);
	hpfpm = dasd_path_get_hpfpm(device);
1512
	ifccpm = dasd_path_get_ifccpm(device);
1513 1514
	dasd_put_device(device);

1515 1516
	return sprintf(buf, "%02x %02x %02x %02x %02x %02x\n", opm, nppm,
		       cablepm, cuirpm, hpfpm, ifccpm);
1517 1518 1519 1520
}

static DEVICE_ATTR(path_masks, 0444, dasd_pm_show, NULL);

1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550
/*
 * threshold value for IFCC/CCC errors
 */
static ssize_t
dasd_path_threshold_show(struct device *dev,
			  struct device_attribute *attr, char *buf)
{
	struct dasd_device *device;
	int len;

	device = dasd_device_from_cdev(to_ccwdev(dev));
	if (IS_ERR(device))
		return -ENODEV;
	len = snprintf(buf, PAGE_SIZE, "%lu\n", device->path_thrhld);
	dasd_put_device(device);
	return len;
}

static ssize_t
dasd_path_threshold_store(struct device *dev, struct device_attribute *attr,
			   const char *buf, size_t count)
{
	struct dasd_device *device;
	unsigned long flags;
	unsigned long val;

	device = dasd_device_from_cdev(to_ccwdev(dev));
	if (IS_ERR(device))
		return -ENODEV;

1551
	if (kstrtoul(buf, 10, &val) != 0 || val > DASD_THRHLD_MAX) {
1552 1553 1554 1555
		dasd_put_device(device);
		return -EINVAL;
	}
	spin_lock_irqsave(get_ccwdev_lock(to_ccwdev(dev)), flags);
1556
	device->path_thrhld = val;
1557 1558 1559 1560 1561 1562
	spin_unlock_irqrestore(get_ccwdev_lock(to_ccwdev(dev)), flags);
	dasd_put_device(device);
	return count;
}
static DEVICE_ATTR(path_threshold, 0644, dasd_path_threshold_show,
		   dasd_path_threshold_store);
1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603

/*
 * configure if path is disabled after IFCC/CCC error threshold is
 * exceeded
 */
static ssize_t
dasd_path_autodisable_show(struct device *dev,
				   struct device_attribute *attr, char *buf)
{
	struct dasd_devmap *devmap;
	int flag;

	devmap = dasd_find_busid(dev_name(dev));
	if (!IS_ERR(devmap))
		flag = (devmap->features & DASD_FEATURE_PATH_AUTODISABLE) != 0;
	else
		flag = (DASD_FEATURE_DEFAULT &
			DASD_FEATURE_PATH_AUTODISABLE) != 0;
	return snprintf(buf, PAGE_SIZE, flag ? "1\n" : "0\n");
}

static ssize_t
dasd_path_autodisable_store(struct device *dev,
				    struct device_attribute *attr,
				    const char *buf, size_t count)
{
	unsigned int val;
	int rc;

	if (kstrtouint(buf, 0, &val) || val > 1)
		return -EINVAL;

	rc = dasd_set_feature(to_ccwdev(dev),
			      DASD_FEATURE_PATH_AUTODISABLE, val);

	return rc ? : count;
}

static DEVICE_ATTR(path_autodisable, 0644,
		   dasd_path_autodisable_show,
		   dasd_path_autodisable_store);
1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651
/*
 * interval for IFCC/CCC checks
 * meaning time with no IFCC/CCC error before the error counter
 * gets reset
 */
static ssize_t
dasd_path_interval_show(struct device *dev,
			struct device_attribute *attr, char *buf)
{
	struct dasd_device *device;
	int len;

	device = dasd_device_from_cdev(to_ccwdev(dev));
	if (IS_ERR(device))
		return -ENODEV;
	len = snprintf(buf, PAGE_SIZE, "%lu\n", device->path_interval);
	dasd_put_device(device);
	return len;
}

static ssize_t
dasd_path_interval_store(struct device *dev, struct device_attribute *attr,
	       const char *buf, size_t count)
{
	struct dasd_device *device;
	unsigned long flags;
	unsigned long val;

	device = dasd_device_from_cdev(to_ccwdev(dev));
	if (IS_ERR(device))
		return -ENODEV;

	if ((kstrtoul(buf, 10, &val) != 0) ||
	    (val > DASD_INTERVAL_MAX) || val == 0) {
		dasd_put_device(device);
		return -EINVAL;
	}
	spin_lock_irqsave(get_ccwdev_lock(to_ccwdev(dev)), flags);
	if (val)
		device->path_interval = val;
	spin_unlock_irqrestore(get_ccwdev_lock(to_ccwdev(dev)), flags);
	dasd_put_device(device);
	return count;
}

static DEVICE_ATTR(path_interval, 0644, dasd_path_interval_show,
		   dasd_path_interval_store);

1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684
static ssize_t
dasd_device_fcs_show(struct device *dev, struct device_attribute *attr,
		     char *buf)
{
	struct dasd_device *device;
	int fc_sec;
	int rc;

	device = dasd_device_from_cdev(to_ccwdev(dev));
	if (IS_ERR(device))
		return -ENODEV;
	fc_sec = dasd_path_get_fcs_device(device);
	if (fc_sec == -EINVAL)
		rc = snprintf(buf, PAGE_SIZE, "Inconsistent\n");
	else
		rc = snprintf(buf, PAGE_SIZE, "%s\n", dasd_path_get_fcs_str(fc_sec));
	dasd_put_device(device);

	return rc;
}
static DEVICE_ATTR(fc_security, 0444, dasd_device_fcs_show, NULL);

static ssize_t
dasd_path_fcs_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
{
	struct dasd_path *path = to_dasd_path(kobj);
	unsigned int fc_sec = path->fc_security;

	return snprintf(buf, PAGE_SIZE, "%s\n", dasd_path_get_fcs_str(fc_sec));
}

static struct kobj_attribute path_fcs_attribute =
	__ATTR(fc_security, 0444, dasd_path_fcs_show, NULL);
1685

1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714
#define DASD_DEFINE_ATTR(_name, _func)					\
static ssize_t dasd_##_name##_show(struct device *dev,			\
				   struct device_attribute *attr,	\
				   char *buf)				\
{									\
	struct ccw_device *cdev = to_ccwdev(dev);			\
	struct dasd_device *device = dasd_device_from_cdev(cdev);	\
	int val = 0;							\
									\
	if (IS_ERR(device))						\
		return -ENODEV;						\
	if (device->discipline && _func)				\
		val = _func(device);					\
	dasd_put_device(device);					\
									\
	return snprintf(buf, PAGE_SIZE, "%d\n", val);			\
}									\
static DEVICE_ATTR(_name, 0444, dasd_##_name##_show, NULL);		\

DASD_DEFINE_ATTR(ese, device->discipline->is_ese);
DASD_DEFINE_ATTR(extent_size, device->discipline->ext_size);
DASD_DEFINE_ATTR(pool_id, device->discipline->ext_pool_id);
DASD_DEFINE_ATTR(space_configured, device->discipline->space_configured);
DASD_DEFINE_ATTR(space_allocated, device->discipline->space_allocated);
DASD_DEFINE_ATTR(logical_capacity, device->discipline->logical_capacity);
DASD_DEFINE_ATTR(warn_threshold, device->discipline->ext_pool_warn_thrshld);
DASD_DEFINE_ATTR(cap_at_warnlevel, device->discipline->ext_pool_cap_at_warnlevel);
DASD_DEFINE_ATTR(pool_oos, device->discipline->ext_pool_oos);

L
Linus Torvalds 已提交
1715 1716 1717
static struct attribute * dasd_attrs[] = {
	&dev_attr_readonly.attr,
	&dev_attr_discipline.attr,
1718
	&dev_attr_status.attr,
1719 1720 1721
	&dev_attr_alias.attr,
	&dev_attr_vendor.attr,
	&dev_attr_uid.attr,
L
Linus Torvalds 已提交
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 1731
	&dev_attr_reservation_policy.attr,
	&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 1738 1739
	&dev_attr_path_interval.attr,
	&dev_attr_path_reset.attr,
	&dev_attr_hpf.attr,
1740
	&dev_attr_ese.attr,
1741
	&dev_attr_fc_security.attr,
L
Linus Torvalds 已提交
1742 1743 1744
	NULL,
};

1745
static const struct attribute_group dasd_attr_group = {
L
Linus Torvalds 已提交
1746 1747 1748
	.attrs = dasd_attrs,
};

1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774
static struct attribute *capacity_attrs[] = {
	&dev_attr_space_configured.attr,
	&dev_attr_space_allocated.attr,
	&dev_attr_logical_capacity.attr,
	NULL,
};

static const struct attribute_group capacity_attr_group = {
	.name = "capacity",
	.attrs = capacity_attrs,
};

static struct attribute *ext_pool_attrs[] = {
	&dev_attr_pool_id.attr,
	&dev_attr_extent_size.attr,
	&dev_attr_warn_threshold.attr,
	&dev_attr_cap_at_warnlevel.attr,
	&dev_attr_pool_oos.attr,
	NULL,
};

static const struct attribute_group ext_pool_attr_group = {
	.name = "extent_pool",
	.attrs = ext_pool_attrs,
};

1775
const struct attribute_group *dasd_dev_groups[] = {
1776 1777 1778 1779 1780
	&dasd_attr_group,
	&capacity_attr_group,
	&ext_pool_attr_group,
	NULL,
};
1781
EXPORT_SYMBOL_GPL(dasd_dev_groups);
1782

1783 1784 1785 1786 1787 1788 1789 1790
/*
 * Return value of the specified feature.
 */
int
dasd_get_feature(struct ccw_device *cdev, int feature)
{
	struct dasd_devmap *devmap;

1791
	devmap = dasd_find_busid(dev_name(&cdev->dev));
1792
	if (IS_ERR(devmap))
1793
		return PTR_ERR(devmap);
1794 1795 1796 1797 1798 1799

	return ((devmap->features & feature) != 0);
}

/*
 * Set / reset given feature.
1800
 * Flag indicates whether to set (!=0) or the reset (=0) the feature.
1801 1802 1803 1804 1805 1806
 */
int
dasd_set_feature(struct ccw_device *cdev, int feature, int flag)
{
	struct dasd_devmap *devmap;

1807
	devmap = dasd_devmap_from_cdev(cdev);
1808
	if (IS_ERR(devmap))
1809
		return PTR_ERR(devmap);
1810 1811 1812 1813 1814 1815

	spin_lock(&dasd_devmap_lock);
	if (flag)
		devmap->features |= feature;
	else
		devmap->features &= ~feature;
1816 1817
	if (devmap->device)
		devmap->device->features = devmap->features;
1818 1819 1820
	spin_unlock(&dasd_devmap_lock);
	return 0;
}
1821
EXPORT_SYMBOL(dasd_set_feature);
1822

1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877
static struct attribute *paths_info_attrs[] = {
	&path_fcs_attribute.attr,
	NULL,
};

static struct kobj_type path_attr_type = {
	.release	= dasd_path_release,
	.default_attrs	= paths_info_attrs,
	.sysfs_ops	= &kobj_sysfs_ops,
};

static void dasd_path_init_kobj(struct dasd_device *device, int chp)
{
	device->path[chp].kobj.kset = device->paths_info;
	kobject_init(&device->path[chp].kobj, &path_attr_type);
}

void dasd_path_create_kobj(struct dasd_device *device, int chp)
{
	int rc;

	if (test_bit(DASD_FLAG_OFFLINE, &device->flags))
		return;
	if (!device->paths_info) {
		dev_warn(&device->cdev->dev, "Unable to create paths objects\n");
		return;
	}
	if (device->path[chp].in_sysfs)
		return;
	if (!device->path[chp].conf_data)
		return;

	dasd_path_init_kobj(device, chp);

	rc = kobject_add(&device->path[chp].kobj, NULL, "%x.%02x",
			 device->path[chp].cssid, device->path[chp].chpid);
	if (rc)
		kobject_put(&device->path[chp].kobj);
	device->path[chp].in_sysfs = true;
}
EXPORT_SYMBOL(dasd_path_create_kobj);

void dasd_path_create_kobjects(struct dasd_device *device)
{
	u8 lpm, opm;

	opm = dasd_path_get_opm(device);
	for (lpm = 0x80; lpm; lpm >>= 1) {
		if (!(lpm & opm))
			continue;
		dasd_path_create_kobj(device, pathmask_to_pos(lpm));
	}
}
EXPORT_SYMBOL(dasd_path_create_kobjects);

1878
static void dasd_path_remove_kobj(struct dasd_device *device, int chp)
1879 1880 1881 1882 1883 1884
{
	if (device->path[chp].in_sysfs) {
		kobject_put(&device->path[chp].kobj);
		device->path[chp].in_sysfs = false;
	}
}
1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897

/*
 * As we keep kobjects for the lifetime of a device, this function must not be
 * called anywhere but in the context of offlining a device.
 */
void dasd_path_remove_kobjects(struct dasd_device *device)
{
	int i;

	for (i = 0; i < 8; i++)
		dasd_path_remove_kobj(device, i);
}
EXPORT_SYMBOL(dasd_path_remove_kobjects);
1898

L
Linus Torvalds 已提交
1899 1900 1901 1902 1903 1904 1905 1906 1907
int
dasd_devmap_init(void)
{
	int i;

	/* Initialize devmap structures. */
	dasd_max_devindex = 0;
	for (i = 0; i < 256; i++)
		INIT_LIST_HEAD(&dasd_hashlists[i]);
1908
	return 0;
L
Linus Torvalds 已提交
1909 1910 1911 1912 1913 1914 1915
}

void
dasd_devmap_exit(void)
{
	dasd_forget_ranges();
}